babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940
  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/Misc/copyTools" {
  7867. import { Nullable } from "babylonjs/types";
  7868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7869. /**
  7870. * Class used to host copy specific utilities
  7871. */
  7872. export class CopyTools {
  7873. /**
  7874. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  7875. * @param texture defines the texture to read pixels from
  7876. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7877. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7878. * @returns The base64 encoded string or null
  7879. */
  7880. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  7881. }
  7882. }
  7883. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7884. /**
  7885. * Define options used to create a depth texture
  7886. */
  7887. export class DepthTextureCreationOptions {
  7888. /** Specifies whether or not a stencil should be allocated in the texture */
  7889. generateStencil?: boolean;
  7890. /** Specifies whether or not bilinear filtering is enable on the texture */
  7891. bilinearFiltering?: boolean;
  7892. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7893. comparisonFunction?: number;
  7894. /** Specifies if the created texture is a cube texture */
  7895. isCube?: boolean;
  7896. }
  7897. }
  7898. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7899. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7900. import { Nullable } from "babylonjs/types";
  7901. import { Scene } from "babylonjs/scene";
  7902. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7903. module "babylonjs/Engines/thinEngine" {
  7904. interface ThinEngine {
  7905. /**
  7906. * Creates a depth stencil cube texture.
  7907. * This is only available in WebGL 2.
  7908. * @param size The size of face edge in the cube texture.
  7909. * @param options The options defining the cube texture.
  7910. * @returns The cube texture
  7911. */
  7912. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7913. /**
  7914. * Creates a cube texture
  7915. * @param rootUrl defines the url where the files to load is located
  7916. * @param scene defines the current scene
  7917. * @param files defines the list of files to load (1 per face)
  7918. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7919. * @param onLoad defines an optional callback raised when the texture is loaded
  7920. * @param onError defines an optional callback raised if there is an issue to load the texture
  7921. * @param format defines the format of the data
  7922. * @param forcedExtension defines the extension to use to pick the right loader
  7923. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7924. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7925. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7926. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7927. * @param loaderOptions options to be passed to the loader
  7928. * @returns the cube texture as an InternalTexture
  7929. */
  7930. 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;
  7931. /**
  7932. * Creates a cube texture
  7933. * @param rootUrl defines the url where the files to load is located
  7934. * @param scene defines the current scene
  7935. * @param files defines the list of files to load (1 per face)
  7936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7937. * @param onLoad defines an optional callback raised when the texture is loaded
  7938. * @param onError defines an optional callback raised if there is an issue to load the texture
  7939. * @param format defines the format of the data
  7940. * @param forcedExtension defines the extension to use to pick the right loader
  7941. * @returns the cube texture as an InternalTexture
  7942. */
  7943. 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;
  7944. /**
  7945. * Creates a cube texture
  7946. * @param rootUrl defines the url where the files to load is located
  7947. * @param scene defines the current scene
  7948. * @param files defines the list of files to load (1 per face)
  7949. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7950. * @param onLoad defines an optional callback raised when the texture is loaded
  7951. * @param onError defines an optional callback raised if there is an issue to load the texture
  7952. * @param format defines the format of the data
  7953. * @param forcedExtension defines the extension to use to pick the right loader
  7954. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7955. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7956. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7957. * @returns the cube texture as an InternalTexture
  7958. */
  7959. 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;
  7960. /** @hidden */
  7961. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7962. /** @hidden */
  7963. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7964. /** @hidden */
  7965. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7966. /** @hidden */
  7967. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7968. /**
  7969. * @hidden
  7970. */
  7971. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7972. }
  7973. }
  7974. }
  7975. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7976. import { Nullable } from "babylonjs/types";
  7977. import { Scene } from "babylonjs/scene";
  7978. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7980. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7981. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7982. import { Observable } from "babylonjs/Misc/observable";
  7983. /**
  7984. * Class for creating a cube texture
  7985. */
  7986. export class CubeTexture extends BaseTexture {
  7987. private _delayedOnLoad;
  7988. /**
  7989. * Observable triggered once the texture has been loaded.
  7990. */
  7991. onLoadObservable: Observable<CubeTexture>;
  7992. /**
  7993. * The url of the texture
  7994. */
  7995. url: string;
  7996. /**
  7997. * Gets or sets the center of the bounding box associated with the cube texture.
  7998. * It must define where the camera used to render the texture was set
  7999. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8000. */
  8001. boundingBoxPosition: Vector3;
  8002. private _boundingBoxSize;
  8003. /**
  8004. * Gets or sets the size of the bounding box associated with the cube texture
  8005. * When defined, the cubemap will switch to local mode
  8006. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8007. * @example https://www.babylonjs-playground.com/#RNASML
  8008. */
  8009. set boundingBoxSize(value: Vector3);
  8010. /**
  8011. * Returns the bounding box size
  8012. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8013. */
  8014. get boundingBoxSize(): Vector3;
  8015. protected _rotationY: number;
  8016. /**
  8017. * Sets texture matrix rotation angle around Y axis in radians.
  8018. */
  8019. set rotationY(value: number);
  8020. /**
  8021. * Gets texture matrix rotation angle around Y axis radians.
  8022. */
  8023. get rotationY(): number;
  8024. /**
  8025. * Are mip maps generated for this texture or not.
  8026. */
  8027. get noMipmap(): boolean;
  8028. private _noMipmap;
  8029. private _files;
  8030. protected _forcedExtension: Nullable<string>;
  8031. private _extensions;
  8032. private _textureMatrix;
  8033. private _format;
  8034. private _createPolynomials;
  8035. private _loaderOptions;
  8036. /**
  8037. * Creates a cube texture from an array of image urls
  8038. * @param files defines an array of image urls
  8039. * @param scene defines the hosting scene
  8040. * @param noMipmap specifies if mip maps are not used
  8041. * @returns a cube texture
  8042. */
  8043. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8044. /**
  8045. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8046. * @param url defines the url of the prefiltered texture
  8047. * @param scene defines the scene the texture is attached to
  8048. * @param forcedExtension defines the extension of the file if different from the url
  8049. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8050. * @return the prefiltered texture
  8051. */
  8052. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8053. /**
  8054. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8055. * as prefiltered data.
  8056. * @param rootUrl defines the url of the texture or the root name of the six images
  8057. * @param null defines the scene or engine the texture is attached to
  8058. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8059. * @param noMipmap defines if mipmaps should be created or not
  8060. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8061. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8062. * @param onError defines a callback triggered in case of error during load
  8063. * @param format defines the internal format to use for the texture once loaded
  8064. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8065. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8066. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8067. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8068. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8069. * @param loaderOptions options to be passed to the loader
  8070. * @return the cube texture
  8071. */
  8072. 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);
  8073. /**
  8074. * Get the current class name of the texture useful for serialization or dynamic coding.
  8075. * @returns "CubeTexture"
  8076. */
  8077. getClassName(): string;
  8078. /**
  8079. * Update the url (and optional buffer) of this texture if url was null during construction.
  8080. * @param url the url of the texture
  8081. * @param forcedExtension defines the extension to use
  8082. * @param onLoad callback called when the texture is loaded (defaults to null)
  8083. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8084. */
  8085. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8086. /**
  8087. * Delays loading of the cube texture
  8088. * @param forcedExtension defines the extension to use
  8089. */
  8090. delayLoad(forcedExtension?: string): void;
  8091. /**
  8092. * Returns the reflection texture matrix
  8093. * @returns the reflection texture matrix
  8094. */
  8095. getReflectionTextureMatrix(): Matrix;
  8096. /**
  8097. * Sets the reflection texture matrix
  8098. * @param value Reflection texture matrix
  8099. */
  8100. setReflectionTextureMatrix(value: Matrix): void;
  8101. /**
  8102. * Parses text to create a cube texture
  8103. * @param parsedTexture define the serialized text to read from
  8104. * @param scene defines the hosting scene
  8105. * @param rootUrl defines the root url of the cube texture
  8106. * @returns a cube texture
  8107. */
  8108. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8109. /**
  8110. * Makes a clone, or deep copy, of the cube texture
  8111. * @returns a new cube texture
  8112. */
  8113. clone(): CubeTexture;
  8114. }
  8115. }
  8116. declare module "babylonjs/Materials/materialDefines" {
  8117. /**
  8118. * Manages the defines for the Material
  8119. */
  8120. export class MaterialDefines {
  8121. /** @hidden */
  8122. protected _keys: string[];
  8123. private _isDirty;
  8124. /** @hidden */
  8125. _renderId: number;
  8126. /** @hidden */
  8127. _areLightsDirty: boolean;
  8128. /** @hidden */
  8129. _areLightsDisposed: boolean;
  8130. /** @hidden */
  8131. _areAttributesDirty: boolean;
  8132. /** @hidden */
  8133. _areTexturesDirty: boolean;
  8134. /** @hidden */
  8135. _areFresnelDirty: boolean;
  8136. /** @hidden */
  8137. _areMiscDirty: boolean;
  8138. /** @hidden */
  8139. _arePrePassDirty: boolean;
  8140. /** @hidden */
  8141. _areImageProcessingDirty: boolean;
  8142. /** @hidden */
  8143. _normals: boolean;
  8144. /** @hidden */
  8145. _uvs: boolean;
  8146. /** @hidden */
  8147. _needNormals: boolean;
  8148. /** @hidden */
  8149. _needUVs: boolean;
  8150. [id: string]: any;
  8151. /**
  8152. * Specifies if the material needs to be re-calculated
  8153. */
  8154. get isDirty(): boolean;
  8155. /**
  8156. * Marks the material to indicate that it has been re-calculated
  8157. */
  8158. markAsProcessed(): void;
  8159. /**
  8160. * Marks the material to indicate that it needs to be re-calculated
  8161. */
  8162. markAsUnprocessed(): void;
  8163. /**
  8164. * Marks the material to indicate all of its defines need to be re-calculated
  8165. */
  8166. markAllAsDirty(): void;
  8167. /**
  8168. * Marks the material to indicate that image processing needs to be re-calculated
  8169. */
  8170. markAsImageProcessingDirty(): void;
  8171. /**
  8172. * Marks the material to indicate the lights need to be re-calculated
  8173. * @param disposed Defines whether the light is dirty due to dispose or not
  8174. */
  8175. markAsLightDirty(disposed?: boolean): void;
  8176. /**
  8177. * Marks the attribute state as changed
  8178. */
  8179. markAsAttributesDirty(): void;
  8180. /**
  8181. * Marks the texture state as changed
  8182. */
  8183. markAsTexturesDirty(): void;
  8184. /**
  8185. * Marks the fresnel state as changed
  8186. */
  8187. markAsFresnelDirty(): void;
  8188. /**
  8189. * Marks the misc state as changed
  8190. */
  8191. markAsMiscDirty(): void;
  8192. /**
  8193. * Marks the prepass state as changed
  8194. */
  8195. markAsPrePassDirty(): void;
  8196. /**
  8197. * Rebuilds the material defines
  8198. */
  8199. rebuild(): void;
  8200. /**
  8201. * Specifies if two material defines are equal
  8202. * @param other - A material define instance to compare to
  8203. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8204. */
  8205. isEqual(other: MaterialDefines): boolean;
  8206. /**
  8207. * Clones this instance's defines to another instance
  8208. * @param other - material defines to clone values to
  8209. */
  8210. cloneTo(other: MaterialDefines): void;
  8211. /**
  8212. * Resets the material define values
  8213. */
  8214. reset(): void;
  8215. /**
  8216. * Converts the material define values to a string
  8217. * @returns - String of material define information
  8218. */
  8219. toString(): string;
  8220. }
  8221. }
  8222. declare module "babylonjs/Materials/colorCurves" {
  8223. import { Effect } from "babylonjs/Materials/effect";
  8224. /**
  8225. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8226. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8227. * 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;
  8228. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8229. */
  8230. export class ColorCurves {
  8231. private _dirty;
  8232. private _tempColor;
  8233. private _globalCurve;
  8234. private _highlightsCurve;
  8235. private _midtonesCurve;
  8236. private _shadowsCurve;
  8237. private _positiveCurve;
  8238. private _negativeCurve;
  8239. private _globalHue;
  8240. private _globalDensity;
  8241. private _globalSaturation;
  8242. private _globalExposure;
  8243. /**
  8244. * Gets the global Hue value.
  8245. * 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).
  8246. */
  8247. get globalHue(): number;
  8248. /**
  8249. * Sets the global Hue value.
  8250. * 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).
  8251. */
  8252. set globalHue(value: number);
  8253. /**
  8254. * Gets the global Density value.
  8255. * 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.
  8256. * Values less than zero provide a filter of opposite hue.
  8257. */
  8258. get globalDensity(): number;
  8259. /**
  8260. * Sets the global Density value.
  8261. * 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.
  8262. * Values less than zero provide a filter of opposite hue.
  8263. */
  8264. set globalDensity(value: number);
  8265. /**
  8266. * Gets the global Saturation value.
  8267. * 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.
  8268. */
  8269. get globalSaturation(): number;
  8270. /**
  8271. * Sets the global Saturation value.
  8272. * 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.
  8273. */
  8274. set globalSaturation(value: number);
  8275. /**
  8276. * Gets the global Exposure value.
  8277. * 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.
  8278. */
  8279. get globalExposure(): number;
  8280. /**
  8281. * Sets the global Exposure value.
  8282. * 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.
  8283. */
  8284. set globalExposure(value: number);
  8285. private _highlightsHue;
  8286. private _highlightsDensity;
  8287. private _highlightsSaturation;
  8288. private _highlightsExposure;
  8289. /**
  8290. * Gets the highlights Hue value.
  8291. * 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).
  8292. */
  8293. get highlightsHue(): number;
  8294. /**
  8295. * Sets the highlights Hue value.
  8296. * 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).
  8297. */
  8298. set highlightsHue(value: number);
  8299. /**
  8300. * Gets the highlights Density value.
  8301. * 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.
  8302. * Values less than zero provide a filter of opposite hue.
  8303. */
  8304. get highlightsDensity(): number;
  8305. /**
  8306. * Sets the highlights Density value.
  8307. * 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.
  8308. * Values less than zero provide a filter of opposite hue.
  8309. */
  8310. set highlightsDensity(value: number);
  8311. /**
  8312. * Gets the highlights Saturation value.
  8313. * 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.
  8314. */
  8315. get highlightsSaturation(): number;
  8316. /**
  8317. * Sets the highlights Saturation value.
  8318. * 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.
  8319. */
  8320. set highlightsSaturation(value: number);
  8321. /**
  8322. * Gets the highlights Exposure value.
  8323. * 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.
  8324. */
  8325. get highlightsExposure(): number;
  8326. /**
  8327. * Sets the highlights Exposure value.
  8328. * 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.
  8329. */
  8330. set highlightsExposure(value: number);
  8331. private _midtonesHue;
  8332. private _midtonesDensity;
  8333. private _midtonesSaturation;
  8334. private _midtonesExposure;
  8335. /**
  8336. * Gets the midtones Hue value.
  8337. * 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).
  8338. */
  8339. get midtonesHue(): number;
  8340. /**
  8341. * Sets the midtones Hue value.
  8342. * 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).
  8343. */
  8344. set midtonesHue(value: number);
  8345. /**
  8346. * Gets the midtones Density value.
  8347. * 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.
  8348. * Values less than zero provide a filter of opposite hue.
  8349. */
  8350. get midtonesDensity(): number;
  8351. /**
  8352. * Sets the midtones Density value.
  8353. * 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.
  8354. * Values less than zero provide a filter of opposite hue.
  8355. */
  8356. set midtonesDensity(value: number);
  8357. /**
  8358. * Gets the midtones Saturation value.
  8359. * 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.
  8360. */
  8361. get midtonesSaturation(): number;
  8362. /**
  8363. * Sets the midtones Saturation value.
  8364. * 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.
  8365. */
  8366. set midtonesSaturation(value: number);
  8367. /**
  8368. * Gets the midtones Exposure value.
  8369. * 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.
  8370. */
  8371. get midtonesExposure(): number;
  8372. /**
  8373. * Sets the midtones Exposure value.
  8374. * 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.
  8375. */
  8376. set midtonesExposure(value: number);
  8377. private _shadowsHue;
  8378. private _shadowsDensity;
  8379. private _shadowsSaturation;
  8380. private _shadowsExposure;
  8381. /**
  8382. * Gets the shadows Hue value.
  8383. * 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).
  8384. */
  8385. get shadowsHue(): number;
  8386. /**
  8387. * Sets the shadows Hue value.
  8388. * 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).
  8389. */
  8390. set shadowsHue(value: number);
  8391. /**
  8392. * Gets the shadows Density value.
  8393. * 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.
  8394. * Values less than zero provide a filter of opposite hue.
  8395. */
  8396. get shadowsDensity(): number;
  8397. /**
  8398. * Sets the shadows Density value.
  8399. * 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.
  8400. * Values less than zero provide a filter of opposite hue.
  8401. */
  8402. set shadowsDensity(value: number);
  8403. /**
  8404. * Gets the shadows Saturation value.
  8405. * 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.
  8406. */
  8407. get shadowsSaturation(): number;
  8408. /**
  8409. * Sets the shadows Saturation value.
  8410. * 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.
  8411. */
  8412. set shadowsSaturation(value: number);
  8413. /**
  8414. * Gets the shadows Exposure value.
  8415. * 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.
  8416. */
  8417. get shadowsExposure(): number;
  8418. /**
  8419. * Sets the shadows Exposure value.
  8420. * 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.
  8421. */
  8422. set shadowsExposure(value: number);
  8423. /**
  8424. * Returns the class name
  8425. * @returns The class name
  8426. */
  8427. getClassName(): string;
  8428. /**
  8429. * Binds the color curves to the shader.
  8430. * @param colorCurves The color curve to bind
  8431. * @param effect The effect to bind to
  8432. * @param positiveUniform The positive uniform shader parameter
  8433. * @param neutralUniform The neutral uniform shader parameter
  8434. * @param negativeUniform The negative uniform shader parameter
  8435. */
  8436. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8437. /**
  8438. * Prepare the list of uniforms associated with the ColorCurves effects.
  8439. * @param uniformsList The list of uniforms used in the effect
  8440. */
  8441. static PrepareUniforms(uniformsList: string[]): void;
  8442. /**
  8443. * Returns color grading data based on a hue, density, saturation and exposure value.
  8444. * @param filterHue The hue of the color filter.
  8445. * @param filterDensity The density of the color filter.
  8446. * @param saturation The saturation.
  8447. * @param exposure The exposure.
  8448. * @param result The result data container.
  8449. */
  8450. private getColorGradingDataToRef;
  8451. /**
  8452. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8453. * @param value The input slider value in range [-100,100].
  8454. * @returns Adjusted value.
  8455. */
  8456. private static applyColorGradingSliderNonlinear;
  8457. /**
  8458. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8459. * @param hue The hue (H) input.
  8460. * @param saturation The saturation (S) input.
  8461. * @param brightness The brightness (B) input.
  8462. * @result An RGBA color represented as Vector4.
  8463. */
  8464. private static fromHSBToRef;
  8465. /**
  8466. * Returns a value clamped between min and max
  8467. * @param value The value to clamp
  8468. * @param min The minimum of value
  8469. * @param max The maximum of value
  8470. * @returns The clamped value.
  8471. */
  8472. private static clamp;
  8473. /**
  8474. * Clones the current color curve instance.
  8475. * @return The cloned curves
  8476. */
  8477. clone(): ColorCurves;
  8478. /**
  8479. * Serializes the current color curve instance to a json representation.
  8480. * @return a JSON representation
  8481. */
  8482. serialize(): any;
  8483. /**
  8484. * Parses the color curve from a json representation.
  8485. * @param source the JSON source to parse
  8486. * @return The parsed curves
  8487. */
  8488. static Parse(source: any): ColorCurves;
  8489. }
  8490. }
  8491. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8492. import { Observable } from "babylonjs/Misc/observable";
  8493. import { Nullable } from "babylonjs/types";
  8494. import { Color4 } from "babylonjs/Maths/math.color";
  8495. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8496. import { Effect } from "babylonjs/Materials/effect";
  8497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8498. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8499. /**
  8500. * Interface to follow in your material defines to integrate easily the
  8501. * Image proccessing functions.
  8502. * @hidden
  8503. */
  8504. export interface IImageProcessingConfigurationDefines {
  8505. IMAGEPROCESSING: boolean;
  8506. VIGNETTE: boolean;
  8507. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8508. VIGNETTEBLENDMODEOPAQUE: boolean;
  8509. TONEMAPPING: boolean;
  8510. TONEMAPPING_ACES: boolean;
  8511. CONTRAST: boolean;
  8512. EXPOSURE: boolean;
  8513. COLORCURVES: boolean;
  8514. COLORGRADING: boolean;
  8515. COLORGRADING3D: boolean;
  8516. SAMPLER3DGREENDEPTH: boolean;
  8517. SAMPLER3DBGRMAP: boolean;
  8518. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8519. }
  8520. /**
  8521. * @hidden
  8522. */
  8523. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8524. IMAGEPROCESSING: boolean;
  8525. VIGNETTE: boolean;
  8526. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8527. VIGNETTEBLENDMODEOPAQUE: boolean;
  8528. TONEMAPPING: boolean;
  8529. TONEMAPPING_ACES: boolean;
  8530. CONTRAST: boolean;
  8531. COLORCURVES: boolean;
  8532. COLORGRADING: boolean;
  8533. COLORGRADING3D: boolean;
  8534. SAMPLER3DGREENDEPTH: boolean;
  8535. SAMPLER3DBGRMAP: boolean;
  8536. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8537. EXPOSURE: boolean;
  8538. constructor();
  8539. }
  8540. /**
  8541. * This groups together the common properties used for image processing either in direct forward pass
  8542. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8543. * or not.
  8544. */
  8545. export class ImageProcessingConfiguration {
  8546. /**
  8547. * Default tone mapping applied in BabylonJS.
  8548. */
  8549. static readonly TONEMAPPING_STANDARD: number;
  8550. /**
  8551. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8552. * to other engines rendering to increase portability.
  8553. */
  8554. static readonly TONEMAPPING_ACES: number;
  8555. /**
  8556. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8557. */
  8558. colorCurves: Nullable<ColorCurves>;
  8559. private _colorCurvesEnabled;
  8560. /**
  8561. * Gets wether the color curves effect is enabled.
  8562. */
  8563. get colorCurvesEnabled(): boolean;
  8564. /**
  8565. * Sets wether the color curves effect is enabled.
  8566. */
  8567. set colorCurvesEnabled(value: boolean);
  8568. private _colorGradingTexture;
  8569. /**
  8570. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8571. */
  8572. get colorGradingTexture(): Nullable<BaseTexture>;
  8573. /**
  8574. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8575. */
  8576. set colorGradingTexture(value: Nullable<BaseTexture>);
  8577. private _colorGradingEnabled;
  8578. /**
  8579. * Gets wether the color grading effect is enabled.
  8580. */
  8581. get colorGradingEnabled(): boolean;
  8582. /**
  8583. * Sets wether the color grading effect is enabled.
  8584. */
  8585. set colorGradingEnabled(value: boolean);
  8586. private _colorGradingWithGreenDepth;
  8587. /**
  8588. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8589. */
  8590. get colorGradingWithGreenDepth(): boolean;
  8591. /**
  8592. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8593. */
  8594. set colorGradingWithGreenDepth(value: boolean);
  8595. private _colorGradingBGR;
  8596. /**
  8597. * Gets wether the color grading texture contains BGR values.
  8598. */
  8599. get colorGradingBGR(): boolean;
  8600. /**
  8601. * Sets wether the color grading texture contains BGR values.
  8602. */
  8603. set colorGradingBGR(value: boolean);
  8604. /** @hidden */
  8605. _exposure: number;
  8606. /**
  8607. * Gets the Exposure used in the effect.
  8608. */
  8609. get exposure(): number;
  8610. /**
  8611. * Sets the Exposure used in the effect.
  8612. */
  8613. set exposure(value: number);
  8614. private _toneMappingEnabled;
  8615. /**
  8616. * Gets wether the tone mapping effect is enabled.
  8617. */
  8618. get toneMappingEnabled(): boolean;
  8619. /**
  8620. * Sets wether the tone mapping effect is enabled.
  8621. */
  8622. set toneMappingEnabled(value: boolean);
  8623. private _toneMappingType;
  8624. /**
  8625. * Gets the type of tone mapping effect.
  8626. */
  8627. get toneMappingType(): number;
  8628. /**
  8629. * Sets the type of tone mapping effect used in BabylonJS.
  8630. */
  8631. set toneMappingType(value: number);
  8632. protected _contrast: number;
  8633. /**
  8634. * Gets the contrast used in the effect.
  8635. */
  8636. get contrast(): number;
  8637. /**
  8638. * Sets the contrast used in the effect.
  8639. */
  8640. set contrast(value: number);
  8641. /**
  8642. * Vignette stretch size.
  8643. */
  8644. vignetteStretch: number;
  8645. /**
  8646. * Vignette centre X Offset.
  8647. */
  8648. vignetteCentreX: number;
  8649. /**
  8650. * Vignette centre Y Offset.
  8651. */
  8652. vignetteCentreY: number;
  8653. /**
  8654. * Vignette weight or intensity of the vignette effect.
  8655. */
  8656. vignetteWeight: number;
  8657. /**
  8658. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8659. * if vignetteEnabled is set to true.
  8660. */
  8661. vignetteColor: Color4;
  8662. /**
  8663. * Camera field of view used by the Vignette effect.
  8664. */
  8665. vignetteCameraFov: number;
  8666. private _vignetteBlendMode;
  8667. /**
  8668. * Gets the vignette blend mode allowing different kind of effect.
  8669. */
  8670. get vignetteBlendMode(): number;
  8671. /**
  8672. * Sets the vignette blend mode allowing different kind of effect.
  8673. */
  8674. set vignetteBlendMode(value: number);
  8675. private _vignetteEnabled;
  8676. /**
  8677. * Gets wether the vignette effect is enabled.
  8678. */
  8679. get vignetteEnabled(): boolean;
  8680. /**
  8681. * Sets wether the vignette effect is enabled.
  8682. */
  8683. set vignetteEnabled(value: boolean);
  8684. private _applyByPostProcess;
  8685. /**
  8686. * Gets wether the image processing is applied through a post process or not.
  8687. */
  8688. get applyByPostProcess(): boolean;
  8689. /**
  8690. * Sets wether the image processing is applied through a post process or not.
  8691. */
  8692. set applyByPostProcess(value: boolean);
  8693. private _isEnabled;
  8694. /**
  8695. * Gets wether the image processing is enabled or not.
  8696. */
  8697. get isEnabled(): boolean;
  8698. /**
  8699. * Sets wether the image processing is enabled or not.
  8700. */
  8701. set isEnabled(value: boolean);
  8702. /**
  8703. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8704. */
  8705. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8706. /**
  8707. * Method called each time the image processing information changes requires to recompile the effect.
  8708. */
  8709. protected _updateParameters(): void;
  8710. /**
  8711. * Gets the current class name.
  8712. * @return "ImageProcessingConfiguration"
  8713. */
  8714. getClassName(): string;
  8715. /**
  8716. * Prepare the list of uniforms associated with the Image Processing effects.
  8717. * @param uniforms The list of uniforms used in the effect
  8718. * @param defines the list of defines currently in use
  8719. */
  8720. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8721. /**
  8722. * Prepare the list of samplers associated with the Image Processing effects.
  8723. * @param samplersList The list of uniforms used in the effect
  8724. * @param defines the list of defines currently in use
  8725. */
  8726. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8727. /**
  8728. * Prepare the list of defines associated to the shader.
  8729. * @param defines the list of defines to complete
  8730. * @param forPostProcess Define if we are currently in post process mode or not
  8731. */
  8732. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8733. /**
  8734. * Returns true if all the image processing information are ready.
  8735. * @returns True if ready, otherwise, false
  8736. */
  8737. isReady(): boolean;
  8738. /**
  8739. * Binds the image processing to the shader.
  8740. * @param effect The effect to bind to
  8741. * @param overrideAspectRatio Override the aspect ratio of the effect
  8742. */
  8743. bind(effect: Effect, overrideAspectRatio?: number): void;
  8744. /**
  8745. * Clones the current image processing instance.
  8746. * @return The cloned image processing
  8747. */
  8748. clone(): ImageProcessingConfiguration;
  8749. /**
  8750. * Serializes the current image processing instance to a json representation.
  8751. * @return a JSON representation
  8752. */
  8753. serialize(): any;
  8754. /**
  8755. * Parses the image processing from a json representation.
  8756. * @param source the JSON source to parse
  8757. * @return The parsed image processing
  8758. */
  8759. static Parse(source: any): ImageProcessingConfiguration;
  8760. private static _VIGNETTEMODE_MULTIPLY;
  8761. private static _VIGNETTEMODE_OPAQUE;
  8762. /**
  8763. * Used to apply the vignette as a mix with the pixel color.
  8764. */
  8765. static get VIGNETTEMODE_MULTIPLY(): number;
  8766. /**
  8767. * Used to apply the vignette as a replacement of the pixel color.
  8768. */
  8769. static get VIGNETTEMODE_OPAQUE(): number;
  8770. }
  8771. }
  8772. declare module "babylonjs/Shaders/postprocess.vertex" {
  8773. /** @hidden */
  8774. export var postprocessVertexShader: {
  8775. name: string;
  8776. shader: string;
  8777. };
  8778. }
  8779. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8781. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8782. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8783. /**
  8784. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8785. */
  8786. export type RenderTargetTextureSize = number | {
  8787. width: number;
  8788. height: number;
  8789. layers?: number;
  8790. };
  8791. module "babylonjs/Engines/thinEngine" {
  8792. interface ThinEngine {
  8793. /**
  8794. * Creates a new render target texture
  8795. * @param size defines the size of the texture
  8796. * @param options defines the options used to create the texture
  8797. * @returns a new render target texture stored in an InternalTexture
  8798. */
  8799. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8800. /**
  8801. * Creates a depth stencil texture.
  8802. * This is only available in WebGL 2 or with the depth texture extension available.
  8803. * @param size The size of face edge in the texture.
  8804. * @param options The options defining the texture.
  8805. * @returns The texture
  8806. */
  8807. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8808. /** @hidden */
  8809. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8810. }
  8811. }
  8812. }
  8813. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8814. /**
  8815. * Defines the kind of connection point for node based material
  8816. */
  8817. export enum NodeMaterialBlockConnectionPointTypes {
  8818. /** Float */
  8819. Float = 1,
  8820. /** Int */
  8821. Int = 2,
  8822. /** Vector2 */
  8823. Vector2 = 4,
  8824. /** Vector3 */
  8825. Vector3 = 8,
  8826. /** Vector4 */
  8827. Vector4 = 16,
  8828. /** Color3 */
  8829. Color3 = 32,
  8830. /** Color4 */
  8831. Color4 = 64,
  8832. /** Matrix */
  8833. Matrix = 128,
  8834. /** Custom object */
  8835. Object = 256,
  8836. /** Detect type based on connection */
  8837. AutoDetect = 1024,
  8838. /** Output type that will be defined by input type */
  8839. BasedOnInput = 2048
  8840. }
  8841. }
  8842. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8843. /**
  8844. * Enum used to define the target of a block
  8845. */
  8846. export enum NodeMaterialBlockTargets {
  8847. /** Vertex shader */
  8848. Vertex = 1,
  8849. /** Fragment shader */
  8850. Fragment = 2,
  8851. /** Neutral */
  8852. Neutral = 4,
  8853. /** Vertex and Fragment */
  8854. VertexAndFragment = 3
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8858. /**
  8859. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8860. */
  8861. export enum NodeMaterialBlockConnectionPointMode {
  8862. /** Value is an uniform */
  8863. Uniform = 0,
  8864. /** Value is a mesh attribute */
  8865. Attribute = 1,
  8866. /** Value is a varying between vertex and fragment shaders */
  8867. Varying = 2,
  8868. /** Mode is undefined */
  8869. Undefined = 3
  8870. }
  8871. }
  8872. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8873. /**
  8874. * Enum used to define system values e.g. values automatically provided by the system
  8875. */
  8876. export enum NodeMaterialSystemValues {
  8877. /** World */
  8878. World = 1,
  8879. /** View */
  8880. View = 2,
  8881. /** Projection */
  8882. Projection = 3,
  8883. /** ViewProjection */
  8884. ViewProjection = 4,
  8885. /** WorldView */
  8886. WorldView = 5,
  8887. /** WorldViewProjection */
  8888. WorldViewProjection = 6,
  8889. /** CameraPosition */
  8890. CameraPosition = 7,
  8891. /** Fog Color */
  8892. FogColor = 8,
  8893. /** Delta time */
  8894. DeltaTime = 9
  8895. }
  8896. }
  8897. declare module "babylonjs/Maths/math.axis" {
  8898. import { Vector3 } from "babylonjs/Maths/math.vector";
  8899. /** Defines supported spaces */
  8900. export enum Space {
  8901. /** Local (object) space */
  8902. LOCAL = 0,
  8903. /** World space */
  8904. WORLD = 1,
  8905. /** Bone space */
  8906. BONE = 2
  8907. }
  8908. /** Defines the 3 main axes */
  8909. export class Axis {
  8910. /** X axis */
  8911. static X: Vector3;
  8912. /** Y axis */
  8913. static Y: Vector3;
  8914. /** Z axis */
  8915. static Z: Vector3;
  8916. }
  8917. /**
  8918. * Defines cartesian components.
  8919. */
  8920. export enum Coordinate {
  8921. /** X axis */
  8922. X = 0,
  8923. /** Y axis */
  8924. Y = 1,
  8925. /** Z axis */
  8926. Z = 2
  8927. }
  8928. }
  8929. declare module "babylonjs/Maths/math.frustum" {
  8930. import { Matrix } from "babylonjs/Maths/math.vector";
  8931. import { DeepImmutable } from "babylonjs/types";
  8932. import { Plane } from "babylonjs/Maths/math.plane";
  8933. /**
  8934. * Represents a camera frustum
  8935. */
  8936. export class Frustum {
  8937. /**
  8938. * Gets the planes representing the frustum
  8939. * @param transform matrix to be applied to the returned planes
  8940. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8941. */
  8942. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8943. /**
  8944. * Gets the near frustum plane transformed by the transform matrix
  8945. * @param transform transformation matrix to be applied to the resulting frustum plane
  8946. * @param frustumPlane the resuling frustum plane
  8947. */
  8948. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8949. /**
  8950. * Gets the far frustum plane transformed by the transform matrix
  8951. * @param transform transformation matrix to be applied to the resulting frustum plane
  8952. * @param frustumPlane the resuling frustum plane
  8953. */
  8954. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8955. /**
  8956. * Gets the left frustum plane transformed by the transform matrix
  8957. * @param transform transformation matrix to be applied to the resulting frustum plane
  8958. * @param frustumPlane the resuling frustum plane
  8959. */
  8960. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8961. /**
  8962. * Gets the right frustum plane transformed by the transform matrix
  8963. * @param transform transformation matrix to be applied to the resulting frustum plane
  8964. * @param frustumPlane the resuling frustum plane
  8965. */
  8966. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8967. /**
  8968. * Gets the top frustum plane transformed by the transform matrix
  8969. * @param transform transformation matrix to be applied to the resulting frustum plane
  8970. * @param frustumPlane the resuling frustum plane
  8971. */
  8972. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8973. /**
  8974. * Gets the bottom frustum plane transformed by the transform matrix
  8975. * @param transform transformation matrix to be applied to the resulting frustum plane
  8976. * @param frustumPlane the resuling frustum plane
  8977. */
  8978. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8979. /**
  8980. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8981. * @param transform transformation matrix to be applied to the resulting frustum planes
  8982. * @param frustumPlanes the resuling frustum planes
  8983. */
  8984. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.size" {
  8988. /**
  8989. * Interface for the size containing width and height
  8990. */
  8991. export interface ISize {
  8992. /**
  8993. * Width
  8994. */
  8995. width: number;
  8996. /**
  8997. * Heighht
  8998. */
  8999. height: number;
  9000. }
  9001. /**
  9002. * Size containing widht and height
  9003. */
  9004. export class Size implements ISize {
  9005. /**
  9006. * Width
  9007. */
  9008. width: number;
  9009. /**
  9010. * Height
  9011. */
  9012. height: number;
  9013. /**
  9014. * Creates a Size object from the given width and height (floats).
  9015. * @param width width of the new size
  9016. * @param height height of the new size
  9017. */
  9018. constructor(width: number, height: number);
  9019. /**
  9020. * Returns a string with the Size width and height
  9021. * @returns a string with the Size width and height
  9022. */
  9023. toString(): string;
  9024. /**
  9025. * "Size"
  9026. * @returns the string "Size"
  9027. */
  9028. getClassName(): string;
  9029. /**
  9030. * Returns the Size hash code.
  9031. * @returns a hash code for a unique width and height
  9032. */
  9033. getHashCode(): number;
  9034. /**
  9035. * Updates the current size from the given one.
  9036. * @param src the given size
  9037. */
  9038. copyFrom(src: Size): void;
  9039. /**
  9040. * Updates in place the current Size from the given floats.
  9041. * @param width width of the new size
  9042. * @param height height of the new size
  9043. * @returns the updated Size.
  9044. */
  9045. copyFromFloats(width: number, height: number): Size;
  9046. /**
  9047. * Updates in place the current Size from the given floats.
  9048. * @param width width to set
  9049. * @param height height to set
  9050. * @returns the updated Size.
  9051. */
  9052. set(width: number, height: number): Size;
  9053. /**
  9054. * Multiplies the width and height by numbers
  9055. * @param w factor to multiple the width by
  9056. * @param h factor to multiple the height by
  9057. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9058. */
  9059. multiplyByFloats(w: number, h: number): Size;
  9060. /**
  9061. * Clones the size
  9062. * @returns a new Size copied from the given one.
  9063. */
  9064. clone(): Size;
  9065. /**
  9066. * True if the current Size and the given one width and height are strictly equal.
  9067. * @param other the other size to compare against
  9068. * @returns True if the current Size and the given one width and height are strictly equal.
  9069. */
  9070. equals(other: Size): boolean;
  9071. /**
  9072. * The surface of the Size : width * height (float).
  9073. */
  9074. get surface(): number;
  9075. /**
  9076. * Create a new size of zero
  9077. * @returns a new Size set to (0.0, 0.0)
  9078. */
  9079. static Zero(): Size;
  9080. /**
  9081. * Sums the width and height of two sizes
  9082. * @param otherSize size to add to this size
  9083. * @returns a new Size set as the addition result of the current Size and the given one.
  9084. */
  9085. add(otherSize: Size): Size;
  9086. /**
  9087. * Subtracts the width and height of two
  9088. * @param otherSize size to subtract to this size
  9089. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9090. */
  9091. subtract(otherSize: Size): Size;
  9092. /**
  9093. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9094. * @param start starting size to lerp between
  9095. * @param end end size to lerp between
  9096. * @param amount amount to lerp between the start and end values
  9097. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9098. */
  9099. static Lerp(start: Size, end: Size, amount: number): Size;
  9100. }
  9101. }
  9102. declare module "babylonjs/Maths/math.vertexFormat" {
  9103. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9104. /**
  9105. * Contains position and normal vectors for a vertex
  9106. */
  9107. export class PositionNormalVertex {
  9108. /** the position of the vertex (defaut: 0,0,0) */
  9109. position: Vector3;
  9110. /** the normal of the vertex (defaut: 0,1,0) */
  9111. normal: Vector3;
  9112. /**
  9113. * Creates a PositionNormalVertex
  9114. * @param position the position of the vertex (defaut: 0,0,0)
  9115. * @param normal the normal of the vertex (defaut: 0,1,0)
  9116. */
  9117. constructor(
  9118. /** the position of the vertex (defaut: 0,0,0) */
  9119. position?: Vector3,
  9120. /** the normal of the vertex (defaut: 0,1,0) */
  9121. normal?: Vector3);
  9122. /**
  9123. * Clones the PositionNormalVertex
  9124. * @returns the cloned PositionNormalVertex
  9125. */
  9126. clone(): PositionNormalVertex;
  9127. }
  9128. /**
  9129. * Contains position, normal and uv vectors for a vertex
  9130. */
  9131. export class PositionNormalTextureVertex {
  9132. /** the position of the vertex (defaut: 0,0,0) */
  9133. position: Vector3;
  9134. /** the normal of the vertex (defaut: 0,1,0) */
  9135. normal: Vector3;
  9136. /** the uv of the vertex (default: 0,0) */
  9137. uv: Vector2;
  9138. /**
  9139. * Creates a PositionNormalTextureVertex
  9140. * @param position the position of the vertex (defaut: 0,0,0)
  9141. * @param normal the normal of the vertex (defaut: 0,1,0)
  9142. * @param uv the uv of the vertex (default: 0,0)
  9143. */
  9144. constructor(
  9145. /** the position of the vertex (defaut: 0,0,0) */
  9146. position?: Vector3,
  9147. /** the normal of the vertex (defaut: 0,1,0) */
  9148. normal?: Vector3,
  9149. /** the uv of the vertex (default: 0,0) */
  9150. uv?: Vector2);
  9151. /**
  9152. * Clones the PositionNormalTextureVertex
  9153. * @returns the cloned PositionNormalTextureVertex
  9154. */
  9155. clone(): PositionNormalTextureVertex;
  9156. }
  9157. }
  9158. declare module "babylonjs/Maths/math" {
  9159. export * from "babylonjs/Maths/math.axis";
  9160. export * from "babylonjs/Maths/math.color";
  9161. export * from "babylonjs/Maths/math.constants";
  9162. export * from "babylonjs/Maths/math.frustum";
  9163. export * from "babylonjs/Maths/math.path";
  9164. export * from "babylonjs/Maths/math.plane";
  9165. export * from "babylonjs/Maths/math.size";
  9166. export * from "babylonjs/Maths/math.vector";
  9167. export * from "babylonjs/Maths/math.vertexFormat";
  9168. export * from "babylonjs/Maths/math.viewport";
  9169. }
  9170. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9171. /**
  9172. * Enum defining the type of animations supported by InputBlock
  9173. */
  9174. export enum AnimatedInputBlockTypes {
  9175. /** No animation */
  9176. None = 0,
  9177. /** Time based animation. Will only work for floats */
  9178. Time = 1
  9179. }
  9180. }
  9181. declare module "babylonjs/Lights/shadowLight" {
  9182. import { Camera } from "babylonjs/Cameras/camera";
  9183. import { Scene } from "babylonjs/scene";
  9184. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9186. import { Light } from "babylonjs/Lights/light";
  9187. /**
  9188. * Interface describing all the common properties and methods a shadow light needs to implement.
  9189. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9190. * as well as binding the different shadow properties to the effects.
  9191. */
  9192. export interface IShadowLight extends Light {
  9193. /**
  9194. * The light id in the scene (used in scene.findLighById for instance)
  9195. */
  9196. id: string;
  9197. /**
  9198. * The position the shdow will be casted from.
  9199. */
  9200. position: Vector3;
  9201. /**
  9202. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9203. */
  9204. direction: Vector3;
  9205. /**
  9206. * The transformed position. Position of the light in world space taking parenting in account.
  9207. */
  9208. transformedPosition: Vector3;
  9209. /**
  9210. * The transformed direction. Direction of the light in world space taking parenting in account.
  9211. */
  9212. transformedDirection: Vector3;
  9213. /**
  9214. * The friendly name of the light in the scene.
  9215. */
  9216. name: string;
  9217. /**
  9218. * Defines the shadow projection clipping minimum z value.
  9219. */
  9220. shadowMinZ: number;
  9221. /**
  9222. * Defines the shadow projection clipping maximum z value.
  9223. */
  9224. shadowMaxZ: number;
  9225. /**
  9226. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9227. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9228. */
  9229. computeTransformedInformation(): boolean;
  9230. /**
  9231. * Gets the scene the light belongs to.
  9232. * @returns The scene
  9233. */
  9234. getScene(): Scene;
  9235. /**
  9236. * Callback defining a custom Projection Matrix Builder.
  9237. * This can be used to override the default projection matrix computation.
  9238. */
  9239. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9240. /**
  9241. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9242. * @param matrix The materix to updated with the projection information
  9243. * @param viewMatrix The transform matrix of the light
  9244. * @param renderList The list of mesh to render in the map
  9245. * @returns The current light
  9246. */
  9247. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9248. /**
  9249. * Gets the current depth scale used in ESM.
  9250. * @returns The scale
  9251. */
  9252. getDepthScale(): number;
  9253. /**
  9254. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9255. * @returns true if a cube texture needs to be use
  9256. */
  9257. needCube(): boolean;
  9258. /**
  9259. * Detects if the projection matrix requires to be recomputed this frame.
  9260. * @returns true if it requires to be recomputed otherwise, false.
  9261. */
  9262. needProjectionMatrixCompute(): boolean;
  9263. /**
  9264. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9265. */
  9266. forceProjectionMatrixCompute(): void;
  9267. /**
  9268. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9269. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9270. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9271. */
  9272. getShadowDirection(faceIndex?: number): Vector3;
  9273. /**
  9274. * Gets the minZ used for shadow according to both the scene and the light.
  9275. * @param activeCamera The camera we are returning the min for
  9276. * @returns the depth min z
  9277. */
  9278. getDepthMinZ(activeCamera: Camera): number;
  9279. /**
  9280. * Gets the maxZ used for shadow according to both the scene and the light.
  9281. * @param activeCamera The camera we are returning the max for
  9282. * @returns the depth max z
  9283. */
  9284. getDepthMaxZ(activeCamera: Camera): number;
  9285. }
  9286. /**
  9287. * Base implementation IShadowLight
  9288. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9289. */
  9290. export abstract class ShadowLight extends Light implements IShadowLight {
  9291. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9292. protected _position: Vector3;
  9293. protected _setPosition(value: Vector3): void;
  9294. /**
  9295. * Sets the position the shadow will be casted from. Also use as the light position for both
  9296. * point and spot lights.
  9297. */
  9298. get position(): Vector3;
  9299. /**
  9300. * Sets the position the shadow will be casted from. Also use as the light position for both
  9301. * point and spot lights.
  9302. */
  9303. set position(value: Vector3);
  9304. protected _direction: Vector3;
  9305. protected _setDirection(value: Vector3): void;
  9306. /**
  9307. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9308. * Also use as the light direction on spot and directional lights.
  9309. */
  9310. get direction(): Vector3;
  9311. /**
  9312. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9313. * Also use as the light direction on spot and directional lights.
  9314. */
  9315. set direction(value: Vector3);
  9316. protected _shadowMinZ: number;
  9317. /**
  9318. * Gets the shadow projection clipping minimum z value.
  9319. */
  9320. get shadowMinZ(): number;
  9321. /**
  9322. * Sets the shadow projection clipping minimum z value.
  9323. */
  9324. set shadowMinZ(value: number);
  9325. protected _shadowMaxZ: number;
  9326. /**
  9327. * Sets the shadow projection clipping maximum z value.
  9328. */
  9329. get shadowMaxZ(): number;
  9330. /**
  9331. * Gets the shadow projection clipping maximum z value.
  9332. */
  9333. set shadowMaxZ(value: number);
  9334. /**
  9335. * Callback defining a custom Projection Matrix Builder.
  9336. * This can be used to override the default projection matrix computation.
  9337. */
  9338. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9339. /**
  9340. * The transformed position. Position of the light in world space taking parenting in account.
  9341. */
  9342. transformedPosition: Vector3;
  9343. /**
  9344. * The transformed direction. Direction of the light in world space taking parenting in account.
  9345. */
  9346. transformedDirection: Vector3;
  9347. private _needProjectionMatrixCompute;
  9348. /**
  9349. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9350. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9351. */
  9352. computeTransformedInformation(): boolean;
  9353. /**
  9354. * Return the depth scale used for the shadow map.
  9355. * @returns the depth scale.
  9356. */
  9357. getDepthScale(): number;
  9358. /**
  9359. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9360. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9361. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9362. */
  9363. getShadowDirection(faceIndex?: number): Vector3;
  9364. /**
  9365. * Returns the ShadowLight absolute position in the World.
  9366. * @returns the position vector in world space
  9367. */
  9368. getAbsolutePosition(): Vector3;
  9369. /**
  9370. * Sets the ShadowLight direction toward the passed target.
  9371. * @param target The point to target in local space
  9372. * @returns the updated ShadowLight direction
  9373. */
  9374. setDirectionToTarget(target: Vector3): Vector3;
  9375. /**
  9376. * Returns the light rotation in euler definition.
  9377. * @returns the x y z rotation in local space.
  9378. */
  9379. getRotation(): Vector3;
  9380. /**
  9381. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9382. * @returns true if a cube texture needs to be use
  9383. */
  9384. needCube(): boolean;
  9385. /**
  9386. * Detects if the projection matrix requires to be recomputed this frame.
  9387. * @returns true if it requires to be recomputed otherwise, false.
  9388. */
  9389. needProjectionMatrixCompute(): boolean;
  9390. /**
  9391. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9392. */
  9393. forceProjectionMatrixCompute(): void;
  9394. /** @hidden */
  9395. _initCache(): void;
  9396. /** @hidden */
  9397. _isSynchronized(): boolean;
  9398. /**
  9399. * Computes the world matrix of the node
  9400. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9401. * @returns the world matrix
  9402. */
  9403. computeWorldMatrix(force?: boolean): Matrix;
  9404. /**
  9405. * Gets the minZ used for shadow according to both the scene and the light.
  9406. * @param activeCamera The camera we are returning the min for
  9407. * @returns the depth min z
  9408. */
  9409. getDepthMinZ(activeCamera: Camera): number;
  9410. /**
  9411. * Gets the maxZ used for shadow according to both the scene and the light.
  9412. * @param activeCamera The camera we are returning the max for
  9413. * @returns the depth max z
  9414. */
  9415. getDepthMaxZ(activeCamera: Camera): number;
  9416. /**
  9417. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9418. * @param matrix The materix to updated with the projection information
  9419. * @param viewMatrix The transform matrix of the light
  9420. * @param renderList The list of mesh to render in the map
  9421. * @returns The current light
  9422. */
  9423. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9424. }
  9425. }
  9426. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9427. /** @hidden */
  9428. export var packingFunctions: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9434. /** @hidden */
  9435. export var bayerDitherFunctions: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9441. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9442. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9443. /** @hidden */
  9444. export var shadowMapFragmentDeclaration: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9450. /** @hidden */
  9451. export var clipPlaneFragmentDeclaration: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9457. /** @hidden */
  9458. export var clipPlaneFragment: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9464. /** @hidden */
  9465. export var shadowMapFragment: {
  9466. name: string;
  9467. shader: string;
  9468. };
  9469. }
  9470. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9471. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9472. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9473. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9474. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9475. /** @hidden */
  9476. export var shadowMapPixelShader: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9482. /** @hidden */
  9483. export var bonesDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexGlobalDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9496. /** @hidden */
  9497. export var morphTargetsVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9503. /** @hidden */
  9504. export var instancesDeclaration: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9510. /** @hidden */
  9511. export var helperFunctions: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9517. /** @hidden */
  9518. export var shadowMapVertexDeclaration: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9524. /** @hidden */
  9525. export var clipPlaneVertexDeclaration: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9531. /** @hidden */
  9532. export var morphTargetsVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9538. /** @hidden */
  9539. export var instancesVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9545. /** @hidden */
  9546. export var bonesVertex: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9552. /** @hidden */
  9553. export var shadowMapVertexNormalBias: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9559. /** @hidden */
  9560. export var shadowMapVertexMetric: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9566. /** @hidden */
  9567. export var clipPlaneVertex: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9573. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9575. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9576. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9578. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9579. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9580. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9581. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9582. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9583. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9584. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9585. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9586. /** @hidden */
  9587. export var shadowMapVertexShader: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9593. /** @hidden */
  9594. export var depthBoxBlurPixelShader: {
  9595. name: string;
  9596. shader: string;
  9597. };
  9598. }
  9599. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9600. /** @hidden */
  9601. export var shadowMapFragmentSoftTransparentShadow: {
  9602. name: string;
  9603. shader: string;
  9604. };
  9605. }
  9606. declare module "babylonjs/Materials/effectFallbacks" {
  9607. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9608. import { Effect } from "babylonjs/Materials/effect";
  9609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9610. /**
  9611. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9612. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9613. */
  9614. export class EffectFallbacks implements IEffectFallbacks {
  9615. private _defines;
  9616. private _currentRank;
  9617. private _maxRank;
  9618. private _mesh;
  9619. /**
  9620. * Removes the fallback from the bound mesh.
  9621. */
  9622. unBindMesh(): void;
  9623. /**
  9624. * Adds a fallback on the specified property.
  9625. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9626. * @param define The name of the define in the shader
  9627. */
  9628. addFallback(rank: number, define: string): void;
  9629. /**
  9630. * Sets the mesh to use CPU skinning when needing to fallback.
  9631. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9632. * @param mesh The mesh to use the fallbacks.
  9633. */
  9634. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9635. /**
  9636. * Checks to see if more fallbacks are still availible.
  9637. */
  9638. get hasMoreFallbacks(): boolean;
  9639. /**
  9640. * Removes the defines that should be removed when falling back.
  9641. * @param currentDefines defines the current define statements for the shader.
  9642. * @param effect defines the current effect we try to compile
  9643. * @returns The resulting defines with defines of the current rank removed.
  9644. */
  9645. reduce(currentDefines: string, effect: Effect): string;
  9646. }
  9647. }
  9648. declare module "babylonjs/Actions/action" {
  9649. import { Observable } from "babylonjs/Misc/observable";
  9650. import { Condition } from "babylonjs/Actions/condition";
  9651. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9652. import { Nullable } from "babylonjs/types";
  9653. import { Scene } from "babylonjs/scene";
  9654. import { ActionManager } from "babylonjs/Actions/actionManager";
  9655. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9656. import { Node } from "babylonjs/node";
  9657. /**
  9658. * Interface used to define Action
  9659. */
  9660. export interface IAction {
  9661. /**
  9662. * Trigger for the action
  9663. */
  9664. trigger: number;
  9665. /** Options of the trigger */
  9666. triggerOptions: any;
  9667. /**
  9668. * Gets the trigger parameters
  9669. * @returns the trigger parameters
  9670. */
  9671. getTriggerParameter(): any;
  9672. /**
  9673. * Internal only - executes current action event
  9674. * @hidden
  9675. */
  9676. _executeCurrent(evt?: ActionEvent): void;
  9677. /**
  9678. * Serialize placeholder for child classes
  9679. * @param parent of child
  9680. * @returns the serialized object
  9681. */
  9682. serialize(parent: any): any;
  9683. /**
  9684. * Internal only
  9685. * @hidden
  9686. */
  9687. _prepare(): void;
  9688. /**
  9689. * Internal only - manager for action
  9690. * @hidden
  9691. */
  9692. _actionManager: Nullable<AbstractActionManager>;
  9693. /**
  9694. * Adds action to chain of actions, may be a DoNothingAction
  9695. * @param action defines the next action to execute
  9696. * @returns The action passed in
  9697. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9698. */
  9699. then(action: IAction): IAction;
  9700. }
  9701. /**
  9702. * The action to be carried out following a trigger
  9703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9704. */
  9705. export class Action implements IAction {
  9706. /** the trigger, with or without parameters, for the action */
  9707. triggerOptions: any;
  9708. /**
  9709. * Trigger for the action
  9710. */
  9711. trigger: number;
  9712. /**
  9713. * Internal only - manager for action
  9714. * @hidden
  9715. */
  9716. _actionManager: ActionManager;
  9717. private _nextActiveAction;
  9718. private _child;
  9719. private _condition?;
  9720. private _triggerParameter;
  9721. /**
  9722. * An event triggered prior to action being executed.
  9723. */
  9724. onBeforeExecuteObservable: Observable<Action>;
  9725. /**
  9726. * Creates a new Action
  9727. * @param triggerOptions the trigger, with or without parameters, for the action
  9728. * @param condition an optional determinant of action
  9729. */
  9730. constructor(
  9731. /** the trigger, with or without parameters, for the action */
  9732. triggerOptions: any, condition?: Condition);
  9733. /**
  9734. * Internal only
  9735. * @hidden
  9736. */
  9737. _prepare(): void;
  9738. /**
  9739. * Gets the trigger parameters
  9740. * @returns the trigger parameters
  9741. */
  9742. getTriggerParameter(): any;
  9743. /**
  9744. * Internal only - executes current action event
  9745. * @hidden
  9746. */
  9747. _executeCurrent(evt?: ActionEvent): void;
  9748. /**
  9749. * Execute placeholder for child classes
  9750. * @param evt optional action event
  9751. */
  9752. execute(evt?: ActionEvent): void;
  9753. /**
  9754. * Skips to next active action
  9755. */
  9756. skipToNextActiveAction(): void;
  9757. /**
  9758. * Adds action to chain of actions, may be a DoNothingAction
  9759. * @param action defines the next action to execute
  9760. * @returns The action passed in
  9761. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9762. */
  9763. then(action: Action): Action;
  9764. /**
  9765. * Internal only
  9766. * @hidden
  9767. */
  9768. _getProperty(propertyPath: string): string;
  9769. /**
  9770. * Internal only
  9771. * @hidden
  9772. */
  9773. _getEffectiveTarget(target: any, propertyPath: string): any;
  9774. /**
  9775. * Serialize placeholder for child classes
  9776. * @param parent of child
  9777. * @returns the serialized object
  9778. */
  9779. serialize(parent: any): any;
  9780. /**
  9781. * Internal only called by serialize
  9782. * @hidden
  9783. */
  9784. protected _serialize(serializedAction: any, parent?: any): any;
  9785. /**
  9786. * Internal only
  9787. * @hidden
  9788. */
  9789. static _SerializeValueAsString: (value: any) => string;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. static _GetTargetProperty: (target: Scene | Node) => {
  9795. name: string;
  9796. targetType: string;
  9797. value: string;
  9798. };
  9799. }
  9800. }
  9801. declare module "babylonjs/Actions/condition" {
  9802. import { ActionManager } from "babylonjs/Actions/actionManager";
  9803. /**
  9804. * A Condition applied to an Action
  9805. */
  9806. export class Condition {
  9807. /**
  9808. * Internal only - manager for action
  9809. * @hidden
  9810. */
  9811. _actionManager: ActionManager;
  9812. /**
  9813. * Internal only
  9814. * @hidden
  9815. */
  9816. _evaluationId: number;
  9817. /**
  9818. * Internal only
  9819. * @hidden
  9820. */
  9821. _currentResult: boolean;
  9822. /**
  9823. * Creates a new Condition
  9824. * @param actionManager the manager of the action the condition is applied to
  9825. */
  9826. constructor(actionManager: ActionManager);
  9827. /**
  9828. * Check if the current condition is valid
  9829. * @returns a boolean
  9830. */
  9831. isValid(): boolean;
  9832. /**
  9833. * Internal only
  9834. * @hidden
  9835. */
  9836. _getProperty(propertyPath: string): string;
  9837. /**
  9838. * Internal only
  9839. * @hidden
  9840. */
  9841. _getEffectiveTarget(target: any, propertyPath: string): any;
  9842. /**
  9843. * Serialize placeholder for child classes
  9844. * @returns the serialized object
  9845. */
  9846. serialize(): any;
  9847. /**
  9848. * Internal only
  9849. * @hidden
  9850. */
  9851. protected _serialize(serializedCondition: any): any;
  9852. }
  9853. /**
  9854. * Defines specific conditional operators as extensions of Condition
  9855. */
  9856. export class ValueCondition extends Condition {
  9857. /** path to specify the property of the target the conditional operator uses */
  9858. propertyPath: string;
  9859. /** the value compared by the conditional operator against the current value of the property */
  9860. value: any;
  9861. /** the conditional operator, default ValueCondition.IsEqual */
  9862. operator: number;
  9863. /**
  9864. * Internal only
  9865. * @hidden
  9866. */
  9867. private static _IsEqual;
  9868. /**
  9869. * Internal only
  9870. * @hidden
  9871. */
  9872. private static _IsDifferent;
  9873. /**
  9874. * Internal only
  9875. * @hidden
  9876. */
  9877. private static _IsGreater;
  9878. /**
  9879. * Internal only
  9880. * @hidden
  9881. */
  9882. private static _IsLesser;
  9883. /**
  9884. * returns the number for IsEqual
  9885. */
  9886. static get IsEqual(): number;
  9887. /**
  9888. * Returns the number for IsDifferent
  9889. */
  9890. static get IsDifferent(): number;
  9891. /**
  9892. * Returns the number for IsGreater
  9893. */
  9894. static get IsGreater(): number;
  9895. /**
  9896. * Returns the number for IsLesser
  9897. */
  9898. static get IsLesser(): number;
  9899. /**
  9900. * Internal only The action manager for the condition
  9901. * @hidden
  9902. */
  9903. _actionManager: ActionManager;
  9904. /**
  9905. * Internal only
  9906. * @hidden
  9907. */
  9908. private _target;
  9909. /**
  9910. * Internal only
  9911. * @hidden
  9912. */
  9913. private _effectiveTarget;
  9914. /**
  9915. * Internal only
  9916. * @hidden
  9917. */
  9918. private _property;
  9919. /**
  9920. * Creates a new ValueCondition
  9921. * @param actionManager manager for the action the condition applies to
  9922. * @param target for the action
  9923. * @param propertyPath path to specify the property of the target the conditional operator uses
  9924. * @param value the value compared by the conditional operator against the current value of the property
  9925. * @param operator the conditional operator, default ValueCondition.IsEqual
  9926. */
  9927. constructor(actionManager: ActionManager, target: any,
  9928. /** path to specify the property of the target the conditional operator uses */
  9929. propertyPath: string,
  9930. /** the value compared by the conditional operator against the current value of the property */
  9931. value: any,
  9932. /** the conditional operator, default ValueCondition.IsEqual */
  9933. operator?: number);
  9934. /**
  9935. * Compares the given value with the property value for the specified conditional operator
  9936. * @returns the result of the comparison
  9937. */
  9938. isValid(): boolean;
  9939. /**
  9940. * Serialize the ValueCondition into a JSON compatible object
  9941. * @returns serialization object
  9942. */
  9943. serialize(): any;
  9944. /**
  9945. * Gets the name of the conditional operator for the ValueCondition
  9946. * @param operator the conditional operator
  9947. * @returns the name
  9948. */
  9949. static GetOperatorName(operator: number): string;
  9950. }
  9951. /**
  9952. * Defines a predicate condition as an extension of Condition
  9953. */
  9954. export class PredicateCondition extends Condition {
  9955. /** defines the predicate function used to validate the condition */
  9956. predicate: () => boolean;
  9957. /**
  9958. * Internal only - manager for action
  9959. * @hidden
  9960. */
  9961. _actionManager: ActionManager;
  9962. /**
  9963. * Creates a new PredicateCondition
  9964. * @param actionManager manager for the action the condition applies to
  9965. * @param predicate defines the predicate function used to validate the condition
  9966. */
  9967. constructor(actionManager: ActionManager,
  9968. /** defines the predicate function used to validate the condition */
  9969. predicate: () => boolean);
  9970. /**
  9971. * @returns the validity of the predicate condition
  9972. */
  9973. isValid(): boolean;
  9974. }
  9975. /**
  9976. * Defines a state condition as an extension of Condition
  9977. */
  9978. export class StateCondition extends Condition {
  9979. /** Value to compare with target state */
  9980. value: string;
  9981. /**
  9982. * Internal only - manager for action
  9983. * @hidden
  9984. */
  9985. _actionManager: ActionManager;
  9986. /**
  9987. * Internal only
  9988. * @hidden
  9989. */
  9990. private _target;
  9991. /**
  9992. * Creates a new StateCondition
  9993. * @param actionManager manager for the action the condition applies to
  9994. * @param target of the condition
  9995. * @param value to compare with target state
  9996. */
  9997. constructor(actionManager: ActionManager, target: any,
  9998. /** Value to compare with target state */
  9999. value: string);
  10000. /**
  10001. * Gets a boolean indicating if the current condition is met
  10002. * @returns the validity of the state
  10003. */
  10004. isValid(): boolean;
  10005. /**
  10006. * Serialize the StateCondition into a JSON compatible object
  10007. * @returns serialization object
  10008. */
  10009. serialize(): any;
  10010. }
  10011. }
  10012. declare module "babylonjs/Actions/directActions" {
  10013. import { Action } from "babylonjs/Actions/action";
  10014. import { Condition } from "babylonjs/Actions/condition";
  10015. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10016. /**
  10017. * This defines an action responsible to toggle a boolean once triggered.
  10018. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10019. */
  10020. export class SwitchBooleanAction extends Action {
  10021. /**
  10022. * The path to the boolean property in the target object
  10023. */
  10024. propertyPath: string;
  10025. private _target;
  10026. private _effectiveTarget;
  10027. private _property;
  10028. /**
  10029. * Instantiate the action
  10030. * @param triggerOptions defines the trigger options
  10031. * @param target defines the object containing the boolean
  10032. * @param propertyPath defines the path to the boolean property in the target object
  10033. * @param condition defines the trigger related conditions
  10034. */
  10035. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10036. /** @hidden */
  10037. _prepare(): void;
  10038. /**
  10039. * Execute the action toggle the boolean value.
  10040. */
  10041. execute(): void;
  10042. /**
  10043. * Serializes the actions and its related information.
  10044. * @param parent defines the object to serialize in
  10045. * @returns the serialized object
  10046. */
  10047. serialize(parent: any): any;
  10048. }
  10049. /**
  10050. * This defines an action responsible to set a the state field of the target
  10051. * to a desired value once triggered.
  10052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10053. */
  10054. export class SetStateAction extends Action {
  10055. /**
  10056. * The value to store in the state field.
  10057. */
  10058. value: string;
  10059. private _target;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param target defines the object containing the state property
  10064. * @param value defines the value to store in the state field
  10065. * @param condition defines the trigger related conditions
  10066. */
  10067. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10068. /**
  10069. * Execute the action and store the value on the target state property.
  10070. */
  10071. execute(): void;
  10072. /**
  10073. * Serializes the actions and its related information.
  10074. * @param parent defines the object to serialize in
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. }
  10079. /**
  10080. * This defines an action responsible to set a property of the target
  10081. * to a desired value once triggered.
  10082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10083. */
  10084. export class SetValueAction extends Action {
  10085. /**
  10086. * The path of the property to set in the target.
  10087. */
  10088. propertyPath: string;
  10089. /**
  10090. * The value to set in the property
  10091. */
  10092. value: any;
  10093. private _target;
  10094. private _effectiveTarget;
  10095. private _property;
  10096. /**
  10097. * Instantiate the action
  10098. * @param triggerOptions defines the trigger options
  10099. * @param target defines the object containing the property
  10100. * @param propertyPath defines the path of the property to set in the target
  10101. * @param value defines the value to set in the property
  10102. * @param condition defines the trigger related conditions
  10103. */
  10104. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10105. /** @hidden */
  10106. _prepare(): void;
  10107. /**
  10108. * Execute the action and set the targetted property to the desired value.
  10109. */
  10110. execute(): void;
  10111. /**
  10112. * Serializes the actions and its related information.
  10113. * @param parent defines the object to serialize in
  10114. * @returns the serialized object
  10115. */
  10116. serialize(parent: any): any;
  10117. }
  10118. /**
  10119. * This defines an action responsible to increment the target value
  10120. * to a desired value once triggered.
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10122. */
  10123. export class IncrementValueAction extends Action {
  10124. /**
  10125. * The path of the property to increment in the target.
  10126. */
  10127. propertyPath: string;
  10128. /**
  10129. * The value we should increment the property by.
  10130. */
  10131. value: any;
  10132. private _target;
  10133. private _effectiveTarget;
  10134. private _property;
  10135. /**
  10136. * Instantiate the action
  10137. * @param triggerOptions defines the trigger options
  10138. * @param target defines the object containing the property
  10139. * @param propertyPath defines the path of the property to increment in the target
  10140. * @param value defines the value value we should increment the property by
  10141. * @param condition defines the trigger related conditions
  10142. */
  10143. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10144. /** @hidden */
  10145. _prepare(): void;
  10146. /**
  10147. * Execute the action and increment the target of the value amount.
  10148. */
  10149. execute(): void;
  10150. /**
  10151. * Serializes the actions and its related information.
  10152. * @param parent defines the object to serialize in
  10153. * @returns the serialized object
  10154. */
  10155. serialize(parent: any): any;
  10156. }
  10157. /**
  10158. * This defines an action responsible to start an animation once triggered.
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10160. */
  10161. export class PlayAnimationAction extends Action {
  10162. /**
  10163. * Where the animation should start (animation frame)
  10164. */
  10165. from: number;
  10166. /**
  10167. * Where the animation should stop (animation frame)
  10168. */
  10169. to: number;
  10170. /**
  10171. * Define if the animation should loop or stop after the first play.
  10172. */
  10173. loop?: boolean;
  10174. private _target;
  10175. /**
  10176. * Instantiate the action
  10177. * @param triggerOptions defines the trigger options
  10178. * @param target defines the target animation or animation name
  10179. * @param from defines from where the animation should start (animation frame)
  10180. * @param end defines where the animation should stop (animation frame)
  10181. * @param loop defines if the animation should loop or stop after the first play
  10182. * @param condition defines the trigger related conditions
  10183. */
  10184. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10185. /** @hidden */
  10186. _prepare(): void;
  10187. /**
  10188. * Execute the action and play the animation.
  10189. */
  10190. execute(): void;
  10191. /**
  10192. * Serializes the actions and its related information.
  10193. * @param parent defines the object to serialize in
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. }
  10198. /**
  10199. * This defines an action responsible to stop an animation once triggered.
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10201. */
  10202. export class StopAnimationAction extends Action {
  10203. private _target;
  10204. /**
  10205. * Instantiate the action
  10206. * @param triggerOptions defines the trigger options
  10207. * @param target defines the target animation or animation name
  10208. * @param condition defines the trigger related conditions
  10209. */
  10210. constructor(triggerOptions: any, target: any, condition?: Condition);
  10211. /** @hidden */
  10212. _prepare(): void;
  10213. /**
  10214. * Execute the action and stop the animation.
  10215. */
  10216. execute(): void;
  10217. /**
  10218. * Serializes the actions and its related information.
  10219. * @param parent defines the object to serialize in
  10220. * @returns the serialized object
  10221. */
  10222. serialize(parent: any): any;
  10223. }
  10224. /**
  10225. * This defines an action responsible that does nothing once triggered.
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10227. */
  10228. export class DoNothingAction extends Action {
  10229. /**
  10230. * Instantiate the action
  10231. * @param triggerOptions defines the trigger options
  10232. * @param condition defines the trigger related conditions
  10233. */
  10234. constructor(triggerOptions?: any, condition?: Condition);
  10235. /**
  10236. * Execute the action and do nothing.
  10237. */
  10238. execute(): void;
  10239. /**
  10240. * Serializes the actions and its related information.
  10241. * @param parent defines the object to serialize in
  10242. * @returns the serialized object
  10243. */
  10244. serialize(parent: any): any;
  10245. }
  10246. /**
  10247. * This defines an action responsible to trigger several actions once triggered.
  10248. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10249. */
  10250. export class CombineAction extends Action {
  10251. /**
  10252. * The list of aggregated animations to run.
  10253. */
  10254. children: Action[];
  10255. /**
  10256. * Instantiate the action
  10257. * @param triggerOptions defines the trigger options
  10258. * @param children defines the list of aggregated animations to run
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10262. /** @hidden */
  10263. _prepare(): void;
  10264. /**
  10265. * Execute the action and executes all the aggregated actions.
  10266. */
  10267. execute(evt: ActionEvent): void;
  10268. /**
  10269. * Serializes the actions and its related information.
  10270. * @param parent defines the object to serialize in
  10271. * @returns the serialized object
  10272. */
  10273. serialize(parent: any): any;
  10274. }
  10275. /**
  10276. * This defines an action responsible to run code (external event) once triggered.
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10278. */
  10279. export class ExecuteCodeAction extends Action {
  10280. /**
  10281. * The callback function to run.
  10282. */
  10283. func: (evt: ActionEvent) => void;
  10284. /**
  10285. * Instantiate the action
  10286. * @param triggerOptions defines the trigger options
  10287. * @param func defines the callback function to run
  10288. * @param condition defines the trigger related conditions
  10289. */
  10290. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10291. /**
  10292. * Execute the action and run the attached code.
  10293. */
  10294. execute(evt: ActionEvent): void;
  10295. }
  10296. /**
  10297. * This defines an action responsible to set the parent property of the target once triggered.
  10298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10299. */
  10300. export class SetParentAction extends Action {
  10301. private _parent;
  10302. private _target;
  10303. /**
  10304. * Instantiate the action
  10305. * @param triggerOptions defines the trigger options
  10306. * @param target defines the target containing the parent property
  10307. * @param parent defines from where the animation should start (animation frame)
  10308. * @param condition defines the trigger related conditions
  10309. */
  10310. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10311. /** @hidden */
  10312. _prepare(): void;
  10313. /**
  10314. * Execute the action and set the parent property.
  10315. */
  10316. execute(): void;
  10317. /**
  10318. * Serializes the actions and its related information.
  10319. * @param parent defines the object to serialize in
  10320. * @returns the serialized object
  10321. */
  10322. serialize(parent: any): any;
  10323. }
  10324. }
  10325. declare module "babylonjs/Actions/actionManager" {
  10326. import { Nullable } from "babylonjs/types";
  10327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10328. import { Scene } from "babylonjs/scene";
  10329. import { IAction } from "babylonjs/Actions/action";
  10330. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10331. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10332. /**
  10333. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10334. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10335. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10336. */
  10337. export class ActionManager extends AbstractActionManager {
  10338. /**
  10339. * Nothing
  10340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10341. */
  10342. static readonly NothingTrigger: number;
  10343. /**
  10344. * On pick
  10345. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10346. */
  10347. static readonly OnPickTrigger: number;
  10348. /**
  10349. * On left pick
  10350. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10351. */
  10352. static readonly OnLeftPickTrigger: number;
  10353. /**
  10354. * On right pick
  10355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10356. */
  10357. static readonly OnRightPickTrigger: number;
  10358. /**
  10359. * On center pick
  10360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10361. */
  10362. static readonly OnCenterPickTrigger: number;
  10363. /**
  10364. * On pick down
  10365. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10366. */
  10367. static readonly OnPickDownTrigger: number;
  10368. /**
  10369. * On double pick
  10370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10371. */
  10372. static readonly OnDoublePickTrigger: number;
  10373. /**
  10374. * On pick up
  10375. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10376. */
  10377. static readonly OnPickUpTrigger: number;
  10378. /**
  10379. * On pick out.
  10380. * This trigger will only be raised if you also declared a OnPickDown
  10381. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10382. */
  10383. static readonly OnPickOutTrigger: number;
  10384. /**
  10385. * On long press
  10386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10387. */
  10388. static readonly OnLongPressTrigger: number;
  10389. /**
  10390. * On pointer over
  10391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10392. */
  10393. static readonly OnPointerOverTrigger: number;
  10394. /**
  10395. * On pointer out
  10396. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10397. */
  10398. static readonly OnPointerOutTrigger: number;
  10399. /**
  10400. * On every frame
  10401. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10402. */
  10403. static readonly OnEveryFrameTrigger: number;
  10404. /**
  10405. * On intersection enter
  10406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10407. */
  10408. static readonly OnIntersectionEnterTrigger: number;
  10409. /**
  10410. * On intersection exit
  10411. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10412. */
  10413. static readonly OnIntersectionExitTrigger: number;
  10414. /**
  10415. * On key down
  10416. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10417. */
  10418. static readonly OnKeyDownTrigger: number;
  10419. /**
  10420. * On key up
  10421. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10422. */
  10423. static readonly OnKeyUpTrigger: number;
  10424. private _scene;
  10425. /**
  10426. * Creates a new action manager
  10427. * @param scene defines the hosting scene
  10428. */
  10429. constructor(scene: Scene);
  10430. /**
  10431. * Releases all associated resources
  10432. */
  10433. dispose(): void;
  10434. /**
  10435. * Gets hosting scene
  10436. * @returns the hosting scene
  10437. */
  10438. getScene(): Scene;
  10439. /**
  10440. * Does this action manager handles actions of any of the given triggers
  10441. * @param triggers defines the triggers to be tested
  10442. * @return a boolean indicating whether one (or more) of the triggers is handled
  10443. */
  10444. hasSpecificTriggers(triggers: number[]): boolean;
  10445. /**
  10446. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10447. * speed.
  10448. * @param triggerA defines the trigger to be tested
  10449. * @param triggerB defines the trigger to be tested
  10450. * @return a boolean indicating whether one (or more) of the triggers is handled
  10451. */
  10452. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10453. /**
  10454. * Does this action manager handles actions of a given trigger
  10455. * @param trigger defines the trigger to be tested
  10456. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10457. * @return whether the trigger is handled
  10458. */
  10459. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10460. /**
  10461. * Does this action manager has pointer triggers
  10462. */
  10463. get hasPointerTriggers(): boolean;
  10464. /**
  10465. * Does this action manager has pick triggers
  10466. */
  10467. get hasPickTriggers(): boolean;
  10468. /**
  10469. * Registers an action to this action manager
  10470. * @param action defines the action to be registered
  10471. * @return the action amended (prepared) after registration
  10472. */
  10473. registerAction(action: IAction): Nullable<IAction>;
  10474. /**
  10475. * Unregisters an action to this action manager
  10476. * @param action defines the action to be unregistered
  10477. * @return a boolean indicating whether the action has been unregistered
  10478. */
  10479. unregisterAction(action: IAction): Boolean;
  10480. /**
  10481. * Process a specific trigger
  10482. * @param trigger defines the trigger to process
  10483. * @param evt defines the event details to be processed
  10484. */
  10485. processTrigger(trigger: number, evt?: IActionEvent): void;
  10486. /** @hidden */
  10487. _getEffectiveTarget(target: any, propertyPath: string): any;
  10488. /** @hidden */
  10489. _getProperty(propertyPath: string): string;
  10490. /**
  10491. * Serialize this manager to a JSON object
  10492. * @param name defines the property name to store this manager
  10493. * @returns a JSON representation of this manager
  10494. */
  10495. serialize(name: string): any;
  10496. /**
  10497. * Creates a new ActionManager from a JSON data
  10498. * @param parsedActions defines the JSON data to read from
  10499. * @param object defines the hosting mesh
  10500. * @param scene defines the hosting scene
  10501. */
  10502. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10503. /**
  10504. * Get a trigger name by index
  10505. * @param trigger defines the trigger index
  10506. * @returns a trigger name
  10507. */
  10508. static GetTriggerName(trigger: number): string;
  10509. }
  10510. }
  10511. declare module "babylonjs/Sprites/sprite" {
  10512. import { Vector3 } from "babylonjs/Maths/math.vector";
  10513. import { Nullable } from "babylonjs/types";
  10514. import { ActionManager } from "babylonjs/Actions/actionManager";
  10515. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10516. import { Color4 } from "babylonjs/Maths/math.color";
  10517. import { Observable } from "babylonjs/Misc/observable";
  10518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10519. import { Animation } from "babylonjs/Animations/animation";
  10520. /**
  10521. * Class used to represent a sprite
  10522. * @see https://doc.babylonjs.com/babylon101/sprites
  10523. */
  10524. export class Sprite implements IAnimatable {
  10525. /** defines the name */
  10526. name: string;
  10527. /** Gets or sets the current world position */
  10528. position: Vector3;
  10529. /** Gets or sets the main color */
  10530. color: Color4;
  10531. /** Gets or sets the width */
  10532. width: number;
  10533. /** Gets or sets the height */
  10534. height: number;
  10535. /** Gets or sets rotation angle */
  10536. angle: number;
  10537. /** Gets or sets the cell index in the sprite sheet */
  10538. cellIndex: number;
  10539. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10540. cellRef: string;
  10541. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10542. invertU: boolean;
  10543. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10544. invertV: boolean;
  10545. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10546. disposeWhenFinishedAnimating: boolean;
  10547. /** Gets the list of attached animations */
  10548. animations: Nullable<Array<Animation>>;
  10549. /** Gets or sets a boolean indicating if the sprite can be picked */
  10550. isPickable: boolean;
  10551. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10552. useAlphaForPicking: boolean;
  10553. /** @hidden */
  10554. _xOffset: number;
  10555. /** @hidden */
  10556. _yOffset: number;
  10557. /** @hidden */
  10558. _xSize: number;
  10559. /** @hidden */
  10560. _ySize: number;
  10561. /**
  10562. * Gets or sets the associated action manager
  10563. */
  10564. actionManager: Nullable<ActionManager>;
  10565. /**
  10566. * An event triggered when the control has been disposed
  10567. */
  10568. onDisposeObservable: Observable<Sprite>;
  10569. private _animationStarted;
  10570. private _loopAnimation;
  10571. private _fromIndex;
  10572. private _toIndex;
  10573. private _delay;
  10574. private _direction;
  10575. private _manager;
  10576. private _time;
  10577. private _onAnimationEnd;
  10578. /**
  10579. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10580. */
  10581. isVisible: boolean;
  10582. /**
  10583. * Gets or sets the sprite size
  10584. */
  10585. get size(): number;
  10586. set size(value: number);
  10587. /**
  10588. * Returns a boolean indicating if the animation is started
  10589. */
  10590. get animationStarted(): boolean;
  10591. /**
  10592. * Gets or sets the unique id of the sprite
  10593. */
  10594. uniqueId: number;
  10595. /**
  10596. * Gets the manager of this sprite
  10597. */
  10598. get manager(): ISpriteManager;
  10599. /**
  10600. * Creates a new Sprite
  10601. * @param name defines the name
  10602. * @param manager defines the manager
  10603. */
  10604. constructor(
  10605. /** defines the name */
  10606. name: string, manager: ISpriteManager);
  10607. /**
  10608. * Returns the string "Sprite"
  10609. * @returns "Sprite"
  10610. */
  10611. getClassName(): string;
  10612. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10613. get fromIndex(): number;
  10614. set fromIndex(value: number);
  10615. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10616. get toIndex(): number;
  10617. set toIndex(value: number);
  10618. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10619. get loopAnimation(): boolean;
  10620. set loopAnimation(value: boolean);
  10621. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10622. get delay(): number;
  10623. set delay(value: number);
  10624. /**
  10625. * Starts an animation
  10626. * @param from defines the initial key
  10627. * @param to defines the end key
  10628. * @param loop defines if the animation must loop
  10629. * @param delay defines the start delay (in ms)
  10630. * @param onAnimationEnd defines a callback to call when animation ends
  10631. */
  10632. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10633. /** Stops current animation (if any) */
  10634. stopAnimation(): void;
  10635. /** @hidden */
  10636. _animate(deltaTime: number): void;
  10637. /** Release associated resources */
  10638. dispose(): void;
  10639. /**
  10640. * Serializes the sprite to a JSON object
  10641. * @returns the JSON object
  10642. */
  10643. serialize(): any;
  10644. /**
  10645. * Parses a JSON object to create a new sprite
  10646. * @param parsedSprite The JSON object to parse
  10647. * @param manager defines the hosting manager
  10648. * @returns the new sprite
  10649. */
  10650. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10651. }
  10652. }
  10653. declare module "babylonjs/Collisions/pickingInfo" {
  10654. import { Nullable } from "babylonjs/types";
  10655. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10657. import { Sprite } from "babylonjs/Sprites/sprite";
  10658. import { Ray } from "babylonjs/Culling/ray";
  10659. /**
  10660. * Information about the result of picking within a scene
  10661. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10662. */
  10663. export class PickingInfo {
  10664. /** @hidden */
  10665. _pickingUnavailable: boolean;
  10666. /**
  10667. * If the pick collided with an object
  10668. */
  10669. hit: boolean;
  10670. /**
  10671. * Distance away where the pick collided
  10672. */
  10673. distance: number;
  10674. /**
  10675. * The location of pick collision
  10676. */
  10677. pickedPoint: Nullable<Vector3>;
  10678. /**
  10679. * The mesh corresponding the the pick collision
  10680. */
  10681. pickedMesh: Nullable<AbstractMesh>;
  10682. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10683. bu: number;
  10684. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10685. bv: number;
  10686. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10687. faceId: number;
  10688. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10689. subMeshFaceId: number;
  10690. /** Id of the the submesh that was picked */
  10691. subMeshId: number;
  10692. /** If a sprite was picked, this will be the sprite the pick collided with */
  10693. pickedSprite: Nullable<Sprite>;
  10694. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10695. thinInstanceIndex: number;
  10696. /**
  10697. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10698. */
  10699. originMesh: Nullable<AbstractMesh>;
  10700. /**
  10701. * The ray that was used to perform the picking.
  10702. */
  10703. ray: Nullable<Ray>;
  10704. /**
  10705. * Gets the normal correspodning to the face the pick collided with
  10706. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10707. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10708. * @returns The normal correspodning to the face the pick collided with
  10709. */
  10710. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10711. /**
  10712. * Gets the texture coordinates of where the pick occured
  10713. * @returns the vector containing the coordnates of the texture
  10714. */
  10715. getTextureCoordinates(): Nullable<Vector2>;
  10716. }
  10717. }
  10718. declare module "babylonjs/Culling/ray" {
  10719. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10720. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10722. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10723. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10724. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10725. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10726. import { Plane } from "babylonjs/Maths/math.plane";
  10727. /**
  10728. * Class representing a ray with position and direction
  10729. */
  10730. export class Ray {
  10731. /** origin point */
  10732. origin: Vector3;
  10733. /** direction */
  10734. direction: Vector3;
  10735. /** length of the ray */
  10736. length: number;
  10737. private static readonly _TmpVector3;
  10738. private _tmpRay;
  10739. /**
  10740. * Creates a new ray
  10741. * @param origin origin point
  10742. * @param direction direction
  10743. * @param length length of the ray
  10744. */
  10745. constructor(
  10746. /** origin point */
  10747. origin: Vector3,
  10748. /** direction */
  10749. direction: Vector3,
  10750. /** length of the ray */
  10751. length?: number);
  10752. /**
  10753. * Checks if the ray intersects a box
  10754. * This does not account for the ray lenght by design to improve perfs.
  10755. * @param minimum bound of the box
  10756. * @param maximum bound of the box
  10757. * @param intersectionTreshold extra extend to be added to the box in all direction
  10758. * @returns if the box was hit
  10759. */
  10760. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10761. /**
  10762. * Checks if the ray intersects a box
  10763. * This does not account for the ray lenght by design to improve perfs.
  10764. * @param box the bounding box to check
  10765. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10766. * @returns if the box was hit
  10767. */
  10768. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10769. /**
  10770. * If the ray hits a sphere
  10771. * @param sphere the bounding sphere to check
  10772. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10773. * @returns true if it hits the sphere
  10774. */
  10775. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10776. /**
  10777. * If the ray hits a triange
  10778. * @param vertex0 triangle vertex
  10779. * @param vertex1 triangle vertex
  10780. * @param vertex2 triangle vertex
  10781. * @returns intersection information if hit
  10782. */
  10783. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10784. /**
  10785. * Checks if ray intersects a plane
  10786. * @param plane the plane to check
  10787. * @returns the distance away it was hit
  10788. */
  10789. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10790. /**
  10791. * Calculate the intercept of a ray on a given axis
  10792. * @param axis to check 'x' | 'y' | 'z'
  10793. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10794. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10795. */
  10796. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10797. /**
  10798. * Checks if ray intersects a mesh
  10799. * @param mesh the mesh to check
  10800. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10801. * @returns picking info of the intersecton
  10802. */
  10803. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10804. /**
  10805. * Checks if ray intersects a mesh
  10806. * @param meshes the meshes to check
  10807. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10808. * @param results array to store result in
  10809. * @returns Array of picking infos
  10810. */
  10811. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10812. private _comparePickingInfo;
  10813. private static smallnum;
  10814. private static rayl;
  10815. /**
  10816. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10817. * @param sega the first point of the segment to test the intersection against
  10818. * @param segb the second point of the segment to test the intersection against
  10819. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10820. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10821. */
  10822. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10823. /**
  10824. * Update the ray from viewport position
  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 this ray updated
  10833. */
  10834. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10835. /**
  10836. * Creates a ray with origin and direction of 0,0,0
  10837. * @returns the new ray
  10838. */
  10839. static Zero(): Ray;
  10840. /**
  10841. * Creates a new ray from screen space and viewport
  10842. * @param x position
  10843. * @param y y position
  10844. * @param viewportWidth viewport width
  10845. * @param viewportHeight viewport height
  10846. * @param world world matrix
  10847. * @param view view matrix
  10848. * @param projection projection matrix
  10849. * @returns new ray
  10850. */
  10851. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10852. /**
  10853. * 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
  10854. * transformed to the given world matrix.
  10855. * @param origin The origin point
  10856. * @param end The end point
  10857. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10858. * @returns the new ray
  10859. */
  10860. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10861. /**
  10862. * Transforms a ray by a matrix
  10863. * @param ray ray to transform
  10864. * @param matrix matrix to apply
  10865. * @returns the resulting new ray
  10866. */
  10867. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10868. /**
  10869. * Transforms a ray by a matrix
  10870. * @param ray ray to transform
  10871. * @param matrix matrix to apply
  10872. * @param result ray to store result in
  10873. */
  10874. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10875. /**
  10876. * Unproject a ray from screen space to object space
  10877. * @param sourceX defines the screen space x coordinate to use
  10878. * @param sourceY defines the screen space y coordinate to use
  10879. * @param viewportWidth defines the current width of the viewport
  10880. * @param viewportHeight defines the current height of the viewport
  10881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10882. * @param view defines the view matrix to use
  10883. * @param projection defines the projection matrix to use
  10884. */
  10885. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10886. }
  10887. /**
  10888. * Type used to define predicate used to select faces when a mesh intersection is detected
  10889. */
  10890. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10891. module "babylonjs/scene" {
  10892. interface Scene {
  10893. /** @hidden */
  10894. _tempPickingRay: Nullable<Ray>;
  10895. /** @hidden */
  10896. _cachedRayForTransform: Ray;
  10897. /** @hidden */
  10898. _pickWithRayInverseMatrix: Matrix;
  10899. /** @hidden */
  10900. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10901. /** @hidden */
  10902. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10903. /** @hidden */
  10904. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10905. }
  10906. }
  10907. }
  10908. declare module "babylonjs/sceneComponent" {
  10909. import { Scene } from "babylonjs/scene";
  10910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10912. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10913. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10914. import { Nullable } from "babylonjs/types";
  10915. import { Camera } from "babylonjs/Cameras/camera";
  10916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10918. import { AbstractScene } from "babylonjs/abstractScene";
  10919. import { Mesh } from "babylonjs/Meshes/mesh";
  10920. /**
  10921. * Groups all the scene component constants in one place to ease maintenance.
  10922. * @hidden
  10923. */
  10924. export class SceneComponentConstants {
  10925. static readonly NAME_EFFECTLAYER: string;
  10926. static readonly NAME_LAYER: string;
  10927. static readonly NAME_LENSFLARESYSTEM: string;
  10928. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10929. static readonly NAME_PARTICLESYSTEM: string;
  10930. static readonly NAME_GAMEPAD: string;
  10931. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10932. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10933. static readonly NAME_PREPASSRENDERER: string;
  10934. static readonly NAME_DEPTHRENDERER: string;
  10935. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10936. static readonly NAME_SPRITE: string;
  10937. static readonly NAME_SUBSURFACE: string;
  10938. static readonly NAME_OUTLINERENDERER: string;
  10939. static readonly NAME_PROCEDURALTEXTURE: string;
  10940. static readonly NAME_SHADOWGENERATOR: string;
  10941. static readonly NAME_OCTREE: string;
  10942. static readonly NAME_PHYSICSENGINE: string;
  10943. static readonly NAME_AUDIO: string;
  10944. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10945. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10946. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10947. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10948. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10949. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10950. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10951. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10952. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10953. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10954. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10955. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10956. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10957. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10958. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10959. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10960. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10961. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10962. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10963. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10964. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10965. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10966. static readonly STEP_AFTERRENDER_AUDIO: number;
  10967. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10968. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10969. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10970. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10971. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10972. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10973. static readonly STEP_POINTERMOVE_SPRITE: number;
  10974. static readonly STEP_POINTERDOWN_SPRITE: number;
  10975. static readonly STEP_POINTERUP_SPRITE: number;
  10976. }
  10977. /**
  10978. * This represents a scene component.
  10979. *
  10980. * This is used to decouple the dependency the scene is having on the different workloads like
  10981. * layers, post processes...
  10982. */
  10983. export interface ISceneComponent {
  10984. /**
  10985. * The name of the component. Each component must have a unique name.
  10986. */
  10987. name: string;
  10988. /**
  10989. * The scene the component belongs to.
  10990. */
  10991. scene: Scene;
  10992. /**
  10993. * Register the component to one instance of a scene.
  10994. */
  10995. register(): void;
  10996. /**
  10997. * Rebuilds the elements related to this component in case of
  10998. * context lost for instance.
  10999. */
  11000. rebuild(): void;
  11001. /**
  11002. * Disposes the component and the associated ressources.
  11003. */
  11004. dispose(): void;
  11005. }
  11006. /**
  11007. * This represents a SERIALIZABLE scene component.
  11008. *
  11009. * This extends Scene Component to add Serialization methods on top.
  11010. */
  11011. export interface ISceneSerializableComponent extends ISceneComponent {
  11012. /**
  11013. * Adds all the elements from the container to the scene
  11014. * @param container the container holding the elements
  11015. */
  11016. addFromContainer(container: AbstractScene): void;
  11017. /**
  11018. * Removes all the elements in the container from the scene
  11019. * @param container contains the elements to remove
  11020. * @param dispose if the removed element should be disposed (default: false)
  11021. */
  11022. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11023. /**
  11024. * Serializes the component data to the specified json object
  11025. * @param serializationObject The object to serialize to
  11026. */
  11027. serialize(serializationObject: any): void;
  11028. }
  11029. /**
  11030. * Strong typing of a Mesh related stage step action
  11031. */
  11032. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11033. /**
  11034. * Strong typing of a Evaluate Sub Mesh related stage step action
  11035. */
  11036. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11037. /**
  11038. * Strong typing of a pre active Mesh related stage step action
  11039. */
  11040. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11041. /**
  11042. * Strong typing of a Camera related stage step action
  11043. */
  11044. export type CameraStageAction = (camera: Camera) => void;
  11045. /**
  11046. * Strong typing of a Camera Frame buffer related stage step action
  11047. */
  11048. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11049. /**
  11050. * Strong typing of a Render Target related stage step action
  11051. */
  11052. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11053. /**
  11054. * Strong typing of a RenderingGroup related stage step action
  11055. */
  11056. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11057. /**
  11058. * Strong typing of a Mesh Render related stage step action
  11059. */
  11060. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11061. /**
  11062. * Strong typing of a simple stage step action
  11063. */
  11064. export type SimpleStageAction = () => void;
  11065. /**
  11066. * Strong typing of a render target action.
  11067. */
  11068. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11069. /**
  11070. * Strong typing of a pointer move action.
  11071. */
  11072. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11073. /**
  11074. * Strong typing of a pointer up/down action.
  11075. */
  11076. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11077. /**
  11078. * Representation of a stage in the scene (Basically a list of ordered steps)
  11079. * @hidden
  11080. */
  11081. export class Stage<T extends Function> extends Array<{
  11082. index: number;
  11083. component: ISceneComponent;
  11084. action: T;
  11085. }> {
  11086. /**
  11087. * Hide ctor from the rest of the world.
  11088. * @param items The items to add.
  11089. */
  11090. private constructor();
  11091. /**
  11092. * Creates a new Stage.
  11093. * @returns A new instance of a Stage
  11094. */
  11095. static Create<T extends Function>(): Stage<T>;
  11096. /**
  11097. * Registers a step in an ordered way in the targeted stage.
  11098. * @param index Defines the position to register the step in
  11099. * @param component Defines the component attached to the step
  11100. * @param action Defines the action to launch during the step
  11101. */
  11102. registerStep(index: number, component: ISceneComponent, action: T): void;
  11103. /**
  11104. * Clears all the steps from the stage.
  11105. */
  11106. clear(): void;
  11107. }
  11108. }
  11109. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11110. import { Nullable } from "babylonjs/types";
  11111. import { Observable } from "babylonjs/Misc/observable";
  11112. import { Scene } from "babylonjs/scene";
  11113. import { Sprite } from "babylonjs/Sprites/sprite";
  11114. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11115. import { Ray } from "babylonjs/Culling/ray";
  11116. import { Camera } from "babylonjs/Cameras/camera";
  11117. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11118. import { ISceneComponent } from "babylonjs/sceneComponent";
  11119. module "babylonjs/scene" {
  11120. interface Scene {
  11121. /** @hidden */
  11122. _pointerOverSprite: Nullable<Sprite>;
  11123. /** @hidden */
  11124. _pickedDownSprite: Nullable<Sprite>;
  11125. /** @hidden */
  11126. _tempSpritePickingRay: Nullable<Ray>;
  11127. /**
  11128. * All of the sprite managers added to this scene
  11129. * @see https://doc.babylonjs.com/babylon101/sprites
  11130. */
  11131. spriteManagers: Array<ISpriteManager>;
  11132. /**
  11133. * An event triggered when sprites rendering is about to start
  11134. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11135. */
  11136. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11137. /**
  11138. * An event triggered when sprites rendering is done
  11139. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11140. */
  11141. onAfterSpritesRenderingObservable: Observable<Scene>;
  11142. /** @hidden */
  11143. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11144. /** Launch a ray to try to pick a sprite in the scene
  11145. * @param x position on screen
  11146. * @param y position on screen
  11147. * @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
  11148. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11149. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11150. * @returns a PickingInfo
  11151. */
  11152. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11153. /** Use the given ray to pick a sprite in the scene
  11154. * @param ray The ray (in world space) to use to pick meshes
  11155. * @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
  11156. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11157. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11158. * @returns a PickingInfo
  11159. */
  11160. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11161. /** @hidden */
  11162. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11163. /** Launch a ray to try to pick sprites in the scene
  11164. * @param x position on screen
  11165. * @param y position on screen
  11166. * @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
  11167. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11168. * @returns a PickingInfo array
  11169. */
  11170. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11171. /** Use the given ray to pick sprites in the scene
  11172. * @param ray The ray (in world space) to use to pick meshes
  11173. * @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
  11174. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11175. * @returns a PickingInfo array
  11176. */
  11177. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11178. /**
  11179. * Force the sprite under the pointer
  11180. * @param sprite defines the sprite to use
  11181. */
  11182. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11183. /**
  11184. * Gets the sprite under the pointer
  11185. * @returns a Sprite or null if no sprite is under the pointer
  11186. */
  11187. getPointerOverSprite(): Nullable<Sprite>;
  11188. }
  11189. }
  11190. /**
  11191. * Defines the sprite scene component responsible to manage sprites
  11192. * in a given scene.
  11193. */
  11194. export class SpriteSceneComponent implements ISceneComponent {
  11195. /**
  11196. * The component name helpfull to identify the component in the list of scene components.
  11197. */
  11198. readonly name: string;
  11199. /**
  11200. * The scene the component belongs to.
  11201. */
  11202. scene: Scene;
  11203. /** @hidden */
  11204. private _spritePredicate;
  11205. /**
  11206. * Creates a new instance of the component for the given scene
  11207. * @param scene Defines the scene to register the component in
  11208. */
  11209. constructor(scene: Scene);
  11210. /**
  11211. * Registers the component in a given scene
  11212. */
  11213. register(): void;
  11214. /**
  11215. * Rebuilds the elements related to this component in case of
  11216. * context lost for instance.
  11217. */
  11218. rebuild(): void;
  11219. /**
  11220. * Disposes the component and the associated ressources.
  11221. */
  11222. dispose(): void;
  11223. private _pickSpriteButKeepRay;
  11224. private _pointerMove;
  11225. private _pointerDown;
  11226. private _pointerUp;
  11227. }
  11228. }
  11229. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11230. /** @hidden */
  11231. export var fogFragmentDeclaration: {
  11232. name: string;
  11233. shader: string;
  11234. };
  11235. }
  11236. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11237. /** @hidden */
  11238. export var fogFragment: {
  11239. name: string;
  11240. shader: string;
  11241. };
  11242. }
  11243. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11244. /** @hidden */
  11245. export var imageProcessingCompatibility: {
  11246. name: string;
  11247. shader: string;
  11248. };
  11249. }
  11250. declare module "babylonjs/Shaders/sprites.fragment" {
  11251. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11252. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11253. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11254. /** @hidden */
  11255. export var spritesPixelShader: {
  11256. name: string;
  11257. shader: string;
  11258. };
  11259. }
  11260. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11261. /** @hidden */
  11262. export var fogVertexDeclaration: {
  11263. name: string;
  11264. shader: string;
  11265. };
  11266. }
  11267. declare module "babylonjs/Shaders/sprites.vertex" {
  11268. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11269. /** @hidden */
  11270. export var spritesVertexShader: {
  11271. name: string;
  11272. shader: string;
  11273. };
  11274. }
  11275. declare module "babylonjs/Sprites/spriteManager" {
  11276. import { IDisposable, Scene } from "babylonjs/scene";
  11277. import { Nullable } from "babylonjs/types";
  11278. import { Observable } from "babylonjs/Misc/observable";
  11279. import { Sprite } from "babylonjs/Sprites/sprite";
  11280. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11281. import { Camera } from "babylonjs/Cameras/camera";
  11282. import { Texture } from "babylonjs/Materials/Textures/texture";
  11283. import "babylonjs/Shaders/sprites.fragment";
  11284. import "babylonjs/Shaders/sprites.vertex";
  11285. import { Ray } from "babylonjs/Culling/ray";
  11286. /**
  11287. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11288. */
  11289. export interface ISpriteManager extends IDisposable {
  11290. /**
  11291. * Gets manager's name
  11292. */
  11293. name: string;
  11294. /**
  11295. * Restricts the camera to viewing objects with the same layerMask.
  11296. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11297. */
  11298. layerMask: number;
  11299. /**
  11300. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11301. */
  11302. isPickable: boolean;
  11303. /**
  11304. * Gets the hosting scene
  11305. */
  11306. scene: Scene;
  11307. /**
  11308. * Specifies the rendering group id for this mesh (0 by default)
  11309. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11310. */
  11311. renderingGroupId: number;
  11312. /**
  11313. * Defines the list of sprites managed by the manager.
  11314. */
  11315. sprites: Array<Sprite>;
  11316. /**
  11317. * Gets or sets the spritesheet texture
  11318. */
  11319. texture: Texture;
  11320. /** Defines the default width of a cell in the spritesheet */
  11321. cellWidth: number;
  11322. /** Defines the default height of a cell in the spritesheet */
  11323. cellHeight: number;
  11324. /**
  11325. * Tests the intersection of a sprite with a specific ray.
  11326. * @param ray The ray we are sending to test the collision
  11327. * @param camera The camera space we are sending rays in
  11328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11329. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11330. * @returns picking info or null.
  11331. */
  11332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11333. /**
  11334. * Intersects the sprites with a ray
  11335. * @param ray defines the ray to intersect with
  11336. * @param camera defines the current active camera
  11337. * @param predicate defines a predicate used to select candidate sprites
  11338. * @returns null if no hit or a PickingInfo array
  11339. */
  11340. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11341. /**
  11342. * Renders the list of sprites on screen.
  11343. */
  11344. render(): void;
  11345. }
  11346. /**
  11347. * Class used to manage multiple sprites on the same spritesheet
  11348. * @see https://doc.babylonjs.com/babylon101/sprites
  11349. */
  11350. export class SpriteManager implements ISpriteManager {
  11351. /** defines the manager's name */
  11352. name: string;
  11353. /** Define the Url to load snippets */
  11354. static SnippetUrl: string;
  11355. /** Snippet ID if the manager was created from the snippet server */
  11356. snippetId: string;
  11357. /** Gets the list of sprites */
  11358. sprites: Sprite[];
  11359. /** Gets or sets the rendering group id (0 by default) */
  11360. renderingGroupId: number;
  11361. /** Gets or sets camera layer mask */
  11362. layerMask: number;
  11363. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11364. fogEnabled: boolean;
  11365. /** Gets or sets a boolean indicating if the sprites are pickable */
  11366. isPickable: boolean;
  11367. /** Defines the default width of a cell in the spritesheet */
  11368. cellWidth: number;
  11369. /** Defines the default height of a cell in the spritesheet */
  11370. cellHeight: number;
  11371. /** Associative array from JSON sprite data file */
  11372. private _cellData;
  11373. /** Array of sprite names from JSON sprite data file */
  11374. private _spriteMap;
  11375. /** True when packed cell data from JSON file is ready*/
  11376. private _packedAndReady;
  11377. private _textureContent;
  11378. private _useInstancing;
  11379. /**
  11380. * An event triggered when the manager is disposed.
  11381. */
  11382. onDisposeObservable: Observable<SpriteManager>;
  11383. private _onDisposeObserver;
  11384. /**
  11385. * Callback called when the manager is disposed
  11386. */
  11387. set onDispose(callback: () => void);
  11388. private _capacity;
  11389. private _fromPacked;
  11390. private _spriteTexture;
  11391. private _epsilon;
  11392. private _scene;
  11393. private _vertexData;
  11394. private _buffer;
  11395. private _vertexBuffers;
  11396. private _spriteBuffer;
  11397. private _indexBuffer;
  11398. private _effectBase;
  11399. private _effectFog;
  11400. private _vertexBufferSize;
  11401. /**
  11402. * Gets or sets the unique id of the sprite
  11403. */
  11404. uniqueId: number;
  11405. /**
  11406. * Gets the array of sprites
  11407. */
  11408. get children(): Sprite[];
  11409. /**
  11410. * Gets the hosting scene
  11411. */
  11412. get scene(): Scene;
  11413. /**
  11414. * Gets the capacity of the manager
  11415. */
  11416. get capacity(): number;
  11417. /**
  11418. * Gets or sets the spritesheet texture
  11419. */
  11420. get texture(): Texture;
  11421. set texture(value: Texture);
  11422. private _blendMode;
  11423. /**
  11424. * Blend mode use to render the particle, it can be any of
  11425. * the static Constants.ALPHA_x properties provided in this class.
  11426. * Default value is Constants.ALPHA_COMBINE
  11427. */
  11428. get blendMode(): number;
  11429. set blendMode(blendMode: number);
  11430. /** Disables writing to the depth buffer when rendering the sprites.
  11431. * It can be handy to disable depth writing when using textures without alpha channel
  11432. * and setting some specific blend modes.
  11433. */
  11434. disableDepthWrite: boolean;
  11435. /**
  11436. * Creates a new sprite manager
  11437. * @param name defines the manager's name
  11438. * @param imgUrl defines the sprite sheet url
  11439. * @param capacity defines the maximum allowed number of sprites
  11440. * @param cellSize defines the size of a sprite cell
  11441. * @param scene defines the hosting scene
  11442. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11443. * @param samplingMode defines the smapling mode to use with spritesheet
  11444. * @param fromPacked set to false; do not alter
  11445. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11446. */
  11447. constructor(
  11448. /** defines the manager's name */
  11449. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11450. /**
  11451. * Returns the string "SpriteManager"
  11452. * @returns "SpriteManager"
  11453. */
  11454. getClassName(): string;
  11455. private _makePacked;
  11456. private _appendSpriteVertex;
  11457. private _checkTextureAlpha;
  11458. /**
  11459. * Intersects the sprites with a ray
  11460. * @param ray defines the ray to intersect with
  11461. * @param camera defines the current active camera
  11462. * @param predicate defines a predicate used to select candidate sprites
  11463. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11464. * @returns null if no hit or a PickingInfo
  11465. */
  11466. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11467. /**
  11468. * Intersects the sprites with a ray
  11469. * @param ray defines the ray to intersect with
  11470. * @param camera defines the current active camera
  11471. * @param predicate defines a predicate used to select candidate sprites
  11472. * @returns null if no hit or a PickingInfo array
  11473. */
  11474. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11475. /**
  11476. * Render all child sprites
  11477. */
  11478. render(): void;
  11479. /**
  11480. * Release associated resources
  11481. */
  11482. dispose(): void;
  11483. /**
  11484. * Serializes the sprite manager to a JSON object
  11485. * @param serializeTexture defines if the texture must be serialized as well
  11486. * @returns the JSON object
  11487. */
  11488. serialize(serializeTexture?: boolean): any;
  11489. /**
  11490. * Parses a JSON object to create a new sprite manager.
  11491. * @param parsedManager The JSON object to parse
  11492. * @param scene The scene to create the sprite managerin
  11493. * @param rootUrl The root url to use to load external dependencies like texture
  11494. * @returns the new sprite manager
  11495. */
  11496. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11497. /**
  11498. * Creates a sprite manager from a snippet saved in a remote file
  11499. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11500. * @param url defines the url to load from
  11501. * @param scene defines the hosting scene
  11502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11503. * @returns a promise that will resolve to the new sprite manager
  11504. */
  11505. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11506. /**
  11507. * Creates a sprite manager from a snippet saved by the sprite editor
  11508. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11509. * @param scene defines the hosting scene
  11510. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11511. * @returns a promise that will resolve to the new sprite manager
  11512. */
  11513. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11514. }
  11515. }
  11516. declare module "babylonjs/Misc/gradients" {
  11517. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11518. /** Interface used by value gradients (color, factor, ...) */
  11519. export interface IValueGradient {
  11520. /**
  11521. * Gets or sets the gradient value (between 0 and 1)
  11522. */
  11523. gradient: number;
  11524. }
  11525. /** Class used to store color4 gradient */
  11526. export class ColorGradient implements IValueGradient {
  11527. /**
  11528. * Gets or sets the gradient value (between 0 and 1)
  11529. */
  11530. gradient: number;
  11531. /**
  11532. * Gets or sets first associated color
  11533. */
  11534. color1: Color4;
  11535. /**
  11536. * Gets or sets second associated color
  11537. */
  11538. color2?: Color4 | undefined;
  11539. /**
  11540. * Creates a new color4 gradient
  11541. * @param gradient gets or sets the gradient value (between 0 and 1)
  11542. * @param color1 gets or sets first associated color
  11543. * @param color2 gets or sets first second color
  11544. */
  11545. constructor(
  11546. /**
  11547. * Gets or sets the gradient value (between 0 and 1)
  11548. */
  11549. gradient: number,
  11550. /**
  11551. * Gets or sets first associated color
  11552. */
  11553. color1: Color4,
  11554. /**
  11555. * Gets or sets second associated color
  11556. */
  11557. color2?: Color4 | undefined);
  11558. /**
  11559. * Will get a color picked randomly between color1 and color2.
  11560. * If color2 is undefined then color1 will be used
  11561. * @param result defines the target Color4 to store the result in
  11562. */
  11563. getColorToRef(result: Color4): void;
  11564. }
  11565. /** Class used to store color 3 gradient */
  11566. export class Color3Gradient implements IValueGradient {
  11567. /**
  11568. * Gets or sets the gradient value (between 0 and 1)
  11569. */
  11570. gradient: number;
  11571. /**
  11572. * Gets or sets the associated color
  11573. */
  11574. color: Color3;
  11575. /**
  11576. * Creates a new color3 gradient
  11577. * @param gradient gets or sets the gradient value (between 0 and 1)
  11578. * @param color gets or sets associated color
  11579. */
  11580. constructor(
  11581. /**
  11582. * Gets or sets the gradient value (between 0 and 1)
  11583. */
  11584. gradient: number,
  11585. /**
  11586. * Gets or sets the associated color
  11587. */
  11588. color: Color3);
  11589. }
  11590. /** Class used to store factor gradient */
  11591. export class FactorGradient implements IValueGradient {
  11592. /**
  11593. * Gets or sets the gradient value (between 0 and 1)
  11594. */
  11595. gradient: number;
  11596. /**
  11597. * Gets or sets first associated factor
  11598. */
  11599. factor1: number;
  11600. /**
  11601. * Gets or sets second associated factor
  11602. */
  11603. factor2?: number | undefined;
  11604. /**
  11605. * Creates a new factor gradient
  11606. * @param gradient gets or sets the gradient value (between 0 and 1)
  11607. * @param factor1 gets or sets first associated factor
  11608. * @param factor2 gets or sets second associated factor
  11609. */
  11610. constructor(
  11611. /**
  11612. * Gets or sets the gradient value (between 0 and 1)
  11613. */
  11614. gradient: number,
  11615. /**
  11616. * Gets or sets first associated factor
  11617. */
  11618. factor1: number,
  11619. /**
  11620. * Gets or sets second associated factor
  11621. */
  11622. factor2?: number | undefined);
  11623. /**
  11624. * Will get a number picked randomly between factor1 and factor2.
  11625. * If factor2 is undefined then factor1 will be used
  11626. * @returns the picked number
  11627. */
  11628. getFactor(): number;
  11629. }
  11630. /**
  11631. * Helper used to simplify some generic gradient tasks
  11632. */
  11633. export class GradientHelper {
  11634. /**
  11635. * Gets the current gradient from an array of IValueGradient
  11636. * @param ratio defines the current ratio to get
  11637. * @param gradients defines the array of IValueGradient
  11638. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11639. */
  11640. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11641. }
  11642. }
  11643. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11644. import { Nullable } from "babylonjs/types";
  11645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11646. import { Scene } from "babylonjs/scene";
  11647. module "babylonjs/Engines/thinEngine" {
  11648. interface ThinEngine {
  11649. /**
  11650. * Creates a raw texture
  11651. * @param data defines the data to store in the texture
  11652. * @param width defines the width of the texture
  11653. * @param height defines the height of the texture
  11654. * @param format defines the format of the data
  11655. * @param generateMipMaps defines if the engine should generate the mip levels
  11656. * @param invertY defines if data must be stored with Y axis inverted
  11657. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11658. * @param compression defines the compression used (null by default)
  11659. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11660. * @returns the raw texture inside an InternalTexture
  11661. */
  11662. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11663. /**
  11664. * Update a raw texture
  11665. * @param texture defines the texture to update
  11666. * @param data defines the data to store in the texture
  11667. * @param format defines the format of the data
  11668. * @param invertY defines if data must be stored with Y axis inverted
  11669. */
  11670. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11671. /**
  11672. * Update a raw texture
  11673. * @param texture defines the texture to update
  11674. * @param data defines the data to store in the texture
  11675. * @param format defines the format of the data
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the compression used (null by default)
  11678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11679. */
  11680. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11681. /**
  11682. * Creates a new raw cube texture
  11683. * @param data defines the array of data to use to create each face
  11684. * @param size defines the size of the textures
  11685. * @param format defines the format of the data
  11686. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11687. * @param generateMipMaps defines if the engine should generate the mip levels
  11688. * @param invertY defines if data must be stored with Y axis inverted
  11689. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11690. * @param compression defines the compression used (null by default)
  11691. * @returns the cube texture as an InternalTexture
  11692. */
  11693. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11694. /**
  11695. * Update a raw cube texture
  11696. * @param texture defines the texture to udpdate
  11697. * @param data defines the data to store
  11698. * @param format defines the data format
  11699. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11700. * @param invertY defines if data must be stored with Y axis inverted
  11701. */
  11702. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11703. /**
  11704. * Update a raw cube texture
  11705. * @param texture defines the texture to udpdate
  11706. * @param data defines the data to store
  11707. * @param format defines the data format
  11708. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. * @param compression defines the compression used (null by default)
  11711. */
  11712. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11713. /**
  11714. * Update a raw cube texture
  11715. * @param texture defines the texture to udpdate
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11719. * @param invertY defines if data must be stored with Y axis inverted
  11720. * @param compression defines the compression used (null by default)
  11721. * @param level defines which level of the texture to update
  11722. */
  11723. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11724. /**
  11725. * Creates a new raw cube texture from a specified url
  11726. * @param url defines the url where the data is located
  11727. * @param scene defines the current scene
  11728. * @param size defines the size of the textures
  11729. * @param format defines the format of the data
  11730. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11731. * @param noMipmap defines if the engine should avoid generating the mip levels
  11732. * @param callback defines a callback used to extract texture data from loaded data
  11733. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11734. * @param onLoad defines a callback called when texture is loaded
  11735. * @param onError defines a callback called if there is an error
  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>): InternalTexture;
  11739. /**
  11740. * Creates a new raw cube texture from a specified url
  11741. * @param url defines the url where the data is located
  11742. * @param scene defines the current scene
  11743. * @param size defines the size of the textures
  11744. * @param format defines the format of the data
  11745. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11746. * @param noMipmap defines if the engine should avoid generating the mip levels
  11747. * @param callback defines a callback used to extract texture data from loaded data
  11748. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11749. * @param onLoad defines a callback called when texture is loaded
  11750. * @param onError defines a callback called if there is an error
  11751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11752. * @param invertY defines if data must be stored with Y axis inverted
  11753. * @returns the cube texture as an InternalTexture
  11754. */
  11755. 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;
  11756. /**
  11757. * Creates a new raw 3D texture
  11758. * @param data defines the data used to create the texture
  11759. * @param width defines the width of the texture
  11760. * @param height defines the height of the texture
  11761. * @param depth defines the depth of the texture
  11762. * @param format defines the format of the texture
  11763. * @param generateMipMaps defines if the engine must generate mip levels
  11764. * @param invertY defines if data must be stored with Y axis inverted
  11765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11766. * @param compression defines the compressed used (can be null)
  11767. * @param textureType defines the compressed used (can be null)
  11768. * @returns a new raw 3D texture (stored in an InternalTexture)
  11769. */
  11770. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11771. /**
  11772. * Update a raw 3D texture
  11773. * @param texture defines the texture to update
  11774. * @param data defines the data to store
  11775. * @param format defines the data format
  11776. * @param invertY defines if data must be stored with Y axis inverted
  11777. */
  11778. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11779. /**
  11780. * Update a raw 3D texture
  11781. * @param texture defines the texture to update
  11782. * @param data defines the data to store
  11783. * @param format defines the data format
  11784. * @param invertY defines if data must be stored with Y axis inverted
  11785. * @param compression defines the used compression (can be null)
  11786. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11787. */
  11788. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11789. /**
  11790. * Creates a new raw 2D array texture
  11791. * @param data defines the data used to create the texture
  11792. * @param width defines the width of the texture
  11793. * @param height defines the height of the texture
  11794. * @param depth defines the number of layers of the texture
  11795. * @param format defines the format of the texture
  11796. * @param generateMipMaps defines if the engine must generate mip levels
  11797. * @param invertY defines if data must be stored with Y axis inverted
  11798. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11799. * @param compression defines the compressed used (can be null)
  11800. * @param textureType defines the compressed used (can be null)
  11801. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11802. */
  11803. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11804. /**
  11805. * Update a raw 2D array texture
  11806. * @param texture defines the texture to update
  11807. * @param data defines the data to store
  11808. * @param format defines the data format
  11809. * @param invertY defines if data must be stored with Y axis inverted
  11810. */
  11811. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11812. /**
  11813. * Update a raw 2D array texture
  11814. * @param texture defines the texture to update
  11815. * @param data defines the data to store
  11816. * @param format defines the data format
  11817. * @param invertY defines if data must be stored with Y axis inverted
  11818. * @param compression defines the used compression (can be null)
  11819. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11820. */
  11821. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11822. }
  11823. }
  11824. }
  11825. declare module "babylonjs/Materials/Textures/rawTexture" {
  11826. import { Texture } from "babylonjs/Materials/Textures/texture";
  11827. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11828. import { Nullable } from "babylonjs/types";
  11829. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11830. import { Scene } from "babylonjs/scene";
  11831. /**
  11832. * Raw texture can help creating a texture directly from an array of data.
  11833. * This can be super useful if you either get the data from an uncompressed source or
  11834. * if you wish to create your texture pixel by pixel.
  11835. */
  11836. export class RawTexture extends Texture {
  11837. /**
  11838. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11839. */
  11840. format: number;
  11841. /**
  11842. * Instantiates a new RawTexture.
  11843. * Raw texture can help creating a texture directly from an array of data.
  11844. * This can be super useful if you either get the data from an uncompressed source or
  11845. * if you wish to create your texture pixel by pixel.
  11846. * @param data define the array of data to use to create the texture
  11847. * @param width define the width of the texture
  11848. * @param height define the height of the texture
  11849. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11850. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11851. * @param generateMipMaps define whether mip maps should be generated or not
  11852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11855. */
  11856. constructor(data: ArrayBufferView, width: number, height: number,
  11857. /**
  11858. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11859. */
  11860. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11861. /**
  11862. * Updates the texture underlying data.
  11863. * @param data Define the new data of the texture
  11864. */
  11865. update(data: ArrayBufferView): void;
  11866. /**
  11867. * Creates a luminance texture from some data.
  11868. * @param data Define the texture data
  11869. * @param width Define the width of the texture
  11870. * @param height Define the height of the texture
  11871. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11872. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11873. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11874. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11875. * @returns the luminance texture
  11876. */
  11877. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11878. /**
  11879. * Creates a luminance alpha texture from some data.
  11880. * @param data Define the texture data
  11881. * @param width Define the width of the texture
  11882. * @param height Define the height of the texture
  11883. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11887. * @returns the luminance alpha texture
  11888. */
  11889. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11890. /**
  11891. * Creates an alpha texture from some data.
  11892. * @param data Define the texture data
  11893. * @param width Define the width of the texture
  11894. * @param height Define the height of the texture
  11895. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11896. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11897. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11898. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11899. * @returns the alpha texture
  11900. */
  11901. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11902. /**
  11903. * Creates a RGB texture from some data.
  11904. * @param data Define the texture data
  11905. * @param width Define the width of the texture
  11906. * @param height Define the height of the texture
  11907. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11911. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11912. * @returns the RGB alpha texture
  11913. */
  11914. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11915. /**
  11916. * Creates a RGBA texture from some data.
  11917. * @param data Define the texture data
  11918. * @param width Define the width of the texture
  11919. * @param height Define the height of the texture
  11920. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11924. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11925. * @returns the RGBA texture
  11926. */
  11927. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11928. /**
  11929. * Creates a R texture from some data.
  11930. * @param data Define the texture data
  11931. * @param width Define the width of the texture
  11932. * @param height Define the height of the texture
  11933. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11937. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11938. * @returns the R texture
  11939. */
  11940. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11941. }
  11942. }
  11943. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11945. import { IndicesArray, DataArray } from "babylonjs/types";
  11946. module "babylonjs/Engines/thinEngine" {
  11947. interface ThinEngine {
  11948. /**
  11949. * Update a dynamic index buffer
  11950. * @param indexBuffer defines the target index buffer
  11951. * @param indices defines the data to update
  11952. * @param offset defines the offset in the target index buffer where update should start
  11953. */
  11954. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11955. /**
  11956. * Updates a dynamic vertex buffer.
  11957. * @param vertexBuffer the vertex buffer to update
  11958. * @param data the data used to update the vertex buffer
  11959. * @param byteOffset the byte offset of the data
  11960. * @param byteLength the byte length of the data
  11961. */
  11962. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11963. }
  11964. }
  11965. }
  11966. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11967. import { Scene } from "babylonjs/scene";
  11968. import { ISceneComponent } from "babylonjs/sceneComponent";
  11969. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11970. module "babylonjs/abstractScene" {
  11971. interface AbstractScene {
  11972. /**
  11973. * The list of procedural textures added to the scene
  11974. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11975. */
  11976. proceduralTextures: Array<ProceduralTexture>;
  11977. }
  11978. }
  11979. /**
  11980. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11981. * in a given scene.
  11982. */
  11983. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11984. /**
  11985. * The component name helpfull to identify the component in the list of scene components.
  11986. */
  11987. readonly name: string;
  11988. /**
  11989. * The scene the component belongs to.
  11990. */
  11991. scene: Scene;
  11992. /**
  11993. * Creates a new instance of the component for the given scene
  11994. * @param scene Defines the scene to register the component in
  11995. */
  11996. constructor(scene: Scene);
  11997. /**
  11998. * Registers the component in a given scene
  11999. */
  12000. register(): void;
  12001. /**
  12002. * Rebuilds the elements related to this component in case of
  12003. * context lost for instance.
  12004. */
  12005. rebuild(): void;
  12006. /**
  12007. * Disposes the component and the associated ressources.
  12008. */
  12009. dispose(): void;
  12010. private _beforeClear;
  12011. }
  12012. }
  12013. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  12014. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12015. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  12016. module "babylonjs/Engines/thinEngine" {
  12017. interface ThinEngine {
  12018. /**
  12019. * Creates a new render target cube texture
  12020. * @param size defines the size of the texture
  12021. * @param options defines the options used to create the texture
  12022. * @returns a new render target cube texture stored in an InternalTexture
  12023. */
  12024. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  12025. }
  12026. }
  12027. }
  12028. declare module "babylonjs/Shaders/procedural.vertex" {
  12029. /** @hidden */
  12030. export var proceduralVertexShader: {
  12031. name: string;
  12032. shader: string;
  12033. };
  12034. }
  12035. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12036. import { Observable } from "babylonjs/Misc/observable";
  12037. import { Nullable } from "babylonjs/types";
  12038. import { Scene } from "babylonjs/scene";
  12039. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12040. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12041. import { Effect } from "babylonjs/Materials/effect";
  12042. import { Texture } from "babylonjs/Materials/Textures/texture";
  12043. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12044. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12045. import "babylonjs/Shaders/procedural.vertex";
  12046. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12047. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12048. /**
  12049. * 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.
  12050. * This is the base class of any Procedural texture and contains most of the shareable code.
  12051. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12052. */
  12053. export class ProceduralTexture extends Texture {
  12054. /**
  12055. * Define if the texture is enabled or not (disabled texture will not render)
  12056. */
  12057. isEnabled: boolean;
  12058. /**
  12059. * Define if the texture must be cleared before rendering (default is true)
  12060. */
  12061. autoClear: boolean;
  12062. /**
  12063. * Callback called when the texture is generated
  12064. */
  12065. onGenerated: () => void;
  12066. /**
  12067. * Event raised when the texture is generated
  12068. */
  12069. onGeneratedObservable: Observable<ProceduralTexture>;
  12070. /**
  12071. * Event raised before the texture is generated
  12072. */
  12073. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12074. /**
  12075. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12076. */
  12077. nodeMaterialSource: Nullable<NodeMaterial>;
  12078. /** @hidden */
  12079. _generateMipMaps: boolean;
  12080. /** @hidden **/
  12081. _effect: Effect;
  12082. /** @hidden */
  12083. _textures: {
  12084. [key: string]: Texture;
  12085. };
  12086. /** @hidden */
  12087. protected _fallbackTexture: Nullable<Texture>;
  12088. private _size;
  12089. private _currentRefreshId;
  12090. private _frameId;
  12091. private _refreshRate;
  12092. private _vertexBuffers;
  12093. private _indexBuffer;
  12094. private _uniforms;
  12095. private _samplers;
  12096. private _fragment;
  12097. private _floats;
  12098. private _ints;
  12099. private _floatsArrays;
  12100. private _colors3;
  12101. private _colors4;
  12102. private _vectors2;
  12103. private _vectors3;
  12104. private _matrices;
  12105. private _fallbackTextureUsed;
  12106. private _fullEngine;
  12107. private _cachedDefines;
  12108. private _contentUpdateId;
  12109. private _contentData;
  12110. /**
  12111. * Instantiates a new procedural texture.
  12112. * 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.
  12113. * This is the base class of any Procedural texture and contains most of the shareable code.
  12114. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12115. * @param name Define the name of the texture
  12116. * @param size Define the size of the texture to create
  12117. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12118. * @param scene Define the scene the texture belongs to
  12119. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12120. * @param generateMipMaps Define if the texture should creates mip maps or not
  12121. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12122. * @param textureType The FBO internal texture type
  12123. */
  12124. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12125. /**
  12126. * The effect that is created when initializing the post process.
  12127. * @returns The created effect corresponding the the postprocess.
  12128. */
  12129. getEffect(): Effect;
  12130. /**
  12131. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12132. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12133. */
  12134. getContent(): Nullable<ArrayBufferView>;
  12135. private _createIndexBuffer;
  12136. /** @hidden */
  12137. _rebuild(): void;
  12138. /**
  12139. * Resets the texture in order to recreate its associated resources.
  12140. * This can be called in case of context loss
  12141. */
  12142. reset(): void;
  12143. protected _getDefines(): string;
  12144. /**
  12145. * Is the texture ready to be used ? (rendered at least once)
  12146. * @returns true if ready, otherwise, false.
  12147. */
  12148. isReady(): boolean;
  12149. /**
  12150. * Resets the refresh counter of the texture and start bak from scratch.
  12151. * Could be useful to regenerate the texture if it is setup to render only once.
  12152. */
  12153. resetRefreshCounter(): void;
  12154. /**
  12155. * Set the fragment shader to use in order to render the texture.
  12156. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12157. */
  12158. setFragment(fragment: any): void;
  12159. /**
  12160. * Define the refresh rate of the texture or the rendering frequency.
  12161. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12162. */
  12163. get refreshRate(): number;
  12164. set refreshRate(value: number);
  12165. /** @hidden */
  12166. _shouldRender(): boolean;
  12167. /**
  12168. * Get the size the texture is rendering at.
  12169. * @returns the size (on cube texture it is always squared)
  12170. */
  12171. getRenderSize(): RenderTargetTextureSize;
  12172. /**
  12173. * Resize the texture to new value.
  12174. * @param size Define the new size the texture should have
  12175. * @param generateMipMaps Define whether the new texture should create mip maps
  12176. */
  12177. resize(size: number, generateMipMaps: boolean): void;
  12178. private _checkUniform;
  12179. /**
  12180. * Set a texture in the shader program used to render.
  12181. * @param name Define the name of the uniform samplers as defined in the shader
  12182. * @param texture Define the texture to bind to this sampler
  12183. * @return the texture itself allowing "fluent" like uniform updates
  12184. */
  12185. setTexture(name: string, texture: Texture): ProceduralTexture;
  12186. /**
  12187. * Set a float in the shader.
  12188. * @param name Define the name of the uniform as defined in the shader
  12189. * @param value Define the value to give to the uniform
  12190. * @return the texture itself allowing "fluent" like uniform updates
  12191. */
  12192. setFloat(name: string, value: number): ProceduralTexture;
  12193. /**
  12194. * Set a int in the shader.
  12195. * @param name Define the name of the uniform as defined in the shader
  12196. * @param value Define the value to give to the uniform
  12197. * @return the texture itself allowing "fluent" like uniform updates
  12198. */
  12199. setInt(name: string, value: number): ProceduralTexture;
  12200. /**
  12201. * Set an array of floats in the shader.
  12202. * @param name Define the name of the uniform as defined in the shader
  12203. * @param value Define the value to give to the uniform
  12204. * @return the texture itself allowing "fluent" like uniform updates
  12205. */
  12206. setFloats(name: string, value: number[]): ProceduralTexture;
  12207. /**
  12208. * Set a vec3 in the shader from a Color3.
  12209. * @param name Define the name of the uniform as defined in the shader
  12210. * @param value Define the value to give to the uniform
  12211. * @return the texture itself allowing "fluent" like uniform updates
  12212. */
  12213. setColor3(name: string, value: Color3): ProceduralTexture;
  12214. /**
  12215. * Set a vec4 in the shader from a Color4.
  12216. * @param name Define the name of the uniform as defined in the shader
  12217. * @param value Define the value to give to the uniform
  12218. * @return the texture itself allowing "fluent" like uniform updates
  12219. */
  12220. setColor4(name: string, value: Color4): ProceduralTexture;
  12221. /**
  12222. * Set a vec2 in the shader from a Vector2.
  12223. * @param name Define the name of the uniform as defined in the shader
  12224. * @param value Define the value to give to the uniform
  12225. * @return the texture itself allowing "fluent" like uniform updates
  12226. */
  12227. setVector2(name: string, value: Vector2): ProceduralTexture;
  12228. /**
  12229. * Set a vec3 in the shader from a Vector3.
  12230. * @param name Define the name of the uniform as defined in the shader
  12231. * @param value Define the value to give to the uniform
  12232. * @return the texture itself allowing "fluent" like uniform updates
  12233. */
  12234. setVector3(name: string, value: Vector3): ProceduralTexture;
  12235. /**
  12236. * Set a mat4 in the shader from a MAtrix.
  12237. * @param name Define the name of the uniform as defined in the shader
  12238. * @param value Define the value to give to the uniform
  12239. * @return the texture itself allowing "fluent" like uniform updates
  12240. */
  12241. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12242. /**
  12243. * Render the texture to its associated render target.
  12244. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12245. */
  12246. render(useCameraPostProcess?: boolean): void;
  12247. /**
  12248. * Clone the texture.
  12249. * @returns the cloned texture
  12250. */
  12251. clone(): ProceduralTexture;
  12252. /**
  12253. * Dispose the texture and release its asoociated resources.
  12254. */
  12255. dispose(): void;
  12256. }
  12257. }
  12258. declare module "babylonjs/Particles/baseParticleSystem" {
  12259. import { Nullable } from "babylonjs/types";
  12260. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12262. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12263. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12264. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12266. import { Color4 } from "babylonjs/Maths/math.color";
  12267. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12268. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12269. import { Animation } from "babylonjs/Animations/animation";
  12270. import { Scene } from "babylonjs/scene";
  12271. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12272. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12273. /**
  12274. * This represents the base class for particle system in Babylon.
  12275. * 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.
  12276. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12277. * @example https://doc.babylonjs.com/babylon101/particles
  12278. */
  12279. export class BaseParticleSystem {
  12280. /**
  12281. * Source color is added to the destination color without alpha affecting the result
  12282. */
  12283. static BLENDMODE_ONEONE: number;
  12284. /**
  12285. * Blend current color and particle color using particle’s alpha
  12286. */
  12287. static BLENDMODE_STANDARD: number;
  12288. /**
  12289. * Add current color and particle color multiplied by particle’s alpha
  12290. */
  12291. static BLENDMODE_ADD: number;
  12292. /**
  12293. * Multiply current color with particle color
  12294. */
  12295. static BLENDMODE_MULTIPLY: number;
  12296. /**
  12297. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12298. */
  12299. static BLENDMODE_MULTIPLYADD: number;
  12300. /**
  12301. * List of animations used by the particle system.
  12302. */
  12303. animations: Animation[];
  12304. /**
  12305. * Gets or sets the unique id of the particle system
  12306. */
  12307. uniqueId: number;
  12308. /**
  12309. * The id of the Particle system.
  12310. */
  12311. id: string;
  12312. /**
  12313. * The friendly name of the Particle system.
  12314. */
  12315. name: string;
  12316. /**
  12317. * Snippet ID if the particle system was created from the snippet server
  12318. */
  12319. snippetId: string;
  12320. /**
  12321. * The rendering group used by the Particle system to chose when to render.
  12322. */
  12323. renderingGroupId: number;
  12324. /**
  12325. * The emitter represents the Mesh or position we are attaching the particle system to.
  12326. */
  12327. emitter: Nullable<AbstractMesh | Vector3>;
  12328. /**
  12329. * The maximum number of particles to emit per frame
  12330. */
  12331. emitRate: number;
  12332. /**
  12333. * If you want to launch only a few particles at once, that can be done, as well.
  12334. */
  12335. manualEmitCount: number;
  12336. /**
  12337. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12338. */
  12339. updateSpeed: number;
  12340. /**
  12341. * The amount of time the particle system is running (depends of the overall update speed).
  12342. */
  12343. targetStopDuration: number;
  12344. /**
  12345. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12346. */
  12347. disposeOnStop: boolean;
  12348. /**
  12349. * Minimum power of emitting particles.
  12350. */
  12351. minEmitPower: number;
  12352. /**
  12353. * Maximum power of emitting particles.
  12354. */
  12355. maxEmitPower: number;
  12356. /**
  12357. * Minimum life time of emitting particles.
  12358. */
  12359. minLifeTime: number;
  12360. /**
  12361. * Maximum life time of emitting particles.
  12362. */
  12363. maxLifeTime: number;
  12364. /**
  12365. * Minimum Size of emitting particles.
  12366. */
  12367. minSize: number;
  12368. /**
  12369. * Maximum Size of emitting particles.
  12370. */
  12371. maxSize: number;
  12372. /**
  12373. * Minimum scale of emitting particles on X axis.
  12374. */
  12375. minScaleX: number;
  12376. /**
  12377. * Maximum scale of emitting particles on X axis.
  12378. */
  12379. maxScaleX: number;
  12380. /**
  12381. * Minimum scale of emitting particles on Y axis.
  12382. */
  12383. minScaleY: number;
  12384. /**
  12385. * Maximum scale of emitting particles on Y axis.
  12386. */
  12387. maxScaleY: number;
  12388. /**
  12389. * Gets or sets the minimal initial rotation in radians.
  12390. */
  12391. minInitialRotation: number;
  12392. /**
  12393. * Gets or sets the maximal initial rotation in radians.
  12394. */
  12395. maxInitialRotation: number;
  12396. /**
  12397. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12398. */
  12399. minAngularSpeed: number;
  12400. /**
  12401. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12402. */
  12403. maxAngularSpeed: number;
  12404. /**
  12405. * The texture used to render each particle. (this can be a spritesheet)
  12406. */
  12407. particleTexture: Nullable<BaseTexture>;
  12408. /**
  12409. * The layer mask we are rendering the particles through.
  12410. */
  12411. layerMask: number;
  12412. /**
  12413. * This can help using your own shader to render the particle system.
  12414. * The according effect will be created
  12415. */
  12416. customShader: any;
  12417. /**
  12418. * By default particle system starts as soon as they are created. This prevents the
  12419. * automatic start to happen and let you decide when to start emitting particles.
  12420. */
  12421. preventAutoStart: boolean;
  12422. private _noiseTexture;
  12423. /**
  12424. * Gets or sets a texture used to add random noise to particle positions
  12425. */
  12426. get noiseTexture(): Nullable<ProceduralTexture>;
  12427. set noiseTexture(value: Nullable<ProceduralTexture>);
  12428. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12429. noiseStrength: Vector3;
  12430. /**
  12431. * Callback triggered when the particle animation is ending.
  12432. */
  12433. onAnimationEnd: Nullable<() => void>;
  12434. /**
  12435. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12436. */
  12437. blendMode: number;
  12438. /**
  12439. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12440. * to override the particles.
  12441. */
  12442. forceDepthWrite: boolean;
  12443. /** 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 */
  12444. preWarmCycles: number;
  12445. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12446. preWarmStepOffset: number;
  12447. /**
  12448. * 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)
  12449. */
  12450. spriteCellChangeSpeed: number;
  12451. /**
  12452. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12453. */
  12454. startSpriteCellID: number;
  12455. /**
  12456. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12457. */
  12458. endSpriteCellID: number;
  12459. /**
  12460. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12461. */
  12462. spriteCellWidth: number;
  12463. /**
  12464. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12465. */
  12466. spriteCellHeight: number;
  12467. /**
  12468. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12469. */
  12470. spriteRandomStartCell: boolean;
  12471. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12472. translationPivot: Vector2;
  12473. /** @hidden */
  12474. protected _isAnimationSheetEnabled: boolean;
  12475. /**
  12476. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12477. */
  12478. beginAnimationOnStart: boolean;
  12479. /**
  12480. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12481. */
  12482. beginAnimationFrom: number;
  12483. /**
  12484. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12485. */
  12486. beginAnimationTo: number;
  12487. /**
  12488. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12489. */
  12490. beginAnimationLoop: boolean;
  12491. /**
  12492. * Gets or sets a world offset applied to all particles
  12493. */
  12494. worldOffset: Vector3;
  12495. /**
  12496. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12497. */
  12498. get isAnimationSheetEnabled(): boolean;
  12499. set isAnimationSheetEnabled(value: boolean);
  12500. /**
  12501. * Get hosting scene
  12502. * @returns the scene
  12503. */
  12504. getScene(): Nullable<Scene>;
  12505. /**
  12506. * You can use gravity if you want to give an orientation to your particles.
  12507. */
  12508. gravity: Vector3;
  12509. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12510. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12511. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12512. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12513. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12514. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12515. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12516. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12517. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12518. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12519. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12520. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12521. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12522. /**
  12523. * Defines the delay in milliseconds before starting the system (0 by default)
  12524. */
  12525. startDelay: number;
  12526. /**
  12527. * Gets the current list of drag gradients.
  12528. * You must use addDragGradient and removeDragGradient to udpate this list
  12529. * @returns the list of drag gradients
  12530. */
  12531. getDragGradients(): Nullable<Array<FactorGradient>>;
  12532. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12533. limitVelocityDamping: number;
  12534. /**
  12535. * Gets the current list of limit velocity gradients.
  12536. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12537. * @returns the list of limit velocity gradients
  12538. */
  12539. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12540. /**
  12541. * Gets the current list of color gradients.
  12542. * You must use addColorGradient and removeColorGradient to udpate this list
  12543. * @returns the list of color gradients
  12544. */
  12545. getColorGradients(): Nullable<Array<ColorGradient>>;
  12546. /**
  12547. * Gets the current list of size gradients.
  12548. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12549. * @returns the list of size gradients
  12550. */
  12551. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12552. /**
  12553. * Gets the current list of color remap gradients.
  12554. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12555. * @returns the list of color remap gradients
  12556. */
  12557. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12558. /**
  12559. * Gets the current list of alpha remap gradients.
  12560. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12561. * @returns the list of alpha remap gradients
  12562. */
  12563. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12564. /**
  12565. * Gets the current list of life time gradients.
  12566. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12567. * @returns the list of life time gradients
  12568. */
  12569. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12570. /**
  12571. * Gets the current list of angular speed gradients.
  12572. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12573. * @returns the list of angular speed gradients
  12574. */
  12575. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12576. /**
  12577. * Gets the current list of velocity gradients.
  12578. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12579. * @returns the list of velocity gradients
  12580. */
  12581. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12582. /**
  12583. * Gets the current list of start size gradients.
  12584. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12585. * @returns the list of start size gradients
  12586. */
  12587. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12588. /**
  12589. * Gets the current list of emit rate gradients.
  12590. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12591. * @returns the list of emit rate gradients
  12592. */
  12593. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12594. /**
  12595. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12596. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12597. */
  12598. get direction1(): Vector3;
  12599. set direction1(value: Vector3);
  12600. /**
  12601. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12602. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12603. */
  12604. get direction2(): Vector3;
  12605. set direction2(value: Vector3);
  12606. /**
  12607. * 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.
  12608. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12609. */
  12610. get minEmitBox(): Vector3;
  12611. set minEmitBox(value: Vector3);
  12612. /**
  12613. * 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.
  12614. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12615. */
  12616. get maxEmitBox(): Vector3;
  12617. set maxEmitBox(value: Vector3);
  12618. /**
  12619. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12620. */
  12621. color1: Color4;
  12622. /**
  12623. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12624. */
  12625. color2: Color4;
  12626. /**
  12627. * Color the particle will have at the end of its lifetime
  12628. */
  12629. colorDead: Color4;
  12630. /**
  12631. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12632. */
  12633. textureMask: Color4;
  12634. /**
  12635. * The particle emitter type defines the emitter used by the particle system.
  12636. * It can be for example box, sphere, or cone...
  12637. */
  12638. particleEmitterType: IParticleEmitterType;
  12639. /** @hidden */
  12640. _isSubEmitter: boolean;
  12641. /**
  12642. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12643. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12644. */
  12645. billboardMode: number;
  12646. protected _isBillboardBased: boolean;
  12647. /**
  12648. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12649. */
  12650. get isBillboardBased(): boolean;
  12651. set isBillboardBased(value: boolean);
  12652. /**
  12653. * The scene the particle system belongs to.
  12654. */
  12655. protected _scene: Nullable<Scene>;
  12656. /**
  12657. * The engine the particle system belongs to.
  12658. */
  12659. protected _engine: ThinEngine;
  12660. /**
  12661. * Local cache of defines for image processing.
  12662. */
  12663. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12664. /**
  12665. * Default configuration related to image processing available in the standard Material.
  12666. */
  12667. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12668. /**
  12669. * Gets the image processing configuration used either in this material.
  12670. */
  12671. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12672. /**
  12673. * Sets the Default image processing configuration used either in the this material.
  12674. *
  12675. * If sets to null, the scene one is in use.
  12676. */
  12677. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12678. /**
  12679. * Attaches a new image processing configuration to the Standard Material.
  12680. * @param configuration
  12681. */
  12682. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12683. /** @hidden */
  12684. protected _reset(): void;
  12685. /** @hidden */
  12686. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12687. /**
  12688. * Instantiates a particle system.
  12689. * 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.
  12690. * @param name The name of the particle system
  12691. */
  12692. constructor(name: string);
  12693. /**
  12694. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12697. * @returns the emitter
  12698. */
  12699. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12700. /**
  12701. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12702. * @param radius The radius of the hemisphere to emit from
  12703. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12704. * @returns the emitter
  12705. */
  12706. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12707. /**
  12708. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12709. * @param radius The radius of the sphere to emit from
  12710. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12711. * @returns the emitter
  12712. */
  12713. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12714. /**
  12715. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12716. * @param radius The radius of the sphere to emit from
  12717. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12718. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12719. * @returns the emitter
  12720. */
  12721. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12722. /**
  12723. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12724. * @param radius The radius of the emission cylinder
  12725. * @param height The height of the emission cylinder
  12726. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12727. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12728. * @returns the emitter
  12729. */
  12730. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12731. /**
  12732. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12733. * @param radius The radius of the cylinder to emit from
  12734. * @param height The height of the emission cylinder
  12735. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12736. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12737. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12738. * @returns the emitter
  12739. */
  12740. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12741. /**
  12742. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12743. * @param radius The radius of the cone to emit from
  12744. * @param angle The base angle of the cone
  12745. * @returns the emitter
  12746. */
  12747. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12748. /**
  12749. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12752. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12753. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12754. * @returns the emitter
  12755. */
  12756. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12757. }
  12758. }
  12759. declare module "babylonjs/Particles/subEmitter" {
  12760. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12761. import { Scene } from "babylonjs/scene";
  12762. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12763. /**
  12764. * Type of sub emitter
  12765. */
  12766. export enum SubEmitterType {
  12767. /**
  12768. * Attached to the particle over it's lifetime
  12769. */
  12770. ATTACHED = 0,
  12771. /**
  12772. * Created when the particle dies
  12773. */
  12774. END = 1
  12775. }
  12776. /**
  12777. * Sub emitter class used to emit particles from an existing particle
  12778. */
  12779. export class SubEmitter {
  12780. /**
  12781. * the particle system to be used by the sub emitter
  12782. */
  12783. particleSystem: ParticleSystem;
  12784. /**
  12785. * Type of the submitter (Default: END)
  12786. */
  12787. type: SubEmitterType;
  12788. /**
  12789. * 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)
  12790. * Note: This only is supported when using an emitter of type Mesh
  12791. */
  12792. inheritDirection: boolean;
  12793. /**
  12794. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12795. */
  12796. inheritedVelocityAmount: number;
  12797. /**
  12798. * Creates a sub emitter
  12799. * @param particleSystem the particle system to be used by the sub emitter
  12800. */
  12801. constructor(
  12802. /**
  12803. * the particle system to be used by the sub emitter
  12804. */
  12805. particleSystem: ParticleSystem);
  12806. /**
  12807. * Clones the sub emitter
  12808. * @returns the cloned sub emitter
  12809. */
  12810. clone(): SubEmitter;
  12811. /**
  12812. * Serialize current object to a JSON object
  12813. * @returns the serialized object
  12814. */
  12815. serialize(): any;
  12816. /** @hidden */
  12817. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12818. /**
  12819. * Creates a new SubEmitter from a serialized JSON version
  12820. * @param serializationObject defines the JSON object to read from
  12821. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12822. * @param rootUrl defines the rootUrl for data loading
  12823. * @returns a new SubEmitter
  12824. */
  12825. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12826. /** Release associated resources */
  12827. dispose(): void;
  12828. }
  12829. }
  12830. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12831. /** @hidden */
  12832. export var imageProcessingDeclaration: {
  12833. name: string;
  12834. shader: string;
  12835. };
  12836. }
  12837. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12838. /** @hidden */
  12839. export var imageProcessingFunctions: {
  12840. name: string;
  12841. shader: string;
  12842. };
  12843. }
  12844. declare module "babylonjs/Shaders/particles.fragment" {
  12845. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12846. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12848. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12849. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12850. /** @hidden */
  12851. export var particlesPixelShader: {
  12852. name: string;
  12853. shader: string;
  12854. };
  12855. }
  12856. declare module "babylonjs/Shaders/particles.vertex" {
  12857. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12859. /** @hidden */
  12860. export var particlesVertexShader: {
  12861. name: string;
  12862. shader: string;
  12863. };
  12864. }
  12865. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12866. import { Nullable } from "babylonjs/types";
  12867. import { Plane } from "babylonjs/Maths/math";
  12868. /**
  12869. * Interface used to define entities containing multiple clip planes
  12870. */
  12871. export interface IClipPlanesHolder {
  12872. /**
  12873. * Gets or sets the active clipplane 1
  12874. */
  12875. clipPlane: Nullable<Plane>;
  12876. /**
  12877. * Gets or sets the active clipplane 2
  12878. */
  12879. clipPlane2: Nullable<Plane>;
  12880. /**
  12881. * Gets or sets the active clipplane 3
  12882. */
  12883. clipPlane3: Nullable<Plane>;
  12884. /**
  12885. * Gets or sets the active clipplane 4
  12886. */
  12887. clipPlane4: Nullable<Plane>;
  12888. /**
  12889. * Gets or sets the active clipplane 5
  12890. */
  12891. clipPlane5: Nullable<Plane>;
  12892. /**
  12893. * Gets or sets the active clipplane 6
  12894. */
  12895. clipPlane6: Nullable<Plane>;
  12896. }
  12897. }
  12898. declare module "babylonjs/Materials/thinMaterialHelper" {
  12899. import { Effect } from "babylonjs/Materials/effect";
  12900. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12901. /**
  12902. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12903. *
  12904. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12905. *
  12906. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12907. */
  12908. export class ThinMaterialHelper {
  12909. /**
  12910. * Binds the clip plane information from the holder to the effect.
  12911. * @param effect The effect we are binding the data to
  12912. * @param holder The entity containing the clip plane information
  12913. */
  12914. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12915. }
  12916. }
  12917. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12918. module "babylonjs/Engines/thinEngine" {
  12919. interface ThinEngine {
  12920. /**
  12921. * Sets alpha constants used by some alpha blending modes
  12922. * @param r defines the red component
  12923. * @param g defines the green component
  12924. * @param b defines the blue component
  12925. * @param a defines the alpha component
  12926. */
  12927. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12928. /**
  12929. * Sets the current alpha mode
  12930. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12931. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12932. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12933. */
  12934. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12935. /**
  12936. * Gets the current alpha mode
  12937. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12938. * @returns the current alpha mode
  12939. */
  12940. getAlphaMode(): number;
  12941. /**
  12942. * Sets the current alpha equation
  12943. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12944. */
  12945. setAlphaEquation(equation: number): void;
  12946. /**
  12947. * Gets the current alpha equation.
  12948. * @returns the current alpha equation
  12949. */
  12950. getAlphaEquation(): number;
  12951. }
  12952. }
  12953. }
  12954. declare module "babylonjs/Particles/particleSystem" {
  12955. import { Nullable } from "babylonjs/types";
  12956. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12957. import { Observable } from "babylonjs/Misc/observable";
  12958. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12959. import { Effect } from "babylonjs/Materials/effect";
  12960. import { IDisposable } from "babylonjs/scene";
  12961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12962. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12963. import { Particle } from "babylonjs/Particles/particle";
  12964. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12965. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12966. import "babylonjs/Shaders/particles.fragment";
  12967. import "babylonjs/Shaders/particles.vertex";
  12968. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12969. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12970. import "babylonjs/Engines/Extensions/engine.alpha";
  12971. import { Scene } from "babylonjs/scene";
  12972. /**
  12973. * This represents a particle system in Babylon.
  12974. * 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.
  12975. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12976. * @example https://doc.babylonjs.com/babylon101/particles
  12977. */
  12978. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12979. /**
  12980. * Billboard mode will only apply to Y axis
  12981. */
  12982. static readonly BILLBOARDMODE_Y: number;
  12983. /**
  12984. * Billboard mode will apply to all axes
  12985. */
  12986. static readonly BILLBOARDMODE_ALL: number;
  12987. /**
  12988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12989. */
  12990. static readonly BILLBOARDMODE_STRETCHED: number;
  12991. /**
  12992. * This function can be defined to provide custom update for active particles.
  12993. * This function will be called instead of regular update (age, position, color, etc.).
  12994. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12995. */
  12996. updateFunction: (particles: Particle[]) => void;
  12997. private _emitterWorldMatrix;
  12998. /**
  12999. * This function can be defined to specify initial direction for every new particle.
  13000. * It by default use the emitterType defined function
  13001. */
  13002. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  13003. /**
  13004. * This function can be defined to specify initial position for every new particle.
  13005. * It by default use the emitterType defined function
  13006. */
  13007. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  13008. /**
  13009. * @hidden
  13010. */
  13011. _inheritedVelocityOffset: Vector3;
  13012. /**
  13013. * An event triggered when the system is disposed
  13014. */
  13015. onDisposeObservable: Observable<IParticleSystem>;
  13016. /**
  13017. * An event triggered when the system is stopped
  13018. */
  13019. onStoppedObservable: Observable<IParticleSystem>;
  13020. private _onDisposeObserver;
  13021. /**
  13022. * Sets a callback that will be triggered when the system is disposed
  13023. */
  13024. set onDispose(callback: () => void);
  13025. private _particles;
  13026. private _epsilon;
  13027. private _capacity;
  13028. private _stockParticles;
  13029. private _newPartsExcess;
  13030. private _vertexData;
  13031. private _vertexBuffer;
  13032. private _vertexBuffers;
  13033. private _spriteBuffer;
  13034. private _indexBuffer;
  13035. private _effect;
  13036. private _customEffect;
  13037. private _cachedDefines;
  13038. private _scaledColorStep;
  13039. private _colorDiff;
  13040. private _scaledDirection;
  13041. private _scaledGravity;
  13042. private _currentRenderId;
  13043. private _alive;
  13044. private _useInstancing;
  13045. private _vertexArrayObject;
  13046. private _started;
  13047. private _stopped;
  13048. private _actualFrame;
  13049. private _scaledUpdateSpeed;
  13050. private _vertexBufferSize;
  13051. /** @hidden */
  13052. _currentEmitRateGradient: Nullable<FactorGradient>;
  13053. /** @hidden */
  13054. _currentEmitRate1: number;
  13055. /** @hidden */
  13056. _currentEmitRate2: number;
  13057. /** @hidden */
  13058. _currentStartSizeGradient: Nullable<FactorGradient>;
  13059. /** @hidden */
  13060. _currentStartSize1: number;
  13061. /** @hidden */
  13062. _currentStartSize2: number;
  13063. private readonly _rawTextureWidth;
  13064. private _rampGradientsTexture;
  13065. private _useRampGradients;
  13066. /** Gets or sets a matrix to use to compute projection */
  13067. defaultProjectionMatrix: Matrix;
  13068. /** Gets or sets a matrix to use to compute view */
  13069. defaultViewMatrix: Matrix;
  13070. /** Gets or sets a boolean indicating that ramp gradients must be used
  13071. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13072. */
  13073. get useRampGradients(): boolean;
  13074. set useRampGradients(value: boolean);
  13075. /**
  13076. * 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.
  13077. * 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: [])
  13078. */
  13079. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13080. private _subEmitters;
  13081. /**
  13082. * @hidden
  13083. * If the particle systems emitter should be disposed when the particle system is disposed
  13084. */
  13085. _disposeEmitterOnDispose: boolean;
  13086. /**
  13087. * The current active Sub-systems, this property is used by the root particle system only.
  13088. */
  13089. activeSubSystems: Array<ParticleSystem>;
  13090. /**
  13091. * Specifies if the particles are updated in emitter local space or world space
  13092. */
  13093. isLocal: boolean;
  13094. private _rootParticleSystem;
  13095. /**
  13096. * Gets the current list of active particles
  13097. */
  13098. get particles(): Particle[];
  13099. /**
  13100. * Gets the number of particles active at the same time.
  13101. * @returns The number of active particles.
  13102. */
  13103. getActiveCount(): number;
  13104. /**
  13105. * Returns the string "ParticleSystem"
  13106. * @returns a string containing the class name
  13107. */
  13108. getClassName(): string;
  13109. /**
  13110. * Gets a boolean indicating that the system is stopping
  13111. * @returns true if the system is currently stopping
  13112. */
  13113. isStopping(): boolean;
  13114. /**
  13115. * Gets the custom effect used to render the particles
  13116. * @param blendMode Blend mode for which the effect should be retrieved
  13117. * @returns The effect
  13118. */
  13119. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13120. /**
  13121. * Sets the custom effect used to render the particles
  13122. * @param effect The effect to set
  13123. * @param blendMode Blend mode for which the effect should be set
  13124. */
  13125. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13126. /** @hidden */
  13127. private _onBeforeDrawParticlesObservable;
  13128. /**
  13129. * Observable that will be called just before the particles are drawn
  13130. */
  13131. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13132. /**
  13133. * Gets the name of the particle vertex shader
  13134. */
  13135. get vertexShaderName(): string;
  13136. /**
  13137. * Instantiates a particle system.
  13138. * 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.
  13139. * @param name The name of the particle system
  13140. * @param capacity The max number of particles alive at the same time
  13141. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13142. * @param customEffect a custom effect used to change the way particles are rendered by default
  13143. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13144. * @param epsilon Offset used to render the particles
  13145. */
  13146. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13147. private _addFactorGradient;
  13148. private _removeFactorGradient;
  13149. /**
  13150. * Adds a new life time gradient
  13151. * @param gradient defines the gradient to use (between 0 and 1)
  13152. * @param factor defines the life time factor to affect to the specified gradient
  13153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13154. * @returns the current particle system
  13155. */
  13156. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13157. /**
  13158. * Remove a specific life time gradient
  13159. * @param gradient defines the gradient to remove
  13160. * @returns the current particle system
  13161. */
  13162. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13163. /**
  13164. * Adds a new size gradient
  13165. * @param gradient defines the gradient to use (between 0 and 1)
  13166. * @param factor defines the size factor to affect to the specified gradient
  13167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13168. * @returns the current particle system
  13169. */
  13170. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13171. /**
  13172. * Remove a specific size gradient
  13173. * @param gradient defines the gradient to remove
  13174. * @returns the current particle system
  13175. */
  13176. removeSizeGradient(gradient: number): IParticleSystem;
  13177. /**
  13178. * Adds a new color remap gradient
  13179. * @param gradient defines the gradient to use (between 0 and 1)
  13180. * @param min defines the color remap minimal range
  13181. * @param max defines the color remap maximal range
  13182. * @returns the current particle system
  13183. */
  13184. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13185. /**
  13186. * Remove a specific color remap gradient
  13187. * @param gradient defines the gradient to remove
  13188. * @returns the current particle system
  13189. */
  13190. removeColorRemapGradient(gradient: number): IParticleSystem;
  13191. /**
  13192. * Adds a new alpha remap gradient
  13193. * @param gradient defines the gradient to use (between 0 and 1)
  13194. * @param min defines the alpha remap minimal range
  13195. * @param max defines the alpha remap maximal range
  13196. * @returns the current particle system
  13197. */
  13198. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13199. /**
  13200. * Remove a specific alpha remap gradient
  13201. * @param gradient defines the gradient to remove
  13202. * @returns the current particle system
  13203. */
  13204. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13205. /**
  13206. * Adds a new angular speed gradient
  13207. * @param gradient defines the gradient to use (between 0 and 1)
  13208. * @param factor defines the angular speed to affect to the specified gradient
  13209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13210. * @returns the current particle system
  13211. */
  13212. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13213. /**
  13214. * Remove a specific angular speed gradient
  13215. * @param gradient defines the gradient to remove
  13216. * @returns the current particle system
  13217. */
  13218. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13219. /**
  13220. * Adds a new velocity gradient
  13221. * @param gradient defines the gradient to use (between 0 and 1)
  13222. * @param factor defines the velocity to affect to the specified gradient
  13223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13224. * @returns the current particle system
  13225. */
  13226. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13227. /**
  13228. * Remove a specific velocity gradient
  13229. * @param gradient defines the gradient to remove
  13230. * @returns the current particle system
  13231. */
  13232. removeVelocityGradient(gradient: number): IParticleSystem;
  13233. /**
  13234. * Adds a new limit velocity gradient
  13235. * @param gradient defines the gradient to use (between 0 and 1)
  13236. * @param factor defines the limit velocity value to affect to the specified gradient
  13237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13238. * @returns the current particle system
  13239. */
  13240. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13241. /**
  13242. * Remove a specific limit velocity gradient
  13243. * @param gradient defines the gradient to remove
  13244. * @returns the current particle system
  13245. */
  13246. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13247. /**
  13248. * Adds a new drag gradient
  13249. * @param gradient defines the gradient to use (between 0 and 1)
  13250. * @param factor defines the drag value to affect to the specified gradient
  13251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13252. * @returns the current particle system
  13253. */
  13254. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13255. /**
  13256. * Remove a specific drag gradient
  13257. * @param gradient defines the gradient to remove
  13258. * @returns the current particle system
  13259. */
  13260. removeDragGradient(gradient: number): IParticleSystem;
  13261. /**
  13262. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13263. * @param gradient defines the gradient to use (between 0 and 1)
  13264. * @param factor defines the emit rate value to affect to the specified gradient
  13265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13266. * @returns the current particle system
  13267. */
  13268. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13269. /**
  13270. * Remove a specific emit rate gradient
  13271. * @param gradient defines the gradient to remove
  13272. * @returns the current particle system
  13273. */
  13274. removeEmitRateGradient(gradient: number): IParticleSystem;
  13275. /**
  13276. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13277. * @param gradient defines the gradient to use (between 0 and 1)
  13278. * @param factor defines the start size value to affect to the specified gradient
  13279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13280. * @returns the current particle system
  13281. */
  13282. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13283. /**
  13284. * Remove a specific start size gradient
  13285. * @param gradient defines the gradient to remove
  13286. * @returns the current particle system
  13287. */
  13288. removeStartSizeGradient(gradient: number): IParticleSystem;
  13289. private _createRampGradientTexture;
  13290. /**
  13291. * Gets the current list of ramp gradients.
  13292. * You must use addRampGradient and removeRampGradient to udpate this list
  13293. * @returns the list of ramp gradients
  13294. */
  13295. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13296. /** Force the system to rebuild all gradients that need to be resync */
  13297. forceRefreshGradients(): void;
  13298. private _syncRampGradientTexture;
  13299. /**
  13300. * Adds a new ramp gradient used to remap particle colors
  13301. * @param gradient defines the gradient to use (between 0 and 1)
  13302. * @param color defines the color to affect to the specified gradient
  13303. * @returns the current particle system
  13304. */
  13305. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13306. /**
  13307. * Remove a specific ramp gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeRampGradient(gradient: number): ParticleSystem;
  13312. /**
  13313. * Adds a new color gradient
  13314. * @param gradient defines the gradient to use (between 0 and 1)
  13315. * @param color1 defines the color to affect to the specified gradient
  13316. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13317. * @returns this particle system
  13318. */
  13319. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13320. /**
  13321. * Remove a specific color gradient
  13322. * @param gradient defines the gradient to remove
  13323. * @returns this particle system
  13324. */
  13325. removeColorGradient(gradient: number): IParticleSystem;
  13326. private _fetchR;
  13327. protected _reset(): void;
  13328. private _resetEffect;
  13329. private _createVertexBuffers;
  13330. private _createIndexBuffer;
  13331. /**
  13332. * Gets the maximum number of particles active at the same time.
  13333. * @returns The max number of active particles.
  13334. */
  13335. getCapacity(): number;
  13336. /**
  13337. * Gets whether there are still active particles in the system.
  13338. * @returns True if it is alive, otherwise false.
  13339. */
  13340. isAlive(): boolean;
  13341. /**
  13342. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13343. * @returns True if it has been started, otherwise false.
  13344. */
  13345. isStarted(): boolean;
  13346. private _prepareSubEmitterInternalArray;
  13347. /**
  13348. * Starts the particle system and begins to emit
  13349. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13350. */
  13351. start(delay?: number): void;
  13352. /**
  13353. * Stops the particle system.
  13354. * @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.
  13355. */
  13356. stop(stopSubEmitters?: boolean): void;
  13357. /**
  13358. * Remove all active particles
  13359. */
  13360. reset(): void;
  13361. /**
  13362. * @hidden (for internal use only)
  13363. */
  13364. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13365. /**
  13366. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13367. * Its lifetime will start back at 0.
  13368. */
  13369. recycleParticle: (particle: Particle) => void;
  13370. private _stopSubEmitters;
  13371. private _createParticle;
  13372. private _removeFromRoot;
  13373. private _emitFromParticle;
  13374. private _update;
  13375. /** @hidden */
  13376. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13377. /** @hidden */
  13378. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13379. /**
  13380. * Fill the defines array according to the current settings of the particle system
  13381. * @param defines Array to be updated
  13382. * @param blendMode blend mode to take into account when updating the array
  13383. */
  13384. fillDefines(defines: Array<string>, blendMode: number): void;
  13385. /**
  13386. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13387. * @param uniforms Uniforms array to fill
  13388. * @param attributes Attributes array to fill
  13389. * @param samplers Samplers array to fill
  13390. */
  13391. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13392. /** @hidden */
  13393. private _getEffect;
  13394. /**
  13395. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13396. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13397. */
  13398. animate(preWarmOnly?: boolean): void;
  13399. private _appendParticleVertices;
  13400. /**
  13401. * Rebuilds the particle system.
  13402. */
  13403. rebuild(): void;
  13404. /**
  13405. * Is this system ready to be used/rendered
  13406. * @return true if the system is ready
  13407. */
  13408. isReady(): boolean;
  13409. private _render;
  13410. /**
  13411. * Renders the particle system in its current state.
  13412. * @returns the current number of particles
  13413. */
  13414. render(): number;
  13415. /**
  13416. * Disposes the particle system and free the associated resources
  13417. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13418. */
  13419. dispose(disposeTexture?: boolean): void;
  13420. /**
  13421. * Clones the particle system.
  13422. * @param name The name of the cloned object
  13423. * @param newEmitter The new emitter to use
  13424. * @returns the cloned particle system
  13425. */
  13426. clone(name: string, newEmitter: any): ParticleSystem;
  13427. /**
  13428. * Serializes the particle system to a JSON object
  13429. * @param serializeTexture defines if the texture must be serialized as well
  13430. * @returns the JSON object
  13431. */
  13432. serialize(serializeTexture?: boolean): any;
  13433. /** @hidden */
  13434. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13435. /** @hidden */
  13436. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13437. /**
  13438. * Parses a JSON object to create a particle system.
  13439. * @param parsedParticleSystem The JSON object to parse
  13440. * @param sceneOrEngine The scene or the engine to create the particle system in
  13441. * @param rootUrl The root url to use to load external dependencies like texture
  13442. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13443. * @returns the Parsed particle system
  13444. */
  13445. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13446. }
  13447. }
  13448. declare module "babylonjs/Particles/particle" {
  13449. import { Nullable } from "babylonjs/types";
  13450. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13451. import { Color4 } from "babylonjs/Maths/math.color";
  13452. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13453. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13454. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13455. /**
  13456. * A particle represents one of the element emitted by a particle system.
  13457. * This is mainly define by its coordinates, direction, velocity and age.
  13458. */
  13459. export class Particle {
  13460. /**
  13461. * The particle system the particle belongs to.
  13462. */
  13463. particleSystem: ParticleSystem;
  13464. private static _Count;
  13465. /**
  13466. * Unique ID of the particle
  13467. */
  13468. id: number;
  13469. /**
  13470. * The world position of the particle in the scene.
  13471. */
  13472. position: Vector3;
  13473. /**
  13474. * The world direction of the particle in the scene.
  13475. */
  13476. direction: Vector3;
  13477. /**
  13478. * The color of the particle.
  13479. */
  13480. color: Color4;
  13481. /**
  13482. * The color change of the particle per step.
  13483. */
  13484. colorStep: Color4;
  13485. /**
  13486. * Defines how long will the life of the particle be.
  13487. */
  13488. lifeTime: number;
  13489. /**
  13490. * The current age of the particle.
  13491. */
  13492. age: number;
  13493. /**
  13494. * The current size of the particle.
  13495. */
  13496. size: number;
  13497. /**
  13498. * The current scale of the particle.
  13499. */
  13500. scale: Vector2;
  13501. /**
  13502. * The current angle of the particle.
  13503. */
  13504. angle: number;
  13505. /**
  13506. * Defines how fast is the angle changing.
  13507. */
  13508. angularSpeed: number;
  13509. /**
  13510. * Defines the cell index used by the particle to be rendered from a sprite.
  13511. */
  13512. cellIndex: number;
  13513. /**
  13514. * The information required to support color remapping
  13515. */
  13516. remapData: Vector4;
  13517. /** @hidden */
  13518. _randomCellOffset?: number;
  13519. /** @hidden */
  13520. _initialDirection: Nullable<Vector3>;
  13521. /** @hidden */
  13522. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13523. /** @hidden */
  13524. _initialStartSpriteCellID: number;
  13525. /** @hidden */
  13526. _initialEndSpriteCellID: number;
  13527. /** @hidden */
  13528. _currentColorGradient: Nullable<ColorGradient>;
  13529. /** @hidden */
  13530. _currentColor1: Color4;
  13531. /** @hidden */
  13532. _currentColor2: Color4;
  13533. /** @hidden */
  13534. _currentSizeGradient: Nullable<FactorGradient>;
  13535. /** @hidden */
  13536. _currentSize1: number;
  13537. /** @hidden */
  13538. _currentSize2: number;
  13539. /** @hidden */
  13540. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13541. /** @hidden */
  13542. _currentAngularSpeed1: number;
  13543. /** @hidden */
  13544. _currentAngularSpeed2: number;
  13545. /** @hidden */
  13546. _currentVelocityGradient: Nullable<FactorGradient>;
  13547. /** @hidden */
  13548. _currentVelocity1: number;
  13549. /** @hidden */
  13550. _currentVelocity2: number;
  13551. /** @hidden */
  13552. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13553. /** @hidden */
  13554. _currentLimitVelocity1: number;
  13555. /** @hidden */
  13556. _currentLimitVelocity2: number;
  13557. /** @hidden */
  13558. _currentDragGradient: Nullable<FactorGradient>;
  13559. /** @hidden */
  13560. _currentDrag1: number;
  13561. /** @hidden */
  13562. _currentDrag2: number;
  13563. /** @hidden */
  13564. _randomNoiseCoordinates1: Vector3;
  13565. /** @hidden */
  13566. _randomNoiseCoordinates2: Vector3;
  13567. /** @hidden */
  13568. _localPosition?: Vector3;
  13569. /**
  13570. * Creates a new instance Particle
  13571. * @param particleSystem the particle system the particle belongs to
  13572. */
  13573. constructor(
  13574. /**
  13575. * The particle system the particle belongs to.
  13576. */
  13577. particleSystem: ParticleSystem);
  13578. private updateCellInfoFromSystem;
  13579. /**
  13580. * Defines how the sprite cell index is updated for the particle
  13581. */
  13582. updateCellIndex(): void;
  13583. /** @hidden */
  13584. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13585. /** @hidden */
  13586. _inheritParticleInfoToSubEmitters(): void;
  13587. /** @hidden */
  13588. _reset(): void;
  13589. /**
  13590. * Copy the properties of particle to another one.
  13591. * @param other the particle to copy the information to.
  13592. */
  13593. copyTo(other: Particle): void;
  13594. }
  13595. }
  13596. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13597. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13598. import { Effect } from "babylonjs/Materials/effect";
  13599. import { Particle } from "babylonjs/Particles/particle";
  13600. import { Nullable } from "babylonjs/types";
  13601. import { Scene } from "babylonjs/scene";
  13602. /**
  13603. * Particle emitter represents a volume emitting particles.
  13604. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13605. */
  13606. export interface IParticleEmitterType {
  13607. /**
  13608. * Called by the particle System when the direction is computed for the created particle.
  13609. * @param worldMatrix is the world matrix of the particle system
  13610. * @param directionToUpdate is the direction vector to update with the result
  13611. * @param particle is the particle we are computed the direction for
  13612. * @param isLocal defines if the direction should be set in local space
  13613. */
  13614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13615. /**
  13616. * Called by the particle System when the position is computed for the created particle.
  13617. * @param worldMatrix is the world matrix of the particle system
  13618. * @param positionToUpdate is the position vector to update with the result
  13619. * @param particle is the particle we are computed the position for
  13620. * @param isLocal defines if the position should be set in local space
  13621. */
  13622. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13623. /**
  13624. * Clones the current emitter and returns a copy of it
  13625. * @returns the new emitter
  13626. */
  13627. clone(): IParticleEmitterType;
  13628. /**
  13629. * Called by the GPUParticleSystem to setup the update shader
  13630. * @param effect defines the update shader
  13631. */
  13632. applyToShader(effect: Effect): void;
  13633. /**
  13634. * Returns a string to use to update the GPU particles update shader
  13635. * @returns the effect defines string
  13636. */
  13637. getEffectDefines(): string;
  13638. /**
  13639. * Returns a string representing the class name
  13640. * @returns a string containing the class name
  13641. */
  13642. getClassName(): string;
  13643. /**
  13644. * Serializes the particle system to a JSON object.
  13645. * @returns the JSON object
  13646. */
  13647. serialize(): any;
  13648. /**
  13649. * Parse properties from a JSON object
  13650. * @param serializationObject defines the JSON object
  13651. * @param scene defines the hosting scene
  13652. */
  13653. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13654. }
  13655. }
  13656. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13657. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13658. import { Effect } from "babylonjs/Materials/effect";
  13659. import { Particle } from "babylonjs/Particles/particle";
  13660. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13661. /**
  13662. * Particle emitter emitting particles from the inside of a box.
  13663. * It emits the particles randomly between 2 given directions.
  13664. */
  13665. export class BoxParticleEmitter implements IParticleEmitterType {
  13666. /**
  13667. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13668. */
  13669. direction1: Vector3;
  13670. /**
  13671. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13672. */
  13673. direction2: Vector3;
  13674. /**
  13675. * 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.
  13676. */
  13677. minEmitBox: Vector3;
  13678. /**
  13679. * 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.
  13680. */
  13681. maxEmitBox: Vector3;
  13682. /**
  13683. * Creates a new instance BoxParticleEmitter
  13684. */
  13685. constructor();
  13686. /**
  13687. * Called by the particle System when the direction is computed for the created particle.
  13688. * @param worldMatrix is the world matrix of the particle system
  13689. * @param directionToUpdate is the direction vector to update with the result
  13690. * @param particle is the particle we are computed the direction for
  13691. * @param isLocal defines if the direction should be set in local space
  13692. */
  13693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13694. /**
  13695. * Called by the particle System when the position is computed for the created particle.
  13696. * @param worldMatrix is the world matrix of the particle system
  13697. * @param positionToUpdate is the position vector to update with the result
  13698. * @param particle is the particle we are computed the position for
  13699. * @param isLocal defines if the position should be set in local space
  13700. */
  13701. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13702. /**
  13703. * Clones the current emitter and returns a copy of it
  13704. * @returns the new emitter
  13705. */
  13706. clone(): BoxParticleEmitter;
  13707. /**
  13708. * Called by the GPUParticleSystem to setup the update shader
  13709. * @param effect defines the update shader
  13710. */
  13711. applyToShader(effect: Effect): void;
  13712. /**
  13713. * Returns a string to use to update the GPU particles update shader
  13714. * @returns a string containng the defines string
  13715. */
  13716. getEffectDefines(): string;
  13717. /**
  13718. * Returns the string "BoxParticleEmitter"
  13719. * @returns a string containing the class name
  13720. */
  13721. getClassName(): string;
  13722. /**
  13723. * Serializes the particle system to a JSON object.
  13724. * @returns the JSON object
  13725. */
  13726. serialize(): any;
  13727. /**
  13728. * Parse properties from a JSON object
  13729. * @param serializationObject defines the JSON object
  13730. */
  13731. parse(serializationObject: any): void;
  13732. }
  13733. }
  13734. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13735. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13736. import { Effect } from "babylonjs/Materials/effect";
  13737. import { Particle } from "babylonjs/Particles/particle";
  13738. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13739. /**
  13740. * Particle emitter emitting particles from the inside of a cone.
  13741. * It emits the particles alongside the cone volume from the base to the particle.
  13742. * The emission direction might be randomized.
  13743. */
  13744. export class ConeParticleEmitter implements IParticleEmitterType {
  13745. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13746. directionRandomizer: number;
  13747. private _radius;
  13748. private _angle;
  13749. private _height;
  13750. /**
  13751. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13752. */
  13753. radiusRange: number;
  13754. /**
  13755. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13756. */
  13757. heightRange: number;
  13758. /**
  13759. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13760. */
  13761. emitFromSpawnPointOnly: boolean;
  13762. /**
  13763. * Gets or sets the radius of the emission cone
  13764. */
  13765. get radius(): number;
  13766. set radius(value: number);
  13767. /**
  13768. * Gets or sets the angle of the emission cone
  13769. */
  13770. get angle(): number;
  13771. set angle(value: number);
  13772. private _buildHeight;
  13773. /**
  13774. * Creates a new instance ConeParticleEmitter
  13775. * @param radius the radius of the emission cone (1 by default)
  13776. * @param angle the cone base angle (PI by default)
  13777. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13778. */
  13779. constructor(radius?: number, angle?: number,
  13780. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13781. directionRandomizer?: number);
  13782. /**
  13783. * Called by the particle System when the direction is computed for the created particle.
  13784. * @param worldMatrix is the world matrix of the particle system
  13785. * @param directionToUpdate is the direction vector to update with the result
  13786. * @param particle is the particle we are computed the direction for
  13787. * @param isLocal defines if the direction should be set in local space
  13788. */
  13789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13790. /**
  13791. * Called by the particle System when the position is computed for the created particle.
  13792. * @param worldMatrix is the world matrix of the particle system
  13793. * @param positionToUpdate is the position vector to update with the result
  13794. * @param particle is the particle we are computed the position for
  13795. * @param isLocal defines if the position should be set in local space
  13796. */
  13797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13798. /**
  13799. * Clones the current emitter and returns a copy of it
  13800. * @returns the new emitter
  13801. */
  13802. clone(): ConeParticleEmitter;
  13803. /**
  13804. * Called by the GPUParticleSystem to setup the update shader
  13805. * @param effect defines the update shader
  13806. */
  13807. applyToShader(effect: Effect): void;
  13808. /**
  13809. * Returns a string to use to update the GPU particles update shader
  13810. * @returns a string containng the defines string
  13811. */
  13812. getEffectDefines(): string;
  13813. /**
  13814. * Returns the string "ConeParticleEmitter"
  13815. * @returns a string containing the class name
  13816. */
  13817. getClassName(): string;
  13818. /**
  13819. * Serializes the particle system to a JSON object.
  13820. * @returns the JSON object
  13821. */
  13822. serialize(): any;
  13823. /**
  13824. * Parse properties from a JSON object
  13825. * @param serializationObject defines the JSON object
  13826. */
  13827. parse(serializationObject: any): void;
  13828. }
  13829. }
  13830. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13831. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13832. import { Effect } from "babylonjs/Materials/effect";
  13833. import { Particle } from "babylonjs/Particles/particle";
  13834. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13835. /**
  13836. * Particle emitter emitting particles from the inside of a cylinder.
  13837. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13838. */
  13839. export class CylinderParticleEmitter implements IParticleEmitterType {
  13840. /**
  13841. * The radius of the emission cylinder.
  13842. */
  13843. radius: number;
  13844. /**
  13845. * The height of the emission cylinder.
  13846. */
  13847. height: number;
  13848. /**
  13849. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13850. */
  13851. radiusRange: number;
  13852. /**
  13853. * How much to randomize the particle direction [0-1].
  13854. */
  13855. directionRandomizer: number;
  13856. /**
  13857. * Creates a new instance CylinderParticleEmitter
  13858. * @param radius the radius of the emission cylinder (1 by default)
  13859. * @param height the height of the emission cylinder (1 by default)
  13860. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13861. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13862. */
  13863. constructor(
  13864. /**
  13865. * The radius of the emission cylinder.
  13866. */
  13867. radius?: number,
  13868. /**
  13869. * The height of the emission cylinder.
  13870. */
  13871. height?: number,
  13872. /**
  13873. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13874. */
  13875. radiusRange?: number,
  13876. /**
  13877. * How much to randomize the particle direction [0-1].
  13878. */
  13879. directionRandomizer?: number);
  13880. /**
  13881. * Called by the particle System when the direction is computed for the created particle.
  13882. * @param worldMatrix is the world matrix of the particle system
  13883. * @param directionToUpdate is the direction vector to update with the result
  13884. * @param particle is the particle we are computed the direction for
  13885. * @param isLocal defines if the direction should be set in local space
  13886. */
  13887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13888. /**
  13889. * Called by the particle System when the position is computed for the created particle.
  13890. * @param worldMatrix is the world matrix of the particle system
  13891. * @param positionToUpdate is the position vector to update with the result
  13892. * @param particle is the particle we are computed the position for
  13893. * @param isLocal defines if the position should be set in local space
  13894. */
  13895. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13896. /**
  13897. * Clones the current emitter and returns a copy of it
  13898. * @returns the new emitter
  13899. */
  13900. clone(): CylinderParticleEmitter;
  13901. /**
  13902. * Called by the GPUParticleSystem to setup the update shader
  13903. * @param effect defines the update shader
  13904. */
  13905. applyToShader(effect: Effect): void;
  13906. /**
  13907. * Returns a string to use to update the GPU particles update shader
  13908. * @returns a string containng the defines string
  13909. */
  13910. getEffectDefines(): string;
  13911. /**
  13912. * Returns the string "CylinderParticleEmitter"
  13913. * @returns a string containing the class name
  13914. */
  13915. getClassName(): string;
  13916. /**
  13917. * Serializes the particle system to a JSON object.
  13918. * @returns the JSON object
  13919. */
  13920. serialize(): any;
  13921. /**
  13922. * Parse properties from a JSON object
  13923. * @param serializationObject defines the JSON object
  13924. */
  13925. parse(serializationObject: any): void;
  13926. }
  13927. /**
  13928. * Particle emitter emitting particles from the inside of a cylinder.
  13929. * It emits the particles randomly between two vectors.
  13930. */
  13931. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  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. * Creates a new instance CylinderDirectedParticleEmitter
  13942. * @param radius the radius of the emission cylinder (1 by default)
  13943. * @param height the height of the emission cylinder (1 by default)
  13944. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13945. * @param direction1 the min limit of the emission direction (up vector by default)
  13946. * @param direction2 the max limit of the emission direction (up vector by default)
  13947. */
  13948. constructor(radius?: number, height?: number, radiusRange?: number,
  13949. /**
  13950. * The min limit of the emission direction.
  13951. */
  13952. direction1?: Vector3,
  13953. /**
  13954. * The max limit of the emission direction.
  13955. */
  13956. direction2?: Vector3);
  13957. /**
  13958. * Called by the particle System when the direction is computed for the created particle.
  13959. * @param worldMatrix is the world matrix of the particle system
  13960. * @param directionToUpdate is the direction vector to update with the result
  13961. * @param particle is the particle we are computed the direction for
  13962. */
  13963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13964. /**
  13965. * Clones the current emitter and returns a copy of it
  13966. * @returns the new emitter
  13967. */
  13968. clone(): CylinderDirectedParticleEmitter;
  13969. /**
  13970. * Called by the GPUParticleSystem to setup the update shader
  13971. * @param effect defines the update shader
  13972. */
  13973. applyToShader(effect: Effect): void;
  13974. /**
  13975. * Returns a string to use to update the GPU particles update shader
  13976. * @returns a string containng the defines string
  13977. */
  13978. getEffectDefines(): string;
  13979. /**
  13980. * Returns the string "CylinderDirectedParticleEmitter"
  13981. * @returns a string containing the class name
  13982. */
  13983. getClassName(): string;
  13984. /**
  13985. * Serializes the particle system to a JSON object.
  13986. * @returns the JSON object
  13987. */
  13988. serialize(): any;
  13989. /**
  13990. * Parse properties from a JSON object
  13991. * @param serializationObject defines the JSON object
  13992. */
  13993. parse(serializationObject: any): void;
  13994. }
  13995. }
  13996. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13997. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13998. import { Effect } from "babylonjs/Materials/effect";
  13999. import { Particle } from "babylonjs/Particles/particle";
  14000. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14001. /**
  14002. * Particle emitter emitting particles from the inside of a hemisphere.
  14003. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  14004. */
  14005. export class HemisphericParticleEmitter implements IParticleEmitterType {
  14006. /**
  14007. * The radius of the emission hemisphere.
  14008. */
  14009. radius: number;
  14010. /**
  14011. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14012. */
  14013. radiusRange: number;
  14014. /**
  14015. * How much to randomize the particle direction [0-1].
  14016. */
  14017. directionRandomizer: number;
  14018. /**
  14019. * Creates a new instance HemisphericParticleEmitter
  14020. * @param radius the radius of the emission hemisphere (1 by default)
  14021. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14022. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14023. */
  14024. constructor(
  14025. /**
  14026. * The radius of the emission hemisphere.
  14027. */
  14028. radius?: number,
  14029. /**
  14030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14031. */
  14032. radiusRange?: number,
  14033. /**
  14034. * How much to randomize the particle direction [0-1].
  14035. */
  14036. directionRandomizer?: number);
  14037. /**
  14038. * Called by the particle System when the direction is computed for the created particle.
  14039. * @param worldMatrix is the world matrix of the particle system
  14040. * @param directionToUpdate is the direction vector to update with the result
  14041. * @param particle is the particle we are computed the direction for
  14042. * @param isLocal defines if the direction should be set in local space
  14043. */
  14044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14045. /**
  14046. * Called by the particle System when the position is computed for the created particle.
  14047. * @param worldMatrix is the world matrix of the particle system
  14048. * @param positionToUpdate is the position vector to update with the result
  14049. * @param particle is the particle we are computed the position for
  14050. * @param isLocal defines if the position should be set in local space
  14051. */
  14052. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14053. /**
  14054. * Clones the current emitter and returns a copy of it
  14055. * @returns the new emitter
  14056. */
  14057. clone(): HemisphericParticleEmitter;
  14058. /**
  14059. * Called by the GPUParticleSystem to setup the update shader
  14060. * @param effect defines the update shader
  14061. */
  14062. applyToShader(effect: Effect): void;
  14063. /**
  14064. * Returns a string to use to update the GPU particles update shader
  14065. * @returns a string containng the defines string
  14066. */
  14067. getEffectDefines(): string;
  14068. /**
  14069. * Returns the string "HemisphericParticleEmitter"
  14070. * @returns a string containing the class name
  14071. */
  14072. getClassName(): string;
  14073. /**
  14074. * Serializes the particle system to a JSON object.
  14075. * @returns the JSON object
  14076. */
  14077. serialize(): any;
  14078. /**
  14079. * Parse properties from a JSON object
  14080. * @param serializationObject defines the JSON object
  14081. */
  14082. parse(serializationObject: any): void;
  14083. }
  14084. }
  14085. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14087. import { Effect } from "babylonjs/Materials/effect";
  14088. import { Particle } from "babylonjs/Particles/particle";
  14089. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14090. /**
  14091. * Particle emitter emitting particles from a point.
  14092. * It emits the particles randomly between 2 given directions.
  14093. */
  14094. export class PointParticleEmitter implements IParticleEmitterType {
  14095. /**
  14096. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14097. */
  14098. direction1: Vector3;
  14099. /**
  14100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14101. */
  14102. direction2: Vector3;
  14103. /**
  14104. * Creates a new instance PointParticleEmitter
  14105. */
  14106. constructor();
  14107. /**
  14108. * Called by the particle System when the direction is computed for the created particle.
  14109. * @param worldMatrix is the world matrix of the particle system
  14110. * @param directionToUpdate is the direction vector to update with the result
  14111. * @param particle is the particle we are computed the direction for
  14112. * @param isLocal defines if the direction should be set in local space
  14113. */
  14114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14115. /**
  14116. * Called by the particle System when the position is computed for the created particle.
  14117. * @param worldMatrix is the world matrix of the particle system
  14118. * @param positionToUpdate is the position vector to update with the result
  14119. * @param particle is the particle we are computed the position for
  14120. * @param isLocal defines if the position should be set in local space
  14121. */
  14122. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14123. /**
  14124. * Clones the current emitter and returns a copy of it
  14125. * @returns the new emitter
  14126. */
  14127. clone(): PointParticleEmitter;
  14128. /**
  14129. * Called by the GPUParticleSystem to setup the update shader
  14130. * @param effect defines the update shader
  14131. */
  14132. applyToShader(effect: Effect): void;
  14133. /**
  14134. * Returns a string to use to update the GPU particles update shader
  14135. * @returns a string containng the defines string
  14136. */
  14137. getEffectDefines(): string;
  14138. /**
  14139. * Returns the string "PointParticleEmitter"
  14140. * @returns a string containing the class name
  14141. */
  14142. getClassName(): string;
  14143. /**
  14144. * Serializes the particle system to a JSON object.
  14145. * @returns the JSON object
  14146. */
  14147. serialize(): any;
  14148. /**
  14149. * Parse properties from a JSON object
  14150. * @param serializationObject defines the JSON object
  14151. */
  14152. parse(serializationObject: any): void;
  14153. }
  14154. }
  14155. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14156. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14157. import { Effect } from "babylonjs/Materials/effect";
  14158. import { Particle } from "babylonjs/Particles/particle";
  14159. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14160. /**
  14161. * Particle emitter emitting particles from the inside of a sphere.
  14162. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14163. */
  14164. export class SphereParticleEmitter implements IParticleEmitterType {
  14165. /**
  14166. * The radius of the emission sphere.
  14167. */
  14168. radius: number;
  14169. /**
  14170. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14171. */
  14172. radiusRange: number;
  14173. /**
  14174. * How much to randomize the particle direction [0-1].
  14175. */
  14176. directionRandomizer: number;
  14177. /**
  14178. * Creates a new instance SphereParticleEmitter
  14179. * @param radius the radius of the emission sphere (1 by default)
  14180. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14181. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14182. */
  14183. constructor(
  14184. /**
  14185. * The radius of the emission sphere.
  14186. */
  14187. radius?: number,
  14188. /**
  14189. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14190. */
  14191. radiusRange?: number,
  14192. /**
  14193. * How much to randomize the particle direction [0-1].
  14194. */
  14195. directionRandomizer?: number);
  14196. /**
  14197. * Called by the particle System when the direction is computed for the created particle.
  14198. * @param worldMatrix is the world matrix of the particle system
  14199. * @param directionToUpdate is the direction vector to update with the result
  14200. * @param particle is the particle we are computed the direction for
  14201. * @param isLocal defines if the direction should be set in local space
  14202. */
  14203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14204. /**
  14205. * Called by the particle System when the position is computed for the created particle.
  14206. * @param worldMatrix is the world matrix of the particle system
  14207. * @param positionToUpdate is the position vector to update with the result
  14208. * @param particle is the particle we are computed the position for
  14209. * @param isLocal defines if the position should be set in local space
  14210. */
  14211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14212. /**
  14213. * Clones the current emitter and returns a copy of it
  14214. * @returns the new emitter
  14215. */
  14216. clone(): SphereParticleEmitter;
  14217. /**
  14218. * Called by the GPUParticleSystem to setup the update shader
  14219. * @param effect defines the update shader
  14220. */
  14221. applyToShader(effect: Effect): void;
  14222. /**
  14223. * Returns a string to use to update the GPU particles update shader
  14224. * @returns a string containng the defines string
  14225. */
  14226. getEffectDefines(): string;
  14227. /**
  14228. * Returns the string "SphereParticleEmitter"
  14229. * @returns a string containing the class name
  14230. */
  14231. getClassName(): string;
  14232. /**
  14233. * Serializes the particle system to a JSON object.
  14234. * @returns the JSON object
  14235. */
  14236. serialize(): any;
  14237. /**
  14238. * Parse properties from a JSON object
  14239. * @param serializationObject defines the JSON object
  14240. */
  14241. parse(serializationObject: any): void;
  14242. }
  14243. /**
  14244. * Particle emitter emitting particles from the inside of a sphere.
  14245. * It emits the particles randomly between two vectors.
  14246. */
  14247. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14248. /**
  14249. * The min limit of the emission direction.
  14250. */
  14251. direction1: Vector3;
  14252. /**
  14253. * The max limit of the emission direction.
  14254. */
  14255. direction2: Vector3;
  14256. /**
  14257. * Creates a new instance SphereDirectedParticleEmitter
  14258. * @param radius the radius of the emission sphere (1 by default)
  14259. * @param direction1 the min limit of the emission direction (up vector by default)
  14260. * @param direction2 the max limit of the emission direction (up vector by default)
  14261. */
  14262. constructor(radius?: number,
  14263. /**
  14264. * The min limit of the emission direction.
  14265. */
  14266. direction1?: Vector3,
  14267. /**
  14268. * The max limit of the emission direction.
  14269. */
  14270. direction2?: Vector3);
  14271. /**
  14272. * Called by the particle System when the direction is computed for the created particle.
  14273. * @param worldMatrix is the world matrix of the particle system
  14274. * @param directionToUpdate is the direction vector to update with the result
  14275. * @param particle is the particle we are computed the direction for
  14276. */
  14277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14278. /**
  14279. * Clones the current emitter and returns a copy of it
  14280. * @returns the new emitter
  14281. */
  14282. clone(): SphereDirectedParticleEmitter;
  14283. /**
  14284. * Called by the GPUParticleSystem to setup the update shader
  14285. * @param effect defines the update shader
  14286. */
  14287. applyToShader(effect: Effect): void;
  14288. /**
  14289. * Returns a string to use to update the GPU particles update shader
  14290. * @returns a string containng the defines string
  14291. */
  14292. getEffectDefines(): string;
  14293. /**
  14294. * Returns the string "SphereDirectedParticleEmitter"
  14295. * @returns a string containing the class name
  14296. */
  14297. getClassName(): string;
  14298. /**
  14299. * Serializes the particle system to a JSON object.
  14300. * @returns the JSON object
  14301. */
  14302. serialize(): any;
  14303. /**
  14304. * Parse properties from a JSON object
  14305. * @param serializationObject defines the JSON object
  14306. */
  14307. parse(serializationObject: any): void;
  14308. }
  14309. }
  14310. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14311. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14312. import { Effect } from "babylonjs/Materials/effect";
  14313. import { Particle } from "babylonjs/Particles/particle";
  14314. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14315. import { Nullable } from "babylonjs/types";
  14316. /**
  14317. * Particle emitter emitting particles from a custom list of positions.
  14318. */
  14319. export class CustomParticleEmitter implements IParticleEmitterType {
  14320. /**
  14321. * Gets or sets the position generator that will create the inital position of each particle.
  14322. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14323. */
  14324. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14325. /**
  14326. * Gets or sets the destination generator that will create the final destination of each particle.
  14327. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14328. */
  14329. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14330. /**
  14331. * Creates a new instance CustomParticleEmitter
  14332. */
  14333. constructor();
  14334. /**
  14335. * Called by the particle System when the direction is computed for the created particle.
  14336. * @param worldMatrix is the world matrix of the particle system
  14337. * @param directionToUpdate is the direction vector to update with the result
  14338. * @param particle is the particle we are computed the direction for
  14339. * @param isLocal defines if the direction should be set in local space
  14340. */
  14341. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14342. /**
  14343. * Called by the particle System when the position is computed for the created particle.
  14344. * @param worldMatrix is the world matrix of the particle system
  14345. * @param positionToUpdate is the position vector to update with the result
  14346. * @param particle is the particle we are computed the position for
  14347. * @param isLocal defines if the position should be set in local space
  14348. */
  14349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14350. /**
  14351. * Clones the current emitter and returns a copy of it
  14352. * @returns the new emitter
  14353. */
  14354. clone(): CustomParticleEmitter;
  14355. /**
  14356. * Called by the GPUParticleSystem to setup the update shader
  14357. * @param effect defines the update shader
  14358. */
  14359. applyToShader(effect: Effect): void;
  14360. /**
  14361. * Returns a string to use to update the GPU particles update shader
  14362. * @returns a string containng the defines string
  14363. */
  14364. getEffectDefines(): string;
  14365. /**
  14366. * Returns the string "PointParticleEmitter"
  14367. * @returns a string containing the class name
  14368. */
  14369. getClassName(): string;
  14370. /**
  14371. * Serializes the particle system to a JSON object.
  14372. * @returns the JSON object
  14373. */
  14374. serialize(): any;
  14375. /**
  14376. * Parse properties from a JSON object
  14377. * @param serializationObject defines the JSON object
  14378. */
  14379. parse(serializationObject: any): void;
  14380. }
  14381. }
  14382. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14383. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14384. import { Effect } from "babylonjs/Materials/effect";
  14385. import { Particle } from "babylonjs/Particles/particle";
  14386. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14387. import { Nullable } from "babylonjs/types";
  14388. import { Scene } from "babylonjs/scene";
  14389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14390. /**
  14391. * Particle emitter emitting particles from the inside of a box.
  14392. * It emits the particles randomly between 2 given directions.
  14393. */
  14394. export class MeshParticleEmitter implements IParticleEmitterType {
  14395. private _indices;
  14396. private _positions;
  14397. private _normals;
  14398. private _storedNormal;
  14399. private _mesh;
  14400. /**
  14401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14402. */
  14403. direction1: Vector3;
  14404. /**
  14405. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14406. */
  14407. direction2: Vector3;
  14408. /**
  14409. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14410. */
  14411. useMeshNormalsForDirection: boolean;
  14412. /** Defines the mesh to use as source */
  14413. get mesh(): Nullable<AbstractMesh>;
  14414. set mesh(value: Nullable<AbstractMesh>);
  14415. /**
  14416. * Creates a new instance MeshParticleEmitter
  14417. * @param mesh defines the mesh to use as source
  14418. */
  14419. constructor(mesh?: Nullable<AbstractMesh>);
  14420. /**
  14421. * Called by the particle System when the direction is computed for the created particle.
  14422. * @param worldMatrix is the world matrix of the particle system
  14423. * @param directionToUpdate is the direction vector to update with the result
  14424. * @param particle is the particle we are computed the direction for
  14425. * @param isLocal defines if the direction should be set in local space
  14426. */
  14427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14428. /**
  14429. * Called by the particle System when the position is computed for the created particle.
  14430. * @param worldMatrix is the world matrix of the particle system
  14431. * @param positionToUpdate is the position vector to update with the result
  14432. * @param particle is the particle we are computed the position for
  14433. * @param isLocal defines if the position should be set in local space
  14434. */
  14435. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14436. /**
  14437. * Clones the current emitter and returns a copy of it
  14438. * @returns the new emitter
  14439. */
  14440. clone(): MeshParticleEmitter;
  14441. /**
  14442. * Called by the GPUParticleSystem to setup the update shader
  14443. * @param effect defines the update shader
  14444. */
  14445. applyToShader(effect: Effect): void;
  14446. /**
  14447. * Returns a string to use to update the GPU particles update shader
  14448. * @returns a string containng the defines string
  14449. */
  14450. getEffectDefines(): string;
  14451. /**
  14452. * Returns the string "BoxParticleEmitter"
  14453. * @returns a string containing the class name
  14454. */
  14455. getClassName(): string;
  14456. /**
  14457. * Serializes the particle system to a JSON object.
  14458. * @returns the JSON object
  14459. */
  14460. serialize(): any;
  14461. /**
  14462. * Parse properties from a JSON object
  14463. * @param serializationObject defines the JSON object
  14464. * @param scene defines the hosting scene
  14465. */
  14466. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14467. }
  14468. }
  14469. declare module "babylonjs/Particles/EmitterTypes/index" {
  14470. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14471. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14472. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14473. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14474. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14475. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14476. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14477. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14478. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14479. }
  14480. declare module "babylonjs/Particles/IParticleSystem" {
  14481. import { Nullable } from "babylonjs/types";
  14482. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14483. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14485. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14486. import { Scene } from "babylonjs/scene";
  14487. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14488. import { Effect } from "babylonjs/Materials/effect";
  14489. import { Observable } from "babylonjs/Misc/observable";
  14490. import { Animation } from "babylonjs/Animations/animation";
  14491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14492. /**
  14493. * Interface representing a particle system in Babylon.js.
  14494. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14495. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14496. */
  14497. export interface IParticleSystem {
  14498. /**
  14499. * List of animations used by the particle system.
  14500. */
  14501. animations: Animation[];
  14502. /**
  14503. * The id of the Particle system.
  14504. */
  14505. id: string;
  14506. /**
  14507. * The name of the Particle system.
  14508. */
  14509. name: string;
  14510. /**
  14511. * The emitter represents the Mesh or position we are attaching the particle system to.
  14512. */
  14513. emitter: Nullable<AbstractMesh | Vector3>;
  14514. /**
  14515. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14516. */
  14517. isBillboardBased: boolean;
  14518. /**
  14519. * The rendering group used by the Particle system to chose when to render.
  14520. */
  14521. renderingGroupId: number;
  14522. /**
  14523. * The layer mask we are rendering the particles through.
  14524. */
  14525. layerMask: number;
  14526. /**
  14527. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14528. */
  14529. updateSpeed: number;
  14530. /**
  14531. * The amount of time the particle system is running (depends of the overall update speed).
  14532. */
  14533. targetStopDuration: number;
  14534. /**
  14535. * The texture used to render each particle. (this can be a spritesheet)
  14536. */
  14537. particleTexture: Nullable<BaseTexture>;
  14538. /**
  14539. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14540. */
  14541. blendMode: number;
  14542. /**
  14543. * Minimum life time of emitting particles.
  14544. */
  14545. minLifeTime: number;
  14546. /**
  14547. * Maximum life time of emitting particles.
  14548. */
  14549. maxLifeTime: number;
  14550. /**
  14551. * Minimum Size of emitting particles.
  14552. */
  14553. minSize: number;
  14554. /**
  14555. * Maximum Size of emitting particles.
  14556. */
  14557. maxSize: number;
  14558. /**
  14559. * Minimum scale of emitting particles on X axis.
  14560. */
  14561. minScaleX: number;
  14562. /**
  14563. * Maximum scale of emitting particles on X axis.
  14564. */
  14565. maxScaleX: number;
  14566. /**
  14567. * Minimum scale of emitting particles on Y axis.
  14568. */
  14569. minScaleY: number;
  14570. /**
  14571. * Maximum scale of emitting particles on Y axis.
  14572. */
  14573. maxScaleY: number;
  14574. /**
  14575. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14576. */
  14577. color1: Color4;
  14578. /**
  14579. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14580. */
  14581. color2: Color4;
  14582. /**
  14583. * Color the particle will have at the end of its lifetime.
  14584. */
  14585. colorDead: Color4;
  14586. /**
  14587. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14588. */
  14589. emitRate: number;
  14590. /**
  14591. * You can use gravity if you want to give an orientation to your particles.
  14592. */
  14593. gravity: Vector3;
  14594. /**
  14595. * Minimum power of emitting particles.
  14596. */
  14597. minEmitPower: number;
  14598. /**
  14599. * Maximum power of emitting particles.
  14600. */
  14601. maxEmitPower: number;
  14602. /**
  14603. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14604. */
  14605. minAngularSpeed: number;
  14606. /**
  14607. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14608. */
  14609. maxAngularSpeed: number;
  14610. /**
  14611. * Gets or sets the minimal initial rotation in radians.
  14612. */
  14613. minInitialRotation: number;
  14614. /**
  14615. * Gets or sets the maximal initial rotation in radians.
  14616. */
  14617. maxInitialRotation: number;
  14618. /**
  14619. * The particle emitter type defines the emitter used by the particle system.
  14620. * It can be for example box, sphere, or cone...
  14621. */
  14622. particleEmitterType: Nullable<IParticleEmitterType>;
  14623. /**
  14624. * Defines the delay in milliseconds before starting the system (0 by default)
  14625. */
  14626. startDelay: number;
  14627. /**
  14628. * 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
  14629. */
  14630. preWarmCycles: number;
  14631. /**
  14632. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14633. */
  14634. preWarmStepOffset: number;
  14635. /**
  14636. * 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)
  14637. */
  14638. spriteCellChangeSpeed: number;
  14639. /**
  14640. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14641. */
  14642. startSpriteCellID: number;
  14643. /**
  14644. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14645. */
  14646. endSpriteCellID: number;
  14647. /**
  14648. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14649. */
  14650. spriteCellWidth: number;
  14651. /**
  14652. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14653. */
  14654. spriteCellHeight: number;
  14655. /**
  14656. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14657. */
  14658. spriteRandomStartCell: boolean;
  14659. /**
  14660. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14661. */
  14662. isAnimationSheetEnabled: boolean;
  14663. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14664. translationPivot: Vector2;
  14665. /**
  14666. * Gets or sets a texture used to add random noise to particle positions
  14667. */
  14668. noiseTexture: Nullable<BaseTexture>;
  14669. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14670. noiseStrength: Vector3;
  14671. /**
  14672. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14673. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14674. */
  14675. billboardMode: number;
  14676. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14677. limitVelocityDamping: number;
  14678. /**
  14679. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14680. */
  14681. beginAnimationOnStart: boolean;
  14682. /**
  14683. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14684. */
  14685. beginAnimationFrom: number;
  14686. /**
  14687. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14688. */
  14689. beginAnimationTo: number;
  14690. /**
  14691. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14692. */
  14693. beginAnimationLoop: boolean;
  14694. /**
  14695. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14696. */
  14697. disposeOnStop: boolean;
  14698. /**
  14699. * Specifies if the particles are updated in emitter local space or world space
  14700. */
  14701. isLocal: boolean;
  14702. /** Snippet ID if the particle system was created from the snippet server */
  14703. snippetId: string;
  14704. /** Gets or sets a matrix to use to compute projection */
  14705. defaultProjectionMatrix: Matrix;
  14706. /**
  14707. * Gets the maximum number of particles active at the same time.
  14708. * @returns The max number of active particles.
  14709. */
  14710. getCapacity(): number;
  14711. /**
  14712. * Gets the number of particles active at the same time.
  14713. * @returns The number of active particles.
  14714. */
  14715. getActiveCount(): number;
  14716. /**
  14717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14718. * @returns True if it has been started, otherwise false.
  14719. */
  14720. isStarted(): boolean;
  14721. /**
  14722. * Animates the particle system for this frame.
  14723. */
  14724. animate(): void;
  14725. /**
  14726. * Renders the particle system in its current state.
  14727. * @returns the current number of particles
  14728. */
  14729. render(): number;
  14730. /**
  14731. * Dispose the particle system and frees its associated resources.
  14732. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14733. */
  14734. dispose(disposeTexture?: boolean): void;
  14735. /**
  14736. * An event triggered when the system is disposed
  14737. */
  14738. onDisposeObservable: Observable<IParticleSystem>;
  14739. /**
  14740. * An event triggered when the system is stopped
  14741. */
  14742. onStoppedObservable: Observable<IParticleSystem>;
  14743. /**
  14744. * Clones the particle system.
  14745. * @param name The name of the cloned object
  14746. * @param newEmitter The new emitter to use
  14747. * @returns the cloned particle system
  14748. */
  14749. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14750. /**
  14751. * Serializes the particle system to a JSON object
  14752. * @param serializeTexture defines if the texture must be serialized as well
  14753. * @returns the JSON object
  14754. */
  14755. serialize(serializeTexture: boolean): any;
  14756. /**
  14757. * Rebuild the particle system
  14758. */
  14759. rebuild(): void;
  14760. /** Force the system to rebuild all gradients that need to be resync */
  14761. forceRefreshGradients(): void;
  14762. /**
  14763. * Starts the particle system and begins to emit
  14764. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14765. */
  14766. start(delay?: number): void;
  14767. /**
  14768. * Stops the particle system.
  14769. */
  14770. stop(): void;
  14771. /**
  14772. * Remove all active particles
  14773. */
  14774. reset(): void;
  14775. /**
  14776. * Gets a boolean indicating that the system is stopping
  14777. * @returns true if the system is currently stopping
  14778. */
  14779. isStopping(): boolean;
  14780. /**
  14781. * Is this system ready to be used/rendered
  14782. * @return true if the system is ready
  14783. */
  14784. isReady(): boolean;
  14785. /**
  14786. * Returns the string "ParticleSystem"
  14787. * @returns a string containing the class name
  14788. */
  14789. getClassName(): string;
  14790. /**
  14791. * Gets the custom effect used to render the particles
  14792. * @param blendMode Blend mode for which the effect should be retrieved
  14793. * @returns The effect
  14794. */
  14795. getCustomEffect(blendMode: number): Nullable<Effect>;
  14796. /**
  14797. * Sets the custom effect used to render the particles
  14798. * @param effect The effect to set
  14799. * @param blendMode Blend mode for which the effect should be set
  14800. */
  14801. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14802. /**
  14803. * Fill the defines array according to the current settings of the particle system
  14804. * @param defines Array to be updated
  14805. * @param blendMode blend mode to take into account when updating the array
  14806. */
  14807. fillDefines(defines: Array<string>, blendMode: number): void;
  14808. /**
  14809. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14810. * @param uniforms Uniforms array to fill
  14811. * @param attributes Attributes array to fill
  14812. * @param samplers Samplers array to fill
  14813. */
  14814. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14815. /**
  14816. * Observable that will be called just before the particles are drawn
  14817. */
  14818. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14819. /**
  14820. * Gets the name of the particle vertex shader
  14821. */
  14822. vertexShaderName: string;
  14823. /**
  14824. * Adds a new color gradient
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param color1 defines the color to affect to the specified gradient
  14827. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14828. * @returns the current particle system
  14829. */
  14830. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14831. /**
  14832. * Remove a specific color gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeColorGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Adds a new size gradient
  14839. * @param gradient defines the gradient to use (between 0 and 1)
  14840. * @param factor defines the size factor to affect to the specified gradient
  14841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14842. * @returns the current particle system
  14843. */
  14844. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14845. /**
  14846. * Remove a specific size gradient
  14847. * @param gradient defines the gradient to remove
  14848. * @returns the current particle system
  14849. */
  14850. removeSizeGradient(gradient: number): IParticleSystem;
  14851. /**
  14852. * Gets the current list of color gradients.
  14853. * You must use addColorGradient and removeColorGradient to udpate this list
  14854. * @returns the list of color gradients
  14855. */
  14856. getColorGradients(): Nullable<Array<ColorGradient>>;
  14857. /**
  14858. * Gets the current list of size gradients.
  14859. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14860. * @returns the list of size gradients
  14861. */
  14862. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14863. /**
  14864. * Gets the current list of angular speed gradients.
  14865. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14866. * @returns the list of angular speed gradients
  14867. */
  14868. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14869. /**
  14870. * Adds a new angular speed gradient
  14871. * @param gradient defines the gradient to use (between 0 and 1)
  14872. * @param factor defines the angular speed to affect to the specified gradient
  14873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14874. * @returns the current particle system
  14875. */
  14876. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14877. /**
  14878. * Remove a specific angular speed gradient
  14879. * @param gradient defines the gradient to remove
  14880. * @returns the current particle system
  14881. */
  14882. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14883. /**
  14884. * Gets the current list of velocity gradients.
  14885. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14886. * @returns the list of velocity gradients
  14887. */
  14888. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14889. /**
  14890. * Adds a new velocity gradient
  14891. * @param gradient defines the gradient to use (between 0 and 1)
  14892. * @param factor defines the velocity to affect to the specified gradient
  14893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14894. * @returns the current particle system
  14895. */
  14896. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14897. /**
  14898. * Remove a specific velocity gradient
  14899. * @param gradient defines the gradient to remove
  14900. * @returns the current particle system
  14901. */
  14902. removeVelocityGradient(gradient: number): IParticleSystem;
  14903. /**
  14904. * Gets the current list of limit velocity gradients.
  14905. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14906. * @returns the list of limit velocity gradients
  14907. */
  14908. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14909. /**
  14910. * Adds a new limit velocity gradient
  14911. * @param gradient defines the gradient to use (between 0 and 1)
  14912. * @param factor defines the limit velocity to affect to the specified gradient
  14913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14914. * @returns the current particle system
  14915. */
  14916. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14917. /**
  14918. * Remove a specific limit velocity gradient
  14919. * @param gradient defines the gradient to remove
  14920. * @returns the current particle system
  14921. */
  14922. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14923. /**
  14924. * Adds a new drag gradient
  14925. * @param gradient defines the gradient to use (between 0 and 1)
  14926. * @param factor defines the drag to affect to the specified gradient
  14927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14928. * @returns the current particle system
  14929. */
  14930. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14931. /**
  14932. * Remove a specific drag gradient
  14933. * @param gradient defines the gradient to remove
  14934. * @returns the current particle system
  14935. */
  14936. removeDragGradient(gradient: number): IParticleSystem;
  14937. /**
  14938. * Gets the current list of drag gradients.
  14939. * You must use addDragGradient and removeDragGradient to udpate this list
  14940. * @returns the list of drag gradients
  14941. */
  14942. getDragGradients(): Nullable<Array<FactorGradient>>;
  14943. /**
  14944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14945. * @param gradient defines the gradient to use (between 0 and 1)
  14946. * @param factor defines the emit rate to affect to the specified gradient
  14947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14948. * @returns the current particle system
  14949. */
  14950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14951. /**
  14952. * Remove a specific emit rate gradient
  14953. * @param gradient defines the gradient to remove
  14954. * @returns the current particle system
  14955. */
  14956. removeEmitRateGradient(gradient: number): IParticleSystem;
  14957. /**
  14958. * Gets the current list of emit rate gradients.
  14959. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14960. * @returns the list of emit rate gradients
  14961. */
  14962. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14963. /**
  14964. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param factor defines the start size to affect to the specified gradient
  14967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14968. * @returns the current particle system
  14969. */
  14970. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14971. /**
  14972. * Remove a specific start size gradient
  14973. * @param gradient defines the gradient to remove
  14974. * @returns the current particle system
  14975. */
  14976. removeStartSizeGradient(gradient: number): IParticleSystem;
  14977. /**
  14978. * Gets the current list of start size gradients.
  14979. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14980. * @returns the list of start size gradients
  14981. */
  14982. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14983. /**
  14984. * Adds a new life time gradient
  14985. * @param gradient defines the gradient to use (between 0 and 1)
  14986. * @param factor defines the life time factor to affect to the specified gradient
  14987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14988. * @returns the current particle system
  14989. */
  14990. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14991. /**
  14992. * Remove a specific life time gradient
  14993. * @param gradient defines the gradient to remove
  14994. * @returns the current particle system
  14995. */
  14996. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14997. /**
  14998. * Gets the current list of life time gradients.
  14999. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15000. * @returns the list of life time gradients
  15001. */
  15002. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15003. /**
  15004. * Gets the current list of color gradients.
  15005. * You must use addColorGradient and removeColorGradient to udpate this list
  15006. * @returns the list of color gradients
  15007. */
  15008. getColorGradients(): Nullable<Array<ColorGradient>>;
  15009. /**
  15010. * Adds a new ramp gradient used to remap particle colors
  15011. * @param gradient defines the gradient to use (between 0 and 1)
  15012. * @param color defines the color to affect to the specified gradient
  15013. * @returns the current particle system
  15014. */
  15015. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15016. /**
  15017. * Gets the current list of ramp gradients.
  15018. * You must use addRampGradient and removeRampGradient to udpate this list
  15019. * @returns the list of ramp gradients
  15020. */
  15021. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15022. /** Gets or sets a boolean indicating that ramp gradients must be used
  15023. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15024. */
  15025. useRampGradients: boolean;
  15026. /**
  15027. * Adds a new color remap gradient
  15028. * @param gradient defines the gradient to use (between 0 and 1)
  15029. * @param min defines the color remap minimal range
  15030. * @param max defines the color remap maximal range
  15031. * @returns the current particle system
  15032. */
  15033. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15034. /**
  15035. * Gets the current list of color remap gradients.
  15036. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15037. * @returns the list of color remap gradients
  15038. */
  15039. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15040. /**
  15041. * Adds a new alpha remap gradient
  15042. * @param gradient defines the gradient to use (between 0 and 1)
  15043. * @param min defines the alpha remap minimal range
  15044. * @param max defines the alpha remap maximal range
  15045. * @returns the current particle system
  15046. */
  15047. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15048. /**
  15049. * Gets the current list of alpha remap gradients.
  15050. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15051. * @returns the list of alpha remap gradients
  15052. */
  15053. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15054. /**
  15055. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15056. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15057. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15058. * @returns the emitter
  15059. */
  15060. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15061. /**
  15062. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15063. * @param radius The radius of the hemisphere to emit from
  15064. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15065. * @returns the emitter
  15066. */
  15067. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15068. /**
  15069. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15070. * @param radius The radius of the sphere to emit from
  15071. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15072. * @returns the emitter
  15073. */
  15074. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15075. /**
  15076. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15077. * @param radius The radius of the sphere to emit from
  15078. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15079. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15080. * @returns the emitter
  15081. */
  15082. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15083. /**
  15084. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15085. * @param radius The radius of the emission cylinder
  15086. * @param height The height of the emission cylinder
  15087. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15088. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15089. * @returns the emitter
  15090. */
  15091. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15092. /**
  15093. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15094. * @param radius The radius of the cylinder to emit from
  15095. * @param height The height of the emission cylinder
  15096. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15097. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15098. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15099. * @returns the emitter
  15100. */
  15101. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15102. /**
  15103. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15104. * @param radius The radius of the cone to emit from
  15105. * @param angle The base angle of the cone
  15106. * @returns the emitter
  15107. */
  15108. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15109. /**
  15110. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15111. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15112. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15113. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15114. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15115. * @returns the emitter
  15116. */
  15117. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15118. /**
  15119. * Get hosting scene
  15120. * @returns the scene
  15121. */
  15122. getScene(): Nullable<Scene>;
  15123. }
  15124. }
  15125. declare module "babylonjs/Meshes/transformNode" {
  15126. import { DeepImmutable } from "babylonjs/types";
  15127. import { Observable } from "babylonjs/Misc/observable";
  15128. import { Nullable } from "babylonjs/types";
  15129. import { Camera } from "babylonjs/Cameras/camera";
  15130. import { Scene } from "babylonjs/scene";
  15131. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15132. import { Node } from "babylonjs/node";
  15133. import { Bone } from "babylonjs/Bones/bone";
  15134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15135. import { Space } from "babylonjs/Maths/math.axis";
  15136. /**
  15137. * 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.
  15138. * @see https://doc.babylonjs.com/how_to/transformnode
  15139. */
  15140. export class TransformNode extends Node {
  15141. /**
  15142. * Object will not rotate to face the camera
  15143. */
  15144. static BILLBOARDMODE_NONE: number;
  15145. /**
  15146. * Object will rotate to face the camera but only on the x axis
  15147. */
  15148. static BILLBOARDMODE_X: number;
  15149. /**
  15150. * Object will rotate to face the camera but only on the y axis
  15151. */
  15152. static BILLBOARDMODE_Y: number;
  15153. /**
  15154. * Object will rotate to face the camera but only on the z axis
  15155. */
  15156. static BILLBOARDMODE_Z: number;
  15157. /**
  15158. * Object will rotate to face the camera
  15159. */
  15160. static BILLBOARDMODE_ALL: number;
  15161. /**
  15162. * Object will rotate to face the camera's position instead of orientation
  15163. */
  15164. static BILLBOARDMODE_USE_POSITION: number;
  15165. private static _TmpRotation;
  15166. private static _TmpScaling;
  15167. private static _TmpTranslation;
  15168. private _forward;
  15169. private _forwardInverted;
  15170. private _up;
  15171. private _right;
  15172. private _rightInverted;
  15173. private _position;
  15174. private _rotation;
  15175. private _rotationQuaternion;
  15176. protected _scaling: Vector3;
  15177. protected _isDirty: boolean;
  15178. private _transformToBoneReferal;
  15179. private _isAbsoluteSynced;
  15180. private _billboardMode;
  15181. /**
  15182. * Gets or sets the billboard mode. Default is 0.
  15183. *
  15184. * | Value | Type | Description |
  15185. * | --- | --- | --- |
  15186. * | 0 | BILLBOARDMODE_NONE | |
  15187. * | 1 | BILLBOARDMODE_X | |
  15188. * | 2 | BILLBOARDMODE_Y | |
  15189. * | 4 | BILLBOARDMODE_Z | |
  15190. * | 7 | BILLBOARDMODE_ALL | |
  15191. *
  15192. */
  15193. get billboardMode(): number;
  15194. set billboardMode(value: number);
  15195. private _preserveParentRotationForBillboard;
  15196. /**
  15197. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15198. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15199. */
  15200. get preserveParentRotationForBillboard(): boolean;
  15201. set preserveParentRotationForBillboard(value: boolean);
  15202. /**
  15203. * 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
  15204. */
  15205. scalingDeterminant: number;
  15206. private _infiniteDistance;
  15207. /**
  15208. * Gets or sets the distance of the object to max, often used by skybox
  15209. */
  15210. get infiniteDistance(): boolean;
  15211. set infiniteDistance(value: boolean);
  15212. /**
  15213. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15214. * By default the system will update normals to compensate
  15215. */
  15216. ignoreNonUniformScaling: boolean;
  15217. /**
  15218. * 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
  15219. */
  15220. reIntegrateRotationIntoRotationQuaternion: boolean;
  15221. /** @hidden */
  15222. _poseMatrix: Nullable<Matrix>;
  15223. /** @hidden */
  15224. _localMatrix: Matrix;
  15225. private _usePivotMatrix;
  15226. private _absolutePosition;
  15227. private _absoluteScaling;
  15228. private _absoluteRotationQuaternion;
  15229. private _pivotMatrix;
  15230. private _pivotMatrixInverse;
  15231. /** @hidden */
  15232. _postMultiplyPivotMatrix: boolean;
  15233. protected _isWorldMatrixFrozen: boolean;
  15234. /** @hidden */
  15235. _indexInSceneTransformNodesArray: number;
  15236. /**
  15237. * An event triggered after the world matrix is updated
  15238. */
  15239. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15240. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15241. /**
  15242. * Gets a string identifying the name of the class
  15243. * @returns "TransformNode" string
  15244. */
  15245. getClassName(): string;
  15246. /**
  15247. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15248. */
  15249. get position(): Vector3;
  15250. set position(newPosition: Vector3);
  15251. /**
  15252. * 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)).
  15253. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15254. */
  15255. get rotation(): Vector3;
  15256. set rotation(newRotation: Vector3);
  15257. /**
  15258. * 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)).
  15259. */
  15260. get scaling(): Vector3;
  15261. set scaling(newScaling: Vector3);
  15262. /**
  15263. * 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).
  15264. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15265. */
  15266. get rotationQuaternion(): Nullable<Quaternion>;
  15267. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15268. /**
  15269. * The forward direction of that transform in world space.
  15270. */
  15271. get forward(): Vector3;
  15272. /**
  15273. * The up direction of that transform in world space.
  15274. */
  15275. get up(): Vector3;
  15276. /**
  15277. * The right direction of that transform in world space.
  15278. */
  15279. get right(): Vector3;
  15280. /**
  15281. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15282. * @param matrix the matrix to copy the pose from
  15283. * @returns this TransformNode.
  15284. */
  15285. updatePoseMatrix(matrix: Matrix): TransformNode;
  15286. /**
  15287. * Returns the mesh Pose matrix.
  15288. * @returns the pose matrix
  15289. */
  15290. getPoseMatrix(): Matrix;
  15291. /** @hidden */
  15292. _isSynchronized(): boolean;
  15293. /** @hidden */
  15294. _initCache(): void;
  15295. /**
  15296. * Flag the transform node as dirty (Forcing it to update everything)
  15297. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15298. * @returns this transform node
  15299. */
  15300. markAsDirty(property: string): TransformNode;
  15301. /**
  15302. * Returns the current mesh absolute position.
  15303. * Returns a Vector3.
  15304. */
  15305. get absolutePosition(): Vector3;
  15306. /**
  15307. * Returns the current mesh absolute scaling.
  15308. * Returns a Vector3.
  15309. */
  15310. get absoluteScaling(): Vector3;
  15311. /**
  15312. * Returns the current mesh absolute rotation.
  15313. * Returns a Quaternion.
  15314. */
  15315. get absoluteRotationQuaternion(): Quaternion;
  15316. /**
  15317. * Sets a new matrix to apply before all other transformation
  15318. * @param matrix defines the transform matrix
  15319. * @returns the current TransformNode
  15320. */
  15321. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15322. /**
  15323. * Sets a new pivot matrix to the current node
  15324. * @param matrix defines the new pivot matrix to use
  15325. * @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
  15326. * @returns the current TransformNode
  15327. */
  15328. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15329. /**
  15330. * Returns the mesh pivot matrix.
  15331. * Default : Identity.
  15332. * @returns the matrix
  15333. */
  15334. getPivotMatrix(): Matrix;
  15335. /**
  15336. * Instantiate (when possible) or clone that node with its hierarchy
  15337. * @param newParent defines the new parent to use for the instance (or clone)
  15338. * @param options defines options to configure how copy is done
  15339. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15340. * @returns an instance (or a clone) of the current node with its hiearchy
  15341. */
  15342. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15343. doNotInstantiate: boolean;
  15344. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15345. /**
  15346. * Prevents the World matrix to be computed any longer
  15347. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15348. * @returns the TransformNode.
  15349. */
  15350. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15351. /**
  15352. * Allows back the World matrix computation.
  15353. * @returns the TransformNode.
  15354. */
  15355. unfreezeWorldMatrix(): this;
  15356. /**
  15357. * True if the World matrix has been frozen.
  15358. */
  15359. get isWorldMatrixFrozen(): boolean;
  15360. /**
  15361. * Retuns the mesh absolute position in the World.
  15362. * @returns a Vector3.
  15363. */
  15364. getAbsolutePosition(): Vector3;
  15365. /**
  15366. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15367. * @param absolutePosition the absolute position to set
  15368. * @returns the TransformNode.
  15369. */
  15370. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15371. /**
  15372. * Sets the mesh position in its local space.
  15373. * @param vector3 the position to set in localspace
  15374. * @returns the TransformNode.
  15375. */
  15376. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15377. /**
  15378. * Returns the mesh position in the local space from the current World matrix values.
  15379. * @returns a new Vector3.
  15380. */
  15381. getPositionExpressedInLocalSpace(): Vector3;
  15382. /**
  15383. * Translates the mesh along the passed Vector3 in its local space.
  15384. * @param vector3 the distance to translate in localspace
  15385. * @returns the TransformNode.
  15386. */
  15387. locallyTranslate(vector3: Vector3): TransformNode;
  15388. private static _lookAtVectorCache;
  15389. /**
  15390. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15391. * @param targetPoint the position (must be in same space as current mesh) to look at
  15392. * @param yawCor optional yaw (y-axis) correction in radians
  15393. * @param pitchCor optional pitch (x-axis) correction in radians
  15394. * @param rollCor optional roll (z-axis) correction in radians
  15395. * @param space the choosen space of the target
  15396. * @returns the TransformNode.
  15397. */
  15398. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15399. /**
  15400. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15401. * This Vector3 is expressed in the World space.
  15402. * @param localAxis axis to rotate
  15403. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15404. */
  15405. getDirection(localAxis: Vector3): Vector3;
  15406. /**
  15407. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15408. * localAxis is expressed in the mesh local space.
  15409. * result is computed in the Wordl space from the mesh World matrix.
  15410. * @param localAxis axis to rotate
  15411. * @param result the resulting transformnode
  15412. * @returns this TransformNode.
  15413. */
  15414. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15415. /**
  15416. * Sets this transform node rotation to the given local axis.
  15417. * @param localAxis the axis in local space
  15418. * @param yawCor optional yaw (y-axis) correction in radians
  15419. * @param pitchCor optional pitch (x-axis) correction in radians
  15420. * @param rollCor optional roll (z-axis) correction in radians
  15421. * @returns this TransformNode
  15422. */
  15423. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15424. /**
  15425. * Sets a new pivot point to the current node
  15426. * @param point defines the new pivot point to use
  15427. * @param space defines if the point is in world or local space (local by default)
  15428. * @returns the current TransformNode
  15429. */
  15430. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15431. /**
  15432. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15433. * @returns the pivot point
  15434. */
  15435. getPivotPoint(): Vector3;
  15436. /**
  15437. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15438. * @param result the vector3 to store the result
  15439. * @returns this TransformNode.
  15440. */
  15441. getPivotPointToRef(result: Vector3): TransformNode;
  15442. /**
  15443. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15444. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15445. */
  15446. getAbsolutePivotPoint(): Vector3;
  15447. /**
  15448. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15449. * @param result vector3 to store the result
  15450. * @returns this TransformNode.
  15451. */
  15452. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15453. /**
  15454. * Defines the passed node as the parent of the current node.
  15455. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15456. * @see https://doc.babylonjs.com/how_to/parenting
  15457. * @param node the node ot set as the parent
  15458. * @returns this TransformNode.
  15459. */
  15460. setParent(node: Nullable<Node>): TransformNode;
  15461. private _nonUniformScaling;
  15462. /**
  15463. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15464. */
  15465. get nonUniformScaling(): boolean;
  15466. /** @hidden */
  15467. _updateNonUniformScalingState(value: boolean): boolean;
  15468. /**
  15469. * Attach the current TransformNode to another TransformNode associated with a bone
  15470. * @param bone Bone affecting the TransformNode
  15471. * @param affectedTransformNode TransformNode associated with the bone
  15472. * @returns this object
  15473. */
  15474. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15475. /**
  15476. * Detach the transform node if its associated with a bone
  15477. * @returns this object
  15478. */
  15479. detachFromBone(): TransformNode;
  15480. private static _rotationAxisCache;
  15481. /**
  15482. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15483. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15484. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15485. * The passed axis is also normalized.
  15486. * @param axis the axis to rotate around
  15487. * @param amount the amount to rotate in radians
  15488. * @param space Space to rotate in (Default: local)
  15489. * @returns the TransformNode.
  15490. */
  15491. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15492. /**
  15493. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15494. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15495. * The passed axis is also normalized. .
  15496. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15497. * @param point the point to rotate around
  15498. * @param axis the axis to rotate around
  15499. * @param amount the amount to rotate in radians
  15500. * @returns the TransformNode
  15501. */
  15502. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15503. /**
  15504. * Translates the mesh along the axis vector for the passed distance in the given space.
  15505. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15506. * @param axis the axis to translate in
  15507. * @param distance the distance to translate
  15508. * @param space Space to rotate in (Default: local)
  15509. * @returns the TransformNode.
  15510. */
  15511. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15512. /**
  15513. * Adds a rotation step to the mesh current rotation.
  15514. * x, y, z are Euler angles expressed in radians.
  15515. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15516. * This means this rotation is made in the mesh local space only.
  15517. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15518. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15519. * ```javascript
  15520. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15521. * ```
  15522. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15523. * 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.
  15524. * @param x Rotation to add
  15525. * @param y Rotation to add
  15526. * @param z Rotation to add
  15527. * @returns the TransformNode.
  15528. */
  15529. addRotation(x: number, y: number, z: number): TransformNode;
  15530. /**
  15531. * @hidden
  15532. */
  15533. protected _getEffectiveParent(): Nullable<Node>;
  15534. /**
  15535. * Computes the world matrix of the node
  15536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15537. * @returns the world matrix
  15538. */
  15539. computeWorldMatrix(force?: boolean): Matrix;
  15540. /**
  15541. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15542. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15543. */
  15544. resetLocalMatrix(independentOfChildren?: boolean): void;
  15545. protected _afterComputeWorldMatrix(): void;
  15546. /**
  15547. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15548. * @param func callback function to add
  15549. *
  15550. * @returns the TransformNode.
  15551. */
  15552. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15553. /**
  15554. * Removes a registered callback function.
  15555. * @param func callback function to remove
  15556. * @returns the TransformNode.
  15557. */
  15558. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15559. /**
  15560. * Gets the position of the current mesh in camera space
  15561. * @param camera defines the camera to use
  15562. * @returns a position
  15563. */
  15564. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15565. /**
  15566. * Returns the distance from the mesh to the active camera
  15567. * @param camera defines the camera to use
  15568. * @returns the distance
  15569. */
  15570. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15571. /**
  15572. * Clone the current transform node
  15573. * @param name Name of the new clone
  15574. * @param newParent New parent for the clone
  15575. * @param doNotCloneChildren Do not clone children hierarchy
  15576. * @returns the new transform node
  15577. */
  15578. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15579. /**
  15580. * Serializes the objects information.
  15581. * @param currentSerializationObject defines the object to serialize in
  15582. * @returns the serialized object
  15583. */
  15584. serialize(currentSerializationObject?: any): any;
  15585. /**
  15586. * Returns a new TransformNode object parsed from the source provided.
  15587. * @param parsedTransformNode is the source.
  15588. * @param scene the scne the object belongs to
  15589. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15590. * @returns a new TransformNode object parsed from the source provided.
  15591. */
  15592. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15593. /**
  15594. * Get all child-transformNodes of this node
  15595. * @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
  15596. * @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
  15597. * @returns an array of TransformNode
  15598. */
  15599. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15600. /**
  15601. * Releases resources associated with this transform node.
  15602. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15603. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15604. */
  15605. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15606. /**
  15607. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15608. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15609. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15610. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15611. * @returns the current mesh
  15612. */
  15613. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15614. private _syncAbsoluteScalingAndRotation;
  15615. }
  15616. }
  15617. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15618. /**
  15619. * Class used to override all child animations of a given target
  15620. */
  15621. export class AnimationPropertiesOverride {
  15622. /**
  15623. * Gets or sets a value indicating if animation blending must be used
  15624. */
  15625. enableBlending: boolean;
  15626. /**
  15627. * Gets or sets the blending speed to use when enableBlending is true
  15628. */
  15629. blendingSpeed: number;
  15630. /**
  15631. * Gets or sets the default loop mode to use
  15632. */
  15633. loopMode: number;
  15634. }
  15635. }
  15636. declare module "babylonjs/Bones/bone" {
  15637. import { Skeleton } from "babylonjs/Bones/skeleton";
  15638. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15639. import { Nullable } from "babylonjs/types";
  15640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15641. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15642. import { Node } from "babylonjs/node";
  15643. import { Space } from "babylonjs/Maths/math.axis";
  15644. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15645. /**
  15646. * Class used to store bone information
  15647. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15648. */
  15649. export class Bone extends Node {
  15650. /**
  15651. * defines the bone name
  15652. */
  15653. name: string;
  15654. private static _tmpVecs;
  15655. private static _tmpQuat;
  15656. private static _tmpMats;
  15657. /**
  15658. * Gets the list of child bones
  15659. */
  15660. children: Bone[];
  15661. /** Gets the animations associated with this bone */
  15662. animations: import("babylonjs/Animations/animation").Animation[];
  15663. /**
  15664. * Gets or sets bone length
  15665. */
  15666. length: number;
  15667. /**
  15668. * @hidden Internal only
  15669. * Set this value to map this bone to a different index in the transform matrices
  15670. * Set this value to -1 to exclude the bone from the transform matrices
  15671. */
  15672. _index: Nullable<number>;
  15673. private _skeleton;
  15674. private _localMatrix;
  15675. private _restPose;
  15676. private _bindPose;
  15677. private _baseMatrix;
  15678. private _absoluteTransform;
  15679. private _invertedAbsoluteTransform;
  15680. private _parent;
  15681. private _scalingDeterminant;
  15682. private _worldTransform;
  15683. private _localScaling;
  15684. private _localRotation;
  15685. private _localPosition;
  15686. private _needToDecompose;
  15687. private _needToCompose;
  15688. /** @hidden */
  15689. _linkedTransformNode: Nullable<TransformNode>;
  15690. /** @hidden */
  15691. _waitingTransformNodeId: Nullable<string>;
  15692. /** @hidden */
  15693. get _matrix(): Matrix;
  15694. /** @hidden */
  15695. set _matrix(value: Matrix);
  15696. /**
  15697. * Create a new bone
  15698. * @param name defines the bone name
  15699. * @param skeleton defines the parent skeleton
  15700. * @param parentBone defines the parent (can be null if the bone is the root)
  15701. * @param localMatrix defines the local matrix
  15702. * @param restPose defines the rest pose matrix
  15703. * @param baseMatrix defines the base matrix
  15704. * @param index defines index of the bone in the hiearchy
  15705. */
  15706. constructor(
  15707. /**
  15708. * defines the bone name
  15709. */
  15710. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15711. /**
  15712. * Gets the current object class name.
  15713. * @return the class name
  15714. */
  15715. getClassName(): string;
  15716. /**
  15717. * Gets the parent skeleton
  15718. * @returns a skeleton
  15719. */
  15720. getSkeleton(): Skeleton;
  15721. /**
  15722. * Gets parent bone
  15723. * @returns a bone or null if the bone is the root of the bone hierarchy
  15724. */
  15725. getParent(): Nullable<Bone>;
  15726. /**
  15727. * Returns an array containing the root bones
  15728. * @returns an array containing the root bones
  15729. */
  15730. getChildren(): Array<Bone>;
  15731. /**
  15732. * Gets the node index in matrix array generated for rendering
  15733. * @returns the node index
  15734. */
  15735. getIndex(): number;
  15736. /**
  15737. * Sets the parent bone
  15738. * @param parent defines the parent (can be null if the bone is the root)
  15739. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15740. */
  15741. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15742. /**
  15743. * Gets the local matrix
  15744. * @returns a matrix
  15745. */
  15746. getLocalMatrix(): Matrix;
  15747. /**
  15748. * Gets the base matrix (initial matrix which remains unchanged)
  15749. * @returns a matrix
  15750. */
  15751. getBaseMatrix(): Matrix;
  15752. /**
  15753. * Gets the rest pose matrix
  15754. * @returns a matrix
  15755. */
  15756. getRestPose(): Matrix;
  15757. /**
  15758. * Sets the rest pose matrix
  15759. * @param matrix the local-space rest pose to set for this bone
  15760. */
  15761. setRestPose(matrix: Matrix): void;
  15762. /**
  15763. * Gets the bind pose matrix
  15764. * @returns the bind pose matrix
  15765. */
  15766. getBindPose(): Matrix;
  15767. /**
  15768. * Sets the bind pose matrix
  15769. * @param matrix the local-space bind pose to set for this bone
  15770. */
  15771. setBindPose(matrix: Matrix): void;
  15772. /**
  15773. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15774. */
  15775. getWorldMatrix(): Matrix;
  15776. /**
  15777. * Sets the local matrix to rest pose matrix
  15778. */
  15779. returnToRest(): void;
  15780. /**
  15781. * Gets the inverse of the absolute transform matrix.
  15782. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15783. * @returns a matrix
  15784. */
  15785. getInvertedAbsoluteTransform(): Matrix;
  15786. /**
  15787. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15788. * @returns a matrix
  15789. */
  15790. getAbsoluteTransform(): Matrix;
  15791. /**
  15792. * Links with the given transform node.
  15793. * The local matrix of this bone is copied from the transform node every frame.
  15794. * @param transformNode defines the transform node to link to
  15795. */
  15796. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15797. /**
  15798. * Gets the node used to drive the bone's transformation
  15799. * @returns a transform node or null
  15800. */
  15801. getTransformNode(): Nullable<TransformNode>;
  15802. /** Gets or sets current position (in local space) */
  15803. get position(): Vector3;
  15804. set position(newPosition: Vector3);
  15805. /** Gets or sets current rotation (in local space) */
  15806. get rotation(): Vector3;
  15807. set rotation(newRotation: Vector3);
  15808. /** Gets or sets current rotation quaternion (in local space) */
  15809. get rotationQuaternion(): Quaternion;
  15810. set rotationQuaternion(newRotation: Quaternion);
  15811. /** Gets or sets current scaling (in local space) */
  15812. get scaling(): Vector3;
  15813. set scaling(newScaling: Vector3);
  15814. /**
  15815. * Gets the animation properties override
  15816. */
  15817. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15818. private _decompose;
  15819. private _compose;
  15820. /**
  15821. * Update the base and local matrices
  15822. * @param matrix defines the new base or local matrix
  15823. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15824. * @param updateLocalMatrix defines if the local matrix should be updated
  15825. */
  15826. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15827. /** @hidden */
  15828. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15829. /**
  15830. * Flag the bone as dirty (Forcing it to update everything)
  15831. */
  15832. markAsDirty(): void;
  15833. /** @hidden */
  15834. _markAsDirtyAndCompose(): void;
  15835. private _markAsDirtyAndDecompose;
  15836. /**
  15837. * Translate the bone in local or world space
  15838. * @param vec The amount to translate the bone
  15839. * @param space The space that the translation is in
  15840. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15841. */
  15842. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15843. /**
  15844. * Set the postion of the bone in local or world space
  15845. * @param position The position to set the bone
  15846. * @param space The space that the position is in
  15847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15848. */
  15849. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15850. /**
  15851. * Set the absolute position of the bone (world space)
  15852. * @param position The position to set the bone
  15853. * @param mesh The mesh that this bone is attached to
  15854. */
  15855. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15856. /**
  15857. * Scale the bone on the x, y and z axes (in local space)
  15858. * @param x The amount to scale the bone on the x axis
  15859. * @param y The amount to scale the bone on the y axis
  15860. * @param z The amount to scale the bone on the z axis
  15861. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15862. */
  15863. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15864. /**
  15865. * Set the bone scaling in local space
  15866. * @param scale defines the scaling vector
  15867. */
  15868. setScale(scale: Vector3): void;
  15869. /**
  15870. * Gets the current scaling in local space
  15871. * @returns the current scaling vector
  15872. */
  15873. getScale(): Vector3;
  15874. /**
  15875. * Gets the current scaling in local space and stores it in a target vector
  15876. * @param result defines the target vector
  15877. */
  15878. getScaleToRef(result: Vector3): void;
  15879. /**
  15880. * Set the yaw, pitch, and roll of the bone in local or world space
  15881. * @param yaw The rotation of the bone on the y axis
  15882. * @param pitch The rotation of the bone on the x axis
  15883. * @param roll The rotation of the bone on the z axis
  15884. * @param space The space that the axes of rotation are in
  15885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15886. */
  15887. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15888. /**
  15889. * Add a rotation to the bone on an axis in local or world space
  15890. * @param axis The axis to rotate the bone on
  15891. * @param amount The amount to rotate the bone
  15892. * @param space The space that the axis is in
  15893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15894. */
  15895. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15896. /**
  15897. * Set the rotation of the bone to a particular axis angle in local or world space
  15898. * @param axis The axis to rotate the bone on
  15899. * @param angle The angle that the bone should be rotated to
  15900. * @param space The space that the axis is in
  15901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15902. */
  15903. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15904. /**
  15905. * Set the euler rotation of the bone in local or world space
  15906. * @param rotation The euler rotation that the bone should be set to
  15907. * @param space The space that the rotation is in
  15908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15909. */
  15910. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15911. /**
  15912. * Set the quaternion rotation of the bone in local or world space
  15913. * @param quat The quaternion rotation that the bone should be set to
  15914. * @param space The space that the rotation is in
  15915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15916. */
  15917. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15918. /**
  15919. * Set the rotation matrix of the bone in local or world space
  15920. * @param rotMat The rotation matrix that the bone should be set to
  15921. * @param space The space that the rotation is in
  15922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15923. */
  15924. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15925. private _rotateWithMatrix;
  15926. private _getNegativeRotationToRef;
  15927. /**
  15928. * Get the position of the bone in local or world space
  15929. * @param space The space that the returned position is in
  15930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15931. * @returns The position of the bone
  15932. */
  15933. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15934. /**
  15935. * Copy the position of the bone to a vector3 in local or world space
  15936. * @param space The space that the returned position is in
  15937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15938. * @param result The vector3 to copy the position to
  15939. */
  15940. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15941. /**
  15942. * Get the absolute position of the bone (world space)
  15943. * @param mesh The mesh that this bone is attached to
  15944. * @returns The absolute position of the bone
  15945. */
  15946. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15947. /**
  15948. * Copy the absolute position of the bone (world space) to the result param
  15949. * @param mesh The mesh that this bone is attached to
  15950. * @param result The vector3 to copy the absolute position to
  15951. */
  15952. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15953. /**
  15954. * Compute the absolute transforms of this bone and its children
  15955. */
  15956. computeAbsoluteTransforms(): void;
  15957. /**
  15958. * Get the world direction from an axis that is in the local space of the bone
  15959. * @param localAxis The local direction that is used to compute the world direction
  15960. * @param mesh The mesh that this bone is attached to
  15961. * @returns The world direction
  15962. */
  15963. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15964. /**
  15965. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15966. * @param localAxis The local direction that is used to compute the world direction
  15967. * @param mesh The mesh that this bone is attached to
  15968. * @param result The vector3 that the world direction will be copied to
  15969. */
  15970. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15971. /**
  15972. * Get the euler rotation of the bone in local or world space
  15973. * @param space The space that the rotation should be in
  15974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15975. * @returns The euler rotation
  15976. */
  15977. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15978. /**
  15979. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15980. * @param space The space that the rotation should be in
  15981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15982. * @param result The vector3 that the rotation should be copied to
  15983. */
  15984. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15985. /**
  15986. * Get the quaternion rotation of the bone in either local or world space
  15987. * @param space The space that the rotation should be in
  15988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15989. * @returns The quaternion rotation
  15990. */
  15991. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15992. /**
  15993. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15994. * @param space The space that the rotation should be in
  15995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15996. * @param result The quaternion that the rotation should be copied to
  15997. */
  15998. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15999. /**
  16000. * Get the rotation matrix of the bone in local or world space
  16001. * @param space The space that the rotation should be in
  16002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  16003. * @returns The rotation matrix
  16004. */
  16005. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  16006. /**
  16007. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  16008. * @param space The space that the rotation should be in
  16009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  16010. * @param result The quaternion that the rotation should be copied to
  16011. */
  16012. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  16013. /**
  16014. * Get the world position of a point that is in the local space of the bone
  16015. * @param position The local position
  16016. * @param mesh The mesh that this bone is attached to
  16017. * @returns The world position
  16018. */
  16019. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16020. /**
  16021. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  16022. * @param position The local position
  16023. * @param mesh The mesh that this bone is attached to
  16024. * @param result The vector3 that the world position should be copied to
  16025. */
  16026. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16027. /**
  16028. * Get the local position of a point that is in world space
  16029. * @param position The world position
  16030. * @param mesh The mesh that this bone is attached to
  16031. * @returns The local position
  16032. */
  16033. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16034. /**
  16035. * Get the local position of a point that is in world space and copy it to the result param
  16036. * @param position The world position
  16037. * @param mesh The mesh that this bone is attached to
  16038. * @param result The vector3 that the local position should be copied to
  16039. */
  16040. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16041. /**
  16042. * Set the current local matrix as the restPose for this bone.
  16043. */
  16044. setCurrentPoseAsRest(): void;
  16045. }
  16046. }
  16047. declare module "babylonjs/Animations/runtimeAnimation" {
  16048. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16049. import { Animatable } from "babylonjs/Animations/animatable";
  16050. import { Scene } from "babylonjs/scene";
  16051. /**
  16052. * Defines a runtime animation
  16053. */
  16054. export class RuntimeAnimation {
  16055. private _events;
  16056. /**
  16057. * The current frame of the runtime animation
  16058. */
  16059. private _currentFrame;
  16060. /**
  16061. * The animation used by the runtime animation
  16062. */
  16063. private _animation;
  16064. /**
  16065. * The target of the runtime animation
  16066. */
  16067. private _target;
  16068. /**
  16069. * The initiating animatable
  16070. */
  16071. private _host;
  16072. /**
  16073. * The original value of the runtime animation
  16074. */
  16075. private _originalValue;
  16076. /**
  16077. * The original blend value of the runtime animation
  16078. */
  16079. private _originalBlendValue;
  16080. /**
  16081. * The offsets cache of the runtime animation
  16082. */
  16083. private _offsetsCache;
  16084. /**
  16085. * The high limits cache of the runtime animation
  16086. */
  16087. private _highLimitsCache;
  16088. /**
  16089. * Specifies if the runtime animation has been stopped
  16090. */
  16091. private _stopped;
  16092. /**
  16093. * The blending factor of the runtime animation
  16094. */
  16095. private _blendingFactor;
  16096. /**
  16097. * The BabylonJS scene
  16098. */
  16099. private _scene;
  16100. /**
  16101. * The current value of the runtime animation
  16102. */
  16103. private _currentValue;
  16104. /** @hidden */
  16105. _animationState: _IAnimationState;
  16106. /**
  16107. * The active target of the runtime animation
  16108. */
  16109. private _activeTargets;
  16110. private _currentActiveTarget;
  16111. private _directTarget;
  16112. /**
  16113. * The target path of the runtime animation
  16114. */
  16115. private _targetPath;
  16116. /**
  16117. * The weight of the runtime animation
  16118. */
  16119. private _weight;
  16120. /**
  16121. * The ratio offset of the runtime animation
  16122. */
  16123. private _ratioOffset;
  16124. /**
  16125. * The previous delay of the runtime animation
  16126. */
  16127. private _previousDelay;
  16128. /**
  16129. * The previous ratio of the runtime animation
  16130. */
  16131. private _previousRatio;
  16132. private _enableBlending;
  16133. private _keys;
  16134. private _minFrame;
  16135. private _maxFrame;
  16136. private _minValue;
  16137. private _maxValue;
  16138. private _targetIsArray;
  16139. /**
  16140. * Gets the current frame of the runtime animation
  16141. */
  16142. get currentFrame(): number;
  16143. /**
  16144. * Gets the weight of the runtime animation
  16145. */
  16146. get weight(): number;
  16147. /**
  16148. * Gets the current value of the runtime animation
  16149. */
  16150. get currentValue(): any;
  16151. /**
  16152. * Gets the target path of the runtime animation
  16153. */
  16154. get targetPath(): string;
  16155. /**
  16156. * Gets the actual target of the runtime animation
  16157. */
  16158. get target(): any;
  16159. /**
  16160. * Gets the additive state of the runtime animation
  16161. */
  16162. get isAdditive(): boolean;
  16163. /** @hidden */
  16164. _onLoop: () => void;
  16165. /**
  16166. * Create a new RuntimeAnimation object
  16167. * @param target defines the target of the animation
  16168. * @param animation defines the source animation object
  16169. * @param scene defines the hosting scene
  16170. * @param host defines the initiating Animatable
  16171. */
  16172. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16173. private _preparePath;
  16174. /**
  16175. * Gets the animation from the runtime animation
  16176. */
  16177. get animation(): Animation;
  16178. /**
  16179. * Resets the runtime animation to the beginning
  16180. * @param restoreOriginal defines whether to restore the target property to the original value
  16181. */
  16182. reset(restoreOriginal?: boolean): void;
  16183. /**
  16184. * Specifies if the runtime animation is stopped
  16185. * @returns Boolean specifying if the runtime animation is stopped
  16186. */
  16187. isStopped(): boolean;
  16188. /**
  16189. * Disposes of the runtime animation
  16190. */
  16191. dispose(): void;
  16192. /**
  16193. * Apply the interpolated value to the target
  16194. * @param currentValue defines the value computed by the animation
  16195. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16196. */
  16197. setValue(currentValue: any, weight: number): void;
  16198. private _getOriginalValues;
  16199. private _setValue;
  16200. /**
  16201. * Gets the loop pmode of the runtime animation
  16202. * @returns Loop Mode
  16203. */
  16204. private _getCorrectLoopMode;
  16205. /**
  16206. * Move the current animation to a given frame
  16207. * @param frame defines the frame to move to
  16208. */
  16209. goToFrame(frame: number): void;
  16210. /**
  16211. * @hidden Internal use only
  16212. */
  16213. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16214. /**
  16215. * Execute the current animation
  16216. * @param delay defines the delay to add to the current frame
  16217. * @param from defines the lower bound of the animation range
  16218. * @param to defines the upper bound of the animation range
  16219. * @param loop defines if the current animation must loop
  16220. * @param speedRatio defines the current speed ratio
  16221. * @param weight defines the weight of the animation (default is -1 so no weight)
  16222. * @param onLoop optional callback called when animation loops
  16223. * @returns a boolean indicating if the animation is running
  16224. */
  16225. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16226. }
  16227. }
  16228. declare module "babylonjs/Animations/animatable" {
  16229. import { Animation } from "babylonjs/Animations/animation";
  16230. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16231. import { Nullable } from "babylonjs/types";
  16232. import { Observable } from "babylonjs/Misc/observable";
  16233. import { Scene } from "babylonjs/scene";
  16234. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16235. import { Node } from "babylonjs/node";
  16236. /**
  16237. * Class used to store an actual running animation
  16238. */
  16239. export class Animatable {
  16240. /** defines the target object */
  16241. target: any;
  16242. /** defines the starting frame number (default is 0) */
  16243. fromFrame: number;
  16244. /** defines the ending frame number (default is 100) */
  16245. toFrame: number;
  16246. /** defines if the animation must loop (default is false) */
  16247. loopAnimation: boolean;
  16248. /** defines a callback to call when animation ends if it is not looping */
  16249. onAnimationEnd?: (() => void) | null | undefined;
  16250. /** defines a callback to call when animation loops */
  16251. onAnimationLoop?: (() => void) | null | undefined;
  16252. /** defines whether the animation should be evaluated additively */
  16253. isAdditive: boolean;
  16254. private _localDelayOffset;
  16255. private _pausedDelay;
  16256. private _runtimeAnimations;
  16257. private _paused;
  16258. private _scene;
  16259. private _speedRatio;
  16260. private _weight;
  16261. private _syncRoot;
  16262. /**
  16263. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16264. * This will only apply for non looping animation (default is true)
  16265. */
  16266. disposeOnEnd: boolean;
  16267. /**
  16268. * Gets a boolean indicating if the animation has started
  16269. */
  16270. animationStarted: boolean;
  16271. /**
  16272. * Observer raised when the animation ends
  16273. */
  16274. onAnimationEndObservable: Observable<Animatable>;
  16275. /**
  16276. * Observer raised when the animation loops
  16277. */
  16278. onAnimationLoopObservable: Observable<Animatable>;
  16279. /**
  16280. * Gets the root Animatable used to synchronize and normalize animations
  16281. */
  16282. get syncRoot(): Nullable<Animatable>;
  16283. /**
  16284. * Gets the current frame of the first RuntimeAnimation
  16285. * Used to synchronize Animatables
  16286. */
  16287. get masterFrame(): number;
  16288. /**
  16289. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16290. */
  16291. get weight(): number;
  16292. set weight(value: number);
  16293. /**
  16294. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16295. */
  16296. get speedRatio(): number;
  16297. set speedRatio(value: number);
  16298. /**
  16299. * Creates a new Animatable
  16300. * @param scene defines the hosting scene
  16301. * @param target defines the target object
  16302. * @param fromFrame defines the starting frame number (default is 0)
  16303. * @param toFrame defines the ending frame number (default is 100)
  16304. * @param loopAnimation defines if the animation must loop (default is false)
  16305. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16306. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16307. * @param animations defines a group of animation to add to the new Animatable
  16308. * @param onAnimationLoop defines a callback to call when animation loops
  16309. * @param isAdditive defines whether the animation should be evaluated additively
  16310. */
  16311. constructor(scene: Scene,
  16312. /** defines the target object */
  16313. target: any,
  16314. /** defines the starting frame number (default is 0) */
  16315. fromFrame?: number,
  16316. /** defines the ending frame number (default is 100) */
  16317. toFrame?: number,
  16318. /** defines if the animation must loop (default is false) */
  16319. loopAnimation?: boolean, speedRatio?: number,
  16320. /** defines a callback to call when animation ends if it is not looping */
  16321. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16322. /** defines a callback to call when animation loops */
  16323. onAnimationLoop?: (() => void) | null | undefined,
  16324. /** defines whether the animation should be evaluated additively */
  16325. isAdditive?: boolean);
  16326. /**
  16327. * Synchronize and normalize current Animatable with a source Animatable
  16328. * This is useful when using animation weights and when animations are not of the same length
  16329. * @param root defines the root Animatable to synchronize with
  16330. * @returns the current Animatable
  16331. */
  16332. syncWith(root: Animatable): Animatable;
  16333. /**
  16334. * Gets the list of runtime animations
  16335. * @returns an array of RuntimeAnimation
  16336. */
  16337. getAnimations(): RuntimeAnimation[];
  16338. /**
  16339. * Adds more animations to the current animatable
  16340. * @param target defines the target of the animations
  16341. * @param animations defines the new animations to add
  16342. */
  16343. appendAnimations(target: any, animations: Animation[]): void;
  16344. /**
  16345. * Gets the source animation for a specific property
  16346. * @param property defines the propertyu to look for
  16347. * @returns null or the source animation for the given property
  16348. */
  16349. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16350. /**
  16351. * Gets the runtime animation for a specific property
  16352. * @param property defines the propertyu to look for
  16353. * @returns null or the runtime animation for the given property
  16354. */
  16355. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16356. /**
  16357. * Resets the animatable to its original state
  16358. */
  16359. reset(): void;
  16360. /**
  16361. * Allows the animatable to blend with current running animations
  16362. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16363. * @param blendingSpeed defines the blending speed to use
  16364. */
  16365. enableBlending(blendingSpeed: number): void;
  16366. /**
  16367. * Disable animation blending
  16368. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16369. */
  16370. disableBlending(): void;
  16371. /**
  16372. * Jump directly to a given frame
  16373. * @param frame defines the frame to jump to
  16374. */
  16375. goToFrame(frame: number): void;
  16376. /**
  16377. * Pause the animation
  16378. */
  16379. pause(): void;
  16380. /**
  16381. * Restart the animation
  16382. */
  16383. restart(): void;
  16384. private _raiseOnAnimationEnd;
  16385. /**
  16386. * Stop and delete the current animation
  16387. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16388. * @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)
  16389. */
  16390. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16391. /**
  16392. * Wait asynchronously for the animation to end
  16393. * @returns a promise which will be fullfilled when the animation ends
  16394. */
  16395. waitAsync(): Promise<Animatable>;
  16396. /** @hidden */
  16397. _animate(delay: number): boolean;
  16398. }
  16399. module "babylonjs/scene" {
  16400. interface Scene {
  16401. /** @hidden */
  16402. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16403. /** @hidden */
  16404. _processLateAnimationBindingsForMatrices(holder: {
  16405. totalWeight: number;
  16406. totalAdditiveWeight: number;
  16407. animations: RuntimeAnimation[];
  16408. additiveAnimations: RuntimeAnimation[];
  16409. originalValue: Matrix;
  16410. }): any;
  16411. /** @hidden */
  16412. _processLateAnimationBindingsForQuaternions(holder: {
  16413. totalWeight: number;
  16414. totalAdditiveWeight: number;
  16415. animations: RuntimeAnimation[];
  16416. additiveAnimations: RuntimeAnimation[];
  16417. originalValue: Quaternion;
  16418. }, refQuaternion: Quaternion): Quaternion;
  16419. /** @hidden */
  16420. _processLateAnimationBindings(): void;
  16421. /**
  16422. * Will start the animation sequence of a given target
  16423. * @param target defines the target
  16424. * @param from defines from which frame should animation start
  16425. * @param to defines until which frame should animation run.
  16426. * @param weight defines the weight to apply to the animation (1.0 by default)
  16427. * @param loop defines if the animation loops
  16428. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16429. * @param onAnimationEnd defines the function to be executed when the animation ends
  16430. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16431. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16432. * @param onAnimationLoop defines the callback to call when an animation loops
  16433. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16434. * @returns the animatable object created for this animation
  16435. */
  16436. 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;
  16437. /**
  16438. * Will start the animation sequence of a given target
  16439. * @param target defines the target
  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 animate 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 animatable object created for this animation
  16451. */
  16452. 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;
  16453. /**
  16454. * Will start the animation sequence of a given target and its hierarchy
  16455. * @param target defines the target
  16456. * @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.
  16457. * @param from defines from which frame should animation start
  16458. * @param to defines until which frame should animation run.
  16459. * @param loop defines if the animation loops
  16460. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16461. * @param onAnimationEnd defines the function to be executed when the animation ends
  16462. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16463. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16464. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16465. * @param onAnimationLoop defines the callback to call when an animation loops
  16466. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16467. * @returns the list of created animatables
  16468. */
  16469. 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[];
  16470. /**
  16471. * Begin a new animation on a given node
  16472. * @param target defines the target where the animation will take place
  16473. * @param animations defines the list of animations to start
  16474. * @param from defines the initial value
  16475. * @param to defines the final value
  16476. * @param loop defines if you want animation to loop (off by default)
  16477. * @param speedRatio defines the speed ratio to apply to all animations
  16478. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16479. * @param onAnimationLoop defines the callback to call when an animation loops
  16480. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16481. * @returns the list of created animatables
  16482. */
  16483. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16484. /**
  16485. * Begin a new animation on a given node and its hierarchy
  16486. * @param target defines the root node where the animation will take place
  16487. * @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.
  16488. * @param animations defines the list of animations to start
  16489. * @param from defines the initial value
  16490. * @param to defines the final value
  16491. * @param loop defines if you want animation to loop (off by default)
  16492. * @param speedRatio defines the speed ratio to apply to all animations
  16493. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16494. * @param onAnimationLoop defines the callback to call when an animation loops
  16495. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16496. * @returns the list of animatables created for all nodes
  16497. */
  16498. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16499. /**
  16500. * Gets the animatable associated with a specific target
  16501. * @param target defines the target of the animatable
  16502. * @returns the required animatable if found
  16503. */
  16504. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16505. /**
  16506. * Gets all animatables associated with a given target
  16507. * @param target defines the target to look animatables for
  16508. * @returns an array of Animatables
  16509. */
  16510. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16511. /**
  16512. * Stops and removes all animations that have been applied to the scene
  16513. */
  16514. stopAllAnimations(): void;
  16515. /**
  16516. * Gets the current delta time used by animation engine
  16517. */
  16518. deltaTime: number;
  16519. }
  16520. }
  16521. module "babylonjs/Bones/bone" {
  16522. interface Bone {
  16523. /**
  16524. * Copy an animation range from another bone
  16525. * @param source defines the source bone
  16526. * @param rangeName defines the range name to copy
  16527. * @param frameOffset defines the frame offset
  16528. * @param rescaleAsRequired defines if rescaling must be applied if required
  16529. * @param skelDimensionsRatio defines the scaling ratio
  16530. * @returns true if operation was successful
  16531. */
  16532. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16533. }
  16534. }
  16535. }
  16536. declare module "babylonjs/Bones/skeleton" {
  16537. import { Bone } from "babylonjs/Bones/bone";
  16538. import { Observable } from "babylonjs/Misc/observable";
  16539. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16540. import { Scene } from "babylonjs/scene";
  16541. import { Nullable } from "babylonjs/types";
  16542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16543. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16544. import { Animatable } from "babylonjs/Animations/animatable";
  16545. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16546. import { Animation } from "babylonjs/Animations/animation";
  16547. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16548. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16549. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16550. /**
  16551. * Class used to handle skinning animations
  16552. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16553. */
  16554. export class Skeleton implements IAnimatable {
  16555. /** defines the skeleton name */
  16556. name: string;
  16557. /** defines the skeleton Id */
  16558. id: string;
  16559. /**
  16560. * Defines the list of child bones
  16561. */
  16562. bones: Bone[];
  16563. /**
  16564. * Defines an estimate of the dimension of the skeleton at rest
  16565. */
  16566. dimensionsAtRest: Vector3;
  16567. /**
  16568. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16569. */
  16570. needInitialSkinMatrix: boolean;
  16571. /**
  16572. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16573. */
  16574. overrideMesh: Nullable<AbstractMesh>;
  16575. /**
  16576. * Gets the list of animations attached to this skeleton
  16577. */
  16578. animations: Array<Animation>;
  16579. private _scene;
  16580. private _isDirty;
  16581. private _transformMatrices;
  16582. private _transformMatrixTexture;
  16583. private _meshesWithPoseMatrix;
  16584. private _animatables;
  16585. private _identity;
  16586. private _synchronizedWithMesh;
  16587. private _ranges;
  16588. private _lastAbsoluteTransformsUpdateId;
  16589. private _canUseTextureForBones;
  16590. private _uniqueId;
  16591. /** @hidden */
  16592. _numBonesWithLinkedTransformNode: number;
  16593. /** @hidden */
  16594. _hasWaitingData: Nullable<boolean>;
  16595. /** @hidden */
  16596. _waitingOverrideMeshId: Nullable<string>;
  16597. /**
  16598. * Specifies if the skeleton should be serialized
  16599. */
  16600. doNotSerialize: boolean;
  16601. private _useTextureToStoreBoneMatrices;
  16602. /**
  16603. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16604. * Please note that this option is not available if the hardware does not support it
  16605. */
  16606. get useTextureToStoreBoneMatrices(): boolean;
  16607. set useTextureToStoreBoneMatrices(value: boolean);
  16608. private _animationPropertiesOverride;
  16609. /**
  16610. * Gets or sets the animation properties override
  16611. */
  16612. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16613. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16614. /**
  16615. * List of inspectable custom properties (used by the Inspector)
  16616. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16617. */
  16618. inspectableCustomProperties: IInspectable[];
  16619. /**
  16620. * An observable triggered before computing the skeleton's matrices
  16621. */
  16622. onBeforeComputeObservable: Observable<Skeleton>;
  16623. /**
  16624. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16625. */
  16626. get isUsingTextureForMatrices(): boolean;
  16627. /**
  16628. * Gets the unique ID of this skeleton
  16629. */
  16630. get uniqueId(): number;
  16631. /**
  16632. * Creates a new skeleton
  16633. * @param name defines the skeleton name
  16634. * @param id defines the skeleton Id
  16635. * @param scene defines the hosting scene
  16636. */
  16637. constructor(
  16638. /** defines the skeleton name */
  16639. name: string,
  16640. /** defines the skeleton Id */
  16641. id: string, scene: Scene);
  16642. /**
  16643. * Gets the current object class name.
  16644. * @return the class name
  16645. */
  16646. getClassName(): string;
  16647. /**
  16648. * Returns an array containing the root bones
  16649. * @returns an array containing the root bones
  16650. */
  16651. getChildren(): Array<Bone>;
  16652. /**
  16653. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16654. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16655. * @returns a Float32Array containing matrices data
  16656. */
  16657. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16658. /**
  16659. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16660. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16661. * @returns a raw texture containing the data
  16662. */
  16663. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16664. /**
  16665. * Gets the current hosting scene
  16666. * @returns a scene object
  16667. */
  16668. getScene(): Scene;
  16669. /**
  16670. * Gets a string representing the current skeleton data
  16671. * @param fullDetails defines a boolean indicating if we want a verbose version
  16672. * @returns a string representing the current skeleton data
  16673. */
  16674. toString(fullDetails?: boolean): string;
  16675. /**
  16676. * Get bone's index searching by name
  16677. * @param name defines bone's name to search for
  16678. * @return the indice of the bone. Returns -1 if not found
  16679. */
  16680. getBoneIndexByName(name: string): number;
  16681. /**
  16682. * Creater a new animation range
  16683. * @param name defines the name of the range
  16684. * @param from defines the start key
  16685. * @param to defines the end key
  16686. */
  16687. createAnimationRange(name: string, from: number, to: number): void;
  16688. /**
  16689. * Delete a specific animation range
  16690. * @param name defines the name of the range
  16691. * @param deleteFrames defines if frames must be removed as well
  16692. */
  16693. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16694. /**
  16695. * Gets a specific animation range
  16696. * @param name defines the name of the range to look for
  16697. * @returns the requested animation range or null if not found
  16698. */
  16699. getAnimationRange(name: string): Nullable<AnimationRange>;
  16700. /**
  16701. * Gets the list of all animation ranges defined on this skeleton
  16702. * @returns an array
  16703. */
  16704. getAnimationRanges(): Nullable<AnimationRange>[];
  16705. /**
  16706. * Copy animation range from a source skeleton.
  16707. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16708. * @param source defines the source skeleton
  16709. * @param name defines the name of the range to copy
  16710. * @param rescaleAsRequired defines if rescaling must be applied if required
  16711. * @returns true if operation was successful
  16712. */
  16713. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16714. /**
  16715. * Forces the skeleton to go to rest pose
  16716. */
  16717. returnToRest(): void;
  16718. private _getHighestAnimationFrame;
  16719. /**
  16720. * Begin a specific animation range
  16721. * @param name defines the name of the range to start
  16722. * @param loop defines if looping must be turned on (false by default)
  16723. * @param speedRatio defines the speed ratio to apply (1 by default)
  16724. * @param onAnimationEnd defines a callback which will be called when animation will end
  16725. * @returns a new animatable
  16726. */
  16727. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16728. /**
  16729. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16730. * @param skeleton defines the Skeleton containing the animation range to convert
  16731. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16732. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16733. * @returns the original skeleton
  16734. */
  16735. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16736. /** @hidden */
  16737. _markAsDirty(): void;
  16738. /** @hidden */
  16739. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16740. /** @hidden */
  16741. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16742. private _computeTransformMatrices;
  16743. /**
  16744. * Build all resources required to render a skeleton
  16745. */
  16746. prepare(): void;
  16747. /**
  16748. * Gets the list of animatables currently running for this skeleton
  16749. * @returns an array of animatables
  16750. */
  16751. getAnimatables(): IAnimatable[];
  16752. /**
  16753. * Clone the current skeleton
  16754. * @param name defines the name of the new skeleton
  16755. * @param id defines the id of the new skeleton
  16756. * @returns the new skeleton
  16757. */
  16758. clone(name: string, id?: string): Skeleton;
  16759. /**
  16760. * Enable animation blending for this skeleton
  16761. * @param blendingSpeed defines the blending speed to apply
  16762. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16763. */
  16764. enableBlending(blendingSpeed?: number): void;
  16765. /**
  16766. * Releases all resources associated with the current skeleton
  16767. */
  16768. dispose(): void;
  16769. /**
  16770. * Serialize the skeleton in a JSON object
  16771. * @returns a JSON object
  16772. */
  16773. serialize(): any;
  16774. /**
  16775. * Creates a new skeleton from serialized data
  16776. * @param parsedSkeleton defines the serialized data
  16777. * @param scene defines the hosting scene
  16778. * @returns a new skeleton
  16779. */
  16780. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16781. /**
  16782. * Compute all node absolute transforms
  16783. * @param forceUpdate defines if computation must be done even if cache is up to date
  16784. */
  16785. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16786. /**
  16787. * Gets the root pose matrix
  16788. * @returns a matrix
  16789. */
  16790. getPoseMatrix(): Nullable<Matrix>;
  16791. /**
  16792. * Sorts bones per internal index
  16793. */
  16794. sortBones(): void;
  16795. private _sortBones;
  16796. /**
  16797. * Set the current local matrix as the restPose for all bones in the skeleton.
  16798. */
  16799. setCurrentPoseAsRest(): void;
  16800. }
  16801. }
  16802. declare module "babylonjs/Meshes/instancedMesh" {
  16803. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16804. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16805. import { Camera } from "babylonjs/Cameras/camera";
  16806. import { Node } from "babylonjs/node";
  16807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16808. import { Mesh } from "babylonjs/Meshes/mesh";
  16809. import { Material } from "babylonjs/Materials/material";
  16810. import { Skeleton } from "babylonjs/Bones/skeleton";
  16811. import { Light } from "babylonjs/Lights/light";
  16812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16813. /**
  16814. * Creates an instance based on a source mesh.
  16815. */
  16816. export class InstancedMesh extends AbstractMesh {
  16817. private _sourceMesh;
  16818. private _currentLOD;
  16819. /** @hidden */
  16820. _indexInSourceMeshInstanceArray: number;
  16821. constructor(name: string, source: Mesh);
  16822. /**
  16823. * Returns the string "InstancedMesh".
  16824. */
  16825. getClassName(): string;
  16826. /** Gets the list of lights affecting that mesh */
  16827. get lightSources(): Light[];
  16828. _resyncLightSources(): void;
  16829. _resyncLightSource(light: Light): void;
  16830. _removeLightSource(light: Light, dispose: boolean): void;
  16831. /**
  16832. * If the source mesh receives shadows
  16833. */
  16834. get receiveShadows(): boolean;
  16835. /**
  16836. * The material of the source mesh
  16837. */
  16838. get material(): Nullable<Material>;
  16839. /**
  16840. * Visibility of the source mesh
  16841. */
  16842. get visibility(): number;
  16843. /**
  16844. * Skeleton of the source mesh
  16845. */
  16846. get skeleton(): Nullable<Skeleton>;
  16847. /**
  16848. * Rendering ground id of the source mesh
  16849. */
  16850. get renderingGroupId(): number;
  16851. set renderingGroupId(value: number);
  16852. /**
  16853. * Returns the total number of vertices (integer).
  16854. */
  16855. getTotalVertices(): number;
  16856. /**
  16857. * Returns a positive integer : the total number of indices in this mesh geometry.
  16858. * @returns the numner of indices or zero if the mesh has no geometry.
  16859. */
  16860. getTotalIndices(): number;
  16861. /**
  16862. * The source mesh of the instance
  16863. */
  16864. get sourceMesh(): Mesh;
  16865. /**
  16866. * Creates a new InstancedMesh object from the mesh model.
  16867. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16868. * @param name defines the name of the new instance
  16869. * @returns a new InstancedMesh
  16870. */
  16871. createInstance(name: string): InstancedMesh;
  16872. /**
  16873. * Is this node ready to be used/rendered
  16874. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16875. * @return {boolean} is it ready
  16876. */
  16877. isReady(completeCheck?: boolean): boolean;
  16878. /**
  16879. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16880. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16881. * @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.
  16882. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16883. */
  16884. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16885. /**
  16886. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16887. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16888. * The `data` are either a numeric array either a Float32Array.
  16889. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16890. * 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).
  16891. * Note that a new underlying VertexBuffer object is created each call.
  16892. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16893. *
  16894. * Possible `kind` values :
  16895. * - VertexBuffer.PositionKind
  16896. * - VertexBuffer.UVKind
  16897. * - VertexBuffer.UV2Kind
  16898. * - VertexBuffer.UV3Kind
  16899. * - VertexBuffer.UV4Kind
  16900. * - VertexBuffer.UV5Kind
  16901. * - VertexBuffer.UV6Kind
  16902. * - VertexBuffer.ColorKind
  16903. * - VertexBuffer.MatricesIndicesKind
  16904. * - VertexBuffer.MatricesIndicesExtraKind
  16905. * - VertexBuffer.MatricesWeightsKind
  16906. * - VertexBuffer.MatricesWeightsExtraKind
  16907. *
  16908. * Returns the Mesh.
  16909. */
  16910. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16911. /**
  16912. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16913. * If the mesh has no geometry, it is simply returned as it is.
  16914. * The `data` are either a numeric array either a Float32Array.
  16915. * No new underlying VertexBuffer object is created.
  16916. * 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.
  16917. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16918. *
  16919. * Possible `kind` values :
  16920. * - VertexBuffer.PositionKind
  16921. * - VertexBuffer.UVKind
  16922. * - VertexBuffer.UV2Kind
  16923. * - VertexBuffer.UV3Kind
  16924. * - VertexBuffer.UV4Kind
  16925. * - VertexBuffer.UV5Kind
  16926. * - VertexBuffer.UV6Kind
  16927. * - VertexBuffer.ColorKind
  16928. * - VertexBuffer.MatricesIndicesKind
  16929. * - VertexBuffer.MatricesIndicesExtraKind
  16930. * - VertexBuffer.MatricesWeightsKind
  16931. * - VertexBuffer.MatricesWeightsExtraKind
  16932. *
  16933. * Returns the Mesh.
  16934. */
  16935. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16936. /**
  16937. * Sets the mesh indices.
  16938. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16939. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16940. * This method creates a new index buffer each call.
  16941. * Returns the Mesh.
  16942. */
  16943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16944. /**
  16945. * Boolean : True if the mesh owns the requested kind of data.
  16946. */
  16947. isVerticesDataPresent(kind: string): boolean;
  16948. /**
  16949. * Returns an array of indices (IndicesArray).
  16950. */
  16951. getIndices(): Nullable<IndicesArray>;
  16952. get _positions(): Nullable<Vector3[]>;
  16953. /**
  16954. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16955. * This means the mesh underlying bounding box and sphere are recomputed.
  16956. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16957. * @returns the current mesh
  16958. */
  16959. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16960. /** @hidden */
  16961. _preActivate(): InstancedMesh;
  16962. /** @hidden */
  16963. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16964. /** @hidden */
  16965. _postActivate(): void;
  16966. getWorldMatrix(): Matrix;
  16967. get isAnInstance(): boolean;
  16968. /**
  16969. * Returns the current associated LOD AbstractMesh.
  16970. */
  16971. getLOD(camera: Camera): AbstractMesh;
  16972. /** @hidden */
  16973. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16974. /** @hidden */
  16975. _syncSubMeshes(): InstancedMesh;
  16976. /** @hidden */
  16977. _generatePointsArray(): boolean;
  16978. /** @hidden */
  16979. _updateBoundingInfo(): AbstractMesh;
  16980. /**
  16981. * Creates a new InstancedMesh from the current mesh.
  16982. * - name (string) : the cloned mesh name
  16983. * - newParent (optional Node) : the optional Node to parent the clone to.
  16984. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16985. *
  16986. * Returns the clone.
  16987. */
  16988. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16989. /**
  16990. * Disposes the InstancedMesh.
  16991. * Returns nothing.
  16992. */
  16993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16994. }
  16995. module "babylonjs/Meshes/mesh" {
  16996. interface Mesh {
  16997. /**
  16998. * Register a custom buffer that will be instanced
  16999. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17000. * @param kind defines the buffer kind
  17001. * @param stride defines the stride in floats
  17002. */
  17003. registerInstancedBuffer(kind: string, stride: number): void;
  17004. /**
  17005. * true to use the edge renderer for all instances of this mesh
  17006. */
  17007. edgesShareWithInstances: boolean;
  17008. /** @hidden */
  17009. _userInstancedBuffersStorage: {
  17010. data: {
  17011. [key: string]: Float32Array;
  17012. };
  17013. sizes: {
  17014. [key: string]: number;
  17015. };
  17016. vertexBuffers: {
  17017. [key: string]: Nullable<VertexBuffer>;
  17018. };
  17019. strides: {
  17020. [key: string]: number;
  17021. };
  17022. };
  17023. }
  17024. }
  17025. module "babylonjs/Meshes/abstractMesh" {
  17026. interface AbstractMesh {
  17027. /**
  17028. * Object used to store instanced buffers defined by user
  17029. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17030. */
  17031. instancedBuffers: {
  17032. [key: string]: any;
  17033. };
  17034. }
  17035. }
  17036. }
  17037. declare module "babylonjs/Materials/shaderMaterial" {
  17038. import { Nullable } from "babylonjs/types";
  17039. import { Scene } from "babylonjs/scene";
  17040. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17042. import { Mesh } from "babylonjs/Meshes/mesh";
  17043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17045. import { Effect } from "babylonjs/Materials/effect";
  17046. import { Material } from "babylonjs/Materials/material";
  17047. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17048. /**
  17049. * Defines the options associated with the creation of a shader material.
  17050. */
  17051. export interface IShaderMaterialOptions {
  17052. /**
  17053. * Does the material work in alpha blend mode
  17054. */
  17055. needAlphaBlending: boolean;
  17056. /**
  17057. * Does the material work in alpha test mode
  17058. */
  17059. needAlphaTesting: boolean;
  17060. /**
  17061. * The list of attribute names used in the shader
  17062. */
  17063. attributes: string[];
  17064. /**
  17065. * The list of unifrom names used in the shader
  17066. */
  17067. uniforms: string[];
  17068. /**
  17069. * The list of UBO names used in the shader
  17070. */
  17071. uniformBuffers: string[];
  17072. /**
  17073. * The list of sampler names used in the shader
  17074. */
  17075. samplers: string[];
  17076. /**
  17077. * The list of defines used in the shader
  17078. */
  17079. defines: string[];
  17080. }
  17081. /**
  17082. * 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.
  17083. *
  17084. * This returned material effects how the mesh will look based on the code in the shaders.
  17085. *
  17086. * @see https://doc.babylonjs.com/how_to/shader_material
  17087. */
  17088. export class ShaderMaterial extends Material {
  17089. private _shaderPath;
  17090. private _options;
  17091. private _textures;
  17092. private _textureArrays;
  17093. private _floats;
  17094. private _ints;
  17095. private _floatsArrays;
  17096. private _colors3;
  17097. private _colors3Arrays;
  17098. private _colors4;
  17099. private _colors4Arrays;
  17100. private _vectors2;
  17101. private _vectors3;
  17102. private _vectors4;
  17103. private _matrices;
  17104. private _matrixArrays;
  17105. private _matrices3x3;
  17106. private _matrices2x2;
  17107. private _vectors2Arrays;
  17108. private _vectors3Arrays;
  17109. private _vectors4Arrays;
  17110. private _cachedWorldViewMatrix;
  17111. private _cachedWorldViewProjectionMatrix;
  17112. private _renderId;
  17113. private _multiview;
  17114. private _cachedDefines;
  17115. /** Define the Url to load snippets */
  17116. static SnippetUrl: string;
  17117. /** Snippet ID if the material was created from the snippet server */
  17118. snippetId: string;
  17119. /**
  17120. * Instantiate a new shader material.
  17121. * 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.
  17122. * This returned material effects how the mesh will look based on the code in the shaders.
  17123. * @see https://doc.babylonjs.com/how_to/shader_material
  17124. * @param name Define the name of the material in the scene
  17125. * @param scene Define the scene the material belongs to
  17126. * @param shaderPath Defines the route to the shader code in one of three ways:
  17127. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17128. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17129. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17130. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17131. * @param options Define the options used to create the shader
  17132. */
  17133. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17134. /**
  17135. * Gets the shader path used to define the shader code
  17136. * It can be modified to trigger a new compilation
  17137. */
  17138. get shaderPath(): any;
  17139. /**
  17140. * Sets the shader path used to define the shader code
  17141. * It can be modified to trigger a new compilation
  17142. */
  17143. set shaderPath(shaderPath: any);
  17144. /**
  17145. * Gets the options used to compile the shader.
  17146. * They can be modified to trigger a new compilation
  17147. */
  17148. get options(): IShaderMaterialOptions;
  17149. /**
  17150. * Gets the current class name of the material e.g. "ShaderMaterial"
  17151. * Mainly use in serialization.
  17152. * @returns the class name
  17153. */
  17154. getClassName(): string;
  17155. /**
  17156. * Specifies if the material will require alpha blending
  17157. * @returns a boolean specifying if alpha blending is needed
  17158. */
  17159. needAlphaBlending(): boolean;
  17160. /**
  17161. * Specifies if this material should be rendered in alpha test mode
  17162. * @returns a boolean specifying if an alpha test is needed.
  17163. */
  17164. needAlphaTesting(): boolean;
  17165. private _checkUniform;
  17166. /**
  17167. * Set a texture in the shader.
  17168. * @param name Define the name of the uniform samplers as defined in the shader
  17169. * @param texture Define the texture to bind to this sampler
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17173. /**
  17174. * Set a texture array in the shader.
  17175. * @param name Define the name of the uniform sampler array as defined in the shader
  17176. * @param textures Define the list of textures to bind to this sampler
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17180. /**
  17181. * Set a float in the shader.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setFloat(name: string, value: number): ShaderMaterial;
  17187. /**
  17188. * Set a int in the shader.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setInt(name: string, value: number): ShaderMaterial;
  17194. /**
  17195. * Set an array of floats in the shader.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setFloats(name: string, value: number[]): ShaderMaterial;
  17201. /**
  17202. * Set a vec3 in the shader from a Color3.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setColor3(name: string, value: Color3): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 array in the shader from a Color3 array.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 in the shader from a Color4.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setColor4(name: string, value: Color4): ShaderMaterial;
  17222. /**
  17223. * Set a vec4 array in the shader from a Color4 array.
  17224. * @param name Define the name of the uniform as defined in the shader
  17225. * @param value Define the value to give to the uniform
  17226. * @return the material itself allowing "fluent" like uniform updates
  17227. */
  17228. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17229. /**
  17230. * Set a vec2 in the shader from a Vector2.
  17231. * @param name Define the name of the uniform as defined in the shader
  17232. * @param value Define the value to give to the uniform
  17233. * @return the material itself allowing "fluent" like uniform updates
  17234. */
  17235. setVector2(name: string, value: Vector2): ShaderMaterial;
  17236. /**
  17237. * Set a vec3 in the shader from a Vector3.
  17238. * @param name Define the name of the uniform as defined in the shader
  17239. * @param value Define the value to give to the uniform
  17240. * @return the material itself allowing "fluent" like uniform updates
  17241. */
  17242. setVector3(name: string, value: Vector3): ShaderMaterial;
  17243. /**
  17244. * Set a vec4 in the shader from a Vector4.
  17245. * @param name Define the name of the uniform as defined in the shader
  17246. * @param value Define the value to give to the uniform
  17247. * @return the material itself allowing "fluent" like uniform updates
  17248. */
  17249. setVector4(name: string, value: Vector4): ShaderMaterial;
  17250. /**
  17251. * Set a mat4 in the shader from a Matrix.
  17252. * @param name Define the name of the uniform as defined in the shader
  17253. * @param value Define the value to give to the uniform
  17254. * @return the material itself allowing "fluent" like uniform updates
  17255. */
  17256. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17257. /**
  17258. * Set a float32Array in the shader from a matrix array.
  17259. * @param name Define the name of the uniform as defined in the shader
  17260. * @param value Define the value to give to the uniform
  17261. * @return the material itself allowing "fluent" like uniform updates
  17262. */
  17263. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17264. /**
  17265. * Set a mat3 in the shader from a Float32Array.
  17266. * @param name Define the name of the uniform as defined in the shader
  17267. * @param value Define the value to give to the uniform
  17268. * @return the material itself allowing "fluent" like uniform updates
  17269. */
  17270. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17271. /**
  17272. * Set a mat2 in the shader from a Float32Array.
  17273. * @param name Define the name of the uniform as defined in the shader
  17274. * @param value Define the value to give to the uniform
  17275. * @return the material itself allowing "fluent" like uniform updates
  17276. */
  17277. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17278. /**
  17279. * Set a vec2 array in the shader from a number array.
  17280. * @param name Define the name of the uniform as defined in the shader
  17281. * @param value Define the value to give to the uniform
  17282. * @return the material itself allowing "fluent" like uniform updates
  17283. */
  17284. setArray2(name: string, value: number[]): ShaderMaterial;
  17285. /**
  17286. * Set a vec3 array in the shader from a number array.
  17287. * @param name Define the name of the uniform as defined in the shader
  17288. * @param value Define the value to give to the uniform
  17289. * @return the material itself allowing "fluent" like uniform updates
  17290. */
  17291. setArray3(name: string, value: number[]): ShaderMaterial;
  17292. /**
  17293. * Set a vec4 array in the shader from a number array.
  17294. * @param name Define the name of the uniform as defined in the shader
  17295. * @param value Define the value to give to the uniform
  17296. * @return the material itself allowing "fluent" like uniform updates
  17297. */
  17298. setArray4(name: string, value: number[]): ShaderMaterial;
  17299. private _checkCache;
  17300. /**
  17301. * Specifies that the submesh is ready to be used
  17302. * @param mesh defines the mesh to check
  17303. * @param subMesh defines which submesh to check
  17304. * @param useInstances specifies that instances should be used
  17305. * @returns a boolean indicating that the submesh is ready or not
  17306. */
  17307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17308. /**
  17309. * Checks if the material is ready to render the requested mesh
  17310. * @param mesh Define the mesh to render
  17311. * @param useInstances Define whether or not the material is used with instances
  17312. * @returns true if ready, otherwise false
  17313. */
  17314. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17315. /**
  17316. * Binds the world matrix to the material
  17317. * @param world defines the world transformation matrix
  17318. * @param effectOverride - If provided, use this effect instead of internal effect
  17319. */
  17320. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17321. /**
  17322. * Binds the submesh to this material by preparing the effect and shader to draw
  17323. * @param world defines the world transformation matrix
  17324. * @param mesh defines the mesh containing the submesh
  17325. * @param subMesh defines the submesh to bind the material to
  17326. */
  17327. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17328. /**
  17329. * Binds the material to the mesh
  17330. * @param world defines the world transformation matrix
  17331. * @param mesh defines the mesh to bind the material to
  17332. * @param effectOverride - If provided, use this effect instead of internal effect
  17333. */
  17334. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17335. protected _afterBind(mesh?: Mesh): void;
  17336. /**
  17337. * Gets the active textures from the material
  17338. * @returns an array of textures
  17339. */
  17340. getActiveTextures(): BaseTexture[];
  17341. /**
  17342. * Specifies if the material uses a texture
  17343. * @param texture defines the texture to check against the material
  17344. * @returns a boolean specifying if the material uses the texture
  17345. */
  17346. hasTexture(texture: BaseTexture): boolean;
  17347. /**
  17348. * Makes a duplicate of the material, and gives it a new name
  17349. * @param name defines the new name for the duplicated material
  17350. * @returns the cloned material
  17351. */
  17352. clone(name: string): ShaderMaterial;
  17353. /**
  17354. * Disposes the material
  17355. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17356. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17357. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17358. */
  17359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17360. /**
  17361. * Serializes this material in a JSON representation
  17362. * @returns the serialized material object
  17363. */
  17364. serialize(): any;
  17365. /**
  17366. * Creates a shader material from parsed shader material data
  17367. * @param source defines the JSON represnetation of the material
  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 new material
  17371. */
  17372. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17373. /**
  17374. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17375. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17376. * @param url defines the url to load from
  17377. * @param scene defines the hosting scene
  17378. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17379. * @returns a promise that will resolve to the new ShaderMaterial
  17380. */
  17381. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17382. /**
  17383. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17384. * @param snippetId defines the snippet to load
  17385. * @param scene defines the hosting scene
  17386. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17387. * @returns a promise that will resolve to the new ShaderMaterial
  17388. */
  17389. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17390. }
  17391. }
  17392. declare module "babylonjs/Shaders/color.fragment" {
  17393. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17394. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17395. /** @hidden */
  17396. export var colorPixelShader: {
  17397. name: string;
  17398. shader: string;
  17399. };
  17400. }
  17401. declare module "babylonjs/Shaders/color.vertex" {
  17402. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17403. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17404. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17405. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17406. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17407. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17408. /** @hidden */
  17409. export var colorVertexShader: {
  17410. name: string;
  17411. shader: string;
  17412. };
  17413. }
  17414. declare module "babylonjs/Meshes/linesMesh" {
  17415. import { Nullable } from "babylonjs/types";
  17416. import { Scene } from "babylonjs/scene";
  17417. import { Color3 } from "babylonjs/Maths/math.color";
  17418. import { Node } from "babylonjs/node";
  17419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17420. import { Mesh } from "babylonjs/Meshes/mesh";
  17421. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17422. import { Effect } from "babylonjs/Materials/effect";
  17423. import { Material } from "babylonjs/Materials/material";
  17424. import "babylonjs/Shaders/color.fragment";
  17425. import "babylonjs/Shaders/color.vertex";
  17426. /**
  17427. * Line mesh
  17428. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17429. */
  17430. export class LinesMesh extends Mesh {
  17431. /**
  17432. * If vertex color should be applied to the mesh
  17433. */
  17434. readonly useVertexColor?: boolean | undefined;
  17435. /**
  17436. * If vertex alpha should be applied to the mesh
  17437. */
  17438. readonly useVertexAlpha?: boolean | undefined;
  17439. /**
  17440. * Color of the line (Default: White)
  17441. */
  17442. color: Color3;
  17443. /**
  17444. * Alpha of the line (Default: 1)
  17445. */
  17446. alpha: number;
  17447. /**
  17448. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17449. * This margin is expressed in world space coordinates, so its value may vary.
  17450. * Default value is 0.1
  17451. */
  17452. intersectionThreshold: number;
  17453. private _colorShader;
  17454. private color4;
  17455. /**
  17456. * Creates a new LinesMesh
  17457. * @param name defines the name
  17458. * @param scene defines the hosting scene
  17459. * @param parent defines the parent mesh if any
  17460. * @param source defines the optional source LinesMesh used to clone data from
  17461. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17462. * When false, achieved by calling a clone(), also passing False.
  17463. * This will make creation of children, recursive.
  17464. * @param useVertexColor defines if this LinesMesh supports vertex color
  17465. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17466. */
  17467. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17468. /**
  17469. * If vertex color should be applied to the mesh
  17470. */
  17471. useVertexColor?: boolean | undefined,
  17472. /**
  17473. * If vertex alpha should be applied to the mesh
  17474. */
  17475. useVertexAlpha?: boolean | undefined);
  17476. private _addClipPlaneDefine;
  17477. private _removeClipPlaneDefine;
  17478. isReady(): boolean;
  17479. /**
  17480. * Returns the string "LineMesh"
  17481. */
  17482. getClassName(): string;
  17483. /**
  17484. * @hidden
  17485. */
  17486. get material(): Material;
  17487. /**
  17488. * @hidden
  17489. */
  17490. set material(value: Material);
  17491. /**
  17492. * @hidden
  17493. */
  17494. get checkCollisions(): boolean;
  17495. /** @hidden */
  17496. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17497. /** @hidden */
  17498. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17499. /**
  17500. * Disposes of the line mesh
  17501. * @param doNotRecurse If children should be disposed
  17502. */
  17503. dispose(doNotRecurse?: boolean): void;
  17504. /**
  17505. * Returns a new LineMesh object cloned from the current one.
  17506. */
  17507. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17508. /**
  17509. * Creates a new InstancedLinesMesh object from the mesh model.
  17510. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17511. * @param name defines the name of the new instance
  17512. * @returns a new InstancedLinesMesh
  17513. */
  17514. createInstance(name: string): InstancedLinesMesh;
  17515. }
  17516. /**
  17517. * Creates an instance based on a source LinesMesh
  17518. */
  17519. export class InstancedLinesMesh extends InstancedMesh {
  17520. /**
  17521. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17522. * This margin is expressed in world space coordinates, so its value may vary.
  17523. * Initilized with the intersectionThreshold value of the source LinesMesh
  17524. */
  17525. intersectionThreshold: number;
  17526. constructor(name: string, source: LinesMesh);
  17527. /**
  17528. * Returns the string "InstancedLinesMesh".
  17529. */
  17530. getClassName(): string;
  17531. }
  17532. }
  17533. declare module "babylonjs/Shaders/line.fragment" {
  17534. /** @hidden */
  17535. export var linePixelShader: {
  17536. name: string;
  17537. shader: string;
  17538. };
  17539. }
  17540. declare module "babylonjs/Shaders/line.vertex" {
  17541. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17542. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17543. /** @hidden */
  17544. export var lineVertexShader: {
  17545. name: string;
  17546. shader: string;
  17547. };
  17548. }
  17549. declare module "babylonjs/Rendering/edgesRenderer" {
  17550. import { Nullable } from "babylonjs/types";
  17551. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17553. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17554. import { IDisposable } from "babylonjs/scene";
  17555. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17556. import "babylonjs/Shaders/line.fragment";
  17557. import "babylonjs/Shaders/line.vertex";
  17558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17559. import { SmartArray } from "babylonjs/Misc/smartArray";
  17560. module "babylonjs/scene" {
  17561. interface Scene {
  17562. /** @hidden */
  17563. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17564. }
  17565. }
  17566. module "babylonjs/Meshes/abstractMesh" {
  17567. interface AbstractMesh {
  17568. /**
  17569. * Gets the edgesRenderer associated with the mesh
  17570. */
  17571. edgesRenderer: Nullable<EdgesRenderer>;
  17572. }
  17573. }
  17574. module "babylonjs/Meshes/linesMesh" {
  17575. interface LinesMesh {
  17576. /**
  17577. * Enables the edge rendering mode on the mesh.
  17578. * This mode makes the mesh edges visible
  17579. * @param epsilon defines the maximal distance between two angles to detect a face
  17580. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17581. * @returns the currentAbstractMesh
  17582. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17583. */
  17584. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17585. }
  17586. }
  17587. module "babylonjs/Meshes/linesMesh" {
  17588. interface InstancedLinesMesh {
  17589. /**
  17590. * Enables the edge rendering mode on the mesh.
  17591. * This mode makes the mesh edges visible
  17592. * @param epsilon defines the maximal distance between two angles to detect a face
  17593. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17594. * @returns the current InstancedLinesMesh
  17595. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17596. */
  17597. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17598. }
  17599. }
  17600. /**
  17601. * Defines the minimum contract an Edges renderer should follow.
  17602. */
  17603. export interface IEdgesRenderer extends IDisposable {
  17604. /**
  17605. * Gets or sets a boolean indicating if the edgesRenderer is active
  17606. */
  17607. isEnabled: boolean;
  17608. /**
  17609. * Renders the edges of the attached mesh,
  17610. */
  17611. render(): void;
  17612. /**
  17613. * Checks wether or not the edges renderer is ready to render.
  17614. * @return true if ready, otherwise false.
  17615. */
  17616. isReady(): boolean;
  17617. /**
  17618. * List of instances to render in case the source mesh has instances
  17619. */
  17620. customInstances: SmartArray<Matrix>;
  17621. }
  17622. /**
  17623. * Defines the additional options of the edges renderer
  17624. */
  17625. export interface IEdgesRendererOptions {
  17626. /**
  17627. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17628. * If not defined, the default value is true
  17629. */
  17630. useAlternateEdgeFinder?: boolean;
  17631. /**
  17632. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17633. * If not defined, the default value is true.
  17634. * 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)
  17635. * This option is used only if useAlternateEdgeFinder = true
  17636. */
  17637. useFastVertexMerger?: boolean;
  17638. /**
  17639. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17640. * The default value is 1e-6
  17641. * This option is used only if useAlternateEdgeFinder = true
  17642. */
  17643. epsilonVertexMerge?: number;
  17644. /**
  17645. * 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
  17646. * 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.
  17647. * This option is used only if useAlternateEdgeFinder = true
  17648. */
  17649. applyTessellation?: boolean;
  17650. /**
  17651. * 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
  17652. * The default value is 1e-6
  17653. * This option is used only if useAlternateEdgeFinder = true
  17654. */
  17655. epsilonVertexAligned?: number;
  17656. }
  17657. /**
  17658. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17659. */
  17660. export class EdgesRenderer implements IEdgesRenderer {
  17661. /**
  17662. * Define the size of the edges with an orthographic camera
  17663. */
  17664. edgesWidthScalerForOrthographic: number;
  17665. /**
  17666. * Define the size of the edges with a perspective camera
  17667. */
  17668. edgesWidthScalerForPerspective: number;
  17669. protected _source: AbstractMesh;
  17670. protected _linesPositions: number[];
  17671. protected _linesNormals: number[];
  17672. protected _linesIndices: number[];
  17673. protected _epsilon: number;
  17674. protected _indicesCount: number;
  17675. protected _lineShader: ShaderMaterial;
  17676. protected _ib: DataBuffer;
  17677. protected _buffers: {
  17678. [key: string]: Nullable<VertexBuffer>;
  17679. };
  17680. protected _buffersForInstances: {
  17681. [key: string]: Nullable<VertexBuffer>;
  17682. };
  17683. protected _checkVerticesInsteadOfIndices: boolean;
  17684. protected _options: Nullable<IEdgesRendererOptions>;
  17685. private _meshRebuildObserver;
  17686. private _meshDisposeObserver;
  17687. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17688. isEnabled: boolean;
  17689. /**
  17690. * List of instances to render in case the source mesh has instances
  17691. */
  17692. customInstances: SmartArray<Matrix>;
  17693. private static GetShader;
  17694. /**
  17695. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17696. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17697. * @param source Mesh used to create edges
  17698. * @param epsilon sum of angles in adjacency to check for edge
  17699. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17700. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17701. * @param options The options to apply when generating the edges
  17702. */
  17703. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17704. protected _prepareRessources(): void;
  17705. /** @hidden */
  17706. _rebuild(): void;
  17707. /**
  17708. * Releases the required resources for the edges renderer
  17709. */
  17710. dispose(): void;
  17711. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17712. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17713. /**
  17714. * Checks if the pair of p0 and p1 is en edge
  17715. * @param faceIndex
  17716. * @param edge
  17717. * @param faceNormals
  17718. * @param p0
  17719. * @param p1
  17720. * @private
  17721. */
  17722. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17723. /**
  17724. * push line into the position, normal and index buffer
  17725. * @protected
  17726. */
  17727. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17728. /**
  17729. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17730. */
  17731. private _tessellateTriangle;
  17732. private _generateEdgesLinesAlternate;
  17733. /**
  17734. * Generates lines edges from adjacencjes
  17735. * @private
  17736. */
  17737. _generateEdgesLines(): void;
  17738. /**
  17739. * Checks wether or not the edges renderer is ready to render.
  17740. * @return true if ready, otherwise false.
  17741. */
  17742. isReady(): boolean;
  17743. /**
  17744. * Renders the edges of the attached mesh,
  17745. */
  17746. render(): void;
  17747. }
  17748. /**
  17749. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17750. */
  17751. export class LineEdgesRenderer extends EdgesRenderer {
  17752. /**
  17753. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17754. * @param source LineMesh used to generate edges
  17755. * @param epsilon not important (specified angle for edge detection)
  17756. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17757. */
  17758. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17759. /**
  17760. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17761. */
  17762. _generateEdgesLines(): void;
  17763. }
  17764. }
  17765. declare module "babylonjs/Rendering/renderingGroup" {
  17766. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17767. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17769. import { Nullable } from "babylonjs/types";
  17770. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17771. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17772. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17773. import { Material } from "babylonjs/Materials/material";
  17774. import { Scene } from "babylonjs/scene";
  17775. /**
  17776. * This represents the object necessary to create a rendering group.
  17777. * This is exclusively used and created by the rendering manager.
  17778. * To modify the behavior, you use the available helpers in your scene or meshes.
  17779. * @hidden
  17780. */
  17781. export class RenderingGroup {
  17782. index: number;
  17783. private static _zeroVector;
  17784. private _scene;
  17785. private _opaqueSubMeshes;
  17786. private _transparentSubMeshes;
  17787. private _alphaTestSubMeshes;
  17788. private _depthOnlySubMeshes;
  17789. private _particleSystems;
  17790. private _spriteManagers;
  17791. private _opaqueSortCompareFn;
  17792. private _alphaTestSortCompareFn;
  17793. private _transparentSortCompareFn;
  17794. private _renderOpaque;
  17795. private _renderAlphaTest;
  17796. private _renderTransparent;
  17797. /** @hidden */
  17798. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17799. onBeforeTransparentRendering: () => void;
  17800. /**
  17801. * Set the opaque sort comparison function.
  17802. * If null the sub meshes will be render in the order they were created
  17803. */
  17804. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17805. /**
  17806. * Set the alpha test sort comparison function.
  17807. * If null the sub meshes will be render in the order they were created
  17808. */
  17809. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17810. /**
  17811. * Set the transparent sort comparison function.
  17812. * If null the sub meshes will be render in the order they were created
  17813. */
  17814. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17815. /**
  17816. * Creates a new rendering group.
  17817. * @param index The rendering group index
  17818. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17819. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17820. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17821. */
  17822. 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>);
  17823. /**
  17824. * Render all the sub meshes contained in the group.
  17825. * @param customRenderFunction Used to override the default render behaviour of the group.
  17826. * @returns true if rendered some submeshes.
  17827. */
  17828. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17829. /**
  17830. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17831. * @param subMeshes The submeshes to render
  17832. */
  17833. private renderOpaqueSorted;
  17834. /**
  17835. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17836. * @param subMeshes The submeshes to render
  17837. */
  17838. private renderAlphaTestSorted;
  17839. /**
  17840. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17841. * @param subMeshes The submeshes to render
  17842. */
  17843. private renderTransparentSorted;
  17844. /**
  17845. * Renders the submeshes in a specified order.
  17846. * @param subMeshes The submeshes to sort before render
  17847. * @param sortCompareFn The comparison function use to sort
  17848. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17849. * @param transparent Specifies to activate blending if true
  17850. */
  17851. private static renderSorted;
  17852. /**
  17853. * Renders the submeshes in the order they were dispatched (no sort applied).
  17854. * @param subMeshes The submeshes to render
  17855. */
  17856. private static renderUnsorted;
  17857. /**
  17858. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17859. * are rendered back to front if in the same alpha index.
  17860. *
  17861. * @param a The first submesh
  17862. * @param b The second submesh
  17863. * @returns The result of the comparison
  17864. */
  17865. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17866. /**
  17867. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17868. * are rendered back to front.
  17869. *
  17870. * @param a The first submesh
  17871. * @param b The second submesh
  17872. * @returns The result of the comparison
  17873. */
  17874. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17875. /**
  17876. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17877. * are rendered front to back (prevent overdraw).
  17878. *
  17879. * @param a The first submesh
  17880. * @param b The second submesh
  17881. * @returns The result of the comparison
  17882. */
  17883. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17884. /**
  17885. * Resets the different lists of submeshes to prepare a new frame.
  17886. */
  17887. prepare(): void;
  17888. dispose(): void;
  17889. /**
  17890. * Inserts the submesh in its correct queue depending on its material.
  17891. * @param subMesh The submesh to dispatch
  17892. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17893. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17894. */
  17895. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17896. dispatchSprites(spriteManager: ISpriteManager): void;
  17897. dispatchParticles(particleSystem: IParticleSystem): void;
  17898. private _renderParticles;
  17899. private _renderSprites;
  17900. }
  17901. }
  17902. declare module "babylonjs/Rendering/renderingManager" {
  17903. import { Nullable } from "babylonjs/types";
  17904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17906. import { SmartArray } from "babylonjs/Misc/smartArray";
  17907. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17908. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17909. import { Material } from "babylonjs/Materials/material";
  17910. import { Scene } from "babylonjs/scene";
  17911. import { Camera } from "babylonjs/Cameras/camera";
  17912. /**
  17913. * Interface describing the different options available in the rendering manager
  17914. * regarding Auto Clear between groups.
  17915. */
  17916. export interface IRenderingManagerAutoClearSetup {
  17917. /**
  17918. * Defines whether or not autoclear is enable.
  17919. */
  17920. autoClear: boolean;
  17921. /**
  17922. * Defines whether or not to autoclear the depth buffer.
  17923. */
  17924. depth: boolean;
  17925. /**
  17926. * Defines whether or not to autoclear the stencil buffer.
  17927. */
  17928. stencil: boolean;
  17929. }
  17930. /**
  17931. * This class is used by the onRenderingGroupObservable
  17932. */
  17933. export class RenderingGroupInfo {
  17934. /**
  17935. * The Scene that being rendered
  17936. */
  17937. scene: Scene;
  17938. /**
  17939. * The camera currently used for the rendering pass
  17940. */
  17941. camera: Nullable<Camera>;
  17942. /**
  17943. * The ID of the renderingGroup being processed
  17944. */
  17945. renderingGroupId: number;
  17946. }
  17947. /**
  17948. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17949. * It is enable to manage the different groups as well as the different necessary sort functions.
  17950. * This should not be used directly aside of the few static configurations
  17951. */
  17952. export class RenderingManager {
  17953. /**
  17954. * The max id used for rendering groups (not included)
  17955. */
  17956. static MAX_RENDERINGGROUPS: number;
  17957. /**
  17958. * The min id used for rendering groups (included)
  17959. */
  17960. static MIN_RENDERINGGROUPS: number;
  17961. /**
  17962. * Used to globally prevent autoclearing scenes.
  17963. */
  17964. static AUTOCLEAR: boolean;
  17965. /**
  17966. * @hidden
  17967. */
  17968. _useSceneAutoClearSetup: boolean;
  17969. private _scene;
  17970. private _renderingGroups;
  17971. private _depthStencilBufferAlreadyCleaned;
  17972. private _autoClearDepthStencil;
  17973. private _customOpaqueSortCompareFn;
  17974. private _customAlphaTestSortCompareFn;
  17975. private _customTransparentSortCompareFn;
  17976. private _renderingGroupInfo;
  17977. /**
  17978. * Instantiates a new rendering group for a particular scene
  17979. * @param scene Defines the scene the groups belongs to
  17980. */
  17981. constructor(scene: Scene);
  17982. private _clearDepthStencilBuffer;
  17983. /**
  17984. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17985. * @hidden
  17986. */
  17987. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17988. /**
  17989. * Resets the different information of the group to prepare a new frame
  17990. * @hidden
  17991. */
  17992. reset(): void;
  17993. /**
  17994. * Dispose and release the group and its associated resources.
  17995. * @hidden
  17996. */
  17997. dispose(): void;
  17998. /**
  17999. * Clear the info related to rendering groups preventing retention points during dispose.
  18000. */
  18001. freeRenderingGroups(): void;
  18002. private _prepareRenderingGroup;
  18003. /**
  18004. * Add a sprite manager to the rendering manager in order to render it this frame.
  18005. * @param spriteManager Define the sprite manager to render
  18006. */
  18007. dispatchSprites(spriteManager: ISpriteManager): void;
  18008. /**
  18009. * Add a particle system to the rendering manager in order to render it this frame.
  18010. * @param particleSystem Define the particle system to render
  18011. */
  18012. dispatchParticles(particleSystem: IParticleSystem): void;
  18013. /**
  18014. * Add a submesh to the manager in order to render it this frame
  18015. * @param subMesh The submesh to dispatch
  18016. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18017. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18018. */
  18019. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18020. /**
  18021. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18022. * This allowed control for front to back rendering or reversly depending of the special needs.
  18023. *
  18024. * @param renderingGroupId The rendering group id corresponding to its index
  18025. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18026. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18027. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18028. */
  18029. 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;
  18030. /**
  18031. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18032. *
  18033. * @param renderingGroupId The rendering group id corresponding to its index
  18034. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18035. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18036. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18037. */
  18038. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18039. /**
  18040. * Gets the current auto clear configuration for one rendering group of the rendering
  18041. * manager.
  18042. * @param index the rendering group index to get the information for
  18043. * @returns The auto clear setup for the requested rendering group
  18044. */
  18045. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18046. }
  18047. }
  18048. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18049. import { SmartArray } from "babylonjs/Misc/smartArray";
  18050. import { Nullable } from "babylonjs/types";
  18051. import { Scene } from "babylonjs/scene";
  18052. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18053. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18055. import { Mesh } from "babylonjs/Meshes/mesh";
  18056. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18057. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18058. import { Effect } from "babylonjs/Materials/effect";
  18059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18060. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18061. import "babylonjs/Shaders/shadowMap.fragment";
  18062. import "babylonjs/Shaders/shadowMap.vertex";
  18063. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18064. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18065. import { Observable } from "babylonjs/Misc/observable";
  18066. /**
  18067. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18068. */
  18069. export interface ICustomShaderOptions {
  18070. /**
  18071. * Gets or sets the custom shader name to use
  18072. */
  18073. shaderName: string;
  18074. /**
  18075. * The list of attribute names used in the shader
  18076. */
  18077. attributes?: string[];
  18078. /**
  18079. * The list of unifrom names used in the shader
  18080. */
  18081. uniforms?: string[];
  18082. /**
  18083. * The list of sampler names used in the shader
  18084. */
  18085. samplers?: string[];
  18086. /**
  18087. * The list of defines used in the shader
  18088. */
  18089. defines?: string[];
  18090. }
  18091. /**
  18092. * Interface to implement to create a shadow generator compatible with BJS.
  18093. */
  18094. export interface IShadowGenerator {
  18095. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18096. id: string;
  18097. /**
  18098. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18099. * @returns The render target texture if present otherwise, null
  18100. */
  18101. getShadowMap(): Nullable<RenderTargetTexture>;
  18102. /**
  18103. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18104. * @param subMesh The submesh we want to render in the shadow map
  18105. * @param useInstances Defines wether will draw in the map using instances
  18106. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18107. * @returns true if ready otherwise, false
  18108. */
  18109. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18110. /**
  18111. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18112. * @param defines Defines of the material we want to update
  18113. * @param lightIndex Index of the light in the enabled light list of the material
  18114. */
  18115. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18116. /**
  18117. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18118. * defined in the generator but impacting the effect).
  18119. * It implies the unifroms available on the materials are the standard BJS ones.
  18120. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18121. * @param effect The effect we are binfing the information for
  18122. */
  18123. bindShadowLight(lightIndex: string, effect: Effect): void;
  18124. /**
  18125. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18126. * (eq to shadow prjection matrix * light transform matrix)
  18127. * @returns The transform matrix used to create the shadow map
  18128. */
  18129. getTransformMatrix(): Matrix;
  18130. /**
  18131. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18132. * Cube and 2D textures for instance.
  18133. */
  18134. recreateShadowMap(): void;
  18135. /**
  18136. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18137. * @param onCompiled Callback triggered at the and of the effects compilation
  18138. * @param options Sets of optional options forcing the compilation with different modes
  18139. */
  18140. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18141. useInstances: boolean;
  18142. }>): void;
  18143. /**
  18144. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18145. * @param options Sets of optional options forcing the compilation with different modes
  18146. * @returns A promise that resolves when the compilation completes
  18147. */
  18148. forceCompilationAsync(options?: Partial<{
  18149. useInstances: boolean;
  18150. }>): Promise<void>;
  18151. /**
  18152. * Serializes the shadow generator setup to a json object.
  18153. * @returns The serialized JSON object
  18154. */
  18155. serialize(): any;
  18156. /**
  18157. * Disposes the Shadow map and related Textures and effects.
  18158. */
  18159. dispose(): void;
  18160. }
  18161. /**
  18162. * Default implementation IShadowGenerator.
  18163. * This is the main object responsible of generating shadows in the framework.
  18164. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18165. */
  18166. export class ShadowGenerator implements IShadowGenerator {
  18167. /**
  18168. * Name of the shadow generator class
  18169. */
  18170. static CLASSNAME: string;
  18171. /**
  18172. * Shadow generator mode None: no filtering applied.
  18173. */
  18174. static readonly FILTER_NONE: number;
  18175. /**
  18176. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18177. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18178. */
  18179. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18180. /**
  18181. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18182. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18183. */
  18184. static readonly FILTER_POISSONSAMPLING: number;
  18185. /**
  18186. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18187. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18188. */
  18189. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18190. /**
  18191. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18192. * edge artifacts on steep falloff.
  18193. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18194. */
  18195. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18196. /**
  18197. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18198. * edge artifacts on steep falloff.
  18199. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18200. */
  18201. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18202. /**
  18203. * Shadow generator mode PCF: Percentage Closer Filtering
  18204. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18205. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18206. */
  18207. static readonly FILTER_PCF: number;
  18208. /**
  18209. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18210. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18211. * Contact Hardening
  18212. */
  18213. static readonly FILTER_PCSS: number;
  18214. /**
  18215. * Reserved for PCF and PCSS
  18216. * Highest Quality.
  18217. *
  18218. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18219. *
  18220. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18221. */
  18222. static readonly QUALITY_HIGH: number;
  18223. /**
  18224. * Reserved for PCF and PCSS
  18225. * Good tradeoff for quality/perf cross devices
  18226. *
  18227. * Execute PCF on a 3*3 kernel.
  18228. *
  18229. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18230. */
  18231. static readonly QUALITY_MEDIUM: number;
  18232. /**
  18233. * Reserved for PCF and PCSS
  18234. * The lowest quality but the fastest.
  18235. *
  18236. * Execute PCF on a 1*1 kernel.
  18237. *
  18238. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18239. */
  18240. static readonly QUALITY_LOW: number;
  18241. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18242. id: string;
  18243. /** Gets or sets the custom shader name to use */
  18244. customShaderOptions: ICustomShaderOptions;
  18245. /**
  18246. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18247. */
  18248. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18249. /**
  18250. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18251. */
  18252. onAfterShadowMapRenderObservable: Observable<Effect>;
  18253. /**
  18254. * Observable triggered before a mesh is rendered in the shadow map.
  18255. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18256. */
  18257. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18258. /**
  18259. * Observable triggered after a mesh is rendered in the shadow map.
  18260. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18261. */
  18262. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18263. protected _bias: number;
  18264. /**
  18265. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18266. */
  18267. get bias(): number;
  18268. /**
  18269. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18270. */
  18271. set bias(bias: number);
  18272. protected _normalBias: number;
  18273. /**
  18274. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18275. */
  18276. get normalBias(): number;
  18277. /**
  18278. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18279. */
  18280. set normalBias(normalBias: number);
  18281. protected _blurBoxOffset: number;
  18282. /**
  18283. * Gets the blur box offset: offset applied during the blur pass.
  18284. * Only useful if useKernelBlur = false
  18285. */
  18286. get blurBoxOffset(): number;
  18287. /**
  18288. * Sets the blur box offset: offset applied during the blur pass.
  18289. * Only useful if useKernelBlur = false
  18290. */
  18291. set blurBoxOffset(value: number);
  18292. protected _blurScale: number;
  18293. /**
  18294. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18295. * 2 means half of the size.
  18296. */
  18297. get blurScale(): number;
  18298. /**
  18299. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18300. * 2 means half of the size.
  18301. */
  18302. set blurScale(value: number);
  18303. protected _blurKernel: number;
  18304. /**
  18305. * Gets the blur kernel: kernel size of the blur pass.
  18306. * Only useful if useKernelBlur = true
  18307. */
  18308. get blurKernel(): number;
  18309. /**
  18310. * Sets the blur kernel: kernel size of the blur pass.
  18311. * Only useful if useKernelBlur = true
  18312. */
  18313. set blurKernel(value: number);
  18314. protected _useKernelBlur: boolean;
  18315. /**
  18316. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18317. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18318. */
  18319. get useKernelBlur(): boolean;
  18320. /**
  18321. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18322. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18323. */
  18324. set useKernelBlur(value: boolean);
  18325. protected _depthScale: number;
  18326. /**
  18327. * Gets the depth scale used in ESM mode.
  18328. */
  18329. get depthScale(): number;
  18330. /**
  18331. * Sets the depth scale used in ESM mode.
  18332. * This can override the scale stored on the light.
  18333. */
  18334. set depthScale(value: number);
  18335. protected _validateFilter(filter: number): number;
  18336. protected _filter: number;
  18337. /**
  18338. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18339. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18340. */
  18341. get filter(): number;
  18342. /**
  18343. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18344. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18345. */
  18346. set filter(value: number);
  18347. /**
  18348. * Gets if the current filter is set to Poisson Sampling.
  18349. */
  18350. get usePoissonSampling(): boolean;
  18351. /**
  18352. * Sets the current filter to Poisson Sampling.
  18353. */
  18354. set usePoissonSampling(value: boolean);
  18355. /**
  18356. * Gets if the current filter is set to ESM.
  18357. */
  18358. get useExponentialShadowMap(): boolean;
  18359. /**
  18360. * Sets the current filter is to ESM.
  18361. */
  18362. set useExponentialShadowMap(value: boolean);
  18363. /**
  18364. * Gets if the current filter is set to filtered ESM.
  18365. */
  18366. get useBlurExponentialShadowMap(): boolean;
  18367. /**
  18368. * Gets if the current filter is set to filtered ESM.
  18369. */
  18370. set useBlurExponentialShadowMap(value: boolean);
  18371. /**
  18372. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18373. * exponential to prevent steep falloff artifacts).
  18374. */
  18375. get useCloseExponentialShadowMap(): boolean;
  18376. /**
  18377. * Sets the current filter to "close ESM" (using the inverse of the
  18378. * exponential to prevent steep falloff artifacts).
  18379. */
  18380. set useCloseExponentialShadowMap(value: boolean);
  18381. /**
  18382. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18383. * exponential to prevent steep falloff artifacts).
  18384. */
  18385. get useBlurCloseExponentialShadowMap(): boolean;
  18386. /**
  18387. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18388. * exponential to prevent steep falloff artifacts).
  18389. */
  18390. set useBlurCloseExponentialShadowMap(value: boolean);
  18391. /**
  18392. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18393. */
  18394. get usePercentageCloserFiltering(): boolean;
  18395. /**
  18396. * Sets the current filter to "PCF" (percentage closer filtering).
  18397. */
  18398. set usePercentageCloserFiltering(value: boolean);
  18399. protected _filteringQuality: number;
  18400. /**
  18401. * Gets the PCF or PCSS Quality.
  18402. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18403. */
  18404. get filteringQuality(): number;
  18405. /**
  18406. * Sets the PCF or PCSS Quality.
  18407. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18408. */
  18409. set filteringQuality(filteringQuality: number);
  18410. /**
  18411. * Gets if the current filter is set to "PCSS" (contact hardening).
  18412. */
  18413. get useContactHardeningShadow(): boolean;
  18414. /**
  18415. * Sets the current filter to "PCSS" (contact hardening).
  18416. */
  18417. set useContactHardeningShadow(value: boolean);
  18418. protected _contactHardeningLightSizeUVRatio: number;
  18419. /**
  18420. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18421. * Using a ratio helps keeping shape stability independently of the map size.
  18422. *
  18423. * It does not account for the light projection as it was having too much
  18424. * instability during the light setup or during light position changes.
  18425. *
  18426. * Only valid if useContactHardeningShadow is true.
  18427. */
  18428. get contactHardeningLightSizeUVRatio(): number;
  18429. /**
  18430. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18431. * Using a ratio helps keeping shape stability independently of the map size.
  18432. *
  18433. * It does not account for the light projection as it was having too much
  18434. * instability during the light setup or during light position changes.
  18435. *
  18436. * Only valid if useContactHardeningShadow is true.
  18437. */
  18438. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18439. protected _darkness: number;
  18440. /** Gets or sets the actual darkness of a shadow */
  18441. get darkness(): number;
  18442. set darkness(value: number);
  18443. /**
  18444. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18445. * 0 means strongest and 1 would means no shadow.
  18446. * @returns the darkness.
  18447. */
  18448. getDarkness(): number;
  18449. /**
  18450. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18451. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18452. * @returns the shadow generator allowing fluent coding.
  18453. */
  18454. setDarkness(darkness: number): ShadowGenerator;
  18455. protected _transparencyShadow: boolean;
  18456. /** Gets or sets the ability to have transparent shadow */
  18457. get transparencyShadow(): boolean;
  18458. set transparencyShadow(value: boolean);
  18459. /**
  18460. * Sets the ability to have transparent shadow (boolean).
  18461. * @param transparent True if transparent else False
  18462. * @returns the shadow generator allowing fluent coding
  18463. */
  18464. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18465. /**
  18466. * Enables or disables shadows with varying strength based on the transparency
  18467. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18468. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18469. * mesh.visibility * alphaTexture.a
  18470. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18471. */
  18472. enableSoftTransparentShadow: boolean;
  18473. protected _shadowMap: Nullable<RenderTargetTexture>;
  18474. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18475. /**
  18476. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18477. * @returns The render target texture if present otherwise, null
  18478. */
  18479. getShadowMap(): Nullable<RenderTargetTexture>;
  18480. /**
  18481. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18482. * @returns The render target texture if the shadow map is present otherwise, null
  18483. */
  18484. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18485. /**
  18486. * Gets the class name of that object
  18487. * @returns "ShadowGenerator"
  18488. */
  18489. getClassName(): string;
  18490. /**
  18491. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18492. * @param mesh Mesh to add
  18493. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18494. * @returns the Shadow Generator itself
  18495. */
  18496. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18497. /**
  18498. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18499. * @param mesh Mesh to remove
  18500. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18501. * @returns the Shadow Generator itself
  18502. */
  18503. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18504. /**
  18505. * Controls the extent to which the shadows fade out at the edge of the frustum
  18506. */
  18507. frustumEdgeFalloff: number;
  18508. protected _light: IShadowLight;
  18509. /**
  18510. * Returns the associated light object.
  18511. * @returns the light generating the shadow
  18512. */
  18513. getLight(): IShadowLight;
  18514. /**
  18515. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18516. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18517. * It might on the other hand introduce peter panning.
  18518. */
  18519. forceBackFacesOnly: boolean;
  18520. protected _scene: Scene;
  18521. protected _lightDirection: Vector3;
  18522. protected _effect: Effect;
  18523. protected _viewMatrix: Matrix;
  18524. protected _projectionMatrix: Matrix;
  18525. protected _transformMatrix: Matrix;
  18526. protected _cachedPosition: Vector3;
  18527. protected _cachedDirection: Vector3;
  18528. protected _cachedDefines: string;
  18529. protected _currentRenderID: number;
  18530. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18531. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18532. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18533. protected _blurPostProcesses: PostProcess[];
  18534. protected _mapSize: number;
  18535. protected _currentFaceIndex: number;
  18536. protected _currentFaceIndexCache: number;
  18537. protected _textureType: number;
  18538. protected _defaultTextureMatrix: Matrix;
  18539. protected _storedUniqueId: Nullable<number>;
  18540. /** @hidden */
  18541. static _SceneComponentInitialization: (scene: Scene) => void;
  18542. /**
  18543. * Gets or sets the size of the texture what stores the shadows
  18544. */
  18545. get mapSize(): number;
  18546. set mapSize(size: number);
  18547. /**
  18548. * Creates a ShadowGenerator object.
  18549. * A ShadowGenerator is the required tool to use the shadows.
  18550. * Each light casting shadows needs to use its own ShadowGenerator.
  18551. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18552. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18553. * @param light The light object generating the shadows.
  18554. * @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.
  18555. */
  18556. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18557. protected _initializeGenerator(): void;
  18558. protected _createTargetRenderTexture(): void;
  18559. protected _initializeShadowMap(): void;
  18560. protected _initializeBlurRTTAndPostProcesses(): void;
  18561. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18562. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18563. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18564. protected _applyFilterValues(): void;
  18565. /**
  18566. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18567. * @param onCompiled Callback triggered at the and of the effects compilation
  18568. * @param options Sets of optional options forcing the compilation with different modes
  18569. */
  18570. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18571. useInstances: boolean;
  18572. }>): void;
  18573. /**
  18574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18575. * @param options Sets of optional options forcing the compilation with different modes
  18576. * @returns A promise that resolves when the compilation completes
  18577. */
  18578. forceCompilationAsync(options?: Partial<{
  18579. useInstances: boolean;
  18580. }>): Promise<void>;
  18581. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18582. private _prepareShadowDefines;
  18583. /**
  18584. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18585. * @param subMesh The submesh we want to render in the shadow map
  18586. * @param useInstances Defines wether will draw in the map using instances
  18587. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18588. * @returns true if ready otherwise, false
  18589. */
  18590. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18591. /**
  18592. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18593. * @param defines Defines of the material we want to update
  18594. * @param lightIndex Index of the light in the enabled light list of the material
  18595. */
  18596. prepareDefines(defines: any, lightIndex: number): void;
  18597. /**
  18598. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18599. * defined in the generator but impacting the effect).
  18600. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18601. * @param effect The effect we are binfing the information for
  18602. */
  18603. bindShadowLight(lightIndex: string, effect: Effect): void;
  18604. /**
  18605. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18606. * (eq to shadow prjection matrix * light transform matrix)
  18607. * @returns The transform matrix used to create the shadow map
  18608. */
  18609. getTransformMatrix(): Matrix;
  18610. /**
  18611. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18612. * Cube and 2D textures for instance.
  18613. */
  18614. recreateShadowMap(): void;
  18615. protected _disposeBlurPostProcesses(): void;
  18616. protected _disposeRTTandPostProcesses(): void;
  18617. /**
  18618. * Disposes the ShadowGenerator.
  18619. * Returns nothing.
  18620. */
  18621. dispose(): void;
  18622. /**
  18623. * Serializes the shadow generator setup to a json object.
  18624. * @returns The serialized JSON object
  18625. */
  18626. serialize(): any;
  18627. /**
  18628. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18629. * @param parsedShadowGenerator The JSON object to parse
  18630. * @param scene The scene to create the shadow map for
  18631. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18632. * @returns The parsed shadow generator
  18633. */
  18634. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18635. }
  18636. }
  18637. declare module "babylonjs/Lights/light" {
  18638. import { Nullable } from "babylonjs/types";
  18639. import { Scene } from "babylonjs/scene";
  18640. import { Vector3 } from "babylonjs/Maths/math.vector";
  18641. import { Color3 } from "babylonjs/Maths/math.color";
  18642. import { Node } from "babylonjs/node";
  18643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18644. import { Effect } from "babylonjs/Materials/effect";
  18645. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18646. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18647. /**
  18648. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18649. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18650. * 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.
  18651. */
  18652. export abstract class Light extends Node {
  18653. /**
  18654. * Falloff Default: light is falling off following the material specification:
  18655. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18656. */
  18657. static readonly FALLOFF_DEFAULT: number;
  18658. /**
  18659. * Falloff Physical: light is falling off following the inverse squared distance law.
  18660. */
  18661. static readonly FALLOFF_PHYSICAL: number;
  18662. /**
  18663. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18664. * to enhance interoperability with other engines.
  18665. */
  18666. static readonly FALLOFF_GLTF: number;
  18667. /**
  18668. * Falloff Standard: light is falling off like in the standard material
  18669. * to enhance interoperability with other materials.
  18670. */
  18671. static readonly FALLOFF_STANDARD: number;
  18672. /**
  18673. * If every light affecting the material is in this lightmapMode,
  18674. * material.lightmapTexture adds or multiplies
  18675. * (depends on material.useLightmapAsShadowmap)
  18676. * after every other light calculations.
  18677. */
  18678. static readonly LIGHTMAP_DEFAULT: number;
  18679. /**
  18680. * material.lightmapTexture as only diffuse lighting from this light
  18681. * adds only specular lighting from this light
  18682. * adds dynamic shadows
  18683. */
  18684. static readonly LIGHTMAP_SPECULAR: number;
  18685. /**
  18686. * material.lightmapTexture as only lighting
  18687. * no light calculation from this light
  18688. * only adds dynamic shadows from this light
  18689. */
  18690. static readonly LIGHTMAP_SHADOWSONLY: number;
  18691. /**
  18692. * Each light type uses the default quantity according to its type:
  18693. * point/spot lights use luminous intensity
  18694. * directional lights use illuminance
  18695. */
  18696. static readonly INTENSITYMODE_AUTOMATIC: number;
  18697. /**
  18698. * lumen (lm)
  18699. */
  18700. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18701. /**
  18702. * candela (lm/sr)
  18703. */
  18704. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18705. /**
  18706. * lux (lm/m^2)
  18707. */
  18708. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18709. /**
  18710. * nit (cd/m^2)
  18711. */
  18712. static readonly INTENSITYMODE_LUMINANCE: number;
  18713. /**
  18714. * Light type const id of the point light.
  18715. */
  18716. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18717. /**
  18718. * Light type const id of the directional light.
  18719. */
  18720. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18721. /**
  18722. * Light type const id of the spot light.
  18723. */
  18724. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18725. /**
  18726. * Light type const id of the hemispheric light.
  18727. */
  18728. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18729. /**
  18730. * Diffuse gives the basic color to an object.
  18731. */
  18732. diffuse: Color3;
  18733. /**
  18734. * Specular produces a highlight color on an object.
  18735. * Note: This is note affecting PBR materials.
  18736. */
  18737. specular: Color3;
  18738. /**
  18739. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18740. * falling off base on range or angle.
  18741. * This can be set to any values in Light.FALLOFF_x.
  18742. *
  18743. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18744. * other types of materials.
  18745. */
  18746. falloffType: number;
  18747. /**
  18748. * Strength of the light.
  18749. * Note: By default it is define in the framework own unit.
  18750. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18751. */
  18752. intensity: number;
  18753. private _range;
  18754. protected _inverseSquaredRange: number;
  18755. /**
  18756. * Defines how far from the source the light is impacting in scene units.
  18757. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18758. */
  18759. get range(): number;
  18760. /**
  18761. * Defines how far from the source the light is impacting in scene units.
  18762. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18763. */
  18764. set range(value: number);
  18765. /**
  18766. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18767. * of light.
  18768. */
  18769. private _photometricScale;
  18770. private _intensityMode;
  18771. /**
  18772. * Gets the photometric scale used to interpret the intensity.
  18773. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18774. */
  18775. get intensityMode(): number;
  18776. /**
  18777. * Sets the photometric scale used to interpret the intensity.
  18778. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18779. */
  18780. set intensityMode(value: number);
  18781. private _radius;
  18782. /**
  18783. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18784. */
  18785. get radius(): number;
  18786. /**
  18787. * sets the light radius used by PBR Materials to simulate soft area lights.
  18788. */
  18789. set radius(value: number);
  18790. private _renderPriority;
  18791. /**
  18792. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18793. * exceeding the number allowed of the materials.
  18794. */
  18795. renderPriority: number;
  18796. private _shadowEnabled;
  18797. /**
  18798. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18799. * the current shadow generator.
  18800. */
  18801. get shadowEnabled(): boolean;
  18802. /**
  18803. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18804. * the current shadow generator.
  18805. */
  18806. set shadowEnabled(value: boolean);
  18807. private _includedOnlyMeshes;
  18808. /**
  18809. * Gets the only meshes impacted by this light.
  18810. */
  18811. get includedOnlyMeshes(): AbstractMesh[];
  18812. /**
  18813. * Sets the only meshes impacted by this light.
  18814. */
  18815. set includedOnlyMeshes(value: AbstractMesh[]);
  18816. private _excludedMeshes;
  18817. /**
  18818. * Gets the meshes not impacted by this light.
  18819. */
  18820. get excludedMeshes(): AbstractMesh[];
  18821. /**
  18822. * Sets the meshes not impacted by this light.
  18823. */
  18824. set excludedMeshes(value: AbstractMesh[]);
  18825. private _excludeWithLayerMask;
  18826. /**
  18827. * Gets the layer id use to find what meshes are not impacted by the light.
  18828. * Inactive if 0
  18829. */
  18830. get excludeWithLayerMask(): number;
  18831. /**
  18832. * Sets the layer id use to find what meshes are not impacted by the light.
  18833. * Inactive if 0
  18834. */
  18835. set excludeWithLayerMask(value: number);
  18836. private _includeOnlyWithLayerMask;
  18837. /**
  18838. * Gets the layer id use to find what meshes are impacted by the light.
  18839. * Inactive if 0
  18840. */
  18841. get includeOnlyWithLayerMask(): number;
  18842. /**
  18843. * Sets the layer id use to find what meshes are impacted by the light.
  18844. * Inactive if 0
  18845. */
  18846. set includeOnlyWithLayerMask(value: number);
  18847. private _lightmapMode;
  18848. /**
  18849. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18850. */
  18851. get lightmapMode(): number;
  18852. /**
  18853. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18854. */
  18855. set lightmapMode(value: number);
  18856. /**
  18857. * Shadow generator associted to the light.
  18858. * @hidden Internal use only.
  18859. */
  18860. _shadowGenerator: Nullable<IShadowGenerator>;
  18861. /**
  18862. * @hidden Internal use only.
  18863. */
  18864. _excludedMeshesIds: string[];
  18865. /**
  18866. * @hidden Internal use only.
  18867. */
  18868. _includedOnlyMeshesIds: string[];
  18869. /**
  18870. * The current light unifom buffer.
  18871. * @hidden Internal use only.
  18872. */
  18873. _uniformBuffer: UniformBuffer;
  18874. /** @hidden */
  18875. _renderId: number;
  18876. /**
  18877. * Creates a Light object in the scene.
  18878. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18879. * @param name The firendly name of the light
  18880. * @param scene The scene the light belongs too
  18881. */
  18882. constructor(name: string, scene: Scene);
  18883. protected abstract _buildUniformLayout(): void;
  18884. /**
  18885. * Sets the passed Effect "effect" with the Light information.
  18886. * @param effect The effect to update
  18887. * @param lightIndex The index of the light in the effect to update
  18888. * @returns The light
  18889. */
  18890. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18891. /**
  18892. * Sets the passed Effect "effect" with the Light textures.
  18893. * @param effect The effect to update
  18894. * @param lightIndex The index of the light in the effect to update
  18895. * @returns The light
  18896. */
  18897. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18898. /**
  18899. * Binds the lights information from the scene to the effect for the given mesh.
  18900. * @param lightIndex Light index
  18901. * @param scene The scene where the light belongs to
  18902. * @param effect The effect we are binding the data to
  18903. * @param useSpecular Defines if specular is supported
  18904. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18905. */
  18906. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18907. /**
  18908. * Sets the passed Effect "effect" with the Light information.
  18909. * @param effect The effect to update
  18910. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18911. * @returns The light
  18912. */
  18913. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18914. /**
  18915. * Returns the string "Light".
  18916. * @returns the class name
  18917. */
  18918. getClassName(): string;
  18919. /** @hidden */
  18920. readonly _isLight: boolean;
  18921. /**
  18922. * Converts the light information to a readable string for debug purpose.
  18923. * @param fullDetails Supports for multiple levels of logging within scene loading
  18924. * @returns the human readable light info
  18925. */
  18926. toString(fullDetails?: boolean): string;
  18927. /** @hidden */
  18928. protected _syncParentEnabledState(): void;
  18929. /**
  18930. * Set the enabled state of this node.
  18931. * @param value - the new enabled state
  18932. */
  18933. setEnabled(value: boolean): void;
  18934. /**
  18935. * Returns the Light associated shadow generator if any.
  18936. * @return the associated shadow generator.
  18937. */
  18938. getShadowGenerator(): Nullable<IShadowGenerator>;
  18939. /**
  18940. * Returns a Vector3, the absolute light position in the World.
  18941. * @returns the world space position of the light
  18942. */
  18943. getAbsolutePosition(): Vector3;
  18944. /**
  18945. * Specifies if the light will affect the passed mesh.
  18946. * @param mesh The mesh to test against the light
  18947. * @return true the mesh is affected otherwise, false.
  18948. */
  18949. canAffectMesh(mesh: AbstractMesh): boolean;
  18950. /**
  18951. * Sort function to order lights for rendering.
  18952. * @param a First Light object to compare to second.
  18953. * @param b Second Light object to compare first.
  18954. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18955. */
  18956. static CompareLightsPriority(a: Light, b: Light): number;
  18957. /**
  18958. * Releases resources associated with this node.
  18959. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18960. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18961. */
  18962. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18963. /**
  18964. * Returns the light type ID (integer).
  18965. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18966. */
  18967. getTypeID(): number;
  18968. /**
  18969. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18970. * @returns the scaled intensity in intensity mode unit
  18971. */
  18972. getScaledIntensity(): number;
  18973. /**
  18974. * Returns a new Light object, named "name", from the current one.
  18975. * @param name The name of the cloned light
  18976. * @param newParent The parent of this light, if it has one
  18977. * @returns the new created light
  18978. */
  18979. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18980. /**
  18981. * Serializes the current light into a Serialization object.
  18982. * @returns the serialized object.
  18983. */
  18984. serialize(): any;
  18985. /**
  18986. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18987. * This new light is named "name" and added to the passed scene.
  18988. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18989. * @param name The friendly name of the light
  18990. * @param scene The scene the new light will belong to
  18991. * @returns the constructor function
  18992. */
  18993. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18994. /**
  18995. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18996. * @param parsedLight The JSON representation of the light
  18997. * @param scene The scene to create the parsed light in
  18998. * @returns the created light after parsing
  18999. */
  19000. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  19001. private _hookArrayForExcluded;
  19002. private _hookArrayForIncludedOnly;
  19003. private _resyncMeshes;
  19004. /**
  19005. * Forces the meshes to update their light related information in their rendering used effects
  19006. * @hidden Internal Use Only
  19007. */
  19008. _markMeshesAsLightDirty(): void;
  19009. /**
  19010. * Recomputes the cached photometric scale if needed.
  19011. */
  19012. private _computePhotometricScale;
  19013. /**
  19014. * Returns the Photometric Scale according to the light type and intensity mode.
  19015. */
  19016. private _getPhotometricScale;
  19017. /**
  19018. * Reorder the light in the scene according to their defined priority.
  19019. * @hidden Internal Use Only
  19020. */
  19021. _reorderLightsInScene(): void;
  19022. /**
  19023. * Prepares the list of defines specific to the light type.
  19024. * @param defines the list of defines
  19025. * @param lightIndex defines the index of the light for the effect
  19026. */
  19027. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19028. }
  19029. }
  19030. declare module "babylonjs/Materials/prePassConfiguration" {
  19031. import { Matrix } from "babylonjs/Maths/math.vector";
  19032. import { Mesh } from "babylonjs/Meshes/mesh";
  19033. import { Scene } from "babylonjs/scene";
  19034. import { Effect } from "babylonjs/Materials/effect";
  19035. /**
  19036. * Configuration needed for prepass-capable materials
  19037. */
  19038. export class PrePassConfiguration {
  19039. /**
  19040. * Previous world matrices of meshes carrying this material
  19041. * Used for computing velocity
  19042. */
  19043. previousWorldMatrices: {
  19044. [index: number]: Matrix;
  19045. };
  19046. /**
  19047. * Previous view project matrix
  19048. * Used for computing velocity
  19049. */
  19050. previousViewProjection: Matrix;
  19051. /**
  19052. * Previous bones of meshes carrying this material
  19053. * Used for computing velocity
  19054. */
  19055. previousBones: {
  19056. [index: number]: Float32Array;
  19057. };
  19058. /**
  19059. * Add the required uniforms to the current list.
  19060. * @param uniforms defines the current uniform list.
  19061. */
  19062. static AddUniforms(uniforms: string[]): void;
  19063. /**
  19064. * Add the required samplers to the current list.
  19065. * @param samplers defines the current sampler list.
  19066. */
  19067. static AddSamplers(samplers: string[]): void;
  19068. /**
  19069. * Binds the material data.
  19070. * @param effect defines the effect to update
  19071. * @param scene defines the scene the material belongs to.
  19072. * @param mesh The mesh
  19073. * @param world World matrix of this mesh
  19074. * @param isFrozen Is the material frozen
  19075. */
  19076. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19077. }
  19078. }
  19079. declare module "babylonjs/Cameras/targetCamera" {
  19080. import { Nullable } from "babylonjs/types";
  19081. import { Camera } from "babylonjs/Cameras/camera";
  19082. import { Scene } from "babylonjs/scene";
  19083. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19084. /**
  19085. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19086. * This is the base of the follow, arc rotate cameras and Free camera
  19087. * @see https://doc.babylonjs.com/features/cameras
  19088. */
  19089. export class TargetCamera extends Camera {
  19090. private static _RigCamTransformMatrix;
  19091. private static _TargetTransformMatrix;
  19092. private static _TargetFocalPoint;
  19093. private _tmpUpVector;
  19094. private _tmpTargetVector;
  19095. /**
  19096. * Define the current direction the camera is moving to
  19097. */
  19098. cameraDirection: Vector3;
  19099. /**
  19100. * Define the current rotation the camera is rotating to
  19101. */
  19102. cameraRotation: Vector2;
  19103. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19104. ignoreParentScaling: boolean;
  19105. /**
  19106. * When set, the up vector of the camera will be updated by the rotation of the camera
  19107. */
  19108. updateUpVectorFromRotation: boolean;
  19109. private _tmpQuaternion;
  19110. /**
  19111. * Define the current rotation of the camera
  19112. */
  19113. rotation: Vector3;
  19114. /**
  19115. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19116. */
  19117. rotationQuaternion: Quaternion;
  19118. /**
  19119. * Define the current speed of the camera
  19120. */
  19121. speed: number;
  19122. /**
  19123. * Add constraint to the camera to prevent it to move freely in all directions and
  19124. * around all axis.
  19125. */
  19126. noRotationConstraint: boolean;
  19127. /**
  19128. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19129. * panning
  19130. */
  19131. invertRotation: boolean;
  19132. /**
  19133. * Speed multiplier for inverse camera panning
  19134. */
  19135. inverseRotationSpeed: number;
  19136. /**
  19137. * Define the current target of the camera as an object or a position.
  19138. */
  19139. lockedTarget: any;
  19140. /** @hidden */
  19141. _currentTarget: Vector3;
  19142. /** @hidden */
  19143. _initialFocalDistance: number;
  19144. /** @hidden */
  19145. _viewMatrix: Matrix;
  19146. /** @hidden */
  19147. _camMatrix: Matrix;
  19148. /** @hidden */
  19149. _cameraTransformMatrix: Matrix;
  19150. /** @hidden */
  19151. _cameraRotationMatrix: Matrix;
  19152. /** @hidden */
  19153. _referencePoint: Vector3;
  19154. /** @hidden */
  19155. _transformedReferencePoint: Vector3;
  19156. /** @hidden */
  19157. _reset: () => void;
  19158. private _defaultUp;
  19159. /**
  19160. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19161. * This is the base of the follow, arc rotate cameras and Free camera
  19162. * @see https://doc.babylonjs.com/features/cameras
  19163. * @param name Defines the name of the camera in the scene
  19164. * @param position Defines the start position of the camera in the scene
  19165. * @param scene Defines the scene the camera belongs to
  19166. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19167. */
  19168. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19169. /**
  19170. * Gets the position in front of the camera at a given distance.
  19171. * @param distance The distance from the camera we want the position to be
  19172. * @returns the position
  19173. */
  19174. getFrontPosition(distance: number): Vector3;
  19175. /** @hidden */
  19176. _getLockedTargetPosition(): Nullable<Vector3>;
  19177. private _storedPosition;
  19178. private _storedRotation;
  19179. private _storedRotationQuaternion;
  19180. /**
  19181. * Store current camera state of the camera (fov, position, rotation, etc..)
  19182. * @returns the camera
  19183. */
  19184. storeState(): Camera;
  19185. /**
  19186. * Restored camera state. You must call storeState() first
  19187. * @returns whether it was successful or not
  19188. * @hidden
  19189. */
  19190. _restoreStateValues(): boolean;
  19191. /** @hidden */
  19192. _initCache(): void;
  19193. /** @hidden */
  19194. _updateCache(ignoreParentClass?: boolean): void;
  19195. /** @hidden */
  19196. _isSynchronizedViewMatrix(): boolean;
  19197. /** @hidden */
  19198. _computeLocalCameraSpeed(): number;
  19199. /**
  19200. * Defines the target the camera should look at.
  19201. * @param target Defines the new target as a Vector or a mesh
  19202. */
  19203. setTarget(target: Vector3): void;
  19204. /**
  19205. * Defines the target point of the camera.
  19206. * The camera looks towards it form the radius distance.
  19207. */
  19208. get target(): Vector3;
  19209. set target(value: Vector3);
  19210. /**
  19211. * Return the current target position of the camera. This value is expressed in local space.
  19212. * @returns the target position
  19213. */
  19214. getTarget(): Vector3;
  19215. /** @hidden */
  19216. _decideIfNeedsToMove(): boolean;
  19217. /** @hidden */
  19218. _updatePosition(): void;
  19219. /** @hidden */
  19220. _checkInputs(): void;
  19221. protected _updateCameraRotationMatrix(): void;
  19222. /**
  19223. * 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)
  19224. * @returns the current camera
  19225. */
  19226. private _rotateUpVectorWithCameraRotationMatrix;
  19227. private _cachedRotationZ;
  19228. private _cachedQuaternionRotationZ;
  19229. /** @hidden */
  19230. _getViewMatrix(): Matrix;
  19231. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19232. /**
  19233. * @hidden
  19234. */
  19235. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19236. /**
  19237. * @hidden
  19238. */
  19239. _updateRigCameras(): void;
  19240. private _getRigCamPositionAndTarget;
  19241. /**
  19242. * Gets the current object class name.
  19243. * @return the class name
  19244. */
  19245. getClassName(): string;
  19246. }
  19247. }
  19248. declare module "babylonjs/Events/keyboardEvents" {
  19249. /**
  19250. * Gather the list of keyboard event types as constants.
  19251. */
  19252. export class KeyboardEventTypes {
  19253. /**
  19254. * The keydown event is fired when a key becomes active (pressed).
  19255. */
  19256. static readonly KEYDOWN: number;
  19257. /**
  19258. * The keyup event is fired when a key has been released.
  19259. */
  19260. static readonly KEYUP: number;
  19261. }
  19262. /**
  19263. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19264. */
  19265. export class KeyboardInfo {
  19266. /**
  19267. * Defines the type of event (KeyboardEventTypes)
  19268. */
  19269. type: number;
  19270. /**
  19271. * Defines the related dom event
  19272. */
  19273. event: KeyboardEvent;
  19274. /**
  19275. * Instantiates a new keyboard info.
  19276. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19277. * @param type Defines the type of event (KeyboardEventTypes)
  19278. * @param event Defines the related dom event
  19279. */
  19280. constructor(
  19281. /**
  19282. * Defines the type of event (KeyboardEventTypes)
  19283. */
  19284. type: number,
  19285. /**
  19286. * Defines the related dom event
  19287. */
  19288. event: KeyboardEvent);
  19289. }
  19290. /**
  19291. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19292. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19293. */
  19294. export class KeyboardInfoPre extends KeyboardInfo {
  19295. /**
  19296. * Defines the type of event (KeyboardEventTypes)
  19297. */
  19298. type: number;
  19299. /**
  19300. * Defines the related dom event
  19301. */
  19302. event: KeyboardEvent;
  19303. /**
  19304. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19305. */
  19306. skipOnPointerObservable: boolean;
  19307. /**
  19308. * Instantiates a new keyboard pre info.
  19309. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19310. * @param type Defines the type of event (KeyboardEventTypes)
  19311. * @param event Defines the related dom event
  19312. */
  19313. constructor(
  19314. /**
  19315. * Defines the type of event (KeyboardEventTypes)
  19316. */
  19317. type: number,
  19318. /**
  19319. * Defines the related dom event
  19320. */
  19321. event: KeyboardEvent);
  19322. }
  19323. }
  19324. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19326. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19327. /**
  19328. * Manage the keyboard inputs to control the movement of a free camera.
  19329. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19330. */
  19331. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19332. /**
  19333. * Defines the camera the input is attached to.
  19334. */
  19335. camera: FreeCamera;
  19336. /**
  19337. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19338. */
  19339. keysUp: number[];
  19340. /**
  19341. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19342. */
  19343. keysUpward: number[];
  19344. /**
  19345. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19346. */
  19347. keysDown: number[];
  19348. /**
  19349. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19350. */
  19351. keysDownward: number[];
  19352. /**
  19353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19354. */
  19355. keysLeft: number[];
  19356. /**
  19357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19358. */
  19359. keysRight: number[];
  19360. private _keys;
  19361. private _onCanvasBlurObserver;
  19362. private _onKeyboardObserver;
  19363. private _engine;
  19364. private _scene;
  19365. /**
  19366. * Attach the input controls to a specific dom element to get the input from.
  19367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19368. */
  19369. attachControl(noPreventDefault?: boolean): void;
  19370. /**
  19371. * Detach the current controls from the specified dom element.
  19372. */
  19373. detachControl(): void;
  19374. /**
  19375. * Update the current camera state depending on the inputs that have been used this frame.
  19376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19377. */
  19378. checkInputs(): void;
  19379. /**
  19380. * Gets the class name of the current intput.
  19381. * @returns the class name
  19382. */
  19383. getClassName(): string;
  19384. /** @hidden */
  19385. _onLostFocus(): void;
  19386. /**
  19387. * Get the friendly name associated with the input class.
  19388. * @returns the input friendly name
  19389. */
  19390. getSimpleName(): string;
  19391. }
  19392. }
  19393. declare module "babylonjs/Events/pointerEvents" {
  19394. import { Nullable } from "babylonjs/types";
  19395. import { Vector2 } from "babylonjs/Maths/math.vector";
  19396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19397. import { Ray } from "babylonjs/Culling/ray";
  19398. /**
  19399. * Gather the list of pointer event types as constants.
  19400. */
  19401. export class PointerEventTypes {
  19402. /**
  19403. * 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.
  19404. */
  19405. static readonly POINTERDOWN: number;
  19406. /**
  19407. * The pointerup event is fired when a pointer is no longer active.
  19408. */
  19409. static readonly POINTERUP: number;
  19410. /**
  19411. * The pointermove event is fired when a pointer changes coordinates.
  19412. */
  19413. static readonly POINTERMOVE: number;
  19414. /**
  19415. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19416. */
  19417. static readonly POINTERWHEEL: number;
  19418. /**
  19419. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19420. */
  19421. static readonly POINTERPICK: number;
  19422. /**
  19423. * The pointertap event is fired when a the object has been touched and released without drag.
  19424. */
  19425. static readonly POINTERTAP: number;
  19426. /**
  19427. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19428. */
  19429. static readonly POINTERDOUBLETAP: number;
  19430. }
  19431. /**
  19432. * Base class of pointer info types.
  19433. */
  19434. export class PointerInfoBase {
  19435. /**
  19436. * Defines the type of event (PointerEventTypes)
  19437. */
  19438. type: number;
  19439. /**
  19440. * Defines the related dom event
  19441. */
  19442. event: PointerEvent | MouseWheelEvent;
  19443. /**
  19444. * Instantiates the base class of pointers info.
  19445. * @param type Defines the type of event (PointerEventTypes)
  19446. * @param event Defines the related dom event
  19447. */
  19448. constructor(
  19449. /**
  19450. * Defines the type of event (PointerEventTypes)
  19451. */
  19452. type: number,
  19453. /**
  19454. * Defines the related dom event
  19455. */
  19456. event: PointerEvent | MouseWheelEvent);
  19457. }
  19458. /**
  19459. * This class is used to store pointer related info for the onPrePointerObservable event.
  19460. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19461. */
  19462. export class PointerInfoPre extends PointerInfoBase {
  19463. /**
  19464. * Ray from a pointer if availible (eg. 6dof controller)
  19465. */
  19466. ray: Nullable<Ray>;
  19467. /**
  19468. * Defines the local position of the pointer on the canvas.
  19469. */
  19470. localPosition: Vector2;
  19471. /**
  19472. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19473. */
  19474. skipOnPointerObservable: boolean;
  19475. /**
  19476. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19477. * @param type Defines the type of event (PointerEventTypes)
  19478. * @param event Defines the related dom event
  19479. * @param localX Defines the local x coordinates of the pointer when the event occured
  19480. * @param localY Defines the local y coordinates of the pointer when the event occured
  19481. */
  19482. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19483. }
  19484. /**
  19485. * This type contains all the data related to a pointer event in Babylon.js.
  19486. * 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.
  19487. */
  19488. export class PointerInfo extends PointerInfoBase {
  19489. /**
  19490. * Defines the picking info associated to the info (if any)\
  19491. */
  19492. pickInfo: Nullable<PickingInfo>;
  19493. /**
  19494. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19495. * @param type Defines the type of event (PointerEventTypes)
  19496. * @param event Defines the related dom event
  19497. * @param pickInfo Defines the picking info associated to the info (if any)\
  19498. */
  19499. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19500. /**
  19501. * Defines the picking info associated to the info (if any)\
  19502. */
  19503. pickInfo: Nullable<PickingInfo>);
  19504. }
  19505. /**
  19506. * Data relating to a touch event on the screen.
  19507. */
  19508. export interface PointerTouch {
  19509. /**
  19510. * X coordinate of touch.
  19511. */
  19512. x: number;
  19513. /**
  19514. * Y coordinate of touch.
  19515. */
  19516. y: number;
  19517. /**
  19518. * Id of touch. Unique for each finger.
  19519. */
  19520. pointerId: number;
  19521. /**
  19522. * Event type passed from DOM.
  19523. */
  19524. type: any;
  19525. }
  19526. }
  19527. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19528. import { Observable } from "babylonjs/Misc/observable";
  19529. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19531. /**
  19532. * Manage the mouse inputs to control the movement of a free camera.
  19533. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19534. */
  19535. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19536. /**
  19537. * Define if touch is enabled in the mouse input
  19538. */
  19539. touchEnabled: boolean;
  19540. /**
  19541. * Defines the camera the input is attached to.
  19542. */
  19543. camera: FreeCamera;
  19544. /**
  19545. * Defines the buttons associated with the input to handle camera move.
  19546. */
  19547. buttons: number[];
  19548. /**
  19549. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19550. */
  19551. angularSensibility: number;
  19552. private _pointerInput;
  19553. private _onMouseMove;
  19554. private _observer;
  19555. private previousPosition;
  19556. /**
  19557. * Observable for when a pointer move event occurs containing the move offset
  19558. */
  19559. onPointerMovedObservable: Observable<{
  19560. offsetX: number;
  19561. offsetY: number;
  19562. }>;
  19563. /**
  19564. * @hidden
  19565. * If the camera should be rotated automatically based on pointer movement
  19566. */
  19567. _allowCameraRotation: boolean;
  19568. /**
  19569. * Manage the mouse inputs to control the movement of a free camera.
  19570. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19571. * @param touchEnabled Defines if touch is enabled or not
  19572. */
  19573. constructor(
  19574. /**
  19575. * Define if touch is enabled in the mouse input
  19576. */
  19577. touchEnabled?: boolean);
  19578. /**
  19579. * Attach the input controls to a specific dom element to get the input from.
  19580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19581. */
  19582. attachControl(noPreventDefault?: boolean): void;
  19583. /**
  19584. * Called on JS contextmenu event.
  19585. * Override this method to provide functionality.
  19586. */
  19587. protected onContextMenu(evt: PointerEvent): void;
  19588. /**
  19589. * Detach the current controls from the specified dom element.
  19590. */
  19591. detachControl(): void;
  19592. /**
  19593. * Gets the class name of the current intput.
  19594. * @returns the class name
  19595. */
  19596. getClassName(): string;
  19597. /**
  19598. * Get the friendly name associated with the input class.
  19599. * @returns the input friendly name
  19600. */
  19601. getSimpleName(): string;
  19602. }
  19603. }
  19604. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  19605. import { Observable } from "babylonjs/Misc/observable";
  19606. import { Camera } from "babylonjs/Cameras/camera";
  19607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19608. /**
  19609. * Base class for mouse wheel input..
  19610. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19611. * for example usage.
  19612. */
  19613. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19614. /**
  19615. * Defines the camera the input is attached to.
  19616. */
  19617. abstract camera: Camera;
  19618. /**
  19619. * How fast is the camera moves in relation to X axis mouseWheel events.
  19620. * Use negative value to reverse direction.
  19621. */
  19622. wheelPrecisionX: number;
  19623. /**
  19624. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19625. * Use negative value to reverse direction.
  19626. */
  19627. wheelPrecisionY: number;
  19628. /**
  19629. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19630. * Use negative value to reverse direction.
  19631. */
  19632. wheelPrecisionZ: number;
  19633. /**
  19634. * Observable for when a mouse wheel move event occurs.
  19635. */
  19636. onChangedObservable: Observable<{
  19637. wheelDeltaX: number;
  19638. wheelDeltaY: number;
  19639. wheelDeltaZ: number;
  19640. }>;
  19641. private _wheel;
  19642. private _observer;
  19643. /**
  19644. * Attach the input controls to a specific dom element to get the input from.
  19645. * @param noPreventDefault Defines whether event caught by the controls
  19646. * should call preventdefault().
  19647. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19648. */
  19649. attachControl(noPreventDefault?: boolean): void;
  19650. /**
  19651. * Detach the current controls from the specified dom element.
  19652. */
  19653. detachControl(): void;
  19654. /**
  19655. * Called for each rendered frame.
  19656. */
  19657. checkInputs(): void;
  19658. /**
  19659. * Gets the class name of the current intput.
  19660. * @returns the class name
  19661. */
  19662. getClassName(): string;
  19663. /**
  19664. * Get the friendly name associated with the input class.
  19665. * @returns the input friendly name
  19666. */
  19667. getSimpleName(): string;
  19668. /**
  19669. * Incremental value of multiple mouse wheel movements of the X axis.
  19670. * Should be zero-ed when read.
  19671. */
  19672. protected _wheelDeltaX: number;
  19673. /**
  19674. * Incremental value of multiple mouse wheel movements of the Y axis.
  19675. * Should be zero-ed when read.
  19676. */
  19677. protected _wheelDeltaY: number;
  19678. /**
  19679. * Incremental value of multiple mouse wheel movements of the Z axis.
  19680. * Should be zero-ed when read.
  19681. */
  19682. protected _wheelDeltaZ: number;
  19683. /**
  19684. * Firefox uses a different scheme to report scroll distances to other
  19685. * browsers. Rather than use complicated methods to calculate the exact
  19686. * multiple we need to apply, let's just cheat and use a constant.
  19687. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19688. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19689. */
  19690. private readonly _ffMultiplier;
  19691. /**
  19692. * Different event attributes for wheel data fall into a few set ranges.
  19693. * Some relevant but dated date here:
  19694. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19695. */
  19696. private readonly _normalize;
  19697. }
  19698. }
  19699. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19702. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  19703. import { Coordinate } from "babylonjs/Maths/math.axis";
  19704. /**
  19705. * Manage the mouse wheel inputs to control a free camera.
  19706. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19707. */
  19708. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19709. /**
  19710. * Defines the camera the input is attached to.
  19711. */
  19712. camera: FreeCamera;
  19713. /**
  19714. * Gets the class name of the current input.
  19715. * @returns the class name
  19716. */
  19717. getClassName(): string;
  19718. /**
  19719. * Set which movement axis (relative to camera's orientation) the mouse
  19720. * wheel's X axis controls.
  19721. * @param axis The axis to be moved. Set null to clear.
  19722. */
  19723. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19724. /**
  19725. * Get the configured movement axis (relative to camera's orientation) the
  19726. * mouse wheel's X axis controls.
  19727. * @returns The configured axis or null if none.
  19728. */
  19729. get wheelXMoveRelative(): Nullable<Coordinate>;
  19730. /**
  19731. * Set which movement axis (relative to camera's orientation) the mouse
  19732. * wheel's Y axis controls.
  19733. * @param axis The axis to be moved. Set null to clear.
  19734. */
  19735. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19736. /**
  19737. * Get the configured movement axis (relative to camera's orientation) the
  19738. * mouse wheel's Y axis controls.
  19739. * @returns The configured axis or null if none.
  19740. */
  19741. get wheelYMoveRelative(): Nullable<Coordinate>;
  19742. /**
  19743. * Set which movement axis (relative to camera's orientation) the mouse
  19744. * wheel's Z axis controls.
  19745. * @param axis The axis to be moved. Set null to clear.
  19746. */
  19747. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19748. /**
  19749. * Get the configured movement axis (relative to camera's orientation) the
  19750. * mouse wheel's Z axis controls.
  19751. * @returns The configured axis or null if none.
  19752. */
  19753. get wheelZMoveRelative(): Nullable<Coordinate>;
  19754. /**
  19755. * Set which rotation axis (relative to camera's orientation) the mouse
  19756. * wheel's X axis controls.
  19757. * @param axis The axis to be moved. Set null to clear.
  19758. */
  19759. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19760. /**
  19761. * Get the configured rotation axis (relative to camera's orientation) the
  19762. * mouse wheel's X axis controls.
  19763. * @returns The configured axis or null if none.
  19764. */
  19765. get wheelXRotateRelative(): Nullable<Coordinate>;
  19766. /**
  19767. * Set which rotation axis (relative to camera's orientation) the mouse
  19768. * wheel's Y axis controls.
  19769. * @param axis The axis to be moved. Set null to clear.
  19770. */
  19771. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19772. /**
  19773. * Get the configured rotation axis (relative to camera's orientation) the
  19774. * mouse wheel's Y axis controls.
  19775. * @returns The configured axis or null if none.
  19776. */
  19777. get wheelYRotateRelative(): Nullable<Coordinate>;
  19778. /**
  19779. * Set which rotation axis (relative to camera's orientation) the mouse
  19780. * wheel's Z axis controls.
  19781. * @param axis The axis to be moved. Set null to clear.
  19782. */
  19783. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19784. /**
  19785. * Get the configured rotation axis (relative to camera's orientation) the
  19786. * mouse wheel's Z axis controls.
  19787. * @returns The configured axis or null if none.
  19788. */
  19789. get wheelZRotateRelative(): Nullable<Coordinate>;
  19790. /**
  19791. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19792. * controls.
  19793. * @param axis The axis to be moved. Set null to clear.
  19794. */
  19795. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19796. /**
  19797. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19798. * X axis controls.
  19799. * @returns The configured axis or null if none.
  19800. */
  19801. get wheelXMoveScene(): Nullable<Coordinate>;
  19802. /**
  19803. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19804. * controls.
  19805. * @param axis The axis to be moved. Set null to clear.
  19806. */
  19807. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19808. /**
  19809. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19810. * Y axis controls.
  19811. * @returns The configured axis or null if none.
  19812. */
  19813. get wheelYMoveScene(): Nullable<Coordinate>;
  19814. /**
  19815. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19816. * controls.
  19817. * @param axis The axis to be moved. Set null to clear.
  19818. */
  19819. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19820. /**
  19821. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19822. * Z axis controls.
  19823. * @returns The configured axis or null if none.
  19824. */
  19825. get wheelZMoveScene(): Nullable<Coordinate>;
  19826. /**
  19827. * Called for each rendered frame.
  19828. */
  19829. checkInputs(): void;
  19830. private _moveRelative;
  19831. private _rotateRelative;
  19832. private _moveScene;
  19833. /**
  19834. * These are set to the desired default behaviour.
  19835. */
  19836. private _wheelXAction;
  19837. private _wheelXActionCoordinate;
  19838. private _wheelYAction;
  19839. private _wheelYActionCoordinate;
  19840. private _wheelZAction;
  19841. private _wheelZActionCoordinate;
  19842. /**
  19843. * Update the camera according to any configured properties for the 3
  19844. * mouse-wheel axis.
  19845. */
  19846. private _updateCamera;
  19847. }
  19848. }
  19849. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19850. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19851. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19852. /**
  19853. * Manage the touch inputs to control the movement of a free camera.
  19854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19855. */
  19856. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19857. /**
  19858. * Define if mouse events can be treated as touch events
  19859. */
  19860. allowMouse: boolean;
  19861. /**
  19862. * Defines the camera the input is attached to.
  19863. */
  19864. camera: FreeCamera;
  19865. /**
  19866. * Defines the touch sensibility for rotation.
  19867. * The higher the faster.
  19868. */
  19869. touchAngularSensibility: number;
  19870. /**
  19871. * Defines the touch sensibility for move.
  19872. * The higher the faster.
  19873. */
  19874. touchMoveSensibility: number;
  19875. private _offsetX;
  19876. private _offsetY;
  19877. private _pointerPressed;
  19878. private _pointerInput?;
  19879. private _observer;
  19880. private _onLostFocus;
  19881. /**
  19882. * Manage the touch inputs to control the movement of a free camera.
  19883. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19884. * @param allowMouse Defines if mouse events can be treated as touch events
  19885. */
  19886. constructor(
  19887. /**
  19888. * Define if mouse events can be treated as touch events
  19889. */
  19890. allowMouse?: boolean);
  19891. /**
  19892. * Attach the input controls to a specific dom element to get the input from.
  19893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19894. */
  19895. attachControl(noPreventDefault?: boolean): void;
  19896. /**
  19897. * Detach the current controls from the specified dom element.
  19898. */
  19899. detachControl(): void;
  19900. /**
  19901. * Update the current camera state depending on the inputs that have been used this frame.
  19902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19903. */
  19904. checkInputs(): void;
  19905. /**
  19906. * Gets the class name of the current intput.
  19907. * @returns the class name
  19908. */
  19909. getClassName(): string;
  19910. /**
  19911. * Get the friendly name associated with the input class.
  19912. * @returns the input friendly name
  19913. */
  19914. getSimpleName(): string;
  19915. }
  19916. }
  19917. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19918. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19919. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19920. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19921. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  19922. import { Nullable } from "babylonjs/types";
  19923. /**
  19924. * Default Inputs manager for the FreeCamera.
  19925. * It groups all the default supported inputs for ease of use.
  19926. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19927. */
  19928. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19929. /**
  19930. * @hidden
  19931. */
  19932. _mouseInput: Nullable<FreeCameraMouseInput>;
  19933. /**
  19934. * @hidden
  19935. */
  19936. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19937. /**
  19938. * Instantiates a new FreeCameraInputsManager.
  19939. * @param camera Defines the camera the inputs belong to
  19940. */
  19941. constructor(camera: FreeCamera);
  19942. /**
  19943. * Add keyboard input support to the input manager.
  19944. * @returns the current input manager
  19945. */
  19946. addKeyboard(): FreeCameraInputsManager;
  19947. /**
  19948. * Add mouse input support to the input manager.
  19949. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19950. * @returns the current input manager
  19951. */
  19952. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19953. /**
  19954. * Removes the mouse input support from the manager
  19955. * @returns the current input manager
  19956. */
  19957. removeMouse(): FreeCameraInputsManager;
  19958. /**
  19959. * Add mouse wheel input support to the input manager.
  19960. * @returns the current input manager
  19961. */
  19962. addMouseWheel(): FreeCameraInputsManager;
  19963. /**
  19964. * Removes the mouse wheel input support from the manager
  19965. * @returns the current input manager
  19966. */
  19967. removeMouseWheel(): FreeCameraInputsManager;
  19968. /**
  19969. * Add touch input support to the input manager.
  19970. * @returns the current input manager
  19971. */
  19972. addTouch(): FreeCameraInputsManager;
  19973. /**
  19974. * Remove all attached input methods from a camera
  19975. */
  19976. clear(): void;
  19977. }
  19978. }
  19979. declare module "babylonjs/Cameras/freeCamera" {
  19980. import { Vector3 } from "babylonjs/Maths/math.vector";
  19981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19982. import { Scene } from "babylonjs/scene";
  19983. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19984. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19985. /**
  19986. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19987. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19988. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19989. */
  19990. export class FreeCamera extends TargetCamera {
  19991. /**
  19992. * Define the collision ellipsoid of the camera.
  19993. * This is helpful to simulate a camera body like the player body around the camera
  19994. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19995. */
  19996. ellipsoid: Vector3;
  19997. /**
  19998. * Define an offset for the position of the ellipsoid around the camera.
  19999. * This can be helpful to determine the center of the body near the gravity center of the body
  20000. * instead of its head.
  20001. */
  20002. ellipsoidOffset: Vector3;
  20003. /**
  20004. * Enable or disable collisions of the camera with the rest of the scene objects.
  20005. */
  20006. checkCollisions: boolean;
  20007. /**
  20008. * Enable or disable gravity on the camera.
  20009. */
  20010. applyGravity: boolean;
  20011. /**
  20012. * Define the input manager associated to the camera.
  20013. */
  20014. inputs: FreeCameraInputsManager;
  20015. /**
  20016. * Gets the input sensibility for a mouse input. (default is 2000.0)
  20017. * Higher values reduce sensitivity.
  20018. */
  20019. get angularSensibility(): number;
  20020. /**
  20021. * Sets the input sensibility for a mouse input. (default is 2000.0)
  20022. * Higher values reduce sensitivity.
  20023. */
  20024. set angularSensibility(value: number);
  20025. /**
  20026. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  20027. */
  20028. get keysUp(): number[];
  20029. set keysUp(value: number[]);
  20030. /**
  20031. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  20032. */
  20033. get keysUpward(): number[];
  20034. set keysUpward(value: number[]);
  20035. /**
  20036. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  20037. */
  20038. get keysDown(): number[];
  20039. set keysDown(value: number[]);
  20040. /**
  20041. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  20042. */
  20043. get keysDownward(): number[];
  20044. set keysDownward(value: number[]);
  20045. /**
  20046. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  20047. */
  20048. get keysLeft(): number[];
  20049. set keysLeft(value: number[]);
  20050. /**
  20051. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  20052. */
  20053. get keysRight(): number[];
  20054. set keysRight(value: number[]);
  20055. /**
  20056. * Event raised when the camera collide with a mesh in the scene.
  20057. */
  20058. onCollide: (collidedMesh: AbstractMesh) => void;
  20059. private _collider;
  20060. private _needMoveForGravity;
  20061. private _oldPosition;
  20062. private _diffPosition;
  20063. private _newPosition;
  20064. /** @hidden */
  20065. _localDirection: Vector3;
  20066. /** @hidden */
  20067. _transformedDirection: Vector3;
  20068. /**
  20069. * Instantiates a Free Camera.
  20070. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  20071. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  20072. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  20073. * @param name Define the name of the camera in the scene
  20074. * @param position Define the start position of the camera in the scene
  20075. * @param scene Define the scene the camera belongs to
  20076. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  20077. */
  20078. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  20079. /**
  20080. * Attach the input controls to a specific dom element to get the input from.
  20081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20082. */
  20083. attachControl(noPreventDefault?: boolean): void;
  20084. /**
  20085. * Detach the current controls from the specified dom element.
  20086. */
  20087. detachControl(): void;
  20088. private _collisionMask;
  20089. /**
  20090. * Define a collision mask to limit the list of object the camera can collide with
  20091. */
  20092. get collisionMask(): number;
  20093. set collisionMask(mask: number);
  20094. /** @hidden */
  20095. _collideWithWorld(displacement: Vector3): void;
  20096. private _onCollisionPositionChange;
  20097. /** @hidden */
  20098. _checkInputs(): void;
  20099. /** @hidden */
  20100. _decideIfNeedsToMove(): boolean;
  20101. /** @hidden */
  20102. _updatePosition(): void;
  20103. /**
  20104. * Destroy the camera and release the current resources hold by it.
  20105. */
  20106. dispose(): void;
  20107. /**
  20108. * Gets the current object class name.
  20109. * @return the class name
  20110. */
  20111. getClassName(): string;
  20112. }
  20113. }
  20114. declare module "babylonjs/Gamepads/gamepad" {
  20115. import { Observable } from "babylonjs/Misc/observable";
  20116. /**
  20117. * Represents a gamepad control stick position
  20118. */
  20119. export class StickValues {
  20120. /**
  20121. * The x component of the control stick
  20122. */
  20123. x: number;
  20124. /**
  20125. * The y component of the control stick
  20126. */
  20127. y: number;
  20128. /**
  20129. * Initializes the gamepad x and y control stick values
  20130. * @param x The x component of the gamepad control stick value
  20131. * @param y The y component of the gamepad control stick value
  20132. */
  20133. constructor(
  20134. /**
  20135. * The x component of the control stick
  20136. */
  20137. x: number,
  20138. /**
  20139. * The y component of the control stick
  20140. */
  20141. y: number);
  20142. }
  20143. /**
  20144. * An interface which manages callbacks for gamepad button changes
  20145. */
  20146. export interface GamepadButtonChanges {
  20147. /**
  20148. * Called when a gamepad has been changed
  20149. */
  20150. changed: boolean;
  20151. /**
  20152. * Called when a gamepad press event has been triggered
  20153. */
  20154. pressChanged: boolean;
  20155. /**
  20156. * Called when a touch event has been triggered
  20157. */
  20158. touchChanged: boolean;
  20159. /**
  20160. * Called when a value has changed
  20161. */
  20162. valueChanged: boolean;
  20163. }
  20164. /**
  20165. * Represents a gamepad
  20166. */
  20167. export class Gamepad {
  20168. /**
  20169. * The id of the gamepad
  20170. */
  20171. id: string;
  20172. /**
  20173. * The index of the gamepad
  20174. */
  20175. index: number;
  20176. /**
  20177. * The browser gamepad
  20178. */
  20179. browserGamepad: any;
  20180. /**
  20181. * Specifies what type of gamepad this represents
  20182. */
  20183. type: number;
  20184. private _leftStick;
  20185. private _rightStick;
  20186. /** @hidden */
  20187. _isConnected: boolean;
  20188. private _leftStickAxisX;
  20189. private _leftStickAxisY;
  20190. private _rightStickAxisX;
  20191. private _rightStickAxisY;
  20192. /**
  20193. * Triggered when the left control stick has been changed
  20194. */
  20195. private _onleftstickchanged;
  20196. /**
  20197. * Triggered when the right control stick has been changed
  20198. */
  20199. private _onrightstickchanged;
  20200. /**
  20201. * Represents a gamepad controller
  20202. */
  20203. static GAMEPAD: number;
  20204. /**
  20205. * Represents a generic controller
  20206. */
  20207. static GENERIC: number;
  20208. /**
  20209. * Represents an XBox controller
  20210. */
  20211. static XBOX: number;
  20212. /**
  20213. * Represents a pose-enabled controller
  20214. */
  20215. static POSE_ENABLED: number;
  20216. /**
  20217. * Represents an Dual Shock controller
  20218. */
  20219. static DUALSHOCK: number;
  20220. /**
  20221. * Specifies whether the left control stick should be Y-inverted
  20222. */
  20223. protected _invertLeftStickY: boolean;
  20224. /**
  20225. * Specifies if the gamepad has been connected
  20226. */
  20227. get isConnected(): boolean;
  20228. /**
  20229. * Initializes the gamepad
  20230. * @param id The id of the gamepad
  20231. * @param index The index of the gamepad
  20232. * @param browserGamepad The browser gamepad
  20233. * @param leftStickX The x component of the left joystick
  20234. * @param leftStickY The y component of the left joystick
  20235. * @param rightStickX The x component of the right joystick
  20236. * @param rightStickY The y component of the right joystick
  20237. */
  20238. constructor(
  20239. /**
  20240. * The id of the gamepad
  20241. */
  20242. id: string,
  20243. /**
  20244. * The index of the gamepad
  20245. */
  20246. index: number,
  20247. /**
  20248. * The browser gamepad
  20249. */
  20250. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  20251. /**
  20252. * Callback triggered when the left joystick has changed
  20253. * @param callback
  20254. */
  20255. onleftstickchanged(callback: (values: StickValues) => void): void;
  20256. /**
  20257. * Callback triggered when the right joystick has changed
  20258. * @param callback
  20259. */
  20260. onrightstickchanged(callback: (values: StickValues) => void): void;
  20261. /**
  20262. * Gets the left joystick
  20263. */
  20264. get leftStick(): StickValues;
  20265. /**
  20266. * Sets the left joystick values
  20267. */
  20268. set leftStick(newValues: StickValues);
  20269. /**
  20270. * Gets the right joystick
  20271. */
  20272. get rightStick(): StickValues;
  20273. /**
  20274. * Sets the right joystick value
  20275. */
  20276. set rightStick(newValues: StickValues);
  20277. /**
  20278. * Updates the gamepad joystick positions
  20279. */
  20280. update(): void;
  20281. /**
  20282. * Disposes the gamepad
  20283. */
  20284. dispose(): void;
  20285. }
  20286. /**
  20287. * Represents a generic gamepad
  20288. */
  20289. export class GenericPad extends Gamepad {
  20290. private _buttons;
  20291. private _onbuttondown;
  20292. private _onbuttonup;
  20293. /**
  20294. * Observable triggered when a button has been pressed
  20295. */
  20296. onButtonDownObservable: Observable<number>;
  20297. /**
  20298. * Observable triggered when a button has been released
  20299. */
  20300. onButtonUpObservable: Observable<number>;
  20301. /**
  20302. * Callback triggered when a button has been pressed
  20303. * @param callback Called when a button has been pressed
  20304. */
  20305. onbuttondown(callback: (buttonPressed: number) => void): void;
  20306. /**
  20307. * Callback triggered when a button has been released
  20308. * @param callback Called when a button has been released
  20309. */
  20310. onbuttonup(callback: (buttonReleased: number) => void): void;
  20311. /**
  20312. * Initializes the generic gamepad
  20313. * @param id The id of the generic gamepad
  20314. * @param index The index of the generic gamepad
  20315. * @param browserGamepad The browser gamepad
  20316. */
  20317. constructor(id: string, index: number, browserGamepad: any);
  20318. private _setButtonValue;
  20319. /**
  20320. * Updates the generic gamepad
  20321. */
  20322. update(): void;
  20323. /**
  20324. * Disposes the generic gamepad
  20325. */
  20326. dispose(): void;
  20327. }
  20328. }
  20329. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20330. import { Observable } from "babylonjs/Misc/observable";
  20331. import { Nullable } from "babylonjs/types";
  20332. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20333. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20335. import { Ray } from "babylonjs/Culling/ray";
  20336. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20337. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20338. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20339. /**
  20340. * Defines the types of pose enabled controllers that are supported
  20341. */
  20342. export enum PoseEnabledControllerType {
  20343. /**
  20344. * HTC Vive
  20345. */
  20346. VIVE = 0,
  20347. /**
  20348. * Oculus Rift
  20349. */
  20350. OCULUS = 1,
  20351. /**
  20352. * Windows mixed reality
  20353. */
  20354. WINDOWS = 2,
  20355. /**
  20356. * Samsung gear VR
  20357. */
  20358. GEAR_VR = 3,
  20359. /**
  20360. * Google Daydream
  20361. */
  20362. DAYDREAM = 4,
  20363. /**
  20364. * Generic
  20365. */
  20366. GENERIC = 5
  20367. }
  20368. /**
  20369. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20370. */
  20371. export interface MutableGamepadButton {
  20372. /**
  20373. * Value of the button/trigger
  20374. */
  20375. value: number;
  20376. /**
  20377. * If the button/trigger is currently touched
  20378. */
  20379. touched: boolean;
  20380. /**
  20381. * If the button/trigger is currently pressed
  20382. */
  20383. pressed: boolean;
  20384. }
  20385. /**
  20386. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20387. * @hidden
  20388. */
  20389. export interface ExtendedGamepadButton extends GamepadButton {
  20390. /**
  20391. * If the button/trigger is currently pressed
  20392. */
  20393. readonly pressed: boolean;
  20394. /**
  20395. * If the button/trigger is currently touched
  20396. */
  20397. readonly touched: boolean;
  20398. /**
  20399. * Value of the button/trigger
  20400. */
  20401. readonly value: number;
  20402. }
  20403. /** @hidden */
  20404. export interface _GamePadFactory {
  20405. /**
  20406. * Returns whether or not the current gamepad can be created for this type of controller.
  20407. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20408. * @returns true if it can be created, otherwise false
  20409. */
  20410. canCreate(gamepadInfo: any): boolean;
  20411. /**
  20412. * Creates a new instance of the Gamepad.
  20413. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20414. * @returns the new gamepad instance
  20415. */
  20416. create(gamepadInfo: any): Gamepad;
  20417. }
  20418. /**
  20419. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20420. */
  20421. export class PoseEnabledControllerHelper {
  20422. /** @hidden */
  20423. static _ControllerFactories: _GamePadFactory[];
  20424. /** @hidden */
  20425. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20426. /**
  20427. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20428. * @param vrGamepad the gamepad to initialized
  20429. * @returns a vr controller of the type the gamepad identified as
  20430. */
  20431. static InitiateController(vrGamepad: any): Gamepad;
  20432. }
  20433. /**
  20434. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20435. */
  20436. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20437. /**
  20438. * If the controller is used in a webXR session
  20439. */
  20440. isXR: boolean;
  20441. private _deviceRoomPosition;
  20442. private _deviceRoomRotationQuaternion;
  20443. /**
  20444. * The device position in babylon space
  20445. */
  20446. devicePosition: Vector3;
  20447. /**
  20448. * The device rotation in babylon space
  20449. */
  20450. deviceRotationQuaternion: Quaternion;
  20451. /**
  20452. * The scale factor of the device in babylon space
  20453. */
  20454. deviceScaleFactor: number;
  20455. /**
  20456. * (Likely devicePosition should be used instead) The device position in its room space
  20457. */
  20458. position: Vector3;
  20459. /**
  20460. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20461. */
  20462. rotationQuaternion: Quaternion;
  20463. /**
  20464. * The type of controller (Eg. Windows mixed reality)
  20465. */
  20466. controllerType: PoseEnabledControllerType;
  20467. protected _calculatedPosition: Vector3;
  20468. private _calculatedRotation;
  20469. /**
  20470. * The raw pose from the device
  20471. */
  20472. rawPose: DevicePose;
  20473. private _trackPosition;
  20474. private _maxRotationDistFromHeadset;
  20475. private _draggedRoomRotation;
  20476. /**
  20477. * @hidden
  20478. */
  20479. _disableTrackPosition(fixedPosition: Vector3): void;
  20480. /**
  20481. * Internal, the mesh attached to the controller
  20482. * @hidden
  20483. */
  20484. _mesh: Nullable<AbstractMesh>;
  20485. private _poseControlledCamera;
  20486. private _leftHandSystemQuaternion;
  20487. /**
  20488. * Internal, matrix used to convert room space to babylon space
  20489. * @hidden
  20490. */
  20491. _deviceToWorld: Matrix;
  20492. /**
  20493. * Node to be used when casting a ray from the controller
  20494. * @hidden
  20495. */
  20496. _pointingPoseNode: Nullable<TransformNode>;
  20497. /**
  20498. * Name of the child mesh that can be used to cast a ray from the controller
  20499. */
  20500. static readonly POINTING_POSE: string;
  20501. /**
  20502. * Creates a new PoseEnabledController from a gamepad
  20503. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20504. */
  20505. constructor(browserGamepad: any);
  20506. private _workingMatrix;
  20507. /**
  20508. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20509. */
  20510. update(): void;
  20511. /**
  20512. * Updates only the pose device and mesh without doing any button event checking
  20513. */
  20514. protected _updatePoseAndMesh(): void;
  20515. /**
  20516. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20517. * @param poseData raw pose fromthe device
  20518. */
  20519. updateFromDevice(poseData: DevicePose): void;
  20520. /**
  20521. * @hidden
  20522. */
  20523. _meshAttachedObservable: Observable<AbstractMesh>;
  20524. /**
  20525. * Attaches a mesh to the controller
  20526. * @param mesh the mesh to be attached
  20527. */
  20528. attachToMesh(mesh: AbstractMesh): void;
  20529. /**
  20530. * Attaches the controllers mesh to a camera
  20531. * @param camera the camera the mesh should be attached to
  20532. */
  20533. attachToPoseControlledCamera(camera: TargetCamera): void;
  20534. /**
  20535. * Disposes of the controller
  20536. */
  20537. dispose(): void;
  20538. /**
  20539. * The mesh that is attached to the controller
  20540. */
  20541. get mesh(): Nullable<AbstractMesh>;
  20542. /**
  20543. * Gets the ray of the controller in the direction the controller is pointing
  20544. * @param length the length the resulting ray should be
  20545. * @returns a ray in the direction the controller is pointing
  20546. */
  20547. getForwardRay(length?: number): Ray;
  20548. }
  20549. }
  20550. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20551. import { Observable } from "babylonjs/Misc/observable";
  20552. import { Scene } from "babylonjs/scene";
  20553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20554. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20555. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20556. import { Nullable } from "babylonjs/types";
  20557. /**
  20558. * Defines the WebVRController object that represents controllers tracked in 3D space
  20559. */
  20560. export abstract class WebVRController extends PoseEnabledController {
  20561. /**
  20562. * Internal, the default controller model for the controller
  20563. */
  20564. protected _defaultModel: Nullable<AbstractMesh>;
  20565. /**
  20566. * Fired when the trigger state has changed
  20567. */
  20568. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20569. /**
  20570. * Fired when the main button state has changed
  20571. */
  20572. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20573. /**
  20574. * Fired when the secondary button state has changed
  20575. */
  20576. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20577. /**
  20578. * Fired when the pad state has changed
  20579. */
  20580. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20581. /**
  20582. * Fired when controllers stick values have changed
  20583. */
  20584. onPadValuesChangedObservable: Observable<StickValues>;
  20585. /**
  20586. * Array of button availible on the controller
  20587. */
  20588. protected _buttons: Array<MutableGamepadButton>;
  20589. private _onButtonStateChange;
  20590. /**
  20591. * Fired when a controller button's state has changed
  20592. * @param callback the callback containing the button that was modified
  20593. */
  20594. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20595. /**
  20596. * X and Y axis corresponding to the controllers joystick
  20597. */
  20598. pad: StickValues;
  20599. /**
  20600. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20601. */
  20602. hand: string;
  20603. /**
  20604. * The default controller model for the controller
  20605. */
  20606. get defaultModel(): Nullable<AbstractMesh>;
  20607. /**
  20608. * Creates a new WebVRController from a gamepad
  20609. * @param vrGamepad the gamepad that the WebVRController should be created from
  20610. */
  20611. constructor(vrGamepad: any);
  20612. /**
  20613. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20614. */
  20615. update(): void;
  20616. /**
  20617. * Function to be called when a button is modified
  20618. */
  20619. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20620. /**
  20621. * Loads a mesh and attaches it to the controller
  20622. * @param scene the scene the mesh should be added to
  20623. * @param meshLoaded callback for when the mesh has been loaded
  20624. */
  20625. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20626. private _setButtonValue;
  20627. private _changes;
  20628. private _checkChanges;
  20629. /**
  20630. * Disposes of th webVRCOntroller
  20631. */
  20632. dispose(): void;
  20633. }
  20634. }
  20635. declare module "babylonjs/Lights/hemisphericLight" {
  20636. import { Nullable } from "babylonjs/types";
  20637. import { Scene } from "babylonjs/scene";
  20638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20639. import { Color3 } from "babylonjs/Maths/math.color";
  20640. import { Effect } from "babylonjs/Materials/effect";
  20641. import { Light } from "babylonjs/Lights/light";
  20642. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20643. /**
  20644. * The HemisphericLight simulates the ambient environment light,
  20645. * so the passed direction is the light reflection direction, not the incoming direction.
  20646. */
  20647. export class HemisphericLight extends Light {
  20648. /**
  20649. * The groundColor is the light in the opposite direction to the one specified during creation.
  20650. * 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.
  20651. */
  20652. groundColor: Color3;
  20653. /**
  20654. * The light reflection direction, not the incoming direction.
  20655. */
  20656. direction: Vector3;
  20657. /**
  20658. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20659. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20660. * The HemisphericLight can't cast shadows.
  20661. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20662. * @param name The friendly name of the light
  20663. * @param direction The direction of the light reflection
  20664. * @param scene The scene the light belongs to
  20665. */
  20666. constructor(name: string, direction: Vector3, scene: Scene);
  20667. protected _buildUniformLayout(): void;
  20668. /**
  20669. * Returns the string "HemisphericLight".
  20670. * @return The class name
  20671. */
  20672. getClassName(): string;
  20673. /**
  20674. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20675. * Returns the updated direction.
  20676. * @param target The target the direction should point to
  20677. * @return The computed direction
  20678. */
  20679. setDirectionToTarget(target: Vector3): Vector3;
  20680. /**
  20681. * Returns the shadow generator associated to the light.
  20682. * @returns Always null for hemispheric lights because it does not support shadows.
  20683. */
  20684. getShadowGenerator(): Nullable<IShadowGenerator>;
  20685. /**
  20686. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20687. * @param effect The effect to update
  20688. * @param lightIndex The index of the light in the effect to update
  20689. * @returns The hemispheric light
  20690. */
  20691. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20692. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20693. /**
  20694. * Computes the world matrix of the node
  20695. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20696. * @param useWasUpdatedFlag defines a reserved property
  20697. * @returns the world matrix
  20698. */
  20699. computeWorldMatrix(): Matrix;
  20700. /**
  20701. * Returns the integer 3.
  20702. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20703. */
  20704. getTypeID(): number;
  20705. /**
  20706. * Prepares the list of defines specific to the light type.
  20707. * @param defines the list of defines
  20708. * @param lightIndex defines the index of the light for the effect
  20709. */
  20710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20711. }
  20712. }
  20713. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20714. /** @hidden */
  20715. export var vrMultiviewToSingleviewPixelShader: {
  20716. name: string;
  20717. shader: string;
  20718. };
  20719. }
  20720. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20721. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20722. import { Scene } from "babylonjs/scene";
  20723. /**
  20724. * Renders to multiple views with a single draw call
  20725. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20726. */
  20727. export class MultiviewRenderTarget extends RenderTargetTexture {
  20728. /**
  20729. * Creates a multiview render target
  20730. * @param scene scene used with the render target
  20731. * @param size the size of the render target (used for each view)
  20732. */
  20733. constructor(scene: Scene, size?: number | {
  20734. width: number;
  20735. height: number;
  20736. } | {
  20737. ratio: number;
  20738. });
  20739. /**
  20740. * @hidden
  20741. * @param faceIndex the face index, if its a cube texture
  20742. */
  20743. _bindFrameBuffer(faceIndex?: number): void;
  20744. /**
  20745. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20746. * @returns the view count
  20747. */
  20748. getViewCount(): number;
  20749. }
  20750. }
  20751. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20752. import { Camera } from "babylonjs/Cameras/camera";
  20753. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20754. import { Nullable } from "babylonjs/types";
  20755. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20756. import { Matrix } from "babylonjs/Maths/math.vector";
  20757. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20758. module "babylonjs/Engines/engine" {
  20759. interface Engine {
  20760. /**
  20761. * Creates a new multiview render target
  20762. * @param width defines the width of the texture
  20763. * @param height defines the height of the texture
  20764. * @returns the created multiview texture
  20765. */
  20766. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20767. /**
  20768. * Binds a multiview framebuffer to be drawn to
  20769. * @param multiviewTexture texture to bind
  20770. */
  20771. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20772. }
  20773. }
  20774. module "babylonjs/Cameras/camera" {
  20775. interface Camera {
  20776. /**
  20777. * @hidden
  20778. * 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)
  20779. */
  20780. _useMultiviewToSingleView: boolean;
  20781. /**
  20782. * @hidden
  20783. * 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)
  20784. */
  20785. _multiviewTexture: Nullable<RenderTargetTexture>;
  20786. /**
  20787. * @hidden
  20788. * ensures the multiview texture of the camera exists and has the specified width/height
  20789. * @param width height to set on the multiview texture
  20790. * @param height width to set on the multiview texture
  20791. */
  20792. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20793. }
  20794. }
  20795. module "babylonjs/scene" {
  20796. interface Scene {
  20797. /** @hidden */
  20798. _transformMatrixR: Matrix;
  20799. /** @hidden */
  20800. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20801. /** @hidden */
  20802. _createMultiviewUbo(): void;
  20803. /** @hidden */
  20804. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20805. /** @hidden */
  20806. _renderMultiviewToSingleView(camera: Camera): void;
  20807. }
  20808. }
  20809. }
  20810. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20811. import { Camera } from "babylonjs/Cameras/camera";
  20812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20813. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20814. import "babylonjs/Engines/Extensions/engine.multiview";
  20815. /**
  20816. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20817. * This will not be used for webXR as it supports displaying texture arrays directly
  20818. */
  20819. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20820. /**
  20821. * Gets a string identifying the name of the class
  20822. * @returns "VRMultiviewToSingleviewPostProcess" string
  20823. */
  20824. getClassName(): string;
  20825. /**
  20826. * Initializes a VRMultiviewToSingleview
  20827. * @param name name of the post process
  20828. * @param camera camera to be applied to
  20829. * @param scaleFactor scaling factor to the size of the output texture
  20830. */
  20831. constructor(name: string, camera: Camera, scaleFactor: number);
  20832. }
  20833. }
  20834. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20835. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20836. import { Nullable } from "babylonjs/types";
  20837. import { Size } from "babylonjs/Maths/math.size";
  20838. import { Observable } from "babylonjs/Misc/observable";
  20839. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20840. /**
  20841. * Interface used to define additional presentation attributes
  20842. */
  20843. export interface IVRPresentationAttributes {
  20844. /**
  20845. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20846. */
  20847. highRefreshRate: boolean;
  20848. /**
  20849. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20850. */
  20851. foveationLevel: number;
  20852. }
  20853. module "babylonjs/Engines/engine" {
  20854. interface Engine {
  20855. /** @hidden */
  20856. _vrDisplay: any;
  20857. /** @hidden */
  20858. _vrSupported: boolean;
  20859. /** @hidden */
  20860. _oldSize: Size;
  20861. /** @hidden */
  20862. _oldHardwareScaleFactor: number;
  20863. /** @hidden */
  20864. _vrExclusivePointerMode: boolean;
  20865. /** @hidden */
  20866. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20867. /** @hidden */
  20868. _onVRDisplayPointerRestricted: () => void;
  20869. /** @hidden */
  20870. _onVRDisplayPointerUnrestricted: () => void;
  20871. /** @hidden */
  20872. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20873. /** @hidden */
  20874. _onVrDisplayDisconnect: Nullable<() => void>;
  20875. /** @hidden */
  20876. _onVrDisplayPresentChange: Nullable<() => void>;
  20877. /**
  20878. * Observable signaled when VR display mode changes
  20879. */
  20880. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20881. /**
  20882. * Observable signaled when VR request present is complete
  20883. */
  20884. onVRRequestPresentComplete: Observable<boolean>;
  20885. /**
  20886. * Observable signaled when VR request present starts
  20887. */
  20888. onVRRequestPresentStart: Observable<Engine>;
  20889. /**
  20890. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20891. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20892. */
  20893. isInVRExclusivePointerMode: boolean;
  20894. /**
  20895. * Gets a boolean indicating if a webVR device was detected
  20896. * @returns true if a webVR device was detected
  20897. */
  20898. isVRDevicePresent(): boolean;
  20899. /**
  20900. * Gets the current webVR device
  20901. * @returns the current webVR device (or null)
  20902. */
  20903. getVRDevice(): any;
  20904. /**
  20905. * Initializes a webVR display and starts listening to display change events
  20906. * The onVRDisplayChangedObservable will be notified upon these changes
  20907. * @returns A promise containing a VRDisplay and if vr is supported
  20908. */
  20909. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20910. /** @hidden */
  20911. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20912. /**
  20913. * Gets or sets the presentation attributes used to configure VR rendering
  20914. */
  20915. vrPresentationAttributes?: IVRPresentationAttributes;
  20916. /**
  20917. * Call this function to switch to webVR mode
  20918. * Will do nothing if webVR is not supported or if there is no webVR device
  20919. * @param options the webvr options provided to the camera. mainly used for multiview
  20920. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20921. */
  20922. enableVR(options: WebVROptions): void;
  20923. /** @hidden */
  20924. _onVRFullScreenTriggered(): void;
  20925. }
  20926. }
  20927. }
  20928. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20929. import { Nullable } from "babylonjs/types";
  20930. import { Observable } from "babylonjs/Misc/observable";
  20931. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20932. import { Scene } from "babylonjs/scene";
  20933. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20934. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20935. import { Node } from "babylonjs/node";
  20936. import { Ray } from "babylonjs/Culling/ray";
  20937. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20938. import "babylonjs/Engines/Extensions/engine.webVR";
  20939. /**
  20940. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20941. * IMPORTANT!! The data is right-hand data.
  20942. * @export
  20943. * @interface DevicePose
  20944. */
  20945. export interface DevicePose {
  20946. /**
  20947. * The position of the device, values in array are [x,y,z].
  20948. */
  20949. readonly position: Nullable<Float32Array>;
  20950. /**
  20951. * The linearVelocity of the device, values in array are [x,y,z].
  20952. */
  20953. readonly linearVelocity: Nullable<Float32Array>;
  20954. /**
  20955. * The linearAcceleration of the device, values in array are [x,y,z].
  20956. */
  20957. readonly linearAcceleration: Nullable<Float32Array>;
  20958. /**
  20959. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20960. */
  20961. readonly orientation: Nullable<Float32Array>;
  20962. /**
  20963. * The angularVelocity of the device, values in array are [x,y,z].
  20964. */
  20965. readonly angularVelocity: Nullable<Float32Array>;
  20966. /**
  20967. * The angularAcceleration of the device, values in array are [x,y,z].
  20968. */
  20969. readonly angularAcceleration: Nullable<Float32Array>;
  20970. }
  20971. /**
  20972. * Interface representing a pose controlled object in Babylon.
  20973. * A pose controlled object has both regular pose values as well as pose values
  20974. * from an external device such as a VR head mounted display
  20975. */
  20976. export interface PoseControlled {
  20977. /**
  20978. * The position of the object in babylon space.
  20979. */
  20980. position: Vector3;
  20981. /**
  20982. * The rotation quaternion of the object in babylon space.
  20983. */
  20984. rotationQuaternion: Quaternion;
  20985. /**
  20986. * The position of the device in babylon space.
  20987. */
  20988. devicePosition?: Vector3;
  20989. /**
  20990. * The rotation quaternion of the device in babylon space.
  20991. */
  20992. deviceRotationQuaternion: Quaternion;
  20993. /**
  20994. * The raw pose coming from the device.
  20995. */
  20996. rawPose: Nullable<DevicePose>;
  20997. /**
  20998. * The scale of the device to be used when translating from device space to babylon space.
  20999. */
  21000. deviceScaleFactor: number;
  21001. /**
  21002. * Updates the poseControlled values based on the input device pose.
  21003. * @param poseData the pose data to update the object with
  21004. */
  21005. updateFromDevice(poseData: DevicePose): void;
  21006. }
  21007. /**
  21008. * Set of options to customize the webVRCamera
  21009. */
  21010. export interface WebVROptions {
  21011. /**
  21012. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  21013. */
  21014. trackPosition?: boolean;
  21015. /**
  21016. * Sets the scale of the vrDevice in babylon space. (default: 1)
  21017. */
  21018. positionScale?: number;
  21019. /**
  21020. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  21021. */
  21022. displayName?: string;
  21023. /**
  21024. * Should the native controller meshes be initialized. (default: true)
  21025. */
  21026. controllerMeshes?: boolean;
  21027. /**
  21028. * Creating a default HemiLight only on controllers. (default: true)
  21029. */
  21030. defaultLightingOnControllers?: boolean;
  21031. /**
  21032. * If you don't want to use the default VR button of the helper. (default: false)
  21033. */
  21034. useCustomVRButton?: boolean;
  21035. /**
  21036. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  21037. */
  21038. customVRButton?: HTMLButtonElement;
  21039. /**
  21040. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  21041. */
  21042. rayLength?: number;
  21043. /**
  21044. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  21045. */
  21046. defaultHeight?: number;
  21047. /**
  21048. * If multiview should be used if availible (default: false)
  21049. */
  21050. useMultiview?: boolean;
  21051. }
  21052. /**
  21053. * This represents a WebVR camera.
  21054. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  21055. * @example https://doc.babylonjs.com/how_to/webvr_camera
  21056. */
  21057. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  21058. private webVROptions;
  21059. /**
  21060. * @hidden
  21061. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  21062. */
  21063. _vrDevice: any;
  21064. /**
  21065. * The rawPose of the vrDevice.
  21066. */
  21067. rawPose: Nullable<DevicePose>;
  21068. private _onVREnabled;
  21069. private _specsVersion;
  21070. private _attached;
  21071. private _frameData;
  21072. protected _descendants: Array<Node>;
  21073. private _deviceRoomPosition;
  21074. /** @hidden */
  21075. _deviceRoomRotationQuaternion: Quaternion;
  21076. private _standingMatrix;
  21077. /**
  21078. * Represents device position in babylon space.
  21079. */
  21080. devicePosition: Vector3;
  21081. /**
  21082. * Represents device rotation in babylon space.
  21083. */
  21084. deviceRotationQuaternion: Quaternion;
  21085. /**
  21086. * The scale of the device to be used when translating from device space to babylon space.
  21087. */
  21088. deviceScaleFactor: number;
  21089. private _deviceToWorld;
  21090. private _worldToDevice;
  21091. /**
  21092. * References to the webVR controllers for the vrDevice.
  21093. */
  21094. controllers: Array<WebVRController>;
  21095. /**
  21096. * Emits an event when a controller is attached.
  21097. */
  21098. onControllersAttachedObservable: Observable<WebVRController[]>;
  21099. /**
  21100. * Emits an event when a controller's mesh has been loaded;
  21101. */
  21102. onControllerMeshLoadedObservable: Observable<WebVRController>;
  21103. /**
  21104. * Emits an event when the HMD's pose has been updated.
  21105. */
  21106. onPoseUpdatedFromDeviceObservable: Observable<any>;
  21107. private _poseSet;
  21108. /**
  21109. * If the rig cameras be used as parent instead of this camera.
  21110. */
  21111. rigParenting: boolean;
  21112. private _lightOnControllers;
  21113. private _defaultHeight?;
  21114. /**
  21115. * Instantiates a WebVRFreeCamera.
  21116. * @param name The name of the WebVRFreeCamera
  21117. * @param position The starting anchor position for the camera
  21118. * @param scene The scene the camera belongs to
  21119. * @param webVROptions a set of customizable options for the webVRCamera
  21120. */
  21121. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  21122. /**
  21123. * Gets the device distance from the ground in meters.
  21124. * @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.
  21125. */
  21126. deviceDistanceToRoomGround(): number;
  21127. /**
  21128. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21129. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  21130. */
  21131. useStandingMatrix(callback?: (bool: boolean) => void): void;
  21132. /**
  21133. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21134. * @returns A promise with a boolean set to if the standing matrix is supported.
  21135. */
  21136. useStandingMatrixAsync(): Promise<boolean>;
  21137. /**
  21138. * Disposes the camera
  21139. */
  21140. dispose(): void;
  21141. /**
  21142. * Gets a vrController by name.
  21143. * @param name The name of the controller to retreive
  21144. * @returns the controller matching the name specified or null if not found
  21145. */
  21146. getControllerByName(name: string): Nullable<WebVRController>;
  21147. private _leftController;
  21148. /**
  21149. * The controller corresponding to the users left hand.
  21150. */
  21151. get leftController(): Nullable<WebVRController>;
  21152. private _rightController;
  21153. /**
  21154. * The controller corresponding to the users right hand.
  21155. */
  21156. get rightController(): Nullable<WebVRController>;
  21157. /**
  21158. * Casts a ray forward from the vrCamera's gaze.
  21159. * @param length Length of the ray (default: 100)
  21160. * @returns the ray corresponding to the gaze
  21161. */
  21162. getForwardRay(length?: number): Ray;
  21163. /**
  21164. * @hidden
  21165. * Updates the camera based on device's frame data
  21166. */
  21167. _checkInputs(): void;
  21168. /**
  21169. * Updates the poseControlled values based on the input device pose.
  21170. * @param poseData Pose coming from the device
  21171. */
  21172. updateFromDevice(poseData: DevicePose): void;
  21173. private _detachIfAttached;
  21174. /**
  21175. * WebVR's attach control will start broadcasting frames to the device.
  21176. * Note that in certain browsers (chrome for example) this function must be called
  21177. * within a user-interaction callback. Example:
  21178. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  21179. *
  21180. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  21181. */
  21182. attachControl(noPreventDefault?: boolean): void;
  21183. /**
  21184. * Detach the current controls from the specified dom element.
  21185. */
  21186. detachControl(): void;
  21187. /**
  21188. * @returns the name of this class
  21189. */
  21190. getClassName(): string;
  21191. /**
  21192. * Calls resetPose on the vrDisplay
  21193. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  21194. */
  21195. resetToCurrentRotation(): void;
  21196. /**
  21197. * @hidden
  21198. * Updates the rig cameras (left and right eye)
  21199. */
  21200. _updateRigCameras(): void;
  21201. private _workingVector;
  21202. private _oneVector;
  21203. private _workingMatrix;
  21204. private updateCacheCalled;
  21205. private _correctPositionIfNotTrackPosition;
  21206. /**
  21207. * @hidden
  21208. * Updates the cached values of the camera
  21209. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  21210. */
  21211. _updateCache(ignoreParentClass?: boolean): void;
  21212. /**
  21213. * @hidden
  21214. * Get current device position in babylon world
  21215. */
  21216. _computeDevicePosition(): void;
  21217. /**
  21218. * Updates the current device position and rotation in the babylon world
  21219. */
  21220. update(): void;
  21221. /**
  21222. * @hidden
  21223. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  21224. * @returns an identity matrix
  21225. */
  21226. _getViewMatrix(): Matrix;
  21227. private _tmpMatrix;
  21228. /**
  21229. * This function is called by the two RIG cameras.
  21230. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  21231. * @hidden
  21232. */
  21233. _getWebVRViewMatrix(): Matrix;
  21234. /** @hidden */
  21235. _getWebVRProjectionMatrix(): Matrix;
  21236. private _onGamepadConnectedObserver;
  21237. private _onGamepadDisconnectedObserver;
  21238. private _updateCacheWhenTrackingDisabledObserver;
  21239. /**
  21240. * Initializes the controllers and their meshes
  21241. */
  21242. initControllers(): void;
  21243. }
  21244. }
  21245. declare module "babylonjs/Materials/materialHelper" {
  21246. import { Nullable } from "babylonjs/types";
  21247. import { Scene } from "babylonjs/scene";
  21248. import { Engine } from "babylonjs/Engines/engine";
  21249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21250. import { Light } from "babylonjs/Lights/light";
  21251. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21252. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21253. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  21254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21255. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21256. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21257. /**
  21258. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  21259. *
  21260. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  21261. *
  21262. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  21263. */
  21264. export class MaterialHelper {
  21265. /**
  21266. * Bind the current view position to an effect.
  21267. * @param effect The effect to be bound
  21268. * @param scene The scene the eyes position is used from
  21269. * @param variableName name of the shader variable that will hold the eye position
  21270. */
  21271. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  21272. /**
  21273. * Helps preparing the defines values about the UVs in used in the effect.
  21274. * UVs are shared as much as we can accross channels in the shaders.
  21275. * @param texture The texture we are preparing the UVs for
  21276. * @param defines The defines to update
  21277. * @param key The channel key "diffuse", "specular"... used in the shader
  21278. */
  21279. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21280. /**
  21281. * Binds a texture matrix value to its corrsponding uniform
  21282. * @param texture The texture to bind the matrix for
  21283. * @param uniformBuffer The uniform buffer receivin the data
  21284. * @param key The channel key "diffuse", "specular"... used in the shader
  21285. */
  21286. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21287. /**
  21288. * Gets the current status of the fog (should it be enabled?)
  21289. * @param mesh defines the mesh to evaluate for fog support
  21290. * @param scene defines the hosting scene
  21291. * @returns true if fog must be enabled
  21292. */
  21293. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21294. /**
  21295. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21296. * @param mesh defines the current mesh
  21297. * @param scene defines the current scene
  21298. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21299. * @param pointsCloud defines if point cloud rendering has to be turned on
  21300. * @param fogEnabled defines if fog has to be turned on
  21301. * @param alphaTest defines if alpha testing has to be turned on
  21302. * @param defines defines the current list of defines
  21303. */
  21304. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21305. /**
  21306. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21307. * @param scene defines the current scene
  21308. * @param engine defines the current engine
  21309. * @param defines specifies the list of active defines
  21310. * @param useInstances defines if instances have to be turned on
  21311. * @param useClipPlane defines if clip plane have to be turned on
  21312. * @param useInstances defines if instances have to be turned on
  21313. * @param useThinInstances defines if thin instances have to be turned on
  21314. */
  21315. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21316. /**
  21317. * Prepares the defines for bones
  21318. * @param mesh The mesh containing the geometry data we will draw
  21319. * @param defines The defines to update
  21320. */
  21321. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21322. /**
  21323. * Prepares the defines for morph targets
  21324. * @param mesh The mesh containing the geometry data we will draw
  21325. * @param defines The defines to update
  21326. */
  21327. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21328. /**
  21329. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21330. * @param mesh The mesh containing the geometry data we will draw
  21331. * @param defines The defines to update
  21332. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21333. * @param useBones Precise whether bones should be used or not (override mesh info)
  21334. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21335. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21336. * @returns false if defines are considered not dirty and have not been checked
  21337. */
  21338. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21339. /**
  21340. * Prepares the defines related to multiview
  21341. * @param scene The scene we are intending to draw
  21342. * @param defines The defines to update
  21343. */
  21344. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21345. /**
  21346. * Prepares the defines related to the prepass
  21347. * @param scene The scene we are intending to draw
  21348. * @param defines The defines to update
  21349. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21350. */
  21351. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21352. /**
  21353. * Prepares the defines related to the light information passed in parameter
  21354. * @param scene The scene we are intending to draw
  21355. * @param mesh The mesh the effect is compiling for
  21356. * @param light The light the effect is compiling for
  21357. * @param lightIndex The index of the light
  21358. * @param defines The defines to update
  21359. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21360. * @param state Defines the current state regarding what is needed (normals, etc...)
  21361. */
  21362. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21363. needNormals: boolean;
  21364. needRebuild: boolean;
  21365. shadowEnabled: boolean;
  21366. specularEnabled: boolean;
  21367. lightmapMode: boolean;
  21368. }): void;
  21369. /**
  21370. * Prepares the defines related to the light information passed in parameter
  21371. * @param scene The scene we are intending to draw
  21372. * @param mesh The mesh the effect is compiling for
  21373. * @param defines The defines to update
  21374. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21375. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21376. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21377. * @returns true if normals will be required for the rest of the effect
  21378. */
  21379. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21380. /**
  21381. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21382. * @param lightIndex defines the light index
  21383. * @param uniformsList The uniform list
  21384. * @param samplersList The sampler list
  21385. * @param projectedLightTexture defines if projected texture must be used
  21386. * @param uniformBuffersList defines an optional list of uniform buffers
  21387. */
  21388. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21389. /**
  21390. * Prepares the uniforms and samplers list to be used in the effect
  21391. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21392. * @param samplersList The sampler list
  21393. * @param defines The defines helping in the list generation
  21394. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21395. */
  21396. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21397. /**
  21398. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21399. * @param defines The defines to update while falling back
  21400. * @param fallbacks The authorized effect fallbacks
  21401. * @param maxSimultaneousLights The maximum number of lights allowed
  21402. * @param rank the current rank of the Effect
  21403. * @returns The newly affected rank
  21404. */
  21405. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21406. private static _TmpMorphInfluencers;
  21407. /**
  21408. * Prepares the list of attributes required for morph targets according to the effect defines.
  21409. * @param attribs The current list of supported attribs
  21410. * @param mesh The mesh to prepare the morph targets attributes for
  21411. * @param influencers The number of influencers
  21412. */
  21413. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21414. /**
  21415. * Prepares the list of attributes required for morph targets according to the effect defines.
  21416. * @param attribs The current list of supported attribs
  21417. * @param mesh The mesh to prepare the morph targets attributes for
  21418. * @param defines The current Defines of the effect
  21419. */
  21420. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21421. /**
  21422. * Prepares the list of attributes required for bones according to the effect defines.
  21423. * @param attribs The current list of supported attribs
  21424. * @param mesh The mesh to prepare the bones attributes for
  21425. * @param defines The current Defines of the effect
  21426. * @param fallbacks The current efffect fallback strategy
  21427. */
  21428. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21429. /**
  21430. * Check and prepare the list of attributes required for instances according to the effect defines.
  21431. * @param attribs The current list of supported attribs
  21432. * @param defines The current MaterialDefines of the effect
  21433. */
  21434. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21435. /**
  21436. * Add the list of attributes required for instances to the attribs array.
  21437. * @param attribs The current list of supported attribs
  21438. */
  21439. static PushAttributesForInstances(attribs: string[]): void;
  21440. /**
  21441. * Binds the light information to the effect.
  21442. * @param light The light containing the generator
  21443. * @param effect The effect we are binding the data to
  21444. * @param lightIndex The light index in the effect used to render
  21445. */
  21446. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21447. /**
  21448. * Binds the lights information from the scene to the effect for the given mesh.
  21449. * @param light Light to bind
  21450. * @param lightIndex Light index
  21451. * @param scene The scene where the light belongs to
  21452. * @param effect The effect we are binding the data to
  21453. * @param useSpecular Defines if specular is supported
  21454. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21455. */
  21456. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21457. /**
  21458. * Binds the lights information from the scene to the effect for the given mesh.
  21459. * @param scene The scene the lights belongs to
  21460. * @param mesh The mesh we are binding the information to render
  21461. * @param effect The effect we are binding the data to
  21462. * @param defines The generated defines for the effect
  21463. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21464. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21465. */
  21466. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21467. private static _tempFogColor;
  21468. /**
  21469. * Binds the fog information from the scene to the effect for the given mesh.
  21470. * @param scene The scene the lights belongs to
  21471. * @param mesh The mesh we are binding the information to render
  21472. * @param effect The effect we are binding the data to
  21473. * @param linearSpace Defines if the fog effect is applied in linear space
  21474. */
  21475. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21476. /**
  21477. * Binds the bones information from the mesh to the effect.
  21478. * @param mesh The mesh we are binding the information to render
  21479. * @param effect The effect we are binding the data to
  21480. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21481. */
  21482. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21483. private static _CopyBonesTransformationMatrices;
  21484. /**
  21485. * Binds the morph targets information from the mesh to the effect.
  21486. * @param abstractMesh The mesh we are binding the information to render
  21487. * @param effect The effect we are binding the data to
  21488. */
  21489. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21490. /**
  21491. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21492. * @param defines The generated defines used in the effect
  21493. * @param effect The effect we are binding the data to
  21494. * @param scene The scene we are willing to render with logarithmic scale for
  21495. */
  21496. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21497. /**
  21498. * Binds the clip plane information from the scene to the effect.
  21499. * @param scene The scene the clip plane information are extracted from
  21500. * @param effect The effect we are binding the data to
  21501. */
  21502. static BindClipPlane(effect: Effect, scene: Scene): void;
  21503. }
  21504. }
  21505. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21507. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21508. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21509. import { Nullable } from "babylonjs/types";
  21510. import { Effect } from "babylonjs/Materials/effect";
  21511. import { Matrix } from "babylonjs/Maths/math.vector";
  21512. import { Scene } from "babylonjs/scene";
  21513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21515. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21516. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21517. import { Observable } from "babylonjs/Misc/observable";
  21518. /**
  21519. * Block used to expose an input value
  21520. */
  21521. export class InputBlock extends NodeMaterialBlock {
  21522. private _mode;
  21523. private _associatedVariableName;
  21524. private _storedValue;
  21525. private _valueCallback;
  21526. private _type;
  21527. private _animationType;
  21528. /** Gets or set a value used to limit the range of float values */
  21529. min: number;
  21530. /** Gets or set a value used to limit the range of float values */
  21531. max: number;
  21532. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21533. isBoolean: boolean;
  21534. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21535. matrixMode: number;
  21536. /** @hidden */
  21537. _systemValue: Nullable<NodeMaterialSystemValues>;
  21538. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21539. isConstant: boolean;
  21540. /** Gets or sets the group to use to display this block in the Inspector */
  21541. groupInInspector: string;
  21542. /** Gets an observable raised when the value is changed */
  21543. onValueChangedObservable: Observable<InputBlock>;
  21544. /**
  21545. * Gets or sets the connection point type (default is float)
  21546. */
  21547. get type(): NodeMaterialBlockConnectionPointTypes;
  21548. /**
  21549. * Creates a new InputBlock
  21550. * @param name defines the block name
  21551. * @param target defines the target of that block (Vertex by default)
  21552. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21553. */
  21554. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21555. /**
  21556. * Validates if a name is a reserve word.
  21557. * @param newName the new name to be given to the node.
  21558. * @returns false if the name is a reserve word, else true.
  21559. */
  21560. validateBlockName(newName: string): boolean;
  21561. /**
  21562. * Gets the output component
  21563. */
  21564. get output(): NodeMaterialConnectionPoint;
  21565. /**
  21566. * Set the source of this connection point to a vertex attribute
  21567. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21568. * @returns the current connection point
  21569. */
  21570. setAsAttribute(attributeName?: string): InputBlock;
  21571. /**
  21572. * Set the source of this connection point to a system value
  21573. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21574. * @returns the current connection point
  21575. */
  21576. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21577. /**
  21578. * Gets or sets the value of that point.
  21579. * Please note that this value will be ignored if valueCallback is defined
  21580. */
  21581. get value(): any;
  21582. set value(value: any);
  21583. /**
  21584. * Gets or sets a callback used to get the value of that point.
  21585. * Please note that setting this value will force the connection point to ignore the value property
  21586. */
  21587. get valueCallback(): () => any;
  21588. set valueCallback(value: () => any);
  21589. /**
  21590. * Gets or sets the associated variable name in the shader
  21591. */
  21592. get associatedVariableName(): string;
  21593. set associatedVariableName(value: string);
  21594. /** Gets or sets the type of animation applied to the input */
  21595. get animationType(): AnimatedInputBlockTypes;
  21596. set animationType(value: AnimatedInputBlockTypes);
  21597. /**
  21598. * Gets a boolean indicating that this connection point not defined yet
  21599. */
  21600. get isUndefined(): boolean;
  21601. /**
  21602. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21603. * In this case the connection point name must be the name of the uniform to use.
  21604. * Can only be set on inputs
  21605. */
  21606. get isUniform(): boolean;
  21607. set isUniform(value: boolean);
  21608. /**
  21609. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21610. * In this case the connection point name must be the name of the attribute to use
  21611. * Can only be set on inputs
  21612. */
  21613. get isAttribute(): boolean;
  21614. set isAttribute(value: boolean);
  21615. /**
  21616. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21617. * Can only be set on exit points
  21618. */
  21619. get isVarying(): boolean;
  21620. set isVarying(value: boolean);
  21621. /**
  21622. * Gets a boolean indicating that the current connection point is a system value
  21623. */
  21624. get isSystemValue(): boolean;
  21625. /**
  21626. * Gets or sets the current well known value or null if not defined as a system value
  21627. */
  21628. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21629. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21630. /**
  21631. * Gets the current class name
  21632. * @returns the class name
  21633. */
  21634. getClassName(): string;
  21635. /**
  21636. * Animate the input if animationType !== None
  21637. * @param scene defines the rendering scene
  21638. */
  21639. animate(scene: Scene): void;
  21640. private _emitDefine;
  21641. initialize(state: NodeMaterialBuildState): void;
  21642. /**
  21643. * Set the input block to its default value (based on its type)
  21644. */
  21645. setDefaultValue(): void;
  21646. private _emitConstant;
  21647. /** @hidden */
  21648. get _noContextSwitch(): boolean;
  21649. private _emit;
  21650. /** @hidden */
  21651. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21652. /** @hidden */
  21653. _transmit(effect: Effect, scene: Scene): void;
  21654. protected _buildBlock(state: NodeMaterialBuildState): void;
  21655. protected _dumpPropertiesCode(): string;
  21656. dispose(): void;
  21657. serialize(): any;
  21658. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21659. }
  21660. }
  21661. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21662. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21663. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21664. import { Nullable } from "babylonjs/types";
  21665. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21666. import { Observable } from "babylonjs/Misc/observable";
  21667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21668. /**
  21669. * Enum used to define the compatibility state between two connection points
  21670. */
  21671. export enum NodeMaterialConnectionPointCompatibilityStates {
  21672. /** Points are compatibles */
  21673. Compatible = 0,
  21674. /** Points are incompatible because of their types */
  21675. TypeIncompatible = 1,
  21676. /** Points are incompatible because of their targets (vertex vs fragment) */
  21677. TargetIncompatible = 2
  21678. }
  21679. /**
  21680. * Defines the direction of a connection point
  21681. */
  21682. export enum NodeMaterialConnectionPointDirection {
  21683. /** Input */
  21684. Input = 0,
  21685. /** Output */
  21686. Output = 1
  21687. }
  21688. /**
  21689. * Defines a connection point for a block
  21690. */
  21691. export class NodeMaterialConnectionPoint {
  21692. /**
  21693. * Checks if two types are equivalent
  21694. * @param type1 type 1 to check
  21695. * @param type2 type 2 to check
  21696. * @returns true if both types are equivalent, else false
  21697. */
  21698. static AreEquivalentTypes(type1: number, type2: number): boolean;
  21699. /** @hidden */
  21700. _ownerBlock: NodeMaterialBlock;
  21701. /** @hidden */
  21702. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21703. private _endpoints;
  21704. private _associatedVariableName;
  21705. private _direction;
  21706. /** @hidden */
  21707. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21708. /** @hidden */
  21709. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21710. /** @hidden */
  21711. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  21712. private _type;
  21713. /** @hidden */
  21714. _enforceAssociatedVariableName: boolean;
  21715. /** Gets the direction of the point */
  21716. get direction(): NodeMaterialConnectionPointDirection;
  21717. /** Indicates that this connection point needs dual validation before being connected to another point */
  21718. needDualDirectionValidation: boolean;
  21719. /**
  21720. * Gets or sets the additional types supported by this connection point
  21721. */
  21722. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21723. /**
  21724. * Gets or sets the additional types excluded by this connection point
  21725. */
  21726. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21727. /**
  21728. * Observable triggered when this point is connected
  21729. */
  21730. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21731. /**
  21732. * Gets or sets the associated variable name in the shader
  21733. */
  21734. get associatedVariableName(): string;
  21735. set associatedVariableName(value: string);
  21736. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21737. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21738. /**
  21739. * Gets or sets the connection point type (default is float)
  21740. */
  21741. get type(): NodeMaterialBlockConnectionPointTypes;
  21742. set type(value: NodeMaterialBlockConnectionPointTypes);
  21743. /**
  21744. * Gets or sets the connection point name
  21745. */
  21746. name: string;
  21747. /**
  21748. * Gets or sets the connection point name
  21749. */
  21750. displayName: string;
  21751. /**
  21752. * Gets or sets a boolean indicating that this connection point can be omitted
  21753. */
  21754. isOptional: boolean;
  21755. /**
  21756. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21757. */
  21758. isExposedOnFrame: boolean;
  21759. /**
  21760. * Gets or sets number indicating the position that the port is exposed to on a frame
  21761. */
  21762. exposedPortPosition: number;
  21763. /**
  21764. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21765. */
  21766. define: string;
  21767. /** @hidden */
  21768. _prioritizeVertex: boolean;
  21769. private _target;
  21770. /** Gets or sets the target of that connection point */
  21771. get target(): NodeMaterialBlockTargets;
  21772. set target(value: NodeMaterialBlockTargets);
  21773. /**
  21774. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21775. */
  21776. get isConnected(): boolean;
  21777. /**
  21778. * Gets a boolean indicating that the current point is connected to an input block
  21779. */
  21780. get isConnectedToInputBlock(): boolean;
  21781. /**
  21782. * Gets a the connected input block (if any)
  21783. */
  21784. get connectInputBlock(): Nullable<InputBlock>;
  21785. /** Get the other side of the connection (if any) */
  21786. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21787. /** Get the block that owns this connection point */
  21788. get ownerBlock(): NodeMaterialBlock;
  21789. /** Get the block connected on the other side of this connection (if any) */
  21790. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21791. /** Get the block connected on the endpoints of this connection (if any) */
  21792. get connectedBlocks(): Array<NodeMaterialBlock>;
  21793. /** Gets the list of connected endpoints */
  21794. get endpoints(): NodeMaterialConnectionPoint[];
  21795. /** Gets a boolean indicating if that output point is connected to at least one input */
  21796. get hasEndpoints(): boolean;
  21797. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21798. get isConnectedInVertexShader(): boolean;
  21799. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21800. get isConnectedInFragmentShader(): boolean;
  21801. /**
  21802. * Creates a block suitable to be used as an input for this input point.
  21803. * If null is returned, a block based on the point type will be created.
  21804. * @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
  21805. */
  21806. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21807. /**
  21808. * Creates a new connection point
  21809. * @param name defines the connection point name
  21810. * @param ownerBlock defines the block hosting this connection point
  21811. * @param direction defines the direction of the connection point
  21812. */
  21813. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21814. /**
  21815. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21816. * @returns the class name
  21817. */
  21818. getClassName(): string;
  21819. /**
  21820. * Gets a boolean indicating if the current point can be connected to another point
  21821. * @param connectionPoint defines the other connection point
  21822. * @returns a boolean
  21823. */
  21824. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21825. /**
  21826. * Gets a number indicating if the current point can be connected to another point
  21827. * @param connectionPoint defines the other connection point
  21828. * @returns a number defining the compatibility state
  21829. */
  21830. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21831. /**
  21832. * Connect this point to another connection point
  21833. * @param connectionPoint defines the other connection point
  21834. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21835. * @returns the current connection point
  21836. */
  21837. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21838. /**
  21839. * Disconnect this point from one of his endpoint
  21840. * @param endpoint defines the other connection point
  21841. * @returns the current connection point
  21842. */
  21843. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21844. /**
  21845. * Serializes this point in a JSON representation
  21846. * @param isInput defines if the connection point is an input (default is true)
  21847. * @returns the serialized point object
  21848. */
  21849. serialize(isInput?: boolean): any;
  21850. /**
  21851. * Release resources
  21852. */
  21853. dispose(): void;
  21854. }
  21855. }
  21856. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21857. /**
  21858. * Enum used to define the material modes
  21859. */
  21860. export enum NodeMaterialModes {
  21861. /** Regular material */
  21862. Material = 0,
  21863. /** For post process */
  21864. PostProcess = 1,
  21865. /** For particle system */
  21866. Particle = 2,
  21867. /** For procedural texture */
  21868. ProceduralTexture = 3
  21869. }
  21870. }
  21871. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21874. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21877. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21878. import { Effect } from "babylonjs/Materials/effect";
  21879. import { Mesh } from "babylonjs/Meshes/mesh";
  21880. import { Nullable } from "babylonjs/types";
  21881. import { Texture } from "babylonjs/Materials/Textures/texture";
  21882. import { Scene } from "babylonjs/scene";
  21883. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21884. /**
  21885. * Block used to read a texture from a sampler
  21886. */
  21887. export class TextureBlock extends NodeMaterialBlock {
  21888. private _defineName;
  21889. private _linearDefineName;
  21890. private _gammaDefineName;
  21891. private _tempTextureRead;
  21892. private _samplerName;
  21893. private _transformedUVName;
  21894. private _textureTransformName;
  21895. private _textureInfoName;
  21896. private _mainUVName;
  21897. private _mainUVDefineName;
  21898. private _fragmentOnly;
  21899. /**
  21900. * Gets or sets the texture associated with the node
  21901. */
  21902. texture: Nullable<Texture>;
  21903. /**
  21904. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21905. */
  21906. convertToGammaSpace: boolean;
  21907. /**
  21908. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21909. */
  21910. convertToLinearSpace: boolean;
  21911. /**
  21912. * Create a new TextureBlock
  21913. * @param name defines the block name
  21914. */
  21915. constructor(name: string, fragmentOnly?: boolean);
  21916. /**
  21917. * Gets the current class name
  21918. * @returns the class name
  21919. */
  21920. getClassName(): string;
  21921. /**
  21922. * Gets the uv input component
  21923. */
  21924. get uv(): NodeMaterialConnectionPoint;
  21925. /**
  21926. * Gets the rgba output component
  21927. */
  21928. get rgba(): NodeMaterialConnectionPoint;
  21929. /**
  21930. * Gets the rgb output component
  21931. */
  21932. get rgb(): NodeMaterialConnectionPoint;
  21933. /**
  21934. * Gets the r output component
  21935. */
  21936. get r(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the g output component
  21939. */
  21940. get g(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the b output component
  21943. */
  21944. get b(): NodeMaterialConnectionPoint;
  21945. /**
  21946. * Gets the a output component
  21947. */
  21948. get a(): NodeMaterialConnectionPoint;
  21949. get target(): NodeMaterialBlockTargets;
  21950. autoConfigure(material: NodeMaterial): void;
  21951. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21953. isReady(): boolean;
  21954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21955. private get _isMixed();
  21956. private _injectVertexCode;
  21957. private _writeTextureRead;
  21958. private _writeOutput;
  21959. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21960. protected _dumpPropertiesCode(): string;
  21961. serialize(): any;
  21962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21963. }
  21964. }
  21965. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21966. /** @hidden */
  21967. export var reflectionFunction: {
  21968. name: string;
  21969. shader: string;
  21970. };
  21971. }
  21972. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21978. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21979. import { Effect } from "babylonjs/Materials/effect";
  21980. import { Mesh } from "babylonjs/Meshes/mesh";
  21981. import { Nullable } from "babylonjs/types";
  21982. import { Scene } from "babylonjs/scene";
  21983. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21984. /**
  21985. * Base block used to read a reflection texture from a sampler
  21986. */
  21987. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21988. /** @hidden */
  21989. _define3DName: string;
  21990. /** @hidden */
  21991. _defineCubicName: string;
  21992. /** @hidden */
  21993. _defineExplicitName: string;
  21994. /** @hidden */
  21995. _defineProjectionName: string;
  21996. /** @hidden */
  21997. _defineLocalCubicName: string;
  21998. /** @hidden */
  21999. _defineSphericalName: string;
  22000. /** @hidden */
  22001. _definePlanarName: string;
  22002. /** @hidden */
  22003. _defineEquirectangularName: string;
  22004. /** @hidden */
  22005. _defineMirroredEquirectangularFixedName: string;
  22006. /** @hidden */
  22007. _defineEquirectangularFixedName: string;
  22008. /** @hidden */
  22009. _defineSkyboxName: string;
  22010. /** @hidden */
  22011. _defineOppositeZ: string;
  22012. /** @hidden */
  22013. _cubeSamplerName: string;
  22014. /** @hidden */
  22015. _2DSamplerName: string;
  22016. protected _positionUVWName: string;
  22017. protected _directionWName: string;
  22018. protected _reflectionVectorName: string;
  22019. /** @hidden */
  22020. _reflectionCoordsName: string;
  22021. /** @hidden */
  22022. _reflectionMatrixName: string;
  22023. protected _reflectionColorName: string;
  22024. /**
  22025. * Gets or sets the texture associated with the node
  22026. */
  22027. texture: Nullable<BaseTexture>;
  22028. /**
  22029. * Create a new ReflectionTextureBaseBlock
  22030. * @param name defines the block name
  22031. */
  22032. constructor(name: string);
  22033. /**
  22034. * Gets the current class name
  22035. * @returns the class name
  22036. */
  22037. getClassName(): string;
  22038. /**
  22039. * Gets the world position input component
  22040. */
  22041. abstract get position(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Gets the world position input component
  22044. */
  22045. abstract get worldPosition(): NodeMaterialConnectionPoint;
  22046. /**
  22047. * Gets the world normal input component
  22048. */
  22049. abstract get worldNormal(): NodeMaterialConnectionPoint;
  22050. /**
  22051. * Gets the world input component
  22052. */
  22053. abstract get world(): NodeMaterialConnectionPoint;
  22054. /**
  22055. * Gets the camera (or eye) position component
  22056. */
  22057. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  22058. /**
  22059. * Gets the view input component
  22060. */
  22061. abstract get view(): NodeMaterialConnectionPoint;
  22062. protected _getTexture(): Nullable<BaseTexture>;
  22063. autoConfigure(material: NodeMaterial): void;
  22064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22065. isReady(): boolean;
  22066. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  22067. /**
  22068. * Gets the code to inject in the vertex shader
  22069. * @param state current state of the node material building
  22070. * @returns the shader code
  22071. */
  22072. handleVertexSide(state: NodeMaterialBuildState): string;
  22073. /**
  22074. * Handles the inits for the fragment code path
  22075. * @param state node material build state
  22076. */
  22077. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  22078. /**
  22079. * Generates the reflection coords code for the fragment code path
  22080. * @param worldNormalVarName name of the world normal variable
  22081. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  22082. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  22083. * @returns the shader code
  22084. */
  22085. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  22086. /**
  22087. * Generates the reflection color code for the fragment code path
  22088. * @param lodVarName name of the lod variable
  22089. * @param swizzleLookupTexture swizzle to use for the final color variable
  22090. * @returns the shader code
  22091. */
  22092. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  22093. /**
  22094. * Generates the code corresponding to the connected output points
  22095. * @param state node material build state
  22096. * @param varName name of the variable to output
  22097. * @returns the shader code
  22098. */
  22099. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  22100. protected _buildBlock(state: NodeMaterialBuildState): this;
  22101. protected _dumpPropertiesCode(): string;
  22102. serialize(): any;
  22103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22104. }
  22105. }
  22106. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  22107. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22108. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22109. import { Nullable } from "babylonjs/types";
  22110. /**
  22111. * Defines a connection point to be used for points with a custom object type
  22112. */
  22113. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  22114. private _blockType;
  22115. private _blockName;
  22116. private _nameForCheking?;
  22117. /**
  22118. * Creates a new connection point
  22119. * @param name defines the connection point name
  22120. * @param ownerBlock defines the block hosting this connection point
  22121. * @param direction defines the direction of the connection point
  22122. */
  22123. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  22124. /**
  22125. * Gets a number indicating if the current point can be connected to another point
  22126. * @param connectionPoint defines the other connection point
  22127. * @returns a number defining the compatibility state
  22128. */
  22129. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  22130. /**
  22131. * Creates a block suitable to be used as an input for this input point.
  22132. * If null is returned, a block based on the point type will be created.
  22133. * @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
  22134. */
  22135. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  22136. }
  22137. }
  22138. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  22139. /**
  22140. * Enum defining the type of properties that can be edited in the property pages in the NME
  22141. */
  22142. export enum PropertyTypeForEdition {
  22143. /** property is a boolean */
  22144. Boolean = 0,
  22145. /** property is a float */
  22146. Float = 1,
  22147. /** property is a Vector2 */
  22148. Vector2 = 2,
  22149. /** property is a list of values */
  22150. List = 3
  22151. }
  22152. /**
  22153. * Interface that defines an option in a variable of type list
  22154. */
  22155. export interface IEditablePropertyListOption {
  22156. /** label of the option */
  22157. "label": string;
  22158. /** value of the option */
  22159. "value": number;
  22160. }
  22161. /**
  22162. * Interface that defines the options available for an editable property
  22163. */
  22164. export interface IEditablePropertyOption {
  22165. /** min value */
  22166. "min"?: number;
  22167. /** max value */
  22168. "max"?: number;
  22169. /** notifiers: indicates which actions to take when the property is changed */
  22170. "notifiers"?: {
  22171. /** the material should be rebuilt */
  22172. "rebuild"?: boolean;
  22173. /** the preview should be updated */
  22174. "update"?: boolean;
  22175. };
  22176. /** list of the options for a variable of type list */
  22177. "options"?: IEditablePropertyListOption[];
  22178. }
  22179. /**
  22180. * Interface that describes an editable property
  22181. */
  22182. export interface IPropertyDescriptionForEdition {
  22183. /** name of the property */
  22184. "propertyName": string;
  22185. /** display name of the property */
  22186. "displayName": string;
  22187. /** type of the property */
  22188. "type": PropertyTypeForEdition;
  22189. /** group of the property - all properties with the same group value will be displayed in a specific section */
  22190. "groupName": string;
  22191. /** options for the property */
  22192. "options": IEditablePropertyOption;
  22193. }
  22194. /**
  22195. * Decorator that flags a property in a node material block as being editable
  22196. */
  22197. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  22198. }
  22199. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  22200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22202. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22204. import { Nullable } from "babylonjs/types";
  22205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22206. import { Mesh } from "babylonjs/Meshes/mesh";
  22207. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22208. import { Effect } from "babylonjs/Materials/effect";
  22209. import { Scene } from "babylonjs/scene";
  22210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22211. /**
  22212. * Block used to implement the refraction part of the sub surface module of the PBR material
  22213. */
  22214. export class RefractionBlock extends NodeMaterialBlock {
  22215. /** @hidden */
  22216. _define3DName: string;
  22217. /** @hidden */
  22218. _refractionMatrixName: string;
  22219. /** @hidden */
  22220. _defineLODRefractionAlpha: string;
  22221. /** @hidden */
  22222. _defineLinearSpecularRefraction: string;
  22223. /** @hidden */
  22224. _defineOppositeZ: string;
  22225. /** @hidden */
  22226. _cubeSamplerName: string;
  22227. /** @hidden */
  22228. _2DSamplerName: string;
  22229. /** @hidden */
  22230. _vRefractionMicrosurfaceInfosName: string;
  22231. /** @hidden */
  22232. _vRefractionInfosName: string;
  22233. private _scene;
  22234. /**
  22235. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22236. * Materials half opaque for instance using refraction could benefit from this control.
  22237. */
  22238. linkRefractionWithTransparency: boolean;
  22239. /**
  22240. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22241. */
  22242. invertRefractionY: boolean;
  22243. /**
  22244. * Gets or sets the texture associated with the node
  22245. */
  22246. texture: Nullable<BaseTexture>;
  22247. /**
  22248. * Create a new RefractionBlock
  22249. * @param name defines the block name
  22250. */
  22251. constructor(name: string);
  22252. /**
  22253. * Gets the current class name
  22254. * @returns the class name
  22255. */
  22256. getClassName(): string;
  22257. /**
  22258. * Gets the intensity input component
  22259. */
  22260. get intensity(): NodeMaterialConnectionPoint;
  22261. /**
  22262. * Gets the index of refraction input component
  22263. */
  22264. get indexOfRefraction(): NodeMaterialConnectionPoint;
  22265. /**
  22266. * Gets the tint at distance input component
  22267. */
  22268. get tintAtDistance(): NodeMaterialConnectionPoint;
  22269. /**
  22270. * Gets the view input component
  22271. */
  22272. get view(): NodeMaterialConnectionPoint;
  22273. /**
  22274. * Gets the refraction object output component
  22275. */
  22276. get refraction(): NodeMaterialConnectionPoint;
  22277. /**
  22278. * Returns true if the block has a texture
  22279. */
  22280. get hasTexture(): boolean;
  22281. protected _getTexture(): Nullable<BaseTexture>;
  22282. autoConfigure(material: NodeMaterial): void;
  22283. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22284. isReady(): boolean;
  22285. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22286. /**
  22287. * Gets the main code of the block (fragment side)
  22288. * @param state current state of the node material building
  22289. * @returns the shader code
  22290. */
  22291. getCode(state: NodeMaterialBuildState): string;
  22292. protected _buildBlock(state: NodeMaterialBuildState): this;
  22293. protected _dumpPropertiesCode(): string;
  22294. serialize(): any;
  22295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22296. }
  22297. }
  22298. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22300. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22301. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22304. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22306. import { Nullable } from "babylonjs/types";
  22307. import { Scene } from "babylonjs/scene";
  22308. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22309. /**
  22310. * Base block used as input for post process
  22311. */
  22312. export class CurrentScreenBlock extends NodeMaterialBlock {
  22313. private _samplerName;
  22314. private _linearDefineName;
  22315. private _gammaDefineName;
  22316. private _mainUVName;
  22317. private _tempTextureRead;
  22318. /**
  22319. * Gets or sets the texture associated with the node
  22320. */
  22321. texture: Nullable<BaseTexture>;
  22322. /**
  22323. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22324. */
  22325. convertToGammaSpace: boolean;
  22326. /**
  22327. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22328. */
  22329. convertToLinearSpace: boolean;
  22330. /**
  22331. * Create a new CurrentScreenBlock
  22332. * @param name defines the block name
  22333. */
  22334. constructor(name: string);
  22335. /**
  22336. * Gets the current class name
  22337. * @returns the class name
  22338. */
  22339. getClassName(): string;
  22340. /**
  22341. * Gets the uv input component
  22342. */
  22343. get uv(): NodeMaterialConnectionPoint;
  22344. /**
  22345. * Gets the rgba output component
  22346. */
  22347. get rgba(): NodeMaterialConnectionPoint;
  22348. /**
  22349. * Gets the rgb output component
  22350. */
  22351. get rgb(): NodeMaterialConnectionPoint;
  22352. /**
  22353. * Gets the r output component
  22354. */
  22355. get r(): NodeMaterialConnectionPoint;
  22356. /**
  22357. * Gets the g output component
  22358. */
  22359. get g(): NodeMaterialConnectionPoint;
  22360. /**
  22361. * Gets the b output component
  22362. */
  22363. get b(): NodeMaterialConnectionPoint;
  22364. /**
  22365. * Gets the a output component
  22366. */
  22367. get a(): NodeMaterialConnectionPoint;
  22368. /**
  22369. * Initialize the block and prepare the context for build
  22370. * @param state defines the state that will be used for the build
  22371. */
  22372. initialize(state: NodeMaterialBuildState): void;
  22373. get target(): NodeMaterialBlockTargets;
  22374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22375. isReady(): boolean;
  22376. private _injectVertexCode;
  22377. private _writeTextureRead;
  22378. private _writeOutput;
  22379. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22380. serialize(): any;
  22381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22382. }
  22383. }
  22384. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22389. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22391. import { Nullable } from "babylonjs/types";
  22392. import { Scene } from "babylonjs/scene";
  22393. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22394. /**
  22395. * Base block used for the particle texture
  22396. */
  22397. export class ParticleTextureBlock extends NodeMaterialBlock {
  22398. private _samplerName;
  22399. private _linearDefineName;
  22400. private _gammaDefineName;
  22401. private _tempTextureRead;
  22402. /**
  22403. * Gets or sets the texture associated with the node
  22404. */
  22405. texture: Nullable<BaseTexture>;
  22406. /**
  22407. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22408. */
  22409. convertToGammaSpace: boolean;
  22410. /**
  22411. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22412. */
  22413. convertToLinearSpace: boolean;
  22414. /**
  22415. * Create a new ParticleTextureBlock
  22416. * @param name defines the block name
  22417. */
  22418. constructor(name: string);
  22419. /**
  22420. * Gets the current class name
  22421. * @returns the class name
  22422. */
  22423. getClassName(): string;
  22424. /**
  22425. * Gets the uv input component
  22426. */
  22427. get uv(): NodeMaterialConnectionPoint;
  22428. /**
  22429. * Gets the rgba output component
  22430. */
  22431. get rgba(): NodeMaterialConnectionPoint;
  22432. /**
  22433. * Gets the rgb output component
  22434. */
  22435. get rgb(): NodeMaterialConnectionPoint;
  22436. /**
  22437. * Gets the r output component
  22438. */
  22439. get r(): NodeMaterialConnectionPoint;
  22440. /**
  22441. * Gets the g output component
  22442. */
  22443. get g(): NodeMaterialConnectionPoint;
  22444. /**
  22445. * Gets the b output component
  22446. */
  22447. get b(): NodeMaterialConnectionPoint;
  22448. /**
  22449. * Gets the a output component
  22450. */
  22451. get a(): NodeMaterialConnectionPoint;
  22452. /**
  22453. * Initialize the block and prepare the context for build
  22454. * @param state defines the state that will be used for the build
  22455. */
  22456. initialize(state: NodeMaterialBuildState): void;
  22457. autoConfigure(material: NodeMaterial): void;
  22458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22459. isReady(): boolean;
  22460. private _writeOutput;
  22461. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22462. serialize(): any;
  22463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22464. }
  22465. }
  22466. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22469. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22470. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22471. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22472. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22473. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22474. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22475. import { Scene } from "babylonjs/scene";
  22476. /**
  22477. * Class used to store shared data between 2 NodeMaterialBuildState
  22478. */
  22479. export class NodeMaterialBuildStateSharedData {
  22480. /**
  22481. * Gets the list of emitted varyings
  22482. */
  22483. temps: string[];
  22484. /**
  22485. * Gets the list of emitted varyings
  22486. */
  22487. varyings: string[];
  22488. /**
  22489. * Gets the varying declaration string
  22490. */
  22491. varyingDeclaration: string;
  22492. /**
  22493. * Input blocks
  22494. */
  22495. inputBlocks: InputBlock[];
  22496. /**
  22497. * Input blocks
  22498. */
  22499. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22500. /**
  22501. * Bindable blocks (Blocks that need to set data to the effect)
  22502. */
  22503. bindableBlocks: NodeMaterialBlock[];
  22504. /**
  22505. * List of blocks that can provide a compilation fallback
  22506. */
  22507. blocksWithFallbacks: NodeMaterialBlock[];
  22508. /**
  22509. * List of blocks that can provide a define update
  22510. */
  22511. blocksWithDefines: NodeMaterialBlock[];
  22512. /**
  22513. * List of blocks that can provide a repeatable content
  22514. */
  22515. repeatableContentBlocks: NodeMaterialBlock[];
  22516. /**
  22517. * List of blocks that can provide a dynamic list of uniforms
  22518. */
  22519. dynamicUniformBlocks: NodeMaterialBlock[];
  22520. /**
  22521. * List of blocks that can block the isReady function for the material
  22522. */
  22523. blockingBlocks: NodeMaterialBlock[];
  22524. /**
  22525. * Gets the list of animated inputs
  22526. */
  22527. animatedInputs: InputBlock[];
  22528. /**
  22529. * Build Id used to avoid multiple recompilations
  22530. */
  22531. buildId: number;
  22532. /** List of emitted variables */
  22533. variableNames: {
  22534. [key: string]: number;
  22535. };
  22536. /** List of emitted defines */
  22537. defineNames: {
  22538. [key: string]: number;
  22539. };
  22540. /** Should emit comments? */
  22541. emitComments: boolean;
  22542. /** Emit build activity */
  22543. verbose: boolean;
  22544. /** Gets or sets the hosting scene */
  22545. scene: Scene;
  22546. /**
  22547. * Gets the compilation hints emitted at compilation time
  22548. */
  22549. hints: {
  22550. needWorldViewMatrix: boolean;
  22551. needWorldViewProjectionMatrix: boolean;
  22552. needAlphaBlending: boolean;
  22553. needAlphaTesting: boolean;
  22554. };
  22555. /**
  22556. * List of compilation checks
  22557. */
  22558. checks: {
  22559. emitVertex: boolean;
  22560. emitFragment: boolean;
  22561. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22562. };
  22563. /**
  22564. * Is vertex program allowed to be empty?
  22565. */
  22566. allowEmptyVertexProgram: boolean;
  22567. /** Creates a new shared data */
  22568. constructor();
  22569. /**
  22570. * Emits console errors and exceptions if there is a failing check
  22571. */
  22572. emitErrors(): void;
  22573. }
  22574. }
  22575. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22576. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22577. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22578. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22579. /**
  22580. * Class used to store node based material build state
  22581. */
  22582. export class NodeMaterialBuildState {
  22583. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22584. supportUniformBuffers: boolean;
  22585. /**
  22586. * Gets the list of emitted attributes
  22587. */
  22588. attributes: string[];
  22589. /**
  22590. * Gets the list of emitted uniforms
  22591. */
  22592. uniforms: string[];
  22593. /**
  22594. * Gets the list of emitted constants
  22595. */
  22596. constants: string[];
  22597. /**
  22598. * Gets the list of emitted samplers
  22599. */
  22600. samplers: string[];
  22601. /**
  22602. * Gets the list of emitted functions
  22603. */
  22604. functions: {
  22605. [key: string]: string;
  22606. };
  22607. /**
  22608. * Gets the list of emitted extensions
  22609. */
  22610. extensions: {
  22611. [key: string]: string;
  22612. };
  22613. /**
  22614. * Gets the target of the compilation state
  22615. */
  22616. target: NodeMaterialBlockTargets;
  22617. /**
  22618. * Gets the list of emitted counters
  22619. */
  22620. counters: {
  22621. [key: string]: number;
  22622. };
  22623. /**
  22624. * Shared data between multiple NodeMaterialBuildState instances
  22625. */
  22626. sharedData: NodeMaterialBuildStateSharedData;
  22627. /** @hidden */
  22628. _vertexState: NodeMaterialBuildState;
  22629. /** @hidden */
  22630. _attributeDeclaration: string;
  22631. /** @hidden */
  22632. _uniformDeclaration: string;
  22633. /** @hidden */
  22634. _constantDeclaration: string;
  22635. /** @hidden */
  22636. _samplerDeclaration: string;
  22637. /** @hidden */
  22638. _varyingTransfer: string;
  22639. /** @hidden */
  22640. _injectAtEnd: string;
  22641. private _repeatableContentAnchorIndex;
  22642. /** @hidden */
  22643. _builtCompilationString: string;
  22644. /**
  22645. * Gets the emitted compilation strings
  22646. */
  22647. compilationString: string;
  22648. /**
  22649. * Finalize the compilation strings
  22650. * @param state defines the current compilation state
  22651. */
  22652. finalize(state: NodeMaterialBuildState): void;
  22653. /** @hidden */
  22654. get _repeatableContentAnchor(): string;
  22655. /** @hidden */
  22656. _getFreeVariableName(prefix: string): string;
  22657. /** @hidden */
  22658. _getFreeDefineName(prefix: string): string;
  22659. /** @hidden */
  22660. _excludeVariableName(name: string): void;
  22661. /** @hidden */
  22662. _emit2DSampler(name: string): void;
  22663. /** @hidden */
  22664. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22665. /** @hidden */
  22666. _emitExtension(name: string, extension: string, define?: string): void;
  22667. /** @hidden */
  22668. _emitFunction(name: string, code: string, comments: string): void;
  22669. /** @hidden */
  22670. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22671. replaceStrings?: {
  22672. search: RegExp;
  22673. replace: string;
  22674. }[];
  22675. repeatKey?: string;
  22676. }): string;
  22677. /** @hidden */
  22678. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22679. repeatKey?: string;
  22680. removeAttributes?: boolean;
  22681. removeUniforms?: boolean;
  22682. removeVaryings?: boolean;
  22683. removeIfDef?: boolean;
  22684. replaceStrings?: {
  22685. search: RegExp;
  22686. replace: string;
  22687. }[];
  22688. }, storeKey?: string): void;
  22689. /** @hidden */
  22690. _registerTempVariable(name: string): boolean;
  22691. /** @hidden */
  22692. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22693. /** @hidden */
  22694. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22695. /** @hidden */
  22696. _emitFloat(value: number): string;
  22697. }
  22698. }
  22699. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22700. /**
  22701. * Helper class used to generate session unique ID
  22702. */
  22703. export class UniqueIdGenerator {
  22704. private static _UniqueIdCounter;
  22705. /**
  22706. * Gets an unique (relatively to the current scene) Id
  22707. */
  22708. static get UniqueId(): number;
  22709. }
  22710. }
  22711. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22712. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22714. import { Nullable } from "babylonjs/types";
  22715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22716. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22717. import { Effect } from "babylonjs/Materials/effect";
  22718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22719. import { Mesh } from "babylonjs/Meshes/mesh";
  22720. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22721. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22722. import { Scene } from "babylonjs/scene";
  22723. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22724. /**
  22725. * Defines a block that can be used inside a node based material
  22726. */
  22727. export class NodeMaterialBlock {
  22728. private _buildId;
  22729. private _buildTarget;
  22730. private _target;
  22731. private _isFinalMerger;
  22732. private _isInput;
  22733. private _name;
  22734. protected _isUnique: boolean;
  22735. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22736. inputsAreExclusive: boolean;
  22737. /** @hidden */
  22738. _codeVariableName: string;
  22739. /** @hidden */
  22740. _inputs: NodeMaterialConnectionPoint[];
  22741. /** @hidden */
  22742. _outputs: NodeMaterialConnectionPoint[];
  22743. /** @hidden */
  22744. _preparationId: number;
  22745. /**
  22746. * Gets the name of the block
  22747. */
  22748. get name(): string;
  22749. /**
  22750. * Sets the name of the block. Will check if the name is valid.
  22751. */
  22752. set name(newName: string);
  22753. /**
  22754. * Gets or sets the unique id of the node
  22755. */
  22756. uniqueId: number;
  22757. /**
  22758. * Gets or sets the comments associated with this block
  22759. */
  22760. comments: string;
  22761. /**
  22762. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22763. */
  22764. get isUnique(): boolean;
  22765. /**
  22766. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22767. */
  22768. get isFinalMerger(): boolean;
  22769. /**
  22770. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22771. */
  22772. get isInput(): boolean;
  22773. /**
  22774. * Gets or sets the build Id
  22775. */
  22776. get buildId(): number;
  22777. set buildId(value: number);
  22778. /**
  22779. * Gets or sets the target of the block
  22780. */
  22781. get target(): NodeMaterialBlockTargets;
  22782. set target(value: NodeMaterialBlockTargets);
  22783. /**
  22784. * Gets the list of input points
  22785. */
  22786. get inputs(): NodeMaterialConnectionPoint[];
  22787. /** Gets the list of output points */
  22788. get outputs(): NodeMaterialConnectionPoint[];
  22789. /**
  22790. * Find an input by its name
  22791. * @param name defines the name of the input to look for
  22792. * @returns the input or null if not found
  22793. */
  22794. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22795. /**
  22796. * Find an output by its name
  22797. * @param name defines the name of the outputto look for
  22798. * @returns the output or null if not found
  22799. */
  22800. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22801. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22802. visibleInInspector: boolean;
  22803. /**
  22804. * Creates a new NodeMaterialBlock
  22805. * @param name defines the block name
  22806. * @param target defines the target of that block (Vertex by default)
  22807. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22808. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22809. */
  22810. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22811. /**
  22812. * Initialize the block and prepare the context for build
  22813. * @param state defines the state that will be used for the build
  22814. */
  22815. initialize(state: NodeMaterialBuildState): void;
  22816. /**
  22817. * Bind data to effect. Will only be called for blocks with isBindable === true
  22818. * @param effect defines the effect to bind data to
  22819. * @param nodeMaterial defines the hosting NodeMaterial
  22820. * @param mesh defines the mesh that will be rendered
  22821. * @param subMesh defines the submesh that will be rendered
  22822. */
  22823. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22824. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22825. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22826. protected _writeFloat(value: number): string;
  22827. /**
  22828. * Gets the current class name e.g. "NodeMaterialBlock"
  22829. * @returns the class name
  22830. */
  22831. getClassName(): string;
  22832. /**
  22833. * Register a new input. Must be called inside a block constructor
  22834. * @param name defines the connection point name
  22835. * @param type defines the connection point type
  22836. * @param isOptional defines a boolean indicating that this input can be omitted
  22837. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22838. * @param point an already created connection point. If not provided, create a new one
  22839. * @returns the current block
  22840. */
  22841. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22842. /**
  22843. * Register a new output. Must be called inside a block constructor
  22844. * @param name defines the connection point name
  22845. * @param type defines the connection point type
  22846. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22847. * @param point an already created connection point. If not provided, create a new one
  22848. * @returns the current block
  22849. */
  22850. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22851. /**
  22852. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22853. * @param forOutput defines an optional connection point to check compatibility with
  22854. * @returns the first available input or null
  22855. */
  22856. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22857. /**
  22858. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22859. * @param forBlock defines an optional block to check compatibility with
  22860. * @returns the first available input or null
  22861. */
  22862. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22863. /**
  22864. * Gets the sibling of the given output
  22865. * @param current defines the current output
  22866. * @returns the next output in the list or null
  22867. */
  22868. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22869. /**
  22870. * Connect current block with another block
  22871. * @param other defines the block to connect with
  22872. * @param options define the various options to help pick the right connections
  22873. * @returns the current block
  22874. */
  22875. connectTo(other: NodeMaterialBlock, options?: {
  22876. input?: string;
  22877. output?: string;
  22878. outputSwizzle?: string;
  22879. }): this | undefined;
  22880. protected _buildBlock(state: NodeMaterialBuildState): void;
  22881. /**
  22882. * Add uniforms, samplers and uniform buffers at compilation time
  22883. * @param state defines the state to update
  22884. * @param nodeMaterial defines the node material requesting the update
  22885. * @param defines defines the material defines to update
  22886. * @param uniformBuffers defines the list of uniform buffer names
  22887. */
  22888. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22889. /**
  22890. * Add potential fallbacks if shader compilation fails
  22891. * @param mesh defines the mesh to be rendered
  22892. * @param fallbacks defines the current prioritized list of fallbacks
  22893. */
  22894. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22895. /**
  22896. * Initialize defines for shader compilation
  22897. * @param mesh defines the mesh to be rendered
  22898. * @param nodeMaterial defines the node material requesting the update
  22899. * @param defines defines the material defines to update
  22900. * @param useInstances specifies that instances should be used
  22901. */
  22902. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22903. /**
  22904. * Update defines for shader compilation
  22905. * @param mesh defines the mesh to be rendered
  22906. * @param nodeMaterial defines the node material requesting the update
  22907. * @param defines defines the material defines to update
  22908. * @param useInstances specifies that instances should be used
  22909. * @param subMesh defines which submesh to render
  22910. */
  22911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22912. /**
  22913. * Lets the block try to connect some inputs automatically
  22914. * @param material defines the hosting NodeMaterial
  22915. */
  22916. autoConfigure(material: NodeMaterial): void;
  22917. /**
  22918. * Function called when a block is declared as repeatable content generator
  22919. * @param vertexShaderState defines the current compilation state for the vertex shader
  22920. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22921. * @param mesh defines the mesh to be rendered
  22922. * @param defines defines the material defines to update
  22923. */
  22924. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22925. /**
  22926. * Checks if the block is ready
  22927. * @param mesh defines the mesh to be rendered
  22928. * @param nodeMaterial defines the node material requesting the update
  22929. * @param defines defines the material defines to update
  22930. * @param useInstances specifies that instances should be used
  22931. * @returns true if the block is ready
  22932. */
  22933. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22934. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  22935. private _processBuild;
  22936. /**
  22937. * Validates the new name for the block node.
  22938. * @param newName the new name to be given to the node.
  22939. * @returns false if the name is a reserve word, else true.
  22940. */
  22941. validateBlockName(newName: string): boolean;
  22942. /**
  22943. * Compile the current node and generate the shader code
  22944. * @param state defines the current compilation state (uniforms, samplers, current string)
  22945. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22946. * @returns true if already built
  22947. */
  22948. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22949. protected _inputRename(name: string): string;
  22950. protected _outputRename(name: string): string;
  22951. protected _dumpPropertiesCode(): string;
  22952. /** @hidden */
  22953. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22954. /** @hidden */
  22955. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22956. /**
  22957. * Clone the current block to a new identical block
  22958. * @param scene defines the hosting scene
  22959. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22960. * @returns a copy of the current block
  22961. */
  22962. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22963. /**
  22964. * Serializes this block in a JSON representation
  22965. * @returns the serialized block object
  22966. */
  22967. serialize(): any;
  22968. /** @hidden */
  22969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22970. private _deserializePortDisplayNamesAndExposedOnFrame;
  22971. /**
  22972. * Release resources
  22973. */
  22974. dispose(): void;
  22975. }
  22976. }
  22977. declare module "babylonjs/Materials/pushMaterial" {
  22978. import { Nullable } from "babylonjs/types";
  22979. import { Scene } from "babylonjs/scene";
  22980. import { Matrix } from "babylonjs/Maths/math.vector";
  22981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22982. import { Mesh } from "babylonjs/Meshes/mesh";
  22983. import { Material } from "babylonjs/Materials/material";
  22984. import { Effect } from "babylonjs/Materials/effect";
  22985. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22986. /**
  22987. * Base class of materials working in push mode in babylon JS
  22988. * @hidden
  22989. */
  22990. export class PushMaterial extends Material {
  22991. protected _activeEffect: Effect;
  22992. protected _normalMatrix: Matrix;
  22993. constructor(name: string, scene: Scene);
  22994. getEffect(): Effect;
  22995. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22996. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22997. /**
  22998. * Binds the given world matrix to the active effect
  22999. *
  23000. * @param world the matrix to bind
  23001. */
  23002. bindOnlyWorldMatrix(world: Matrix): void;
  23003. /**
  23004. * Binds the given normal matrix to the active effect
  23005. *
  23006. * @param normalMatrix the matrix to bind
  23007. */
  23008. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  23009. bind(world: Matrix, mesh?: Mesh): void;
  23010. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  23011. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  23012. }
  23013. }
  23014. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  23015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23016. /**
  23017. * Root class for all node material optimizers
  23018. */
  23019. export class NodeMaterialOptimizer {
  23020. /**
  23021. * Function used to optimize a NodeMaterial graph
  23022. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  23023. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  23024. */
  23025. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  23026. }
  23027. }
  23028. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  23029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23032. import { Scene } from "babylonjs/scene";
  23033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23034. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  23035. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23036. /**
  23037. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  23038. */
  23039. export class TransformBlock extends NodeMaterialBlock {
  23040. /**
  23041. * Defines the value to use to complement W value to transform it to a Vector4
  23042. */
  23043. complementW: number;
  23044. /**
  23045. * Defines the value to use to complement z value to transform it to a Vector4
  23046. */
  23047. complementZ: number;
  23048. /**
  23049. * Creates a new TransformBlock
  23050. * @param name defines the block name
  23051. */
  23052. constructor(name: string);
  23053. /**
  23054. * Gets the current class name
  23055. * @returns the class name
  23056. */
  23057. getClassName(): string;
  23058. /**
  23059. * Gets the vector input
  23060. */
  23061. get vector(): NodeMaterialConnectionPoint;
  23062. /**
  23063. * Gets the output component
  23064. */
  23065. get output(): NodeMaterialConnectionPoint;
  23066. /**
  23067. * Gets the xyz output component
  23068. */
  23069. get xyz(): NodeMaterialConnectionPoint;
  23070. /**
  23071. * Gets the matrix transform input
  23072. */
  23073. get transform(): NodeMaterialConnectionPoint;
  23074. protected _buildBlock(state: NodeMaterialBuildState): this;
  23075. /**
  23076. * Update defines for shader compilation
  23077. * @param mesh defines the mesh to be rendered
  23078. * @param nodeMaterial defines the node material requesting the update
  23079. * @param defines defines the material defines to update
  23080. * @param useInstances specifies that instances should be used
  23081. * @param subMesh defines which submesh to render
  23082. */
  23083. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  23084. serialize(): any;
  23085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23086. protected _dumpPropertiesCode(): string;
  23087. }
  23088. }
  23089. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  23090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23093. /**
  23094. * Block used to output the vertex position
  23095. */
  23096. export class VertexOutputBlock extends NodeMaterialBlock {
  23097. /**
  23098. * Creates a new VertexOutputBlock
  23099. * @param name defines the block name
  23100. */
  23101. constructor(name: string);
  23102. /**
  23103. * Gets the current class name
  23104. * @returns the class name
  23105. */
  23106. getClassName(): string;
  23107. /**
  23108. * Gets the vector input component
  23109. */
  23110. get vector(): NodeMaterialConnectionPoint;
  23111. protected _buildBlock(state: NodeMaterialBuildState): this;
  23112. }
  23113. }
  23114. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  23115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23118. /**
  23119. * Block used to output the final color
  23120. */
  23121. export class FragmentOutputBlock extends NodeMaterialBlock {
  23122. /**
  23123. * Create a new FragmentOutputBlock
  23124. * @param name defines the block name
  23125. */
  23126. constructor(name: string);
  23127. /**
  23128. * Gets the current class name
  23129. * @returns the class name
  23130. */
  23131. getClassName(): string;
  23132. /**
  23133. * Gets the rgba input component
  23134. */
  23135. get rgba(): NodeMaterialConnectionPoint;
  23136. /**
  23137. * Gets the rgb input component
  23138. */
  23139. get rgb(): NodeMaterialConnectionPoint;
  23140. /**
  23141. * Gets the a input component
  23142. */
  23143. get a(): NodeMaterialConnectionPoint;
  23144. protected _buildBlock(state: NodeMaterialBuildState): this;
  23145. }
  23146. }
  23147. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  23148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23151. /**
  23152. * Block used for the particle ramp gradient section
  23153. */
  23154. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  23155. /**
  23156. * Create a new ParticleRampGradientBlock
  23157. * @param name defines the block name
  23158. */
  23159. constructor(name: string);
  23160. /**
  23161. * Gets the current class name
  23162. * @returns the class name
  23163. */
  23164. getClassName(): string;
  23165. /**
  23166. * Gets the color input component
  23167. */
  23168. get color(): NodeMaterialConnectionPoint;
  23169. /**
  23170. * Gets the rampColor output component
  23171. */
  23172. get rampColor(): NodeMaterialConnectionPoint;
  23173. /**
  23174. * Initialize the block and prepare the context for build
  23175. * @param state defines the state that will be used for the build
  23176. */
  23177. initialize(state: NodeMaterialBuildState): void;
  23178. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23179. }
  23180. }
  23181. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  23182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23185. /**
  23186. * Block used for the particle blend multiply section
  23187. */
  23188. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  23189. /**
  23190. * Create a new ParticleBlendMultiplyBlock
  23191. * @param name defines the block name
  23192. */
  23193. constructor(name: string);
  23194. /**
  23195. * Gets the current class name
  23196. * @returns the class name
  23197. */
  23198. getClassName(): string;
  23199. /**
  23200. * Gets the color input component
  23201. */
  23202. get color(): NodeMaterialConnectionPoint;
  23203. /**
  23204. * Gets the alphaTexture input component
  23205. */
  23206. get alphaTexture(): NodeMaterialConnectionPoint;
  23207. /**
  23208. * Gets the alphaColor input component
  23209. */
  23210. get alphaColor(): NodeMaterialConnectionPoint;
  23211. /**
  23212. * Gets the blendColor output component
  23213. */
  23214. get blendColor(): NodeMaterialConnectionPoint;
  23215. /**
  23216. * Initialize the block and prepare the context for build
  23217. * @param state defines the state that will be used for the build
  23218. */
  23219. initialize(state: NodeMaterialBuildState): void;
  23220. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23221. }
  23222. }
  23223. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  23224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23227. /**
  23228. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  23229. */
  23230. export class VectorMergerBlock extends NodeMaterialBlock {
  23231. /**
  23232. * Create a new VectorMergerBlock
  23233. * @param name defines the block name
  23234. */
  23235. constructor(name: string);
  23236. /**
  23237. * Gets the current class name
  23238. * @returns the class name
  23239. */
  23240. getClassName(): string;
  23241. /**
  23242. * Gets the xyz component (input)
  23243. */
  23244. get xyzIn(): NodeMaterialConnectionPoint;
  23245. /**
  23246. * Gets the xy component (input)
  23247. */
  23248. get xyIn(): NodeMaterialConnectionPoint;
  23249. /**
  23250. * Gets the x component (input)
  23251. */
  23252. get x(): NodeMaterialConnectionPoint;
  23253. /**
  23254. * Gets the y component (input)
  23255. */
  23256. get y(): NodeMaterialConnectionPoint;
  23257. /**
  23258. * Gets the z component (input)
  23259. */
  23260. get z(): NodeMaterialConnectionPoint;
  23261. /**
  23262. * Gets the w component (input)
  23263. */
  23264. get w(): NodeMaterialConnectionPoint;
  23265. /**
  23266. * Gets the xyzw component (output)
  23267. */
  23268. get xyzw(): NodeMaterialConnectionPoint;
  23269. /**
  23270. * Gets the xyz component (output)
  23271. */
  23272. get xyzOut(): NodeMaterialConnectionPoint;
  23273. /**
  23274. * Gets the xy component (output)
  23275. */
  23276. get xyOut(): NodeMaterialConnectionPoint;
  23277. /**
  23278. * Gets the xy component (output)
  23279. * @deprecated Please use xyOut instead.
  23280. */
  23281. get xy(): NodeMaterialConnectionPoint;
  23282. /**
  23283. * Gets the xyz component (output)
  23284. * @deprecated Please use xyzOut instead.
  23285. */
  23286. get xyz(): NodeMaterialConnectionPoint;
  23287. protected _buildBlock(state: NodeMaterialBuildState): this;
  23288. }
  23289. }
  23290. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23294. import { Vector2 } from "babylonjs/Maths/math.vector";
  23295. import { Scene } from "babylonjs/scene";
  23296. /**
  23297. * Block used to remap a float from a range to a new one
  23298. */
  23299. export class RemapBlock extends NodeMaterialBlock {
  23300. /**
  23301. * Gets or sets the source range
  23302. */
  23303. sourceRange: Vector2;
  23304. /**
  23305. * Gets or sets the target range
  23306. */
  23307. targetRange: Vector2;
  23308. /**
  23309. * Creates a new RemapBlock
  23310. * @param name defines the block name
  23311. */
  23312. constructor(name: string);
  23313. /**
  23314. * Gets the current class name
  23315. * @returns the class name
  23316. */
  23317. getClassName(): string;
  23318. /**
  23319. * Gets the input component
  23320. */
  23321. get input(): NodeMaterialConnectionPoint;
  23322. /**
  23323. * Gets the source min input component
  23324. */
  23325. get sourceMin(): NodeMaterialConnectionPoint;
  23326. /**
  23327. * Gets the source max input component
  23328. */
  23329. get sourceMax(): NodeMaterialConnectionPoint;
  23330. /**
  23331. * Gets the target min input component
  23332. */
  23333. get targetMin(): NodeMaterialConnectionPoint;
  23334. /**
  23335. * Gets the target max input component
  23336. */
  23337. get targetMax(): NodeMaterialConnectionPoint;
  23338. /**
  23339. * Gets the output component
  23340. */
  23341. get output(): NodeMaterialConnectionPoint;
  23342. protected _buildBlock(state: NodeMaterialBuildState): this;
  23343. protected _dumpPropertiesCode(): string;
  23344. serialize(): any;
  23345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23346. }
  23347. }
  23348. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23352. /**
  23353. * Block used to multiply 2 values
  23354. */
  23355. export class MultiplyBlock extends NodeMaterialBlock {
  23356. /**
  23357. * Creates a new MultiplyBlock
  23358. * @param name defines the block name
  23359. */
  23360. constructor(name: string);
  23361. /**
  23362. * Gets the current class name
  23363. * @returns the class name
  23364. */
  23365. getClassName(): string;
  23366. /**
  23367. * Gets the left operand input component
  23368. */
  23369. get left(): NodeMaterialConnectionPoint;
  23370. /**
  23371. * Gets the right operand input component
  23372. */
  23373. get right(): NodeMaterialConnectionPoint;
  23374. /**
  23375. * Gets the output component
  23376. */
  23377. get output(): NodeMaterialConnectionPoint;
  23378. protected _buildBlock(state: NodeMaterialBuildState): this;
  23379. }
  23380. }
  23381. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23385. /**
  23386. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23387. */
  23388. export class ColorSplitterBlock extends NodeMaterialBlock {
  23389. /**
  23390. * Create a new ColorSplitterBlock
  23391. * @param name defines the block name
  23392. */
  23393. constructor(name: string);
  23394. /**
  23395. * Gets the current class name
  23396. * @returns the class name
  23397. */
  23398. getClassName(): string;
  23399. /**
  23400. * Gets the rgba component (input)
  23401. */
  23402. get rgba(): NodeMaterialConnectionPoint;
  23403. /**
  23404. * Gets the rgb component (input)
  23405. */
  23406. get rgbIn(): NodeMaterialConnectionPoint;
  23407. /**
  23408. * Gets the rgb component (output)
  23409. */
  23410. get rgbOut(): NodeMaterialConnectionPoint;
  23411. /**
  23412. * Gets the r component (output)
  23413. */
  23414. get r(): NodeMaterialConnectionPoint;
  23415. /**
  23416. * Gets the g component (output)
  23417. */
  23418. get g(): NodeMaterialConnectionPoint;
  23419. /**
  23420. * Gets the b component (output)
  23421. */
  23422. get b(): NodeMaterialConnectionPoint;
  23423. /**
  23424. * Gets the a component (output)
  23425. */
  23426. get a(): NodeMaterialConnectionPoint;
  23427. protected _inputRename(name: string): string;
  23428. protected _outputRename(name: string): string;
  23429. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23430. }
  23431. }
  23432. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23436. import { Scene } from "babylonjs/scene";
  23437. /**
  23438. * Operations supported by the Trigonometry block
  23439. */
  23440. export enum TrigonometryBlockOperations {
  23441. /** Cos */
  23442. Cos = 0,
  23443. /** Sin */
  23444. Sin = 1,
  23445. /** Abs */
  23446. Abs = 2,
  23447. /** Exp */
  23448. Exp = 3,
  23449. /** Exp2 */
  23450. Exp2 = 4,
  23451. /** Round */
  23452. Round = 5,
  23453. /** Floor */
  23454. Floor = 6,
  23455. /** Ceiling */
  23456. Ceiling = 7,
  23457. /** Square root */
  23458. Sqrt = 8,
  23459. /** Log */
  23460. Log = 9,
  23461. /** Tangent */
  23462. Tan = 10,
  23463. /** Arc tangent */
  23464. ArcTan = 11,
  23465. /** Arc cosinus */
  23466. ArcCos = 12,
  23467. /** Arc sinus */
  23468. ArcSin = 13,
  23469. /** Fraction */
  23470. Fract = 14,
  23471. /** Sign */
  23472. Sign = 15,
  23473. /** To radians (from degrees) */
  23474. Radians = 16,
  23475. /** To degrees (from radians) */
  23476. Degrees = 17
  23477. }
  23478. /**
  23479. * Block used to apply trigonometry operation to floats
  23480. */
  23481. export class TrigonometryBlock extends NodeMaterialBlock {
  23482. /**
  23483. * Gets or sets the operation applied by the block
  23484. */
  23485. operation: TrigonometryBlockOperations;
  23486. /**
  23487. * Creates a new TrigonometryBlock
  23488. * @param name defines the block name
  23489. */
  23490. constructor(name: string);
  23491. /**
  23492. * Gets the current class name
  23493. * @returns the class name
  23494. */
  23495. getClassName(): string;
  23496. /**
  23497. * Gets the input component
  23498. */
  23499. get input(): NodeMaterialConnectionPoint;
  23500. /**
  23501. * Gets the output component
  23502. */
  23503. get output(): NodeMaterialConnectionPoint;
  23504. protected _buildBlock(state: NodeMaterialBuildState): this;
  23505. serialize(): any;
  23506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23507. protected _dumpPropertiesCode(): string;
  23508. }
  23509. }
  23510. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23512. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23513. import { Scene } from "babylonjs/scene";
  23514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23515. import { Matrix } from "babylonjs/Maths/math.vector";
  23516. import { Mesh } from "babylonjs/Meshes/mesh";
  23517. import { Engine } from "babylonjs/Engines/engine";
  23518. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23519. import { Observable } from "babylonjs/Misc/observable";
  23520. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23521. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23522. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23523. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23524. import { Nullable } from "babylonjs/types";
  23525. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23526. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23527. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23528. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23529. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23530. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23531. import { Effect } from "babylonjs/Materials/effect";
  23532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23533. import { Camera } from "babylonjs/Cameras/camera";
  23534. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23535. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23536. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23537. /**
  23538. * Interface used to configure the node material editor
  23539. */
  23540. export interface INodeMaterialEditorOptions {
  23541. /** Define the URl to load node editor script */
  23542. editorURL?: string;
  23543. }
  23544. /** @hidden */
  23545. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23546. NORMAL: boolean;
  23547. TANGENT: boolean;
  23548. UV1: boolean;
  23549. /** BONES */
  23550. NUM_BONE_INFLUENCERS: number;
  23551. BonesPerMesh: number;
  23552. BONETEXTURE: boolean;
  23553. /** MORPH TARGETS */
  23554. MORPHTARGETS: boolean;
  23555. MORPHTARGETS_NORMAL: boolean;
  23556. MORPHTARGETS_TANGENT: boolean;
  23557. MORPHTARGETS_UV: boolean;
  23558. NUM_MORPH_INFLUENCERS: number;
  23559. /** IMAGE PROCESSING */
  23560. IMAGEPROCESSING: boolean;
  23561. VIGNETTE: boolean;
  23562. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23563. VIGNETTEBLENDMODEOPAQUE: boolean;
  23564. TONEMAPPING: boolean;
  23565. TONEMAPPING_ACES: boolean;
  23566. CONTRAST: boolean;
  23567. EXPOSURE: boolean;
  23568. COLORCURVES: boolean;
  23569. COLORGRADING: boolean;
  23570. COLORGRADING3D: boolean;
  23571. SAMPLER3DGREENDEPTH: boolean;
  23572. SAMPLER3DBGRMAP: boolean;
  23573. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23574. /** MISC. */
  23575. BUMPDIRECTUV: number;
  23576. constructor();
  23577. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23578. }
  23579. /**
  23580. * Class used to configure NodeMaterial
  23581. */
  23582. export interface INodeMaterialOptions {
  23583. /**
  23584. * Defines if blocks should emit comments
  23585. */
  23586. emitComments: boolean;
  23587. }
  23588. /**
  23589. * Class used to create a node based material built by assembling shader blocks
  23590. */
  23591. export class NodeMaterial extends PushMaterial {
  23592. private static _BuildIdGenerator;
  23593. private _options;
  23594. private _vertexCompilationState;
  23595. private _fragmentCompilationState;
  23596. private _sharedData;
  23597. private _buildId;
  23598. private _buildWasSuccessful;
  23599. private _cachedWorldViewMatrix;
  23600. private _cachedWorldViewProjectionMatrix;
  23601. private _optimizers;
  23602. private _animationFrame;
  23603. /** Define the Url to load node editor script */
  23604. static EditorURL: string;
  23605. /** Define the Url to load snippets */
  23606. static SnippetUrl: string;
  23607. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23608. static IgnoreTexturesAtLoadTime: boolean;
  23609. private BJSNODEMATERIALEDITOR;
  23610. /** Get the inspector from bundle or global */
  23611. private _getGlobalNodeMaterialEditor;
  23612. /**
  23613. * Snippet ID if the material was created from the snippet server
  23614. */
  23615. snippetId: string;
  23616. /**
  23617. * Gets or sets data used by visual editor
  23618. * @see https://nme.babylonjs.com
  23619. */
  23620. editorData: any;
  23621. /**
  23622. * 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)
  23623. */
  23624. ignoreAlpha: boolean;
  23625. /**
  23626. * Defines the maximum number of lights that can be used in the material
  23627. */
  23628. maxSimultaneousLights: number;
  23629. /**
  23630. * Observable raised when the material is built
  23631. */
  23632. onBuildObservable: Observable<NodeMaterial>;
  23633. /**
  23634. * Gets or sets the root nodes of the material vertex shader
  23635. */
  23636. _vertexOutputNodes: NodeMaterialBlock[];
  23637. /**
  23638. * Gets or sets the root nodes of the material fragment (pixel) shader
  23639. */
  23640. _fragmentOutputNodes: NodeMaterialBlock[];
  23641. /** Gets or sets options to control the node material overall behavior */
  23642. get options(): INodeMaterialOptions;
  23643. set options(options: INodeMaterialOptions);
  23644. /**
  23645. * Default configuration related to image processing available in the standard Material.
  23646. */
  23647. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23648. /**
  23649. * Gets the image processing configuration used either in this material.
  23650. */
  23651. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23652. /**
  23653. * Sets the Default image processing configuration used either in the this material.
  23654. *
  23655. * If sets to null, the scene one is in use.
  23656. */
  23657. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23658. /**
  23659. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23660. */
  23661. attachedBlocks: NodeMaterialBlock[];
  23662. /**
  23663. * Specifies the mode of the node material
  23664. * @hidden
  23665. */
  23666. _mode: NodeMaterialModes;
  23667. /**
  23668. * Gets the mode property
  23669. */
  23670. get mode(): NodeMaterialModes;
  23671. /**
  23672. * A free comment about the material
  23673. */
  23674. comment: string;
  23675. /**
  23676. * Create a new node based material
  23677. * @param name defines the material name
  23678. * @param scene defines the hosting scene
  23679. * @param options defines creation option
  23680. */
  23681. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23682. /**
  23683. * Gets the current class name of the material e.g. "NodeMaterial"
  23684. * @returns the class name
  23685. */
  23686. getClassName(): string;
  23687. /**
  23688. * Keep track of the image processing observer to allow dispose and replace.
  23689. */
  23690. private _imageProcessingObserver;
  23691. /**
  23692. * Attaches a new image processing configuration to the Standard Material.
  23693. * @param configuration
  23694. */
  23695. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23696. /**
  23697. * Get a block by its name
  23698. * @param name defines the name of the block to retrieve
  23699. * @returns the required block or null if not found
  23700. */
  23701. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23702. /**
  23703. * Get a block by its name
  23704. * @param predicate defines the predicate used to find the good candidate
  23705. * @returns the required block or null if not found
  23706. */
  23707. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23708. /**
  23709. * Get an input block by its name
  23710. * @param predicate defines the predicate used to find the good candidate
  23711. * @returns the required input block or null if not found
  23712. */
  23713. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23714. /**
  23715. * Gets the list of input blocks attached to this material
  23716. * @returns an array of InputBlocks
  23717. */
  23718. getInputBlocks(): InputBlock[];
  23719. /**
  23720. * Adds a new optimizer to the list of optimizers
  23721. * @param optimizer defines the optimizers to add
  23722. * @returns the current material
  23723. */
  23724. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23725. /**
  23726. * Remove an optimizer from the list of optimizers
  23727. * @param optimizer defines the optimizers to remove
  23728. * @returns the current material
  23729. */
  23730. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23731. /**
  23732. * Add a new block to the list of output nodes
  23733. * @param node defines the node to add
  23734. * @returns the current material
  23735. */
  23736. addOutputNode(node: NodeMaterialBlock): this;
  23737. /**
  23738. * Remove a block from the list of root nodes
  23739. * @param node defines the node to remove
  23740. * @returns the current material
  23741. */
  23742. removeOutputNode(node: NodeMaterialBlock): this;
  23743. private _addVertexOutputNode;
  23744. private _removeVertexOutputNode;
  23745. private _addFragmentOutputNode;
  23746. private _removeFragmentOutputNode;
  23747. /**
  23748. * Specifies if the material will require alpha blending
  23749. * @returns a boolean specifying if alpha blending is needed
  23750. */
  23751. needAlphaBlending(): boolean;
  23752. /**
  23753. * Specifies if this material should be rendered in alpha test mode
  23754. * @returns a boolean specifying if an alpha test is needed.
  23755. */
  23756. needAlphaTesting(): boolean;
  23757. private _initializeBlock;
  23758. private _resetDualBlocks;
  23759. /**
  23760. * Remove a block from the current node material
  23761. * @param block defines the block to remove
  23762. */
  23763. removeBlock(block: NodeMaterialBlock): void;
  23764. /**
  23765. * Build the material and generates the inner effect
  23766. * @param verbose defines if the build should log activity
  23767. */
  23768. build(verbose?: boolean): void;
  23769. /**
  23770. * Runs an otpimization phase to try to improve the shader code
  23771. */
  23772. optimize(): void;
  23773. private _prepareDefinesForAttributes;
  23774. /**
  23775. * Create a post process from the material
  23776. * @param camera The camera to apply the render pass to.
  23777. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23779. * @param engine The engine which the post process will be applied. (default: current engine)
  23780. * @param reusable If the post process can be reused on the same frame. (default: false)
  23781. * @param textureType Type of textures used when performing the post process. (default: 0)
  23782. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23783. * @returns the post process created
  23784. */
  23785. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23786. /**
  23787. * Create the post process effect from the material
  23788. * @param postProcess The post process to create the effect for
  23789. */
  23790. createEffectForPostProcess(postProcess: PostProcess): void;
  23791. private _createEffectForPostProcess;
  23792. /**
  23793. * Create a new procedural texture based on this node material
  23794. * @param size defines the size of the texture
  23795. * @param scene defines the hosting scene
  23796. * @returns the new procedural texture attached to this node material
  23797. */
  23798. createProceduralTexture(size: number | {
  23799. width: number;
  23800. height: number;
  23801. layers?: number;
  23802. }, scene: Scene): Nullable<ProceduralTexture>;
  23803. private _createEffectForParticles;
  23804. private _checkInternals;
  23805. /**
  23806. * Create the effect to be used as the custom effect for a particle system
  23807. * @param particleSystem Particle system to create the effect for
  23808. * @param onCompiled defines a function to call when the effect creation is successful
  23809. * @param onError defines a function to call when the effect creation has failed
  23810. */
  23811. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23812. private _processDefines;
  23813. /**
  23814. * Get if the submesh is ready to be used and all its information available.
  23815. * Child classes can use it to update shaders
  23816. * @param mesh defines the mesh to check
  23817. * @param subMesh defines which submesh to check
  23818. * @param useInstances specifies that instances should be used
  23819. * @returns a boolean indicating that the submesh is ready or not
  23820. */
  23821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23822. /**
  23823. * Get a string representing the shaders built by the current node graph
  23824. */
  23825. get compiledShaders(): string;
  23826. /**
  23827. * Binds the world matrix to the material
  23828. * @param world defines the world transformation matrix
  23829. */
  23830. bindOnlyWorldMatrix(world: Matrix): void;
  23831. /**
  23832. * Binds the submesh to this material by preparing the effect and shader to draw
  23833. * @param world defines the world transformation matrix
  23834. * @param mesh defines the mesh containing the submesh
  23835. * @param subMesh defines the submesh to bind the material to
  23836. */
  23837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23838. /**
  23839. * Gets the active textures from the material
  23840. * @returns an array of textures
  23841. */
  23842. getActiveTextures(): BaseTexture[];
  23843. /**
  23844. * Gets the list of texture blocks
  23845. * @returns an array of texture blocks
  23846. */
  23847. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23848. /**
  23849. * Specifies if the material uses a texture
  23850. * @param texture defines the texture to check against the material
  23851. * @returns a boolean specifying if the material uses the texture
  23852. */
  23853. hasTexture(texture: BaseTexture): boolean;
  23854. /**
  23855. * Disposes the material
  23856. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23857. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23858. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23859. */
  23860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23861. /** Creates the node editor window. */
  23862. private _createNodeEditor;
  23863. /**
  23864. * Launch the node material editor
  23865. * @param config Define the configuration of the editor
  23866. * @return a promise fulfilled when the node editor is visible
  23867. */
  23868. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23869. /**
  23870. * Clear the current material
  23871. */
  23872. clear(): void;
  23873. /**
  23874. * Clear the current material and set it to a default state
  23875. */
  23876. setToDefault(): void;
  23877. /**
  23878. * Clear the current material and set it to a default state for post process
  23879. */
  23880. setToDefaultPostProcess(): void;
  23881. /**
  23882. * Clear the current material and set it to a default state for procedural texture
  23883. */
  23884. setToDefaultProceduralTexture(): void;
  23885. /**
  23886. * Clear the current material and set it to a default state for particle
  23887. */
  23888. setToDefaultParticle(): void;
  23889. /**
  23890. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23891. * @param url defines the url to load from
  23892. * @returns a promise that will fullfil when the material is fully loaded
  23893. */
  23894. loadAsync(url: string): Promise<void>;
  23895. private _gatherBlocks;
  23896. /**
  23897. * Generate a string containing the code declaration required to create an equivalent of this material
  23898. * @returns a string
  23899. */
  23900. generateCode(): string;
  23901. /**
  23902. * Serializes this material in a JSON representation
  23903. * @returns the serialized material object
  23904. */
  23905. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23906. private _restoreConnections;
  23907. /**
  23908. * Clear the current graph and load a new one from a serialization object
  23909. * @param source defines the JSON representation of the material
  23910. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23911. * @param merge defines whether or not the source must be merged or replace the current content
  23912. */
  23913. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23914. /**
  23915. * Makes a duplicate of the current material.
  23916. * @param name - name to use for the new material.
  23917. */
  23918. clone(name: string): NodeMaterial;
  23919. /**
  23920. * Creates a node material from parsed material data
  23921. * @param source defines the JSON representation of the material
  23922. * @param scene defines the hosting scene
  23923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23924. * @returns a new node material
  23925. */
  23926. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23927. /**
  23928. * Creates a node material from a snippet saved in a remote file
  23929. * @param name defines the name of the material to create
  23930. * @param url defines the url to load from
  23931. * @param scene defines the hosting scene
  23932. * @returns a promise that will resolve to the new node material
  23933. */
  23934. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23935. /**
  23936. * Creates a node material from a snippet saved by the node material editor
  23937. * @param snippetId defines the snippet to load
  23938. * @param scene defines the hosting scene
  23939. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23940. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23941. * @returns a promise that will resolve to the new node material
  23942. */
  23943. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23944. /**
  23945. * Creates a new node material set to default basic configuration
  23946. * @param name defines the name of the material
  23947. * @param scene defines the hosting scene
  23948. * @returns a new NodeMaterial
  23949. */
  23950. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23951. }
  23952. }
  23953. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23954. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23955. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23956. import { Nullable } from "babylonjs/types";
  23957. module "babylonjs/Engines/thinEngine" {
  23958. interface ThinEngine {
  23959. /**
  23960. * Unbind a list of render target textures from the webGL context
  23961. * This is used only when drawBuffer extension or webGL2 are active
  23962. * @param textures defines the render target textures to unbind
  23963. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23964. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23965. */
  23966. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23967. /**
  23968. * Create a multi render target texture
  23969. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23970. * @param size defines the size of the texture
  23971. * @param options defines the creation options
  23972. * @returns the cube texture as an InternalTexture
  23973. */
  23974. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23975. /**
  23976. * Update the sample count for a given multiple render target texture
  23977. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23978. * @param textures defines the textures to update
  23979. * @param samples defines the sample count to set
  23980. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23981. */
  23982. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23983. /**
  23984. * Select a subsets of attachments to draw to.
  23985. * @param attachments gl attachments
  23986. */
  23987. bindAttachments(attachments: number[]): void;
  23988. /**
  23989. * Creates a layout object to draw/clear on specific textures in a MRT
  23990. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23991. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23992. */
  23993. buildTextureLayout(textureStatus: boolean[]): number[];
  23994. /**
  23995. * Restores the webgl state to only draw on the main color attachment
  23996. */
  23997. restoreSingleAttachment(): void;
  23998. }
  23999. }
  24000. }
  24001. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24002. import { Scene } from "babylonjs/scene";
  24003. import { Engine } from "babylonjs/Engines/engine";
  24004. import { Texture } from "babylonjs/Materials/Textures/texture";
  24005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24006. import "babylonjs/Engines/Extensions/engine.multiRender";
  24007. /**
  24008. * Creation options of the multi render target texture.
  24009. */
  24010. export interface IMultiRenderTargetOptions {
  24011. /**
  24012. * Define if the texture needs to create mip maps after render.
  24013. */
  24014. generateMipMaps?: boolean;
  24015. /**
  24016. * Define the types of all the draw buffers we want to create
  24017. */
  24018. types?: number[];
  24019. /**
  24020. * Define the sampling modes of all the draw buffers we want to create
  24021. */
  24022. samplingModes?: number[];
  24023. /**
  24024. * Define if a depth buffer is required
  24025. */
  24026. generateDepthBuffer?: boolean;
  24027. /**
  24028. * Define if a stencil buffer is required
  24029. */
  24030. generateStencilBuffer?: boolean;
  24031. /**
  24032. * Define if a depth texture is required instead of a depth buffer
  24033. */
  24034. generateDepthTexture?: boolean;
  24035. /**
  24036. * Define the number of desired draw buffers
  24037. */
  24038. textureCount?: number;
  24039. /**
  24040. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24041. */
  24042. doNotChangeAspectRatio?: boolean;
  24043. /**
  24044. * Define the default type of the buffers we are creating
  24045. */
  24046. defaultType?: number;
  24047. }
  24048. /**
  24049. * A multi render target, like a render target provides the ability to render to a texture.
  24050. * Unlike the render target, it can render to several draw buffers in one draw.
  24051. * This is specially interesting in deferred rendering or for any effects requiring more than
  24052. * just one color from a single pass.
  24053. */
  24054. export class MultiRenderTarget extends RenderTargetTexture {
  24055. private _internalTextures;
  24056. private _textures;
  24057. private _multiRenderTargetOptions;
  24058. private _count;
  24059. /**
  24060. * Get if draw buffers are currently supported by the used hardware and browser.
  24061. */
  24062. get isSupported(): boolean;
  24063. /**
  24064. * Get the list of textures generated by the multi render target.
  24065. */
  24066. get textures(): Texture[];
  24067. /**
  24068. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24069. */
  24070. get count(): number;
  24071. /**
  24072. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24073. */
  24074. get depthTexture(): Texture;
  24075. /**
  24076. * Set the wrapping mode on U of all the textures we are rendering to.
  24077. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24078. */
  24079. set wrapU(wrap: number);
  24080. /**
  24081. * Set the wrapping mode on V of all the textures we are rendering to.
  24082. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24083. */
  24084. set wrapV(wrap: number);
  24085. /**
  24086. * Instantiate a new multi render target texture.
  24087. * A multi render target, like a render target provides the ability to render to a texture.
  24088. * Unlike the render target, it can render to several draw buffers in one draw.
  24089. * This is specially interesting in deferred rendering or for any effects requiring more than
  24090. * just one color from a single pass.
  24091. * @param name Define the name of the texture
  24092. * @param size Define the size of the buffers to render to
  24093. * @param count Define the number of target we are rendering into
  24094. * @param scene Define the scene the texture belongs to
  24095. * @param options Define the options used to create the multi render target
  24096. */
  24097. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24098. private _initTypes;
  24099. /** @hidden */
  24100. _rebuild(forceFullRebuild?: boolean): void;
  24101. private _createInternalTextures;
  24102. private _createTextures;
  24103. /**
  24104. * Replaces a texture within the MRT.
  24105. * @param texture The new texture to insert in the MRT
  24106. * @param index The index of the texture to replace
  24107. */
  24108. replaceTexture(texture: Texture, index: number): void;
  24109. /**
  24110. * Define the number of samples used if MSAA is enabled.
  24111. */
  24112. get samples(): number;
  24113. set samples(value: number);
  24114. /**
  24115. * Resize all the textures in the multi render target.
  24116. * Be careful as it will recreate all the data in the new texture.
  24117. * @param size Define the new size
  24118. */
  24119. resize(size: any): void;
  24120. /**
  24121. * Changes the number of render targets in this MRT
  24122. * Be careful as it will recreate all the data in the new texture.
  24123. * @param count new texture count
  24124. * @param options Specifies texture types and sampling modes for new textures
  24125. */
  24126. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24127. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24128. /**
  24129. * Dispose the render targets and their associated resources
  24130. */
  24131. dispose(): void;
  24132. /**
  24133. * Release all the underlying texture used as draw buffers.
  24134. */
  24135. releaseInternalTextures(): void;
  24136. }
  24137. }
  24138. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24139. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24140. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24141. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24142. /** @hidden */
  24143. export var imageProcessingPixelShader: {
  24144. name: string;
  24145. shader: string;
  24146. };
  24147. }
  24148. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24149. import { Nullable } from "babylonjs/types";
  24150. import { Color4 } from "babylonjs/Maths/math.color";
  24151. import { Camera } from "babylonjs/Cameras/camera";
  24152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24153. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24154. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24155. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24156. import { Engine } from "babylonjs/Engines/engine";
  24157. import "babylonjs/Shaders/imageProcessing.fragment";
  24158. import "babylonjs/Shaders/postprocess.vertex";
  24159. /**
  24160. * ImageProcessingPostProcess
  24161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24162. */
  24163. export class ImageProcessingPostProcess extends PostProcess {
  24164. /**
  24165. * Default configuration related to image processing available in the PBR Material.
  24166. */
  24167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24168. /**
  24169. * Gets the image processing configuration used either in this material.
  24170. */
  24171. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24172. /**
  24173. * Sets the Default image processing configuration used either in the this material.
  24174. *
  24175. * If sets to null, the scene one is in use.
  24176. */
  24177. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24178. /**
  24179. * Keep track of the image processing observer to allow dispose and replace.
  24180. */
  24181. private _imageProcessingObserver;
  24182. /**
  24183. * Attaches a new image processing configuration to the PBR Material.
  24184. * @param configuration
  24185. */
  24186. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24187. /**
  24188. * If the post process is supported.
  24189. */
  24190. get isSupported(): boolean;
  24191. /**
  24192. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24193. */
  24194. get colorCurves(): Nullable<ColorCurves>;
  24195. /**
  24196. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24197. */
  24198. set colorCurves(value: Nullable<ColorCurves>);
  24199. /**
  24200. * Gets wether the color curves effect is enabled.
  24201. */
  24202. get colorCurvesEnabled(): boolean;
  24203. /**
  24204. * Sets wether the color curves effect is enabled.
  24205. */
  24206. set colorCurvesEnabled(value: boolean);
  24207. /**
  24208. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24209. */
  24210. get colorGradingTexture(): Nullable<BaseTexture>;
  24211. /**
  24212. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24213. */
  24214. set colorGradingTexture(value: Nullable<BaseTexture>);
  24215. /**
  24216. * Gets wether the color grading effect is enabled.
  24217. */
  24218. get colorGradingEnabled(): boolean;
  24219. /**
  24220. * Gets wether the color grading effect is enabled.
  24221. */
  24222. set colorGradingEnabled(value: boolean);
  24223. /**
  24224. * Gets exposure used in the effect.
  24225. */
  24226. get exposure(): number;
  24227. /**
  24228. * Sets exposure used in the effect.
  24229. */
  24230. set exposure(value: number);
  24231. /**
  24232. * Gets wether tonemapping is enabled or not.
  24233. */
  24234. get toneMappingEnabled(): boolean;
  24235. /**
  24236. * Sets wether tonemapping is enabled or not
  24237. */
  24238. set toneMappingEnabled(value: boolean);
  24239. /**
  24240. * Gets the type of tone mapping effect.
  24241. */
  24242. get toneMappingType(): number;
  24243. /**
  24244. * Sets the type of tone mapping effect.
  24245. */
  24246. set toneMappingType(value: number);
  24247. /**
  24248. * Gets contrast used in the effect.
  24249. */
  24250. get contrast(): number;
  24251. /**
  24252. * Sets contrast used in the effect.
  24253. */
  24254. set contrast(value: number);
  24255. /**
  24256. * Gets Vignette stretch size.
  24257. */
  24258. get vignetteStretch(): number;
  24259. /**
  24260. * Sets Vignette stretch size.
  24261. */
  24262. set vignetteStretch(value: number);
  24263. /**
  24264. * Gets Vignette centre X Offset.
  24265. */
  24266. get vignetteCentreX(): number;
  24267. /**
  24268. * Sets Vignette centre X Offset.
  24269. */
  24270. set vignetteCentreX(value: number);
  24271. /**
  24272. * Gets Vignette centre Y Offset.
  24273. */
  24274. get vignetteCentreY(): number;
  24275. /**
  24276. * Sets Vignette centre Y Offset.
  24277. */
  24278. set vignetteCentreY(value: number);
  24279. /**
  24280. * Gets Vignette weight or intensity of the vignette effect.
  24281. */
  24282. get vignetteWeight(): number;
  24283. /**
  24284. * Sets Vignette weight or intensity of the vignette effect.
  24285. */
  24286. set vignetteWeight(value: number);
  24287. /**
  24288. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24289. * if vignetteEnabled is set to true.
  24290. */
  24291. get vignetteColor(): Color4;
  24292. /**
  24293. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24294. * if vignetteEnabled is set to true.
  24295. */
  24296. set vignetteColor(value: Color4);
  24297. /**
  24298. * Gets Camera field of view used by the Vignette effect.
  24299. */
  24300. get vignetteCameraFov(): number;
  24301. /**
  24302. * Sets Camera field of view used by the Vignette effect.
  24303. */
  24304. set vignetteCameraFov(value: number);
  24305. /**
  24306. * Gets the vignette blend mode allowing different kind of effect.
  24307. */
  24308. get vignetteBlendMode(): number;
  24309. /**
  24310. * Sets the vignette blend mode allowing different kind of effect.
  24311. */
  24312. set vignetteBlendMode(value: number);
  24313. /**
  24314. * Gets wether the vignette effect is enabled.
  24315. */
  24316. get vignetteEnabled(): boolean;
  24317. /**
  24318. * Sets wether the vignette effect is enabled.
  24319. */
  24320. set vignetteEnabled(value: boolean);
  24321. private _fromLinearSpace;
  24322. /**
  24323. * Gets wether the input of the processing is in Gamma or Linear Space.
  24324. */
  24325. get fromLinearSpace(): boolean;
  24326. /**
  24327. * Sets wether the input of the processing is in Gamma or Linear Space.
  24328. */
  24329. set fromLinearSpace(value: boolean);
  24330. /**
  24331. * Defines cache preventing GC.
  24332. */
  24333. private _defines;
  24334. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24335. /**
  24336. * "ImageProcessingPostProcess"
  24337. * @returns "ImageProcessingPostProcess"
  24338. */
  24339. getClassName(): string;
  24340. /**
  24341. * @hidden
  24342. */
  24343. _updateParameters(): void;
  24344. dispose(camera?: Camera): void;
  24345. }
  24346. }
  24347. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24348. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24349. /**
  24350. * Interface for defining prepass effects in the prepass post-process pipeline
  24351. */
  24352. export interface PrePassEffectConfiguration {
  24353. /**
  24354. * Name of the effect
  24355. */
  24356. name: string;
  24357. /**
  24358. * Post process to attach for this effect
  24359. */
  24360. postProcess?: PostProcess;
  24361. /**
  24362. * Textures required in the MRT
  24363. */
  24364. texturesRequired: number[];
  24365. /**
  24366. * Is the effect enabled
  24367. */
  24368. enabled: boolean;
  24369. /**
  24370. * Disposes the effect configuration
  24371. */
  24372. dispose?: () => void;
  24373. /**
  24374. * Creates the associated post process
  24375. */
  24376. createPostProcess?: () => PostProcess;
  24377. }
  24378. }
  24379. declare module "babylonjs/Materials/fresnelParameters" {
  24380. import { DeepImmutable } from "babylonjs/types";
  24381. import { Color3 } from "babylonjs/Maths/math.color";
  24382. /**
  24383. * Options to be used when creating a FresnelParameters.
  24384. */
  24385. export type IFresnelParametersCreationOptions = {
  24386. /**
  24387. * Define the color used on edges (grazing angle)
  24388. */
  24389. leftColor?: Color3;
  24390. /**
  24391. * Define the color used on center
  24392. */
  24393. rightColor?: Color3;
  24394. /**
  24395. * Define bias applied to computed fresnel term
  24396. */
  24397. bias?: number;
  24398. /**
  24399. * Defined the power exponent applied to fresnel term
  24400. */
  24401. power?: number;
  24402. /**
  24403. * Define if the fresnel effect is enable or not.
  24404. */
  24405. isEnabled?: boolean;
  24406. };
  24407. /**
  24408. * Serialized format for FresnelParameters.
  24409. */
  24410. export type IFresnelParametersSerialized = {
  24411. /**
  24412. * Define the color used on edges (grazing angle) [as an array]
  24413. */
  24414. leftColor: number[];
  24415. /**
  24416. * Define the color used on center [as an array]
  24417. */
  24418. rightColor: number[];
  24419. /**
  24420. * Define bias applied to computed fresnel term
  24421. */
  24422. bias: number;
  24423. /**
  24424. * Defined the power exponent applied to fresnel term
  24425. */
  24426. power?: number;
  24427. /**
  24428. * Define if the fresnel effect is enable or not.
  24429. */
  24430. isEnabled: boolean;
  24431. };
  24432. /**
  24433. * This represents all the required information to add a fresnel effect on a material:
  24434. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24435. */
  24436. export class FresnelParameters {
  24437. private _isEnabled;
  24438. /**
  24439. * Define if the fresnel effect is enable or not.
  24440. */
  24441. get isEnabled(): boolean;
  24442. set isEnabled(value: boolean);
  24443. /**
  24444. * Define the color used on edges (grazing angle)
  24445. */
  24446. leftColor: Color3;
  24447. /**
  24448. * Define the color used on center
  24449. */
  24450. rightColor: Color3;
  24451. /**
  24452. * Define bias applied to computed fresnel term
  24453. */
  24454. bias: number;
  24455. /**
  24456. * Defined the power exponent applied to fresnel term
  24457. */
  24458. power: number;
  24459. /**
  24460. * Creates a new FresnelParameters object.
  24461. *
  24462. * @param options provide your own settings to optionally to override defaults
  24463. */
  24464. constructor(options?: IFresnelParametersCreationOptions);
  24465. /**
  24466. * Clones the current fresnel and its valuues
  24467. * @returns a clone fresnel configuration
  24468. */
  24469. clone(): FresnelParameters;
  24470. /**
  24471. * Determines equality between FresnelParameters objects
  24472. * @param otherFresnelParameters defines the second operand
  24473. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24474. */
  24475. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24476. /**
  24477. * Serializes the current fresnel parameters to a JSON representation.
  24478. * @return the JSON serialization
  24479. */
  24480. serialize(): IFresnelParametersSerialized;
  24481. /**
  24482. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24483. * @param parsedFresnelParameters Define the JSON representation
  24484. * @returns the parsed parameters
  24485. */
  24486. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24487. }
  24488. }
  24489. declare module "babylonjs/Materials/materialFlags" {
  24490. /**
  24491. * This groups all the flags used to control the materials channel.
  24492. */
  24493. export class MaterialFlags {
  24494. private static _DiffuseTextureEnabled;
  24495. /**
  24496. * Are diffuse textures enabled in the application.
  24497. */
  24498. static get DiffuseTextureEnabled(): boolean;
  24499. static set DiffuseTextureEnabled(value: boolean);
  24500. private static _DetailTextureEnabled;
  24501. /**
  24502. * Are detail textures enabled in the application.
  24503. */
  24504. static get DetailTextureEnabled(): boolean;
  24505. static set DetailTextureEnabled(value: boolean);
  24506. private static _AmbientTextureEnabled;
  24507. /**
  24508. * Are ambient textures enabled in the application.
  24509. */
  24510. static get AmbientTextureEnabled(): boolean;
  24511. static set AmbientTextureEnabled(value: boolean);
  24512. private static _OpacityTextureEnabled;
  24513. /**
  24514. * Are opacity textures enabled in the application.
  24515. */
  24516. static get OpacityTextureEnabled(): boolean;
  24517. static set OpacityTextureEnabled(value: boolean);
  24518. private static _ReflectionTextureEnabled;
  24519. /**
  24520. * Are reflection textures enabled in the application.
  24521. */
  24522. static get ReflectionTextureEnabled(): boolean;
  24523. static set ReflectionTextureEnabled(value: boolean);
  24524. private static _EmissiveTextureEnabled;
  24525. /**
  24526. * Are emissive textures enabled in the application.
  24527. */
  24528. static get EmissiveTextureEnabled(): boolean;
  24529. static set EmissiveTextureEnabled(value: boolean);
  24530. private static _SpecularTextureEnabled;
  24531. /**
  24532. * Are specular textures enabled in the application.
  24533. */
  24534. static get SpecularTextureEnabled(): boolean;
  24535. static set SpecularTextureEnabled(value: boolean);
  24536. private static _BumpTextureEnabled;
  24537. /**
  24538. * Are bump textures enabled in the application.
  24539. */
  24540. static get BumpTextureEnabled(): boolean;
  24541. static set BumpTextureEnabled(value: boolean);
  24542. private static _LightmapTextureEnabled;
  24543. /**
  24544. * Are lightmap textures enabled in the application.
  24545. */
  24546. static get LightmapTextureEnabled(): boolean;
  24547. static set LightmapTextureEnabled(value: boolean);
  24548. private static _RefractionTextureEnabled;
  24549. /**
  24550. * Are refraction textures enabled in the application.
  24551. */
  24552. static get RefractionTextureEnabled(): boolean;
  24553. static set RefractionTextureEnabled(value: boolean);
  24554. private static _ColorGradingTextureEnabled;
  24555. /**
  24556. * Are color grading textures enabled in the application.
  24557. */
  24558. static get ColorGradingTextureEnabled(): boolean;
  24559. static set ColorGradingTextureEnabled(value: boolean);
  24560. private static _FresnelEnabled;
  24561. /**
  24562. * Are fresnels enabled in the application.
  24563. */
  24564. static get FresnelEnabled(): boolean;
  24565. static set FresnelEnabled(value: boolean);
  24566. private static _ClearCoatTextureEnabled;
  24567. /**
  24568. * Are clear coat textures enabled in the application.
  24569. */
  24570. static get ClearCoatTextureEnabled(): boolean;
  24571. static set ClearCoatTextureEnabled(value: boolean);
  24572. private static _ClearCoatBumpTextureEnabled;
  24573. /**
  24574. * Are clear coat bump textures enabled in the application.
  24575. */
  24576. static get ClearCoatBumpTextureEnabled(): boolean;
  24577. static set ClearCoatBumpTextureEnabled(value: boolean);
  24578. private static _ClearCoatTintTextureEnabled;
  24579. /**
  24580. * Are clear coat tint textures enabled in the application.
  24581. */
  24582. static get ClearCoatTintTextureEnabled(): boolean;
  24583. static set ClearCoatTintTextureEnabled(value: boolean);
  24584. private static _SheenTextureEnabled;
  24585. /**
  24586. * Are sheen textures enabled in the application.
  24587. */
  24588. static get SheenTextureEnabled(): boolean;
  24589. static set SheenTextureEnabled(value: boolean);
  24590. private static _AnisotropicTextureEnabled;
  24591. /**
  24592. * Are anisotropic textures enabled in the application.
  24593. */
  24594. static get AnisotropicTextureEnabled(): boolean;
  24595. static set AnisotropicTextureEnabled(value: boolean);
  24596. private static _ThicknessTextureEnabled;
  24597. /**
  24598. * Are thickness textures enabled in the application.
  24599. */
  24600. static get ThicknessTextureEnabled(): boolean;
  24601. static set ThicknessTextureEnabled(value: boolean);
  24602. }
  24603. }
  24604. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24605. /** @hidden */
  24606. export var defaultFragmentDeclaration: {
  24607. name: string;
  24608. shader: string;
  24609. };
  24610. }
  24611. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24612. /** @hidden */
  24613. export var defaultUboDeclaration: {
  24614. name: string;
  24615. shader: string;
  24616. };
  24617. }
  24618. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24619. /** @hidden */
  24620. export var prePassDeclaration: {
  24621. name: string;
  24622. shader: string;
  24623. };
  24624. }
  24625. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24626. /** @hidden */
  24627. export var lightFragmentDeclaration: {
  24628. name: string;
  24629. shader: string;
  24630. };
  24631. }
  24632. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24633. /** @hidden */
  24634. export var lightUboDeclaration: {
  24635. name: string;
  24636. shader: string;
  24637. };
  24638. }
  24639. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24640. /** @hidden */
  24641. export var lightsFragmentFunctions: {
  24642. name: string;
  24643. shader: string;
  24644. };
  24645. }
  24646. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24647. /** @hidden */
  24648. export var shadowsFragmentFunctions: {
  24649. name: string;
  24650. shader: string;
  24651. };
  24652. }
  24653. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24654. /** @hidden */
  24655. export var fresnelFunction: {
  24656. name: string;
  24657. shader: string;
  24658. };
  24659. }
  24660. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24661. /** @hidden */
  24662. export var bumpFragmentMainFunctions: {
  24663. name: string;
  24664. shader: string;
  24665. };
  24666. }
  24667. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24668. /** @hidden */
  24669. export var bumpFragmentFunctions: {
  24670. name: string;
  24671. shader: string;
  24672. };
  24673. }
  24674. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24675. /** @hidden */
  24676. export var logDepthDeclaration: {
  24677. name: string;
  24678. shader: string;
  24679. };
  24680. }
  24681. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24682. /** @hidden */
  24683. export var bumpFragment: {
  24684. name: string;
  24685. shader: string;
  24686. };
  24687. }
  24688. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24689. /** @hidden */
  24690. export var depthPrePass: {
  24691. name: string;
  24692. shader: string;
  24693. };
  24694. }
  24695. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24696. /** @hidden */
  24697. export var lightFragment: {
  24698. name: string;
  24699. shader: string;
  24700. };
  24701. }
  24702. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24703. /** @hidden */
  24704. export var logDepthFragment: {
  24705. name: string;
  24706. shader: string;
  24707. };
  24708. }
  24709. declare module "babylonjs/Shaders/default.fragment" {
  24710. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24711. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24712. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24713. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24714. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24715. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24716. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24717. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24718. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24719. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24720. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24721. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24722. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24723. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24724. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24725. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24726. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24727. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24728. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24729. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24730. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24731. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24732. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24733. /** @hidden */
  24734. export var defaultPixelShader: {
  24735. name: string;
  24736. shader: string;
  24737. };
  24738. }
  24739. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24740. /** @hidden */
  24741. export var defaultVertexDeclaration: {
  24742. name: string;
  24743. shader: string;
  24744. };
  24745. }
  24746. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24747. /** @hidden */
  24748. export var prePassVertexDeclaration: {
  24749. name: string;
  24750. shader: string;
  24751. };
  24752. }
  24753. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24754. /** @hidden */
  24755. export var bumpVertexDeclaration: {
  24756. name: string;
  24757. shader: string;
  24758. };
  24759. }
  24760. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24761. /** @hidden */
  24762. export var prePassVertex: {
  24763. name: string;
  24764. shader: string;
  24765. };
  24766. }
  24767. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24768. /** @hidden */
  24769. export var bumpVertex: {
  24770. name: string;
  24771. shader: string;
  24772. };
  24773. }
  24774. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24775. /** @hidden */
  24776. export var fogVertex: {
  24777. name: string;
  24778. shader: string;
  24779. };
  24780. }
  24781. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24782. /** @hidden */
  24783. export var shadowsVertex: {
  24784. name: string;
  24785. shader: string;
  24786. };
  24787. }
  24788. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24789. /** @hidden */
  24790. export var pointCloudVertex: {
  24791. name: string;
  24792. shader: string;
  24793. };
  24794. }
  24795. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24796. /** @hidden */
  24797. export var logDepthVertex: {
  24798. name: string;
  24799. shader: string;
  24800. };
  24801. }
  24802. declare module "babylonjs/Shaders/default.vertex" {
  24803. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24804. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24806. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24807. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24808. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24809. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24810. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24811. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24812. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24813. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24816. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24818. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24819. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24820. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24821. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24822. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24823. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24824. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24825. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24826. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24827. /** @hidden */
  24828. export var defaultVertexShader: {
  24829. name: string;
  24830. shader: string;
  24831. };
  24832. }
  24833. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24834. import { Nullable } from "babylonjs/types";
  24835. import { Scene } from "babylonjs/scene";
  24836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24837. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24838. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24839. /**
  24840. * @hidden
  24841. */
  24842. export interface IMaterialDetailMapDefines {
  24843. DETAIL: boolean;
  24844. DETAILDIRECTUV: number;
  24845. DETAIL_NORMALBLENDMETHOD: number;
  24846. /** @hidden */
  24847. _areTexturesDirty: boolean;
  24848. }
  24849. /**
  24850. * Define the code related to the detail map parameters of a material
  24851. *
  24852. * Inspired from:
  24853. * 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
  24854. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24855. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24856. */
  24857. export class DetailMapConfiguration {
  24858. private _texture;
  24859. /**
  24860. * The detail texture of the material.
  24861. */
  24862. texture: Nullable<BaseTexture>;
  24863. /**
  24864. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24865. * Bigger values mean stronger blending
  24866. */
  24867. diffuseBlendLevel: number;
  24868. /**
  24869. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24870. * Bigger values mean stronger blending. Only used with PBR materials
  24871. */
  24872. roughnessBlendLevel: number;
  24873. /**
  24874. * Defines how strong the bump effect from the detail map is
  24875. * Bigger values mean stronger effect
  24876. */
  24877. bumpLevel: number;
  24878. private _normalBlendMethod;
  24879. /**
  24880. * The method used to blend the bump and detail normals together
  24881. */
  24882. normalBlendMethod: number;
  24883. private _isEnabled;
  24884. /**
  24885. * Enable or disable the detail map on this material
  24886. */
  24887. isEnabled: boolean;
  24888. /** @hidden */
  24889. private _internalMarkAllSubMeshesAsTexturesDirty;
  24890. /** @hidden */
  24891. _markAllSubMeshesAsTexturesDirty(): void;
  24892. /**
  24893. * Instantiate a new detail map
  24894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24895. */
  24896. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24897. /**
  24898. * Gets whether the submesh is ready to be used or not.
  24899. * @param defines the list of "defines" to update.
  24900. * @param scene defines the scene the material belongs to.
  24901. * @returns - boolean indicating that the submesh is ready or not.
  24902. */
  24903. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24904. /**
  24905. * Update the defines for detail map usage
  24906. * @param defines the list of "defines" to update.
  24907. * @param scene defines the scene the material belongs to.
  24908. */
  24909. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24910. /**
  24911. * Binds the material data.
  24912. * @param uniformBuffer defines the Uniform buffer to fill in.
  24913. * @param scene defines the scene the material belongs to.
  24914. * @param isFrozen defines whether the material is frozen or not.
  24915. */
  24916. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24917. /**
  24918. * Checks to see if a texture is used in the material.
  24919. * @param texture - Base texture to use.
  24920. * @returns - Boolean specifying if a texture is used in the material.
  24921. */
  24922. hasTexture(texture: BaseTexture): boolean;
  24923. /**
  24924. * Returns an array of the actively used textures.
  24925. * @param activeTextures Array of BaseTextures
  24926. */
  24927. getActiveTextures(activeTextures: BaseTexture[]): void;
  24928. /**
  24929. * Returns the animatable textures.
  24930. * @param animatables Array of animatable textures.
  24931. */
  24932. getAnimatables(animatables: IAnimatable[]): void;
  24933. /**
  24934. * Disposes the resources of the material.
  24935. * @param forceDisposeTextures - Forces the disposal of all textures.
  24936. */
  24937. dispose(forceDisposeTextures?: boolean): void;
  24938. /**
  24939. * Get the current class name useful for serialization or dynamic coding.
  24940. * @returns "DetailMap"
  24941. */
  24942. getClassName(): string;
  24943. /**
  24944. * Add the required uniforms to the current list.
  24945. * @param uniforms defines the current uniform list.
  24946. */
  24947. static AddUniforms(uniforms: string[]): void;
  24948. /**
  24949. * Add the required samplers to the current list.
  24950. * @param samplers defines the current sampler list.
  24951. */
  24952. static AddSamplers(samplers: string[]): void;
  24953. /**
  24954. * Add the required uniforms to the current buffer.
  24955. * @param uniformBuffer defines the current uniform buffer.
  24956. */
  24957. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24958. /**
  24959. * Makes a duplicate of the current instance into another one.
  24960. * @param detailMap define the instance where to copy the info
  24961. */
  24962. copyTo(detailMap: DetailMapConfiguration): void;
  24963. /**
  24964. * Serializes this detail map instance
  24965. * @returns - An object with the serialized instance.
  24966. */
  24967. serialize(): any;
  24968. /**
  24969. * Parses a detail map setting from a serialized object.
  24970. * @param source - Serialized object.
  24971. * @param scene Defines the scene we are parsing for
  24972. * @param rootUrl Defines the rootUrl to load from
  24973. */
  24974. parse(source: any, scene: Scene, rootUrl: string): void;
  24975. }
  24976. }
  24977. declare module "babylonjs/Materials/standardMaterial" {
  24978. import { SmartArray } from "babylonjs/Misc/smartArray";
  24979. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24980. import { Nullable } from "babylonjs/types";
  24981. import { Scene } from "babylonjs/scene";
  24982. import { Matrix } from "babylonjs/Maths/math.vector";
  24983. import { Color3 } from "babylonjs/Maths/math.color";
  24984. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24986. import { Mesh } from "babylonjs/Meshes/mesh";
  24987. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24988. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24989. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24990. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24991. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24992. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24994. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24995. import "babylonjs/Shaders/default.fragment";
  24996. import "babylonjs/Shaders/default.vertex";
  24997. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24998. /** @hidden */
  24999. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  25000. MAINUV1: boolean;
  25001. MAINUV2: boolean;
  25002. DIFFUSE: boolean;
  25003. DIFFUSEDIRECTUV: number;
  25004. DETAIL: boolean;
  25005. DETAILDIRECTUV: number;
  25006. DETAIL_NORMALBLENDMETHOD: number;
  25007. AMBIENT: boolean;
  25008. AMBIENTDIRECTUV: number;
  25009. OPACITY: boolean;
  25010. OPACITYDIRECTUV: number;
  25011. OPACITYRGB: boolean;
  25012. REFLECTION: boolean;
  25013. EMISSIVE: boolean;
  25014. EMISSIVEDIRECTUV: number;
  25015. SPECULAR: boolean;
  25016. SPECULARDIRECTUV: number;
  25017. BUMP: boolean;
  25018. BUMPDIRECTUV: number;
  25019. PARALLAX: boolean;
  25020. PARALLAXOCCLUSION: boolean;
  25021. SPECULAROVERALPHA: boolean;
  25022. CLIPPLANE: boolean;
  25023. CLIPPLANE2: boolean;
  25024. CLIPPLANE3: boolean;
  25025. CLIPPLANE4: boolean;
  25026. CLIPPLANE5: boolean;
  25027. CLIPPLANE6: boolean;
  25028. ALPHATEST: boolean;
  25029. DEPTHPREPASS: boolean;
  25030. ALPHAFROMDIFFUSE: boolean;
  25031. POINTSIZE: boolean;
  25032. FOG: boolean;
  25033. SPECULARTERM: boolean;
  25034. DIFFUSEFRESNEL: boolean;
  25035. OPACITYFRESNEL: boolean;
  25036. REFLECTIONFRESNEL: boolean;
  25037. REFRACTIONFRESNEL: boolean;
  25038. EMISSIVEFRESNEL: boolean;
  25039. FRESNEL: boolean;
  25040. NORMAL: boolean;
  25041. UV1: boolean;
  25042. UV2: boolean;
  25043. VERTEXCOLOR: boolean;
  25044. VERTEXALPHA: boolean;
  25045. NUM_BONE_INFLUENCERS: number;
  25046. BonesPerMesh: number;
  25047. BONETEXTURE: boolean;
  25048. BONES_VELOCITY_ENABLED: boolean;
  25049. INSTANCES: boolean;
  25050. THIN_INSTANCES: boolean;
  25051. GLOSSINESS: boolean;
  25052. ROUGHNESS: boolean;
  25053. EMISSIVEASILLUMINATION: boolean;
  25054. LINKEMISSIVEWITHDIFFUSE: boolean;
  25055. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25056. LIGHTMAP: boolean;
  25057. LIGHTMAPDIRECTUV: number;
  25058. OBJECTSPACE_NORMALMAP: boolean;
  25059. USELIGHTMAPASSHADOWMAP: boolean;
  25060. REFLECTIONMAP_3D: boolean;
  25061. REFLECTIONMAP_SPHERICAL: boolean;
  25062. REFLECTIONMAP_PLANAR: boolean;
  25063. REFLECTIONMAP_CUBIC: boolean;
  25064. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25065. REFLECTIONMAP_PROJECTION: boolean;
  25066. REFLECTIONMAP_SKYBOX: boolean;
  25067. REFLECTIONMAP_EXPLICIT: boolean;
  25068. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25069. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25070. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25071. INVERTCUBICMAP: boolean;
  25072. LOGARITHMICDEPTH: boolean;
  25073. REFRACTION: boolean;
  25074. REFRACTIONMAP_3D: boolean;
  25075. REFLECTIONOVERALPHA: boolean;
  25076. TWOSIDEDLIGHTING: boolean;
  25077. SHADOWFLOAT: boolean;
  25078. MORPHTARGETS: boolean;
  25079. MORPHTARGETS_NORMAL: boolean;
  25080. MORPHTARGETS_TANGENT: boolean;
  25081. MORPHTARGETS_UV: boolean;
  25082. NUM_MORPH_INFLUENCERS: number;
  25083. NONUNIFORMSCALING: boolean;
  25084. PREMULTIPLYALPHA: boolean;
  25085. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  25086. ALPHABLEND: boolean;
  25087. PREPASS: boolean;
  25088. PREPASS_IRRADIANCE: boolean;
  25089. PREPASS_IRRADIANCE_INDEX: number;
  25090. PREPASS_ALBEDO: boolean;
  25091. PREPASS_ALBEDO_INDEX: number;
  25092. PREPASS_DEPTHNORMAL: boolean;
  25093. PREPASS_DEPTHNORMAL_INDEX: number;
  25094. PREPASS_POSITION: boolean;
  25095. PREPASS_POSITION_INDEX: number;
  25096. PREPASS_VELOCITY: boolean;
  25097. PREPASS_VELOCITY_INDEX: number;
  25098. PREPASS_REFLECTIVITY: boolean;
  25099. PREPASS_REFLECTIVITY_INDEX: number;
  25100. SCENE_MRT_COUNT: number;
  25101. RGBDLIGHTMAP: boolean;
  25102. RGBDREFLECTION: boolean;
  25103. RGBDREFRACTION: boolean;
  25104. IMAGEPROCESSING: boolean;
  25105. VIGNETTE: boolean;
  25106. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25107. VIGNETTEBLENDMODEOPAQUE: boolean;
  25108. TONEMAPPING: boolean;
  25109. TONEMAPPING_ACES: boolean;
  25110. CONTRAST: boolean;
  25111. COLORCURVES: boolean;
  25112. COLORGRADING: boolean;
  25113. COLORGRADING3D: boolean;
  25114. SAMPLER3DGREENDEPTH: boolean;
  25115. SAMPLER3DBGRMAP: boolean;
  25116. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25117. MULTIVIEW: boolean;
  25118. /**
  25119. * If the reflection texture on this material is in linear color space
  25120. * @hidden
  25121. */
  25122. IS_REFLECTION_LINEAR: boolean;
  25123. /**
  25124. * If the refraction texture on this material is in linear color space
  25125. * @hidden
  25126. */
  25127. IS_REFRACTION_LINEAR: boolean;
  25128. EXPOSURE: boolean;
  25129. constructor();
  25130. setReflectionMode(modeToEnable: string): void;
  25131. }
  25132. /**
  25133. * This is the default material used in Babylon. It is the best trade off between quality
  25134. * and performances.
  25135. * @see https://doc.babylonjs.com/babylon101/materials
  25136. */
  25137. export class StandardMaterial extends PushMaterial {
  25138. private _diffuseTexture;
  25139. /**
  25140. * The basic texture of the material as viewed under a light.
  25141. */
  25142. diffuseTexture: Nullable<BaseTexture>;
  25143. private _ambientTexture;
  25144. /**
  25145. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25146. */
  25147. ambientTexture: Nullable<BaseTexture>;
  25148. private _opacityTexture;
  25149. /**
  25150. * Define the transparency of the material from a texture.
  25151. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25152. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  25153. */
  25154. opacityTexture: Nullable<BaseTexture>;
  25155. private _reflectionTexture;
  25156. /**
  25157. * Define the texture used to display the reflection.
  25158. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25159. */
  25160. reflectionTexture: Nullable<BaseTexture>;
  25161. private _emissiveTexture;
  25162. /**
  25163. * Define texture of the material as if self lit.
  25164. * This will be mixed in the final result even in the absence of light.
  25165. */
  25166. emissiveTexture: Nullable<BaseTexture>;
  25167. private _specularTexture;
  25168. /**
  25169. * Define how the color and intensity of the highlight given by the light in the material.
  25170. */
  25171. specularTexture: Nullable<BaseTexture>;
  25172. private _bumpTexture;
  25173. /**
  25174. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  25175. * 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.
  25176. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  25177. */
  25178. bumpTexture: Nullable<BaseTexture>;
  25179. private _lightmapTexture;
  25180. /**
  25181. * Complex lighting can be computationally expensive to compute at runtime.
  25182. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  25183. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  25184. */
  25185. lightmapTexture: Nullable<BaseTexture>;
  25186. private _refractionTexture;
  25187. /**
  25188. * Define the texture used to display the refraction.
  25189. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25190. */
  25191. refractionTexture: Nullable<BaseTexture>;
  25192. /**
  25193. * The color of the material lit by the environmental background lighting.
  25194. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  25195. */
  25196. ambientColor: Color3;
  25197. /**
  25198. * The basic color of the material as viewed under a light.
  25199. */
  25200. diffuseColor: Color3;
  25201. /**
  25202. * Define how the color and intensity of the highlight given by the light in the material.
  25203. */
  25204. specularColor: Color3;
  25205. /**
  25206. * Define the color of the material as if self lit.
  25207. * This will be mixed in the final result even in the absence of light.
  25208. */
  25209. emissiveColor: Color3;
  25210. /**
  25211. * Defines how sharp are the highlights in the material.
  25212. * The bigger the value the sharper giving a more glossy feeling to the result.
  25213. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  25214. */
  25215. specularPower: number;
  25216. private _useAlphaFromDiffuseTexture;
  25217. /**
  25218. * Does the transparency come from the diffuse texture alpha channel.
  25219. */
  25220. useAlphaFromDiffuseTexture: boolean;
  25221. private _useEmissiveAsIllumination;
  25222. /**
  25223. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  25224. */
  25225. useEmissiveAsIllumination: boolean;
  25226. private _linkEmissiveWithDiffuse;
  25227. /**
  25228. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  25229. * the emissive level when the final color is close to one.
  25230. */
  25231. linkEmissiveWithDiffuse: boolean;
  25232. private _useSpecularOverAlpha;
  25233. /**
  25234. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  25235. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25236. */
  25237. useSpecularOverAlpha: boolean;
  25238. private _useReflectionOverAlpha;
  25239. /**
  25240. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25241. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25242. */
  25243. useReflectionOverAlpha: boolean;
  25244. private _disableLighting;
  25245. /**
  25246. * Does lights from the scene impacts this material.
  25247. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  25248. */
  25249. disableLighting: boolean;
  25250. private _useObjectSpaceNormalMap;
  25251. /**
  25252. * Allows using an object space normal map (instead of tangent space).
  25253. */
  25254. useObjectSpaceNormalMap: boolean;
  25255. private _useParallax;
  25256. /**
  25257. * Is parallax enabled or not.
  25258. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25259. */
  25260. useParallax: boolean;
  25261. private _useParallaxOcclusion;
  25262. /**
  25263. * Is parallax occlusion enabled or not.
  25264. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  25265. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25266. */
  25267. useParallaxOcclusion: boolean;
  25268. /**
  25269. * 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.
  25270. */
  25271. parallaxScaleBias: number;
  25272. private _roughness;
  25273. /**
  25274. * Helps to define how blurry the reflections should appears in the material.
  25275. */
  25276. roughness: number;
  25277. /**
  25278. * In case of refraction, define the value of the index of refraction.
  25279. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25280. */
  25281. indexOfRefraction: number;
  25282. /**
  25283. * Invert the refraction texture alongside the y axis.
  25284. * It can be useful with procedural textures or probe for instance.
  25285. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25286. */
  25287. invertRefractionY: boolean;
  25288. /**
  25289. * Defines the alpha limits in alpha test mode.
  25290. */
  25291. alphaCutOff: number;
  25292. private _useLightmapAsShadowmap;
  25293. /**
  25294. * In case of light mapping, define whether the map contains light or shadow informations.
  25295. */
  25296. useLightmapAsShadowmap: boolean;
  25297. private _diffuseFresnelParameters;
  25298. /**
  25299. * Define the diffuse fresnel parameters of the material.
  25300. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25301. */
  25302. diffuseFresnelParameters: FresnelParameters;
  25303. private _opacityFresnelParameters;
  25304. /**
  25305. * Define the opacity fresnel parameters of the material.
  25306. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25307. */
  25308. opacityFresnelParameters: FresnelParameters;
  25309. private _reflectionFresnelParameters;
  25310. /**
  25311. * Define the reflection fresnel parameters of the material.
  25312. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25313. */
  25314. reflectionFresnelParameters: FresnelParameters;
  25315. private _refractionFresnelParameters;
  25316. /**
  25317. * Define the refraction fresnel parameters of the material.
  25318. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25319. */
  25320. refractionFresnelParameters: FresnelParameters;
  25321. private _emissiveFresnelParameters;
  25322. /**
  25323. * Define the emissive fresnel parameters of the material.
  25324. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25325. */
  25326. emissiveFresnelParameters: FresnelParameters;
  25327. private _useReflectionFresnelFromSpecular;
  25328. /**
  25329. * If true automatically deducts the fresnels values from the material specularity.
  25330. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25331. */
  25332. useReflectionFresnelFromSpecular: boolean;
  25333. private _useGlossinessFromSpecularMapAlpha;
  25334. /**
  25335. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25336. */
  25337. useGlossinessFromSpecularMapAlpha: boolean;
  25338. private _maxSimultaneousLights;
  25339. /**
  25340. * Defines the maximum number of lights that can be used in the material
  25341. */
  25342. maxSimultaneousLights: number;
  25343. private _invertNormalMapX;
  25344. /**
  25345. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25346. */
  25347. invertNormalMapX: boolean;
  25348. private _invertNormalMapY;
  25349. /**
  25350. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25351. */
  25352. invertNormalMapY: boolean;
  25353. private _twoSidedLighting;
  25354. /**
  25355. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25356. */
  25357. twoSidedLighting: boolean;
  25358. /**
  25359. * Default configuration related to image processing available in the standard Material.
  25360. */
  25361. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25362. /**
  25363. * Gets the image processing configuration used either in this material.
  25364. */
  25365. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25366. /**
  25367. * Sets the Default image processing configuration used either in the this material.
  25368. *
  25369. * If sets to null, the scene one is in use.
  25370. */
  25371. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25372. /**
  25373. * Keep track of the image processing observer to allow dispose and replace.
  25374. */
  25375. private _imageProcessingObserver;
  25376. /**
  25377. * Attaches a new image processing configuration to the Standard Material.
  25378. * @param configuration
  25379. */
  25380. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25381. /**
  25382. * Defines additionnal PrePass parameters for the material.
  25383. */
  25384. readonly prePassConfiguration: PrePassConfiguration;
  25385. /**
  25386. * Gets wether the color curves effect is enabled.
  25387. */
  25388. get cameraColorCurvesEnabled(): boolean;
  25389. /**
  25390. * Sets wether the color curves effect is enabled.
  25391. */
  25392. set cameraColorCurvesEnabled(value: boolean);
  25393. /**
  25394. * Gets wether the color grading effect is enabled.
  25395. */
  25396. get cameraColorGradingEnabled(): boolean;
  25397. /**
  25398. * Gets wether the color grading effect is enabled.
  25399. */
  25400. set cameraColorGradingEnabled(value: boolean);
  25401. /**
  25402. * Gets wether tonemapping is enabled or not.
  25403. */
  25404. get cameraToneMappingEnabled(): boolean;
  25405. /**
  25406. * Sets wether tonemapping is enabled or not
  25407. */
  25408. set cameraToneMappingEnabled(value: boolean);
  25409. /**
  25410. * The camera exposure used on this material.
  25411. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25412. * This corresponds to a photographic exposure.
  25413. */
  25414. get cameraExposure(): number;
  25415. /**
  25416. * The camera exposure used on this material.
  25417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25418. * This corresponds to a photographic exposure.
  25419. */
  25420. set cameraExposure(value: number);
  25421. /**
  25422. * Gets The camera contrast used on this material.
  25423. */
  25424. get cameraContrast(): number;
  25425. /**
  25426. * Sets The camera contrast used on this material.
  25427. */
  25428. set cameraContrast(value: number);
  25429. /**
  25430. * Gets the Color Grading 2D Lookup Texture.
  25431. */
  25432. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25433. /**
  25434. * Sets the Color Grading 2D Lookup Texture.
  25435. */
  25436. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25437. /**
  25438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25440. * 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;
  25441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25442. */
  25443. get cameraColorCurves(): Nullable<ColorCurves>;
  25444. /**
  25445. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25446. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25447. * 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;
  25448. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25449. */
  25450. set cameraColorCurves(value: Nullable<ColorCurves>);
  25451. /**
  25452. * Can this material render to several textures at once
  25453. */
  25454. get canRenderToMRT(): boolean;
  25455. /**
  25456. * Defines the detail map parameters for the material.
  25457. */
  25458. readonly detailMap: DetailMapConfiguration;
  25459. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25460. protected _worldViewProjectionMatrix: Matrix;
  25461. protected _globalAmbientColor: Color3;
  25462. protected _useLogarithmicDepth: boolean;
  25463. protected _rebuildInParallel: boolean;
  25464. /**
  25465. * Instantiates a new standard material.
  25466. * This is the default material used in Babylon. It is the best trade off between quality
  25467. * and performances.
  25468. * @see https://doc.babylonjs.com/babylon101/materials
  25469. * @param name Define the name of the material in the scene
  25470. * @param scene Define the scene the material belong to
  25471. */
  25472. constructor(name: string, scene: Scene);
  25473. /**
  25474. * Gets a boolean indicating that current material needs to register RTT
  25475. */
  25476. get hasRenderTargetTextures(): boolean;
  25477. /**
  25478. * Gets the current class name of the material e.g. "StandardMaterial"
  25479. * Mainly use in serialization.
  25480. * @returns the class name
  25481. */
  25482. getClassName(): string;
  25483. /**
  25484. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25485. * You can try switching to logarithmic depth.
  25486. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25487. */
  25488. get useLogarithmicDepth(): boolean;
  25489. set useLogarithmicDepth(value: boolean);
  25490. /**
  25491. * Specifies if the material will require alpha blending
  25492. * @returns a boolean specifying if alpha blending is needed
  25493. */
  25494. needAlphaBlending(): boolean;
  25495. /**
  25496. * Specifies if this material should be rendered in alpha test mode
  25497. * @returns a boolean specifying if an alpha test is needed.
  25498. */
  25499. needAlphaTesting(): boolean;
  25500. /**
  25501. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25502. */
  25503. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25504. /**
  25505. * Specifies whether or not there is a usable alpha channel for transparency.
  25506. */
  25507. protected _hasAlphaChannel(): boolean;
  25508. /**
  25509. * Get the texture used for alpha test purpose.
  25510. * @returns the diffuse texture in case of the standard material.
  25511. */
  25512. getAlphaTestTexture(): Nullable<BaseTexture>;
  25513. /**
  25514. * Get if the submesh is ready to be used and all its information available.
  25515. * Child classes can use it to update shaders
  25516. * @param mesh defines the mesh to check
  25517. * @param subMesh defines which submesh to check
  25518. * @param useInstances specifies that instances should be used
  25519. * @returns a boolean indicating that the submesh is ready or not
  25520. */
  25521. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25522. /**
  25523. * Builds the material UBO layouts.
  25524. * Used internally during the effect preparation.
  25525. */
  25526. buildUniformLayout(): void;
  25527. /**
  25528. * Unbinds the material from the mesh
  25529. */
  25530. unbind(): void;
  25531. /**
  25532. * Binds the submesh to this material by preparing the effect and shader to draw
  25533. * @param world defines the world transformation matrix
  25534. * @param mesh defines the mesh containing the submesh
  25535. * @param subMesh defines the submesh to bind the material to
  25536. */
  25537. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25538. /**
  25539. * Get the list of animatables in the material.
  25540. * @returns the list of animatables object used in the material
  25541. */
  25542. getAnimatables(): IAnimatable[];
  25543. /**
  25544. * Gets the active textures from the material
  25545. * @returns an array of textures
  25546. */
  25547. getActiveTextures(): BaseTexture[];
  25548. /**
  25549. * Specifies if the material uses a texture
  25550. * @param texture defines the texture to check against the material
  25551. * @returns a boolean specifying if the material uses the texture
  25552. */
  25553. hasTexture(texture: BaseTexture): boolean;
  25554. /**
  25555. * Disposes the material
  25556. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25557. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25558. */
  25559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25560. /**
  25561. * Makes a duplicate of the material, and gives it a new name
  25562. * @param name defines the new name for the duplicated material
  25563. * @returns the cloned material
  25564. */
  25565. clone(name: string): StandardMaterial;
  25566. /**
  25567. * Serializes this material in a JSON representation
  25568. * @returns the serialized material object
  25569. */
  25570. serialize(): any;
  25571. /**
  25572. * Creates a standard material from parsed material data
  25573. * @param source defines the JSON representation of the material
  25574. * @param scene defines the hosting scene
  25575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25576. * @returns a new standard material
  25577. */
  25578. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25579. /**
  25580. * Are diffuse textures enabled in the application.
  25581. */
  25582. static get DiffuseTextureEnabled(): boolean;
  25583. static set DiffuseTextureEnabled(value: boolean);
  25584. /**
  25585. * Are detail textures enabled in the application.
  25586. */
  25587. static get DetailTextureEnabled(): boolean;
  25588. static set DetailTextureEnabled(value: boolean);
  25589. /**
  25590. * Are ambient textures enabled in the application.
  25591. */
  25592. static get AmbientTextureEnabled(): boolean;
  25593. static set AmbientTextureEnabled(value: boolean);
  25594. /**
  25595. * Are opacity textures enabled in the application.
  25596. */
  25597. static get OpacityTextureEnabled(): boolean;
  25598. static set OpacityTextureEnabled(value: boolean);
  25599. /**
  25600. * Are reflection textures enabled in the application.
  25601. */
  25602. static get ReflectionTextureEnabled(): boolean;
  25603. static set ReflectionTextureEnabled(value: boolean);
  25604. /**
  25605. * Are emissive textures enabled in the application.
  25606. */
  25607. static get EmissiveTextureEnabled(): boolean;
  25608. static set EmissiveTextureEnabled(value: boolean);
  25609. /**
  25610. * Are specular textures enabled in the application.
  25611. */
  25612. static get SpecularTextureEnabled(): boolean;
  25613. static set SpecularTextureEnabled(value: boolean);
  25614. /**
  25615. * Are bump textures enabled in the application.
  25616. */
  25617. static get BumpTextureEnabled(): boolean;
  25618. static set BumpTextureEnabled(value: boolean);
  25619. /**
  25620. * Are lightmap textures enabled in the application.
  25621. */
  25622. static get LightmapTextureEnabled(): boolean;
  25623. static set LightmapTextureEnabled(value: boolean);
  25624. /**
  25625. * Are refraction textures enabled in the application.
  25626. */
  25627. static get RefractionTextureEnabled(): boolean;
  25628. static set RefractionTextureEnabled(value: boolean);
  25629. /**
  25630. * Are color grading textures enabled in the application.
  25631. */
  25632. static get ColorGradingTextureEnabled(): boolean;
  25633. static set ColorGradingTextureEnabled(value: boolean);
  25634. /**
  25635. * Are fresnels enabled in the application.
  25636. */
  25637. static get FresnelEnabled(): boolean;
  25638. static set FresnelEnabled(value: boolean);
  25639. }
  25640. }
  25641. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25642. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25643. /** @hidden */
  25644. export var rgbdDecodePixelShader: {
  25645. name: string;
  25646. shader: string;
  25647. };
  25648. }
  25649. declare module "babylonjs/Misc/rgbdTextureTools" {
  25650. import "babylonjs/Shaders/rgbdDecode.fragment";
  25651. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25652. import { Texture } from "babylonjs/Materials/Textures/texture";
  25653. /**
  25654. * Class used to host RGBD texture specific utilities
  25655. */
  25656. export class RGBDTextureTools {
  25657. /**
  25658. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25659. * @param texture the texture to expand.
  25660. */
  25661. static ExpandRGBDTexture(texture: Texture): void;
  25662. }
  25663. }
  25664. declare module "babylonjs/Misc/brdfTextureTools" {
  25665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25666. import { Scene } from "babylonjs/scene";
  25667. /**
  25668. * Class used to host texture specific utilities
  25669. */
  25670. export class BRDFTextureTools {
  25671. /**
  25672. * Prevents texture cache collision
  25673. */
  25674. private static _instanceNumber;
  25675. /**
  25676. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25677. * @param scene defines the hosting scene
  25678. * @returns the environment BRDF texture
  25679. */
  25680. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25681. private static _environmentBRDFBase64Texture;
  25682. }
  25683. }
  25684. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25685. import { Nullable } from "babylonjs/types";
  25686. import { Color3 } from "babylonjs/Maths/math.color";
  25687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25688. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25689. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25690. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25691. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25692. import { Engine } from "babylonjs/Engines/engine";
  25693. import { Scene } from "babylonjs/scene";
  25694. /**
  25695. * @hidden
  25696. */
  25697. export interface IMaterialClearCoatDefines {
  25698. CLEARCOAT: boolean;
  25699. CLEARCOAT_DEFAULTIOR: boolean;
  25700. CLEARCOAT_TEXTURE: boolean;
  25701. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25702. CLEARCOAT_TEXTUREDIRECTUV: number;
  25703. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25704. CLEARCOAT_BUMP: boolean;
  25705. CLEARCOAT_BUMPDIRECTUV: number;
  25706. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25707. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25708. CLEARCOAT_REMAP_F0: boolean;
  25709. CLEARCOAT_TINT: boolean;
  25710. CLEARCOAT_TINT_TEXTURE: boolean;
  25711. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25712. /** @hidden */
  25713. _areTexturesDirty: boolean;
  25714. }
  25715. /**
  25716. * Define the code related to the clear coat parameters of the pbr material.
  25717. */
  25718. export class PBRClearCoatConfiguration {
  25719. /**
  25720. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25721. * The default fits with a polyurethane material.
  25722. */
  25723. private static readonly _DefaultIndexOfRefraction;
  25724. private _isEnabled;
  25725. /**
  25726. * Defines if the clear coat is enabled in the material.
  25727. */
  25728. isEnabled: boolean;
  25729. /**
  25730. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25731. */
  25732. intensity: number;
  25733. /**
  25734. * Defines the clear coat layer roughness.
  25735. */
  25736. roughness: number;
  25737. private _indexOfRefraction;
  25738. /**
  25739. * Defines the index of refraction of the clear coat.
  25740. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25741. * The default fits with a polyurethane material.
  25742. * Changing the default value is more performance intensive.
  25743. */
  25744. indexOfRefraction: number;
  25745. private _texture;
  25746. /**
  25747. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25748. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25749. * if textureRoughness is not empty, else no texture roughness is used
  25750. */
  25751. texture: Nullable<BaseTexture>;
  25752. private _useRoughnessFromMainTexture;
  25753. /**
  25754. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25755. * If false, the green channel from textureRoughness is used for roughness
  25756. */
  25757. useRoughnessFromMainTexture: boolean;
  25758. private _textureRoughness;
  25759. /**
  25760. * Stores the clear coat roughness in a texture (green channel)
  25761. * Not used if useRoughnessFromMainTexture is true
  25762. */
  25763. textureRoughness: Nullable<BaseTexture>;
  25764. private _remapF0OnInterfaceChange;
  25765. /**
  25766. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25767. */
  25768. remapF0OnInterfaceChange: boolean;
  25769. private _bumpTexture;
  25770. /**
  25771. * Define the clear coat specific bump texture.
  25772. */
  25773. bumpTexture: Nullable<BaseTexture>;
  25774. private _isTintEnabled;
  25775. /**
  25776. * Defines if the clear coat tint is enabled in the material.
  25777. */
  25778. isTintEnabled: boolean;
  25779. /**
  25780. * Defines the clear coat tint of the material.
  25781. * This is only use if tint is enabled
  25782. */
  25783. tintColor: Color3;
  25784. /**
  25785. * Defines the distance at which the tint color should be found in the
  25786. * clear coat media.
  25787. * This is only use if tint is enabled
  25788. */
  25789. tintColorAtDistance: number;
  25790. /**
  25791. * Defines the clear coat layer thickness.
  25792. * This is only use if tint is enabled
  25793. */
  25794. tintThickness: number;
  25795. private _tintTexture;
  25796. /**
  25797. * Stores the clear tint values in a texture.
  25798. * rgb is tint
  25799. * a is a thickness factor
  25800. */
  25801. tintTexture: Nullable<BaseTexture>;
  25802. /** @hidden */
  25803. private _internalMarkAllSubMeshesAsTexturesDirty;
  25804. /** @hidden */
  25805. _markAllSubMeshesAsTexturesDirty(): void;
  25806. /**
  25807. * Instantiate a new istance of clear coat configuration.
  25808. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25809. */
  25810. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25811. /**
  25812. * Gets wehter the submesh is ready to be used or not.
  25813. * @param defines the list of "defines" to update.
  25814. * @param scene defines the scene the material belongs to.
  25815. * @param engine defines the engine the material belongs to.
  25816. * @param disableBumpMap defines wether the material disables bump or not.
  25817. * @returns - boolean indicating that the submesh is ready or not.
  25818. */
  25819. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25820. /**
  25821. * Checks to see if a texture is used in the material.
  25822. * @param defines the list of "defines" to update.
  25823. * @param scene defines the scene to the material belongs to.
  25824. */
  25825. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25826. /**
  25827. * Binds the material data.
  25828. * @param uniformBuffer defines the Uniform buffer to fill in.
  25829. * @param scene defines the scene the material belongs to.
  25830. * @param engine defines the engine the material belongs to.
  25831. * @param disableBumpMap defines wether the material disables bump or not.
  25832. * @param isFrozen defines wether the material is frozen or not.
  25833. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25834. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25835. * @param subMesh the submesh to bind data for
  25836. */
  25837. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25838. /**
  25839. * Checks to see if a texture is used in the material.
  25840. * @param texture - Base texture to use.
  25841. * @returns - Boolean specifying if a texture is used in the material.
  25842. */
  25843. hasTexture(texture: BaseTexture): boolean;
  25844. /**
  25845. * Returns an array of the actively used textures.
  25846. * @param activeTextures Array of BaseTextures
  25847. */
  25848. getActiveTextures(activeTextures: BaseTexture[]): void;
  25849. /**
  25850. * Returns the animatable textures.
  25851. * @param animatables Array of animatable textures.
  25852. */
  25853. getAnimatables(animatables: IAnimatable[]): void;
  25854. /**
  25855. * Disposes the resources of the material.
  25856. * @param forceDisposeTextures - Forces the disposal of all textures.
  25857. */
  25858. dispose(forceDisposeTextures?: boolean): void;
  25859. /**
  25860. * Get the current class name of the texture useful for serialization or dynamic coding.
  25861. * @returns "PBRClearCoatConfiguration"
  25862. */
  25863. getClassName(): string;
  25864. /**
  25865. * Add fallbacks to the effect fallbacks list.
  25866. * @param defines defines the Base texture to use.
  25867. * @param fallbacks defines the current fallback list.
  25868. * @param currentRank defines the current fallback rank.
  25869. * @returns the new fallback rank.
  25870. */
  25871. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25872. /**
  25873. * Add the required uniforms to the current list.
  25874. * @param uniforms defines the current uniform list.
  25875. */
  25876. static AddUniforms(uniforms: string[]): void;
  25877. /**
  25878. * Add the required samplers to the current list.
  25879. * @param samplers defines the current sampler list.
  25880. */
  25881. static AddSamplers(samplers: string[]): void;
  25882. /**
  25883. * Add the required uniforms to the current buffer.
  25884. * @param uniformBuffer defines the current uniform buffer.
  25885. */
  25886. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25887. /**
  25888. * Makes a duplicate of the current configuration into another one.
  25889. * @param clearCoatConfiguration define the config where to copy the info
  25890. */
  25891. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25892. /**
  25893. * Serializes this clear coat configuration.
  25894. * @returns - An object with the serialized config.
  25895. */
  25896. serialize(): any;
  25897. /**
  25898. * Parses a anisotropy Configuration from a serialized object.
  25899. * @param source - Serialized object.
  25900. * @param scene Defines the scene we are parsing for
  25901. * @param rootUrl Defines the rootUrl to load from
  25902. */
  25903. parse(source: any, scene: Scene, rootUrl: string): void;
  25904. }
  25905. }
  25906. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25907. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25909. import { Vector2 } from "babylonjs/Maths/math.vector";
  25910. import { Scene } from "babylonjs/scene";
  25911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25912. import { Nullable } from "babylonjs/types";
  25913. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25914. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25915. /**
  25916. * @hidden
  25917. */
  25918. export interface IMaterialAnisotropicDefines {
  25919. ANISOTROPIC: boolean;
  25920. ANISOTROPIC_TEXTURE: boolean;
  25921. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25922. MAINUV1: boolean;
  25923. _areTexturesDirty: boolean;
  25924. _needUVs: boolean;
  25925. }
  25926. /**
  25927. * Define the code related to the anisotropic parameters of the pbr material.
  25928. */
  25929. export class PBRAnisotropicConfiguration {
  25930. private _isEnabled;
  25931. /**
  25932. * Defines if the anisotropy is enabled in the material.
  25933. */
  25934. isEnabled: boolean;
  25935. /**
  25936. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25937. */
  25938. intensity: number;
  25939. /**
  25940. * Defines if the effect is along the tangents, bitangents or in between.
  25941. * By default, the effect is "strectching" the highlights along the tangents.
  25942. */
  25943. direction: Vector2;
  25944. private _texture;
  25945. /**
  25946. * Stores the anisotropy values in a texture.
  25947. * rg is direction (like normal from -1 to 1)
  25948. * b is a intensity
  25949. */
  25950. texture: Nullable<BaseTexture>;
  25951. /** @hidden */
  25952. private _internalMarkAllSubMeshesAsTexturesDirty;
  25953. /** @hidden */
  25954. _markAllSubMeshesAsTexturesDirty(): void;
  25955. /**
  25956. * Instantiate a new istance of anisotropy configuration.
  25957. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25958. */
  25959. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25960. /**
  25961. * Specifies that the submesh is ready to be used.
  25962. * @param defines the list of "defines" to update.
  25963. * @param scene defines the scene the material belongs to.
  25964. * @returns - boolean indicating that the submesh is ready or not.
  25965. */
  25966. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25967. /**
  25968. * Checks to see if a texture is used in the material.
  25969. * @param defines the list of "defines" to update.
  25970. * @param mesh the mesh we are preparing the defines for.
  25971. * @param scene defines the scene the material belongs to.
  25972. */
  25973. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25974. /**
  25975. * Binds the material data.
  25976. * @param uniformBuffer defines the Uniform buffer to fill in.
  25977. * @param scene defines the scene the material belongs to.
  25978. * @param isFrozen defines wether the material is frozen or not.
  25979. */
  25980. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25981. /**
  25982. * Checks to see if a texture is used in the material.
  25983. * @param texture - Base texture to use.
  25984. * @returns - Boolean specifying if a texture is used in the material.
  25985. */
  25986. hasTexture(texture: BaseTexture): boolean;
  25987. /**
  25988. * Returns an array of the actively used textures.
  25989. * @param activeTextures Array of BaseTextures
  25990. */
  25991. getActiveTextures(activeTextures: BaseTexture[]): void;
  25992. /**
  25993. * Returns the animatable textures.
  25994. * @param animatables Array of animatable textures.
  25995. */
  25996. getAnimatables(animatables: IAnimatable[]): void;
  25997. /**
  25998. * Disposes the resources of the material.
  25999. * @param forceDisposeTextures - Forces the disposal of all textures.
  26000. */
  26001. dispose(forceDisposeTextures?: boolean): void;
  26002. /**
  26003. * Get the current class name of the texture useful for serialization or dynamic coding.
  26004. * @returns "PBRAnisotropicConfiguration"
  26005. */
  26006. getClassName(): string;
  26007. /**
  26008. * Add fallbacks to the effect fallbacks list.
  26009. * @param defines defines the Base texture to use.
  26010. * @param fallbacks defines the current fallback list.
  26011. * @param currentRank defines the current fallback rank.
  26012. * @returns the new fallback rank.
  26013. */
  26014. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26015. /**
  26016. * Add the required uniforms to the current list.
  26017. * @param uniforms defines the current uniform list.
  26018. */
  26019. static AddUniforms(uniforms: string[]): void;
  26020. /**
  26021. * Add the required uniforms to the current buffer.
  26022. * @param uniformBuffer defines the current uniform buffer.
  26023. */
  26024. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26025. /**
  26026. * Add the required samplers to the current list.
  26027. * @param samplers defines the current sampler list.
  26028. */
  26029. static AddSamplers(samplers: string[]): void;
  26030. /**
  26031. * Makes a duplicate of the current configuration into another one.
  26032. * @param anisotropicConfiguration define the config where to copy the info
  26033. */
  26034. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  26035. /**
  26036. * Serializes this anisotropy configuration.
  26037. * @returns - An object with the serialized config.
  26038. */
  26039. serialize(): any;
  26040. /**
  26041. * Parses a anisotropy Configuration from a serialized object.
  26042. * @param source - Serialized object.
  26043. * @param scene Defines the scene we are parsing for
  26044. * @param rootUrl Defines the rootUrl to load from
  26045. */
  26046. parse(source: any, scene: Scene, rootUrl: string): void;
  26047. }
  26048. }
  26049. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  26050. import { Scene } from "babylonjs/scene";
  26051. /**
  26052. * @hidden
  26053. */
  26054. export interface IMaterialBRDFDefines {
  26055. BRDF_V_HEIGHT_CORRELATED: boolean;
  26056. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26057. SPHERICAL_HARMONICS: boolean;
  26058. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26059. /** @hidden */
  26060. _areMiscDirty: boolean;
  26061. }
  26062. /**
  26063. * Define the code related to the BRDF parameters of the pbr material.
  26064. */
  26065. export class PBRBRDFConfiguration {
  26066. /**
  26067. * Default value used for the energy conservation.
  26068. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26069. */
  26070. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  26071. /**
  26072. * Default value used for the Smith Visibility Height Correlated mode.
  26073. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26074. */
  26075. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  26076. /**
  26077. * Default value used for the IBL diffuse part.
  26078. * This can help switching back to the polynomials mode globally which is a tiny bit
  26079. * less GPU intensive at the drawback of a lower quality.
  26080. */
  26081. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  26082. /**
  26083. * Default value used for activating energy conservation for the specular workflow.
  26084. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26085. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26086. */
  26087. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  26088. private _useEnergyConservation;
  26089. /**
  26090. * Defines if the material uses energy conservation.
  26091. */
  26092. useEnergyConservation: boolean;
  26093. private _useSmithVisibilityHeightCorrelated;
  26094. /**
  26095. * LEGACY Mode set to false
  26096. * Defines if the material uses height smith correlated visibility term.
  26097. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  26098. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  26099. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  26100. * Not relying on height correlated will also disable energy conservation.
  26101. */
  26102. useSmithVisibilityHeightCorrelated: boolean;
  26103. private _useSphericalHarmonics;
  26104. /**
  26105. * LEGACY Mode set to false
  26106. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  26107. * diffuse part of the IBL.
  26108. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  26109. * to the ground truth.
  26110. */
  26111. useSphericalHarmonics: boolean;
  26112. private _useSpecularGlossinessInputEnergyConservation;
  26113. /**
  26114. * Defines if the material uses energy conservation, when the specular workflow is active.
  26115. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26116. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26117. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  26118. */
  26119. useSpecularGlossinessInputEnergyConservation: boolean;
  26120. /** @hidden */
  26121. private _internalMarkAllSubMeshesAsMiscDirty;
  26122. /** @hidden */
  26123. _markAllSubMeshesAsMiscDirty(): void;
  26124. /**
  26125. * Instantiate a new istance of clear coat configuration.
  26126. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  26127. */
  26128. constructor(markAllSubMeshesAsMiscDirty: () => void);
  26129. /**
  26130. * Checks to see if a texture is used in the material.
  26131. * @param defines the list of "defines" to update.
  26132. */
  26133. prepareDefines(defines: IMaterialBRDFDefines): void;
  26134. /**
  26135. * Get the current class name of the texture useful for serialization or dynamic coding.
  26136. * @returns "PBRClearCoatConfiguration"
  26137. */
  26138. getClassName(): string;
  26139. /**
  26140. * Makes a duplicate of the current configuration into another one.
  26141. * @param brdfConfiguration define the config where to copy the info
  26142. */
  26143. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  26144. /**
  26145. * Serializes this BRDF configuration.
  26146. * @returns - An object with the serialized config.
  26147. */
  26148. serialize(): any;
  26149. /**
  26150. * Parses a anisotropy Configuration from a serialized object.
  26151. * @param source - Serialized object.
  26152. * @param scene Defines the scene we are parsing for
  26153. * @param rootUrl Defines the rootUrl to load from
  26154. */
  26155. parse(source: any, scene: Scene, rootUrl: string): void;
  26156. }
  26157. }
  26158. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  26159. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26160. import { Color3 } from "babylonjs/Maths/math.color";
  26161. import { Scene } from "babylonjs/scene";
  26162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26163. import { Nullable } from "babylonjs/types";
  26164. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26165. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26166. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26167. /**
  26168. * @hidden
  26169. */
  26170. export interface IMaterialSheenDefines {
  26171. SHEEN: boolean;
  26172. SHEEN_TEXTURE: boolean;
  26173. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26174. SHEEN_TEXTUREDIRECTUV: number;
  26175. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26176. SHEEN_LINKWITHALBEDO: boolean;
  26177. SHEEN_ROUGHNESS: boolean;
  26178. SHEEN_ALBEDOSCALING: boolean;
  26179. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26180. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26181. /** @hidden */
  26182. _areTexturesDirty: boolean;
  26183. }
  26184. /**
  26185. * Define the code related to the Sheen parameters of the pbr material.
  26186. */
  26187. export class PBRSheenConfiguration {
  26188. private _isEnabled;
  26189. /**
  26190. * Defines if the material uses sheen.
  26191. */
  26192. isEnabled: boolean;
  26193. private _linkSheenWithAlbedo;
  26194. /**
  26195. * Defines if the sheen is linked to the sheen color.
  26196. */
  26197. linkSheenWithAlbedo: boolean;
  26198. /**
  26199. * Defines the sheen intensity.
  26200. */
  26201. intensity: number;
  26202. /**
  26203. * Defines the sheen color.
  26204. */
  26205. color: Color3;
  26206. private _texture;
  26207. /**
  26208. * Stores the sheen tint values in a texture.
  26209. * rgb is tint
  26210. * 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)
  26211. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  26212. */
  26213. texture: Nullable<BaseTexture>;
  26214. private _useRoughnessFromMainTexture;
  26215. /**
  26216. * Indicates that the alpha channel of the texture property will be used for roughness.
  26217. * Has no effect if the roughness (and texture!) property is not defined
  26218. */
  26219. useRoughnessFromMainTexture: boolean;
  26220. private _roughness;
  26221. /**
  26222. * Defines the sheen roughness.
  26223. * It is not taken into account if linkSheenWithAlbedo is true.
  26224. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  26225. */
  26226. roughness: Nullable<number>;
  26227. private _textureRoughness;
  26228. /**
  26229. * Stores the sheen roughness in a texture.
  26230. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  26231. */
  26232. textureRoughness: Nullable<BaseTexture>;
  26233. private _albedoScaling;
  26234. /**
  26235. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  26236. * It allows the strength of the sheen effect to not depend on the base color of the material,
  26237. * making it easier to setup and tweak the effect
  26238. */
  26239. albedoScaling: boolean;
  26240. /** @hidden */
  26241. private _internalMarkAllSubMeshesAsTexturesDirty;
  26242. /** @hidden */
  26243. _markAllSubMeshesAsTexturesDirty(): void;
  26244. /**
  26245. * Instantiate a new istance of clear coat configuration.
  26246. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26247. */
  26248. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  26249. /**
  26250. * Specifies that the submesh is ready to be used.
  26251. * @param defines the list of "defines" to update.
  26252. * @param scene defines the scene the material belongs to.
  26253. * @returns - boolean indicating that the submesh is ready or not.
  26254. */
  26255. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  26256. /**
  26257. * Checks to see if a texture is used in the material.
  26258. * @param defines the list of "defines" to update.
  26259. * @param scene defines the scene the material belongs to.
  26260. */
  26261. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  26262. /**
  26263. * Binds the material data.
  26264. * @param uniformBuffer defines the Uniform buffer to fill in.
  26265. * @param scene defines the scene the material belongs to.
  26266. * @param isFrozen defines wether the material is frozen or not.
  26267. * @param subMesh the submesh to bind data for
  26268. */
  26269. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  26270. /**
  26271. * Checks to see if a texture is used in the material.
  26272. * @param texture - Base texture to use.
  26273. * @returns - Boolean specifying if a texture is used in the material.
  26274. */
  26275. hasTexture(texture: BaseTexture): boolean;
  26276. /**
  26277. * Returns an array of the actively used textures.
  26278. * @param activeTextures Array of BaseTextures
  26279. */
  26280. getActiveTextures(activeTextures: BaseTexture[]): void;
  26281. /**
  26282. * Returns the animatable textures.
  26283. * @param animatables Array of animatable textures.
  26284. */
  26285. getAnimatables(animatables: IAnimatable[]): void;
  26286. /**
  26287. * Disposes the resources of the material.
  26288. * @param forceDisposeTextures - Forces the disposal of all textures.
  26289. */
  26290. dispose(forceDisposeTextures?: boolean): void;
  26291. /**
  26292. * Get the current class name of the texture useful for serialization or dynamic coding.
  26293. * @returns "PBRSheenConfiguration"
  26294. */
  26295. getClassName(): string;
  26296. /**
  26297. * Add fallbacks to the effect fallbacks list.
  26298. * @param defines defines the Base texture to use.
  26299. * @param fallbacks defines the current fallback list.
  26300. * @param currentRank defines the current fallback rank.
  26301. * @returns the new fallback rank.
  26302. */
  26303. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26304. /**
  26305. * Add the required uniforms to the current list.
  26306. * @param uniforms defines the current uniform list.
  26307. */
  26308. static AddUniforms(uniforms: string[]): void;
  26309. /**
  26310. * Add the required uniforms to the current buffer.
  26311. * @param uniformBuffer defines the current uniform buffer.
  26312. */
  26313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26314. /**
  26315. * Add the required samplers to the current list.
  26316. * @param samplers defines the current sampler list.
  26317. */
  26318. static AddSamplers(samplers: string[]): void;
  26319. /**
  26320. * Makes a duplicate of the current configuration into another one.
  26321. * @param sheenConfiguration define the config where to copy the info
  26322. */
  26323. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26324. /**
  26325. * Serializes this BRDF configuration.
  26326. * @returns - An object with the serialized config.
  26327. */
  26328. serialize(): any;
  26329. /**
  26330. * Parses a anisotropy Configuration from a serialized object.
  26331. * @param source - Serialized object.
  26332. * @param scene Defines the scene we are parsing for
  26333. * @param rootUrl Defines the rootUrl to load from
  26334. */
  26335. parse(source: any, scene: Scene, rootUrl: string): void;
  26336. }
  26337. }
  26338. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26339. import { Nullable } from "babylonjs/types";
  26340. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26341. import { Color3 } from "babylonjs/Maths/math.color";
  26342. import { SmartArray } from "babylonjs/Misc/smartArray";
  26343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26344. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26345. import { Effect } from "babylonjs/Materials/effect";
  26346. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26347. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26348. import { Engine } from "babylonjs/Engines/engine";
  26349. import { Scene } from "babylonjs/scene";
  26350. /**
  26351. * @hidden
  26352. */
  26353. export interface IMaterialSubSurfaceDefines {
  26354. SUBSURFACE: boolean;
  26355. SS_REFRACTION: boolean;
  26356. SS_TRANSLUCENCY: boolean;
  26357. SS_SCATTERING: boolean;
  26358. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26359. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26360. SS_REFRACTIONMAP_3D: boolean;
  26361. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26362. SS_LODINREFRACTIONALPHA: boolean;
  26363. SS_GAMMAREFRACTION: boolean;
  26364. SS_RGBDREFRACTION: boolean;
  26365. SS_LINEARSPECULARREFRACTION: boolean;
  26366. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26367. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26368. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26369. /** @hidden */
  26370. _areTexturesDirty: boolean;
  26371. }
  26372. /**
  26373. * Define the code related to the sub surface parameters of the pbr material.
  26374. */
  26375. export class PBRSubSurfaceConfiguration {
  26376. private _isRefractionEnabled;
  26377. /**
  26378. * Defines if the refraction is enabled in the material.
  26379. */
  26380. isRefractionEnabled: boolean;
  26381. private _isTranslucencyEnabled;
  26382. /**
  26383. * Defines if the translucency is enabled in the material.
  26384. */
  26385. isTranslucencyEnabled: boolean;
  26386. private _isScatteringEnabled;
  26387. /**
  26388. * Defines if the sub surface scattering is enabled in the material.
  26389. */
  26390. isScatteringEnabled: boolean;
  26391. private _scatteringDiffusionProfileIndex;
  26392. /**
  26393. * Diffusion profile for subsurface scattering.
  26394. * Useful for better scattering in the skins or foliages.
  26395. */
  26396. get scatteringDiffusionProfile(): Nullable<Color3>;
  26397. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26398. /**
  26399. * Defines the refraction intensity of the material.
  26400. * The refraction when enabled replaces the Diffuse part of the material.
  26401. * The intensity helps transitionning between diffuse and refraction.
  26402. */
  26403. refractionIntensity: number;
  26404. /**
  26405. * Defines the translucency intensity of the material.
  26406. * When translucency has been enabled, this defines how much of the "translucency"
  26407. * is addded to the diffuse part of the material.
  26408. */
  26409. translucencyIntensity: number;
  26410. /**
  26411. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26412. */
  26413. useAlbedoToTintRefraction: boolean;
  26414. private _thicknessTexture;
  26415. /**
  26416. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26417. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26418. * 0 would mean minimumThickness
  26419. * 1 would mean maximumThickness
  26420. * The other channels might be use as a mask to vary the different effects intensity.
  26421. */
  26422. thicknessTexture: Nullable<BaseTexture>;
  26423. private _refractionTexture;
  26424. /**
  26425. * Defines the texture to use for refraction.
  26426. */
  26427. refractionTexture: Nullable<BaseTexture>;
  26428. private _indexOfRefraction;
  26429. /**
  26430. * Index of refraction of the material base layer.
  26431. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26432. *
  26433. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26434. *
  26435. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26436. */
  26437. indexOfRefraction: number;
  26438. private _volumeIndexOfRefraction;
  26439. /**
  26440. * Index of refraction of the material's volume.
  26441. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26442. *
  26443. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26444. * the volume will use the same IOR as the surface.
  26445. */
  26446. get volumeIndexOfRefraction(): number;
  26447. set volumeIndexOfRefraction(value: number);
  26448. private _invertRefractionY;
  26449. /**
  26450. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26451. */
  26452. invertRefractionY: boolean;
  26453. private _linkRefractionWithTransparency;
  26454. /**
  26455. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26456. * Materials half opaque for instance using refraction could benefit from this control.
  26457. */
  26458. linkRefractionWithTransparency: boolean;
  26459. /**
  26460. * Defines the minimum thickness stored in the thickness map.
  26461. * If no thickness map is defined, this value will be used to simulate thickness.
  26462. */
  26463. minimumThickness: number;
  26464. /**
  26465. * Defines the maximum thickness stored in the thickness map.
  26466. */
  26467. maximumThickness: number;
  26468. /**
  26469. * Defines the volume tint of the material.
  26470. * This is used for both translucency and scattering.
  26471. */
  26472. tintColor: Color3;
  26473. /**
  26474. * Defines the distance at which the tint color should be found in the media.
  26475. * This is used for refraction only.
  26476. */
  26477. tintColorAtDistance: number;
  26478. /**
  26479. * Defines how far each channel transmit through the media.
  26480. * It is defined as a color to simplify it selection.
  26481. */
  26482. diffusionDistance: Color3;
  26483. private _useMaskFromThicknessTexture;
  26484. /**
  26485. * Stores the intensity of the different subsurface effects in the thickness texture.
  26486. * * the green channel is the translucency intensity.
  26487. * * the blue channel is the scattering intensity.
  26488. * * the alpha channel is the refraction intensity.
  26489. */
  26490. useMaskFromThicknessTexture: boolean;
  26491. private _scene;
  26492. /** @hidden */
  26493. private _internalMarkAllSubMeshesAsTexturesDirty;
  26494. private _internalMarkScenePrePassDirty;
  26495. /** @hidden */
  26496. _markAllSubMeshesAsTexturesDirty(): void;
  26497. /** @hidden */
  26498. _markScenePrePassDirty(): void;
  26499. /**
  26500. * Instantiate a new istance of sub surface configuration.
  26501. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26502. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26503. * @param scene The scene
  26504. */
  26505. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26506. /**
  26507. * Gets wehter the submesh is ready to be used or not.
  26508. * @param defines the list of "defines" to update.
  26509. * @param scene defines the scene the material belongs to.
  26510. * @returns - boolean indicating that the submesh is ready or not.
  26511. */
  26512. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26513. /**
  26514. * Checks to see if a texture is used in the material.
  26515. * @param defines the list of "defines" to update.
  26516. * @param scene defines the scene to the material belongs to.
  26517. */
  26518. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26519. /**
  26520. * Binds the material data.
  26521. * @param uniformBuffer defines the Uniform buffer to fill in.
  26522. * @param scene defines the scene the material belongs to.
  26523. * @param engine defines the engine the material belongs to.
  26524. * @param isFrozen defines whether the material is frozen or not.
  26525. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26526. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26527. */
  26528. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26529. /**
  26530. * Unbinds the material from the mesh.
  26531. * @param activeEffect defines the effect that should be unbound from.
  26532. * @returns true if unbound, otherwise false
  26533. */
  26534. unbind(activeEffect: Effect): boolean;
  26535. /**
  26536. * Returns the texture used for refraction or null if none is used.
  26537. * @param scene defines the scene the material belongs to.
  26538. * @returns - Refraction texture if present. If no refraction texture and refraction
  26539. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26540. */
  26541. private _getRefractionTexture;
  26542. /**
  26543. * Returns true if alpha blending should be disabled.
  26544. */
  26545. get disableAlphaBlending(): boolean;
  26546. /**
  26547. * Fills the list of render target textures.
  26548. * @param renderTargets the list of render targets to update
  26549. */
  26550. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26551. /**
  26552. * Checks to see if a texture is used in the material.
  26553. * @param texture - Base texture to use.
  26554. * @returns - Boolean specifying if a texture is used in the material.
  26555. */
  26556. hasTexture(texture: BaseTexture): boolean;
  26557. /**
  26558. * Gets a boolean indicating that current material needs to register RTT
  26559. * @returns true if this uses a render target otherwise false.
  26560. */
  26561. hasRenderTargetTextures(): boolean;
  26562. /**
  26563. * Returns an array of the actively used textures.
  26564. * @param activeTextures Array of BaseTextures
  26565. */
  26566. getActiveTextures(activeTextures: BaseTexture[]): void;
  26567. /**
  26568. * Returns the animatable textures.
  26569. * @param animatables Array of animatable textures.
  26570. */
  26571. getAnimatables(animatables: IAnimatable[]): void;
  26572. /**
  26573. * Disposes the resources of the material.
  26574. * @param forceDisposeTextures - Forces the disposal of all textures.
  26575. */
  26576. dispose(forceDisposeTextures?: boolean): void;
  26577. /**
  26578. * Get the current class name of the texture useful for serialization or dynamic coding.
  26579. * @returns "PBRSubSurfaceConfiguration"
  26580. */
  26581. getClassName(): string;
  26582. /**
  26583. * Add fallbacks to the effect fallbacks list.
  26584. * @param defines defines the Base texture to use.
  26585. * @param fallbacks defines the current fallback list.
  26586. * @param currentRank defines the current fallback rank.
  26587. * @returns the new fallback rank.
  26588. */
  26589. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26590. /**
  26591. * Add the required uniforms to the current list.
  26592. * @param uniforms defines the current uniform list.
  26593. */
  26594. static AddUniforms(uniforms: string[]): void;
  26595. /**
  26596. * Add the required samplers to the current list.
  26597. * @param samplers defines the current sampler list.
  26598. */
  26599. static AddSamplers(samplers: string[]): void;
  26600. /**
  26601. * Add the required uniforms to the current buffer.
  26602. * @param uniformBuffer defines the current uniform buffer.
  26603. */
  26604. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26605. /**
  26606. * Makes a duplicate of the current configuration into another one.
  26607. * @param configuration define the config where to copy the info
  26608. */
  26609. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26610. /**
  26611. * Serializes this Sub Surface configuration.
  26612. * @returns - An object with the serialized config.
  26613. */
  26614. serialize(): any;
  26615. /**
  26616. * Parses a anisotropy Configuration from a serialized object.
  26617. * @param source - Serialized object.
  26618. * @param scene Defines the scene we are parsing for
  26619. * @param rootUrl Defines the rootUrl to load from
  26620. */
  26621. parse(source: any, scene: Scene, rootUrl: string): void;
  26622. }
  26623. }
  26624. declare module "babylonjs/Maths/sphericalPolynomial" {
  26625. import { Vector3 } from "babylonjs/Maths/math.vector";
  26626. import { Color3 } from "babylonjs/Maths/math.color";
  26627. /**
  26628. * Class representing spherical harmonics coefficients to the 3rd degree
  26629. */
  26630. export class SphericalHarmonics {
  26631. /**
  26632. * Defines whether or not the harmonics have been prescaled for rendering.
  26633. */
  26634. preScaled: boolean;
  26635. /**
  26636. * The l0,0 coefficients of the spherical harmonics
  26637. */
  26638. l00: Vector3;
  26639. /**
  26640. * The l1,-1 coefficients of the spherical harmonics
  26641. */
  26642. l1_1: Vector3;
  26643. /**
  26644. * The l1,0 coefficients of the spherical harmonics
  26645. */
  26646. l10: Vector3;
  26647. /**
  26648. * The l1,1 coefficients of the spherical harmonics
  26649. */
  26650. l11: Vector3;
  26651. /**
  26652. * The l2,-2 coefficients of the spherical harmonics
  26653. */
  26654. l2_2: Vector3;
  26655. /**
  26656. * The l2,-1 coefficients of the spherical harmonics
  26657. */
  26658. l2_1: Vector3;
  26659. /**
  26660. * The l2,0 coefficients of the spherical harmonics
  26661. */
  26662. l20: Vector3;
  26663. /**
  26664. * The l2,1 coefficients of the spherical harmonics
  26665. */
  26666. l21: Vector3;
  26667. /**
  26668. * The l2,2 coefficients of the spherical harmonics
  26669. */
  26670. l22: Vector3;
  26671. /**
  26672. * Adds a light to the spherical harmonics
  26673. * @param direction the direction of the light
  26674. * @param color the color of the light
  26675. * @param deltaSolidAngle the delta solid angle of the light
  26676. */
  26677. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26678. /**
  26679. * Scales the spherical harmonics by the given amount
  26680. * @param scale the amount to scale
  26681. */
  26682. scaleInPlace(scale: number): void;
  26683. /**
  26684. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26685. *
  26686. * ```
  26687. * E_lm = A_l * L_lm
  26688. * ```
  26689. *
  26690. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26691. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26692. * the scaling factors are given in equation 9.
  26693. */
  26694. convertIncidentRadianceToIrradiance(): void;
  26695. /**
  26696. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26697. *
  26698. * ```
  26699. * L = (1/pi) * E * rho
  26700. * ```
  26701. *
  26702. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26703. */
  26704. convertIrradianceToLambertianRadiance(): void;
  26705. /**
  26706. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26707. * required operations at run time.
  26708. *
  26709. * This is simply done by scaling back the SH with Ylm constants parameter.
  26710. * The trigonometric part being applied by the shader at run time.
  26711. */
  26712. preScaleForRendering(): void;
  26713. /**
  26714. * Constructs a spherical harmonics from an array.
  26715. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26716. * @returns the spherical harmonics
  26717. */
  26718. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26719. /**
  26720. * Gets the spherical harmonics from polynomial
  26721. * @param polynomial the spherical polynomial
  26722. * @returns the spherical harmonics
  26723. */
  26724. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26725. }
  26726. /**
  26727. * Class representing spherical polynomial coefficients to the 3rd degree
  26728. */
  26729. export class SphericalPolynomial {
  26730. private _harmonics;
  26731. /**
  26732. * The spherical harmonics used to create the polynomials.
  26733. */
  26734. get preScaledHarmonics(): SphericalHarmonics;
  26735. /**
  26736. * The x coefficients of the spherical polynomial
  26737. */
  26738. x: Vector3;
  26739. /**
  26740. * The y coefficients of the spherical polynomial
  26741. */
  26742. y: Vector3;
  26743. /**
  26744. * The z coefficients of the spherical polynomial
  26745. */
  26746. z: Vector3;
  26747. /**
  26748. * The xx coefficients of the spherical polynomial
  26749. */
  26750. xx: Vector3;
  26751. /**
  26752. * The yy coefficients of the spherical polynomial
  26753. */
  26754. yy: Vector3;
  26755. /**
  26756. * The zz coefficients of the spherical polynomial
  26757. */
  26758. zz: Vector3;
  26759. /**
  26760. * The xy coefficients of the spherical polynomial
  26761. */
  26762. xy: Vector3;
  26763. /**
  26764. * The yz coefficients of the spherical polynomial
  26765. */
  26766. yz: Vector3;
  26767. /**
  26768. * The zx coefficients of the spherical polynomial
  26769. */
  26770. zx: Vector3;
  26771. /**
  26772. * Adds an ambient color to the spherical polynomial
  26773. * @param color the color to add
  26774. */
  26775. addAmbient(color: Color3): void;
  26776. /**
  26777. * Scales the spherical polynomial by the given amount
  26778. * @param scale the amount to scale
  26779. */
  26780. scaleInPlace(scale: number): void;
  26781. /**
  26782. * Gets the spherical polynomial from harmonics
  26783. * @param harmonics the spherical harmonics
  26784. * @returns the spherical polynomial
  26785. */
  26786. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26787. /**
  26788. * Constructs a spherical polynomial from an array.
  26789. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26790. * @returns the spherical polynomial
  26791. */
  26792. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26793. }
  26794. }
  26795. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26796. import { Nullable } from "babylonjs/types";
  26797. /**
  26798. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26799. */
  26800. export interface CubeMapInfo {
  26801. /**
  26802. * The pixel array for the front face.
  26803. * This is stored in format, left to right, up to down format.
  26804. */
  26805. front: Nullable<ArrayBufferView>;
  26806. /**
  26807. * The pixel array for the back face.
  26808. * This is stored in format, left to right, up to down format.
  26809. */
  26810. back: Nullable<ArrayBufferView>;
  26811. /**
  26812. * The pixel array for the left face.
  26813. * This is stored in format, left to right, up to down format.
  26814. */
  26815. left: Nullable<ArrayBufferView>;
  26816. /**
  26817. * The pixel array for the right face.
  26818. * This is stored in format, left to right, up to down format.
  26819. */
  26820. right: Nullable<ArrayBufferView>;
  26821. /**
  26822. * The pixel array for the up face.
  26823. * This is stored in format, left to right, up to down format.
  26824. */
  26825. up: Nullable<ArrayBufferView>;
  26826. /**
  26827. * The pixel array for the down face.
  26828. * This is stored in format, left to right, up to down format.
  26829. */
  26830. down: Nullable<ArrayBufferView>;
  26831. /**
  26832. * The size of the cubemap stored.
  26833. *
  26834. * Each faces will be size * size pixels.
  26835. */
  26836. size: number;
  26837. /**
  26838. * The format of the texture.
  26839. *
  26840. * RGBA, RGB.
  26841. */
  26842. format: number;
  26843. /**
  26844. * The type of the texture data.
  26845. *
  26846. * UNSIGNED_INT, FLOAT.
  26847. */
  26848. type: number;
  26849. /**
  26850. * Specifies whether the texture is in gamma space.
  26851. */
  26852. gammaSpace: boolean;
  26853. }
  26854. /**
  26855. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26856. */
  26857. export class PanoramaToCubeMapTools {
  26858. private static FACE_LEFT;
  26859. private static FACE_RIGHT;
  26860. private static FACE_FRONT;
  26861. private static FACE_BACK;
  26862. private static FACE_DOWN;
  26863. private static FACE_UP;
  26864. /**
  26865. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26866. *
  26867. * @param float32Array The source data.
  26868. * @param inputWidth The width of the input panorama.
  26869. * @param inputHeight The height of the input panorama.
  26870. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26871. * @return The cubemap data
  26872. */
  26873. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26874. private static CreateCubemapTexture;
  26875. private static CalcProjectionSpherical;
  26876. }
  26877. }
  26878. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26879. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26881. import { Nullable } from "babylonjs/types";
  26882. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26883. /**
  26884. * Helper class dealing with the extraction of spherical polynomial dataArray
  26885. * from a cube map.
  26886. */
  26887. export class CubeMapToSphericalPolynomialTools {
  26888. private static FileFaces;
  26889. /**
  26890. * Converts a texture to the according Spherical Polynomial data.
  26891. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26892. *
  26893. * @param texture The texture to extract the information from.
  26894. * @return The Spherical Polynomial data.
  26895. */
  26896. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26897. /**
  26898. * Converts a cubemap to the according Spherical Polynomial data.
  26899. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26900. *
  26901. * @param cubeInfo The Cube map to extract the information from.
  26902. * @return The Spherical Polynomial data.
  26903. */
  26904. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26905. }
  26906. }
  26907. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26908. import { Nullable } from "babylonjs/types";
  26909. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26910. module "babylonjs/Materials/Textures/baseTexture" {
  26911. interface BaseTexture {
  26912. /**
  26913. * Get the polynomial representation of the texture data.
  26914. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26915. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26916. */
  26917. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26918. }
  26919. }
  26920. }
  26921. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26922. /** @hidden */
  26923. export var pbrFragmentDeclaration: {
  26924. name: string;
  26925. shader: string;
  26926. };
  26927. }
  26928. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26929. /** @hidden */
  26930. export var pbrUboDeclaration: {
  26931. name: string;
  26932. shader: string;
  26933. };
  26934. }
  26935. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26936. /** @hidden */
  26937. export var pbrFragmentExtraDeclaration: {
  26938. name: string;
  26939. shader: string;
  26940. };
  26941. }
  26942. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26943. /** @hidden */
  26944. export var pbrFragmentSamplersDeclaration: {
  26945. name: string;
  26946. shader: string;
  26947. };
  26948. }
  26949. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26950. /** @hidden */
  26951. export var subSurfaceScatteringFunctions: {
  26952. name: string;
  26953. shader: string;
  26954. };
  26955. }
  26956. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26957. /** @hidden */
  26958. export var importanceSampling: {
  26959. name: string;
  26960. shader: string;
  26961. };
  26962. }
  26963. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26964. /** @hidden */
  26965. export var pbrHelperFunctions: {
  26966. name: string;
  26967. shader: string;
  26968. };
  26969. }
  26970. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26971. /** @hidden */
  26972. export var harmonicsFunctions: {
  26973. name: string;
  26974. shader: string;
  26975. };
  26976. }
  26977. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26978. /** @hidden */
  26979. export var pbrDirectLightingSetupFunctions: {
  26980. name: string;
  26981. shader: string;
  26982. };
  26983. }
  26984. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26985. /** @hidden */
  26986. export var pbrDirectLightingFalloffFunctions: {
  26987. name: string;
  26988. shader: string;
  26989. };
  26990. }
  26991. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26992. /** @hidden */
  26993. export var pbrBRDFFunctions: {
  26994. name: string;
  26995. shader: string;
  26996. };
  26997. }
  26998. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26999. /** @hidden */
  27000. export var hdrFilteringFunctions: {
  27001. name: string;
  27002. shader: string;
  27003. };
  27004. }
  27005. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  27006. /** @hidden */
  27007. export var pbrDirectLightingFunctions: {
  27008. name: string;
  27009. shader: string;
  27010. };
  27011. }
  27012. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  27013. /** @hidden */
  27014. export var pbrIBLFunctions: {
  27015. name: string;
  27016. shader: string;
  27017. };
  27018. }
  27019. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  27020. /** @hidden */
  27021. export var pbrBlockAlbedoOpacity: {
  27022. name: string;
  27023. shader: string;
  27024. };
  27025. }
  27026. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  27027. /** @hidden */
  27028. export var pbrBlockReflectivity: {
  27029. name: string;
  27030. shader: string;
  27031. };
  27032. }
  27033. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  27034. /** @hidden */
  27035. export var pbrBlockAmbientOcclusion: {
  27036. name: string;
  27037. shader: string;
  27038. };
  27039. }
  27040. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  27041. /** @hidden */
  27042. export var pbrBlockAlphaFresnel: {
  27043. name: string;
  27044. shader: string;
  27045. };
  27046. }
  27047. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  27048. /** @hidden */
  27049. export var pbrBlockAnisotropic: {
  27050. name: string;
  27051. shader: string;
  27052. };
  27053. }
  27054. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  27055. /** @hidden */
  27056. export var pbrBlockReflection: {
  27057. name: string;
  27058. shader: string;
  27059. };
  27060. }
  27061. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  27062. /** @hidden */
  27063. export var pbrBlockSheen: {
  27064. name: string;
  27065. shader: string;
  27066. };
  27067. }
  27068. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  27069. /** @hidden */
  27070. export var pbrBlockClearcoat: {
  27071. name: string;
  27072. shader: string;
  27073. };
  27074. }
  27075. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  27076. /** @hidden */
  27077. export var pbrBlockSubSurface: {
  27078. name: string;
  27079. shader: string;
  27080. };
  27081. }
  27082. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  27083. /** @hidden */
  27084. export var pbrBlockNormalGeometric: {
  27085. name: string;
  27086. shader: string;
  27087. };
  27088. }
  27089. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  27090. /** @hidden */
  27091. export var pbrBlockNormalFinal: {
  27092. name: string;
  27093. shader: string;
  27094. };
  27095. }
  27096. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  27097. /** @hidden */
  27098. export var pbrBlockLightmapInit: {
  27099. name: string;
  27100. shader: string;
  27101. };
  27102. }
  27103. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  27104. /** @hidden */
  27105. export var pbrBlockGeometryInfo: {
  27106. name: string;
  27107. shader: string;
  27108. };
  27109. }
  27110. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  27111. /** @hidden */
  27112. export var pbrBlockReflectance0: {
  27113. name: string;
  27114. shader: string;
  27115. };
  27116. }
  27117. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  27118. /** @hidden */
  27119. export var pbrBlockReflectance: {
  27120. name: string;
  27121. shader: string;
  27122. };
  27123. }
  27124. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  27125. /** @hidden */
  27126. export var pbrBlockDirectLighting: {
  27127. name: string;
  27128. shader: string;
  27129. };
  27130. }
  27131. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  27132. /** @hidden */
  27133. export var pbrBlockFinalLitComponents: {
  27134. name: string;
  27135. shader: string;
  27136. };
  27137. }
  27138. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  27139. /** @hidden */
  27140. export var pbrBlockFinalUnlitComponents: {
  27141. name: string;
  27142. shader: string;
  27143. };
  27144. }
  27145. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  27146. /** @hidden */
  27147. export var pbrBlockFinalColorComposition: {
  27148. name: string;
  27149. shader: string;
  27150. };
  27151. }
  27152. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  27153. /** @hidden */
  27154. export var pbrBlockImageProcessing: {
  27155. name: string;
  27156. shader: string;
  27157. };
  27158. }
  27159. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  27160. /** @hidden */
  27161. export var pbrDebug: {
  27162. name: string;
  27163. shader: string;
  27164. };
  27165. }
  27166. declare module "babylonjs/Shaders/pbr.fragment" {
  27167. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  27168. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  27169. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27170. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  27171. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27172. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27173. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  27174. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27175. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27176. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27177. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27178. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27179. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  27180. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  27181. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  27182. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27183. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27184. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27185. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  27186. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  27187. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  27188. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  27189. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  27190. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  27191. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27192. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27193. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27194. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  27195. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  27196. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  27197. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  27198. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  27199. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  27200. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  27201. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  27202. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  27203. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27204. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  27205. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27206. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  27207. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27208. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  27209. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  27210. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  27211. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  27212. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  27213. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27214. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  27215. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  27216. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  27217. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27218. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27219. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  27220. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  27221. /** @hidden */
  27222. export var pbrPixelShader: {
  27223. name: string;
  27224. shader: string;
  27225. };
  27226. }
  27227. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  27228. /** @hidden */
  27229. export var pbrVertexDeclaration: {
  27230. name: string;
  27231. shader: string;
  27232. };
  27233. }
  27234. declare module "babylonjs/Shaders/pbr.vertex" {
  27235. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  27236. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27237. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27238. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27239. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27240. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  27241. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27242. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27243. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27244. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27245. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27246. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27247. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27248. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27249. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27250. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27251. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27252. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27253. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  27254. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27255. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27256. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27257. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27258. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27259. /** @hidden */
  27260. export var pbrVertexShader: {
  27261. name: string;
  27262. shader: string;
  27263. };
  27264. }
  27265. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  27266. import { Nullable } from "babylonjs/types";
  27267. import { Scene } from "babylonjs/scene";
  27268. import { Matrix } from "babylonjs/Maths/math.vector";
  27269. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27271. import { Mesh } from "babylonjs/Meshes/mesh";
  27272. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  27273. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  27274. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  27275. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  27276. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  27277. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  27278. import { Color3 } from "babylonjs/Maths/math.color";
  27279. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27280. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  27281. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27282. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27284. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27285. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  27286. import "babylonjs/Shaders/pbr.fragment";
  27287. import "babylonjs/Shaders/pbr.vertex";
  27288. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  27289. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27290. /**
  27291. * Manages the defines for the PBR Material.
  27292. * @hidden
  27293. */
  27294. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27295. PBR: boolean;
  27296. NUM_SAMPLES: string;
  27297. REALTIME_FILTERING: boolean;
  27298. MAINUV1: boolean;
  27299. MAINUV2: boolean;
  27300. UV1: boolean;
  27301. UV2: boolean;
  27302. ALBEDO: boolean;
  27303. GAMMAALBEDO: boolean;
  27304. ALBEDODIRECTUV: number;
  27305. VERTEXCOLOR: boolean;
  27306. DETAIL: boolean;
  27307. DETAILDIRECTUV: number;
  27308. DETAIL_NORMALBLENDMETHOD: number;
  27309. AMBIENT: boolean;
  27310. AMBIENTDIRECTUV: number;
  27311. AMBIENTINGRAYSCALE: boolean;
  27312. OPACITY: boolean;
  27313. VERTEXALPHA: boolean;
  27314. OPACITYDIRECTUV: number;
  27315. OPACITYRGB: boolean;
  27316. ALPHATEST: boolean;
  27317. DEPTHPREPASS: boolean;
  27318. ALPHABLEND: boolean;
  27319. ALPHAFROMALBEDO: boolean;
  27320. ALPHATESTVALUE: string;
  27321. SPECULAROVERALPHA: boolean;
  27322. RADIANCEOVERALPHA: boolean;
  27323. ALPHAFRESNEL: boolean;
  27324. LINEARALPHAFRESNEL: boolean;
  27325. PREMULTIPLYALPHA: boolean;
  27326. EMISSIVE: boolean;
  27327. EMISSIVEDIRECTUV: number;
  27328. REFLECTIVITY: boolean;
  27329. REFLECTIVITYDIRECTUV: number;
  27330. SPECULARTERM: boolean;
  27331. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27332. MICROSURFACEAUTOMATIC: boolean;
  27333. LODBASEDMICROSFURACE: boolean;
  27334. MICROSURFACEMAP: boolean;
  27335. MICROSURFACEMAPDIRECTUV: number;
  27336. METALLICWORKFLOW: boolean;
  27337. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27338. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27339. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27340. AOSTOREINMETALMAPRED: boolean;
  27341. METALLIC_REFLECTANCE: boolean;
  27342. METALLIC_REFLECTANCEDIRECTUV: number;
  27343. ENVIRONMENTBRDF: boolean;
  27344. ENVIRONMENTBRDF_RGBD: boolean;
  27345. NORMAL: boolean;
  27346. TANGENT: boolean;
  27347. BUMP: boolean;
  27348. BUMPDIRECTUV: number;
  27349. OBJECTSPACE_NORMALMAP: boolean;
  27350. PARALLAX: boolean;
  27351. PARALLAXOCCLUSION: boolean;
  27352. NORMALXYSCALE: boolean;
  27353. LIGHTMAP: boolean;
  27354. LIGHTMAPDIRECTUV: number;
  27355. USELIGHTMAPASSHADOWMAP: boolean;
  27356. GAMMALIGHTMAP: boolean;
  27357. RGBDLIGHTMAP: boolean;
  27358. REFLECTION: boolean;
  27359. REFLECTIONMAP_3D: boolean;
  27360. REFLECTIONMAP_SPHERICAL: boolean;
  27361. REFLECTIONMAP_PLANAR: boolean;
  27362. REFLECTIONMAP_CUBIC: boolean;
  27363. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27364. REFLECTIONMAP_PROJECTION: boolean;
  27365. REFLECTIONMAP_SKYBOX: boolean;
  27366. REFLECTIONMAP_EXPLICIT: boolean;
  27367. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27368. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27369. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27370. INVERTCUBICMAP: boolean;
  27371. USESPHERICALFROMREFLECTIONMAP: boolean;
  27372. USEIRRADIANCEMAP: boolean;
  27373. SPHERICAL_HARMONICS: boolean;
  27374. USESPHERICALINVERTEX: boolean;
  27375. REFLECTIONMAP_OPPOSITEZ: boolean;
  27376. LODINREFLECTIONALPHA: boolean;
  27377. GAMMAREFLECTION: boolean;
  27378. RGBDREFLECTION: boolean;
  27379. LINEARSPECULARREFLECTION: boolean;
  27380. RADIANCEOCCLUSION: boolean;
  27381. HORIZONOCCLUSION: boolean;
  27382. INSTANCES: boolean;
  27383. THIN_INSTANCES: boolean;
  27384. PREPASS: boolean;
  27385. PREPASS_IRRADIANCE: boolean;
  27386. PREPASS_IRRADIANCE_INDEX: number;
  27387. PREPASS_ALBEDO: boolean;
  27388. PREPASS_ALBEDO_INDEX: number;
  27389. PREPASS_DEPTHNORMAL: boolean;
  27390. PREPASS_DEPTHNORMAL_INDEX: number;
  27391. PREPASS_POSITION: boolean;
  27392. PREPASS_POSITION_INDEX: number;
  27393. PREPASS_VELOCITY: boolean;
  27394. PREPASS_VELOCITY_INDEX: number;
  27395. PREPASS_REFLECTIVITY: boolean;
  27396. PREPASS_REFLECTIVITY_INDEX: number;
  27397. SCENE_MRT_COUNT: number;
  27398. NUM_BONE_INFLUENCERS: number;
  27399. BonesPerMesh: number;
  27400. BONETEXTURE: boolean;
  27401. BONES_VELOCITY_ENABLED: boolean;
  27402. NONUNIFORMSCALING: boolean;
  27403. MORPHTARGETS: boolean;
  27404. MORPHTARGETS_NORMAL: boolean;
  27405. MORPHTARGETS_TANGENT: boolean;
  27406. MORPHTARGETS_UV: boolean;
  27407. NUM_MORPH_INFLUENCERS: number;
  27408. IMAGEPROCESSING: boolean;
  27409. VIGNETTE: boolean;
  27410. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27411. VIGNETTEBLENDMODEOPAQUE: boolean;
  27412. TONEMAPPING: boolean;
  27413. TONEMAPPING_ACES: boolean;
  27414. CONTRAST: boolean;
  27415. COLORCURVES: boolean;
  27416. COLORGRADING: boolean;
  27417. COLORGRADING3D: boolean;
  27418. SAMPLER3DGREENDEPTH: boolean;
  27419. SAMPLER3DBGRMAP: boolean;
  27420. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27421. EXPOSURE: boolean;
  27422. MULTIVIEW: boolean;
  27423. USEPHYSICALLIGHTFALLOFF: boolean;
  27424. USEGLTFLIGHTFALLOFF: boolean;
  27425. TWOSIDEDLIGHTING: boolean;
  27426. SHADOWFLOAT: boolean;
  27427. CLIPPLANE: boolean;
  27428. CLIPPLANE2: boolean;
  27429. CLIPPLANE3: boolean;
  27430. CLIPPLANE4: boolean;
  27431. CLIPPLANE5: boolean;
  27432. CLIPPLANE6: boolean;
  27433. POINTSIZE: boolean;
  27434. FOG: boolean;
  27435. LOGARITHMICDEPTH: boolean;
  27436. FORCENORMALFORWARD: boolean;
  27437. SPECULARAA: boolean;
  27438. CLEARCOAT: boolean;
  27439. CLEARCOAT_DEFAULTIOR: boolean;
  27440. CLEARCOAT_TEXTURE: boolean;
  27441. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27442. CLEARCOAT_TEXTUREDIRECTUV: number;
  27443. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27444. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27445. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27446. CLEARCOAT_BUMP: boolean;
  27447. CLEARCOAT_BUMPDIRECTUV: number;
  27448. CLEARCOAT_REMAP_F0: boolean;
  27449. CLEARCOAT_TINT: boolean;
  27450. CLEARCOAT_TINT_TEXTURE: boolean;
  27451. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27452. ANISOTROPIC: boolean;
  27453. ANISOTROPIC_TEXTURE: boolean;
  27454. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27455. BRDF_V_HEIGHT_CORRELATED: boolean;
  27456. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27457. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27458. SHEEN: boolean;
  27459. SHEEN_TEXTURE: boolean;
  27460. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27461. SHEEN_TEXTUREDIRECTUV: number;
  27462. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27463. SHEEN_LINKWITHALBEDO: boolean;
  27464. SHEEN_ROUGHNESS: boolean;
  27465. SHEEN_ALBEDOSCALING: boolean;
  27466. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27467. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27468. SUBSURFACE: boolean;
  27469. SS_REFRACTION: boolean;
  27470. SS_TRANSLUCENCY: boolean;
  27471. SS_SCATTERING: boolean;
  27472. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27473. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27474. SS_REFRACTIONMAP_3D: boolean;
  27475. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27476. SS_LODINREFRACTIONALPHA: boolean;
  27477. SS_GAMMAREFRACTION: boolean;
  27478. SS_RGBDREFRACTION: boolean;
  27479. SS_LINEARSPECULARREFRACTION: boolean;
  27480. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27481. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27482. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27483. UNLIT: boolean;
  27484. DEBUGMODE: number;
  27485. /**
  27486. * Initializes the PBR Material defines.
  27487. */
  27488. constructor();
  27489. /**
  27490. * Resets the PBR Material defines.
  27491. */
  27492. reset(): void;
  27493. }
  27494. /**
  27495. * The Physically based material base class of BJS.
  27496. *
  27497. * This offers the main features of a standard PBR material.
  27498. * For more information, please refer to the documentation :
  27499. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27500. */
  27501. export abstract class PBRBaseMaterial extends PushMaterial {
  27502. /**
  27503. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27504. */
  27505. static readonly PBRMATERIAL_OPAQUE: number;
  27506. /**
  27507. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27508. */
  27509. static readonly PBRMATERIAL_ALPHATEST: number;
  27510. /**
  27511. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27512. */
  27513. static readonly PBRMATERIAL_ALPHABLEND: number;
  27514. /**
  27515. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27516. * They are also discarded below the alpha cutoff threshold to improve performances.
  27517. */
  27518. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27519. /**
  27520. * Defines the default value of how much AO map is occluding the analytical lights
  27521. * (point spot...).
  27522. */
  27523. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27524. /**
  27525. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27526. */
  27527. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27528. /**
  27529. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27530. * to enhance interoperability with other engines.
  27531. */
  27532. static readonly LIGHTFALLOFF_GLTF: number;
  27533. /**
  27534. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27535. * to enhance interoperability with other materials.
  27536. */
  27537. static readonly LIGHTFALLOFF_STANDARD: number;
  27538. /**
  27539. * Intensity of the direct lights e.g. the four lights available in your scene.
  27540. * This impacts both the direct diffuse and specular highlights.
  27541. */
  27542. protected _directIntensity: number;
  27543. /**
  27544. * Intensity of the emissive part of the material.
  27545. * This helps controlling the emissive effect without modifying the emissive color.
  27546. */
  27547. protected _emissiveIntensity: number;
  27548. /**
  27549. * Intensity of the environment e.g. how much the environment will light the object
  27550. * either through harmonics for rough material or through the refelction for shiny ones.
  27551. */
  27552. protected _environmentIntensity: number;
  27553. /**
  27554. * This is a special control allowing the reduction of the specular highlights coming from the
  27555. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27556. */
  27557. protected _specularIntensity: number;
  27558. /**
  27559. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27560. */
  27561. private _lightingInfos;
  27562. /**
  27563. * Debug Control allowing disabling the bump map on this material.
  27564. */
  27565. protected _disableBumpMap: boolean;
  27566. /**
  27567. * AKA Diffuse Texture in standard nomenclature.
  27568. */
  27569. protected _albedoTexture: Nullable<BaseTexture>;
  27570. /**
  27571. * AKA Occlusion Texture in other nomenclature.
  27572. */
  27573. protected _ambientTexture: Nullable<BaseTexture>;
  27574. /**
  27575. * AKA Occlusion Texture Intensity in other nomenclature.
  27576. */
  27577. protected _ambientTextureStrength: number;
  27578. /**
  27579. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27580. * 1 means it completely occludes it
  27581. * 0 mean it has no impact
  27582. */
  27583. protected _ambientTextureImpactOnAnalyticalLights: number;
  27584. /**
  27585. * Stores the alpha values in a texture.
  27586. */
  27587. protected _opacityTexture: Nullable<BaseTexture>;
  27588. /**
  27589. * Stores the reflection values in a texture.
  27590. */
  27591. protected _reflectionTexture: Nullable<BaseTexture>;
  27592. /**
  27593. * Stores the emissive values in a texture.
  27594. */
  27595. protected _emissiveTexture: Nullable<BaseTexture>;
  27596. /**
  27597. * AKA Specular texture in other nomenclature.
  27598. */
  27599. protected _reflectivityTexture: Nullable<BaseTexture>;
  27600. /**
  27601. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27602. */
  27603. protected _metallicTexture: Nullable<BaseTexture>;
  27604. /**
  27605. * Specifies the metallic scalar of the metallic/roughness workflow.
  27606. * Can also be used to scale the metalness values of the metallic texture.
  27607. */
  27608. protected _metallic: Nullable<number>;
  27609. /**
  27610. * Specifies the roughness scalar of the metallic/roughness workflow.
  27611. * Can also be used to scale the roughness values of the metallic texture.
  27612. */
  27613. protected _roughness: Nullable<number>;
  27614. /**
  27615. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27616. * By default the indexOfrefraction is used to compute F0;
  27617. *
  27618. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27619. *
  27620. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27621. * F90 = metallicReflectanceColor;
  27622. */
  27623. protected _metallicF0Factor: number;
  27624. /**
  27625. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27626. * By default the F90 is always 1;
  27627. *
  27628. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27629. *
  27630. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27631. * F90 = metallicReflectanceColor;
  27632. */
  27633. protected _metallicReflectanceColor: Color3;
  27634. /**
  27635. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27636. * This is multiply against the scalar values defined in the material.
  27637. */
  27638. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27639. /**
  27640. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27641. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27642. */
  27643. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27644. /**
  27645. * Stores surface normal data used to displace a mesh in a texture.
  27646. */
  27647. protected _bumpTexture: Nullable<BaseTexture>;
  27648. /**
  27649. * Stores the pre-calculated light information of a mesh in a texture.
  27650. */
  27651. protected _lightmapTexture: Nullable<BaseTexture>;
  27652. /**
  27653. * The color of a material in ambient lighting.
  27654. */
  27655. protected _ambientColor: Color3;
  27656. /**
  27657. * AKA Diffuse Color in other nomenclature.
  27658. */
  27659. protected _albedoColor: Color3;
  27660. /**
  27661. * AKA Specular Color in other nomenclature.
  27662. */
  27663. protected _reflectivityColor: Color3;
  27664. /**
  27665. * The color applied when light is reflected from a material.
  27666. */
  27667. protected _reflectionColor: Color3;
  27668. /**
  27669. * The color applied when light is emitted from a material.
  27670. */
  27671. protected _emissiveColor: Color3;
  27672. /**
  27673. * AKA Glossiness in other nomenclature.
  27674. */
  27675. protected _microSurface: number;
  27676. /**
  27677. * Specifies that the material will use the light map as a show map.
  27678. */
  27679. protected _useLightmapAsShadowmap: boolean;
  27680. /**
  27681. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27682. * makes the reflect vector face the model (under horizon).
  27683. */
  27684. protected _useHorizonOcclusion: boolean;
  27685. /**
  27686. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27687. * too much the area relying on ambient texture to define their ambient occlusion.
  27688. */
  27689. protected _useRadianceOcclusion: boolean;
  27690. /**
  27691. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27692. */
  27693. protected _useAlphaFromAlbedoTexture: boolean;
  27694. /**
  27695. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27696. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27697. */
  27698. protected _useSpecularOverAlpha: boolean;
  27699. /**
  27700. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27701. */
  27702. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27703. /**
  27704. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27705. */
  27706. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27707. /**
  27708. * Specifies if the metallic texture contains the roughness information in its green channel.
  27709. */
  27710. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27711. /**
  27712. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27713. */
  27714. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27715. /**
  27716. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27717. */
  27718. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27719. /**
  27720. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27721. */
  27722. protected _useAmbientInGrayScale: boolean;
  27723. /**
  27724. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27725. * The material will try to infer what glossiness each pixel should be.
  27726. */
  27727. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27728. /**
  27729. * Defines the falloff type used in this material.
  27730. * It by default is Physical.
  27731. */
  27732. protected _lightFalloff: number;
  27733. /**
  27734. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27735. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27736. */
  27737. protected _useRadianceOverAlpha: boolean;
  27738. /**
  27739. * Allows using an object space normal map (instead of tangent space).
  27740. */
  27741. protected _useObjectSpaceNormalMap: boolean;
  27742. /**
  27743. * Allows using the bump map in parallax mode.
  27744. */
  27745. protected _useParallax: boolean;
  27746. /**
  27747. * Allows using the bump map in parallax occlusion mode.
  27748. */
  27749. protected _useParallaxOcclusion: boolean;
  27750. /**
  27751. * Controls the scale bias of the parallax mode.
  27752. */
  27753. protected _parallaxScaleBias: number;
  27754. /**
  27755. * If sets to true, disables all the lights affecting the material.
  27756. */
  27757. protected _disableLighting: boolean;
  27758. /**
  27759. * Number of Simultaneous lights allowed on the material.
  27760. */
  27761. protected _maxSimultaneousLights: number;
  27762. /**
  27763. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27764. */
  27765. protected _invertNormalMapX: boolean;
  27766. /**
  27767. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27768. */
  27769. protected _invertNormalMapY: boolean;
  27770. /**
  27771. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27772. */
  27773. protected _twoSidedLighting: boolean;
  27774. /**
  27775. * Defines the alpha limits in alpha test mode.
  27776. */
  27777. protected _alphaCutOff: number;
  27778. /**
  27779. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27780. */
  27781. protected _forceAlphaTest: boolean;
  27782. /**
  27783. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27784. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27785. */
  27786. protected _useAlphaFresnel: boolean;
  27787. /**
  27788. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27789. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27790. */
  27791. protected _useLinearAlphaFresnel: boolean;
  27792. /**
  27793. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27794. * from cos thetav and roughness:
  27795. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27796. */
  27797. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27798. /**
  27799. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27800. */
  27801. protected _forceIrradianceInFragment: boolean;
  27802. private _realTimeFiltering;
  27803. /**
  27804. * Enables realtime filtering on the texture.
  27805. */
  27806. get realTimeFiltering(): boolean;
  27807. set realTimeFiltering(b: boolean);
  27808. private _realTimeFilteringQuality;
  27809. /**
  27810. * Quality switch for realtime filtering
  27811. */
  27812. get realTimeFilteringQuality(): number;
  27813. set realTimeFilteringQuality(n: number);
  27814. /**
  27815. * Can this material render to several textures at once
  27816. */
  27817. get canRenderToMRT(): boolean;
  27818. /**
  27819. * Force normal to face away from face.
  27820. */
  27821. protected _forceNormalForward: boolean;
  27822. /**
  27823. * Enables specular anti aliasing in the PBR shader.
  27824. * It will both interacts on the Geometry for analytical and IBL lighting.
  27825. * It also prefilter the roughness map based on the bump values.
  27826. */
  27827. protected _enableSpecularAntiAliasing: boolean;
  27828. /**
  27829. * Default configuration related to image processing available in the PBR Material.
  27830. */
  27831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27832. /**
  27833. * Keep track of the image processing observer to allow dispose and replace.
  27834. */
  27835. private _imageProcessingObserver;
  27836. /**
  27837. * Attaches a new image processing configuration to the PBR Material.
  27838. * @param configuration
  27839. */
  27840. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27841. /**
  27842. * Stores the available render targets.
  27843. */
  27844. private _renderTargets;
  27845. /**
  27846. * Sets the global ambient color for the material used in lighting calculations.
  27847. */
  27848. private _globalAmbientColor;
  27849. /**
  27850. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27851. */
  27852. private _useLogarithmicDepth;
  27853. /**
  27854. * If set to true, no lighting calculations will be applied.
  27855. */
  27856. private _unlit;
  27857. private _debugMode;
  27858. /**
  27859. * @hidden
  27860. * This is reserved for the inspector.
  27861. * Defines the material debug mode.
  27862. * It helps seeing only some components of the material while troubleshooting.
  27863. */
  27864. debugMode: number;
  27865. /**
  27866. * @hidden
  27867. * This is reserved for the inspector.
  27868. * Specify from where on screen the debug mode should start.
  27869. * The value goes from -1 (full screen) to 1 (not visible)
  27870. * It helps with side by side comparison against the final render
  27871. * This defaults to -1
  27872. */
  27873. private debugLimit;
  27874. /**
  27875. * @hidden
  27876. * This is reserved for the inspector.
  27877. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27878. * You can use the factor to better multiply the final value.
  27879. */
  27880. private debugFactor;
  27881. /**
  27882. * Defines the clear coat layer parameters for the material.
  27883. */
  27884. readonly clearCoat: PBRClearCoatConfiguration;
  27885. /**
  27886. * Defines the anisotropic parameters for the material.
  27887. */
  27888. readonly anisotropy: PBRAnisotropicConfiguration;
  27889. /**
  27890. * Defines the BRDF parameters for the material.
  27891. */
  27892. readonly brdf: PBRBRDFConfiguration;
  27893. /**
  27894. * Defines the Sheen parameters for the material.
  27895. */
  27896. readonly sheen: PBRSheenConfiguration;
  27897. /**
  27898. * Defines the SubSurface parameters for the material.
  27899. */
  27900. readonly subSurface: PBRSubSurfaceConfiguration;
  27901. /**
  27902. * Defines additionnal PrePass parameters for the material.
  27903. */
  27904. readonly prePassConfiguration: PrePassConfiguration;
  27905. /**
  27906. * Defines the detail map parameters for the material.
  27907. */
  27908. readonly detailMap: DetailMapConfiguration;
  27909. protected _rebuildInParallel: boolean;
  27910. /**
  27911. * Instantiates a new PBRMaterial instance.
  27912. *
  27913. * @param name The material name
  27914. * @param scene The scene the material will be use in.
  27915. */
  27916. constructor(name: string, scene: Scene);
  27917. /**
  27918. * Gets a boolean indicating that current material needs to register RTT
  27919. */
  27920. get hasRenderTargetTextures(): boolean;
  27921. /**
  27922. * Gets the name of the material class.
  27923. */
  27924. getClassName(): string;
  27925. /**
  27926. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27927. */
  27928. get useLogarithmicDepth(): boolean;
  27929. /**
  27930. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27931. */
  27932. set useLogarithmicDepth(value: boolean);
  27933. /**
  27934. * Returns true if alpha blending should be disabled.
  27935. */
  27936. protected get _disableAlphaBlending(): boolean;
  27937. /**
  27938. * Specifies whether or not this material should be rendered in alpha blend mode.
  27939. */
  27940. needAlphaBlending(): boolean;
  27941. /**
  27942. * Specifies whether or not this material should be rendered in alpha test mode.
  27943. */
  27944. needAlphaTesting(): boolean;
  27945. /**
  27946. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27947. */
  27948. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27949. /**
  27950. * Specifies whether or not there is a usable alpha channel for transparency.
  27951. */
  27952. protected _hasAlphaChannel(): boolean;
  27953. /**
  27954. * Gets the texture used for the alpha test.
  27955. */
  27956. getAlphaTestTexture(): Nullable<BaseTexture>;
  27957. /**
  27958. * Specifies that the submesh is ready to be used.
  27959. * @param mesh - BJS mesh.
  27960. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27961. * @param useInstances - Specifies that instances should be used.
  27962. * @returns - boolean indicating that the submesh is ready or not.
  27963. */
  27964. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27965. /**
  27966. * Specifies if the material uses metallic roughness workflow.
  27967. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27968. */
  27969. isMetallicWorkflow(): boolean;
  27970. private _prepareEffect;
  27971. private _prepareDefines;
  27972. /**
  27973. * Force shader compilation
  27974. */
  27975. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27976. /**
  27977. * Initializes the uniform buffer layout for the shader.
  27978. */
  27979. buildUniformLayout(): void;
  27980. /**
  27981. * Unbinds the material from the mesh
  27982. */
  27983. unbind(): void;
  27984. /**
  27985. * Binds the submesh data.
  27986. * @param world - The world matrix.
  27987. * @param mesh - The BJS mesh.
  27988. * @param subMesh - A submesh of the BJS mesh.
  27989. */
  27990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27991. /**
  27992. * Returns the animatable textures.
  27993. * @returns - Array of animatable textures.
  27994. */
  27995. getAnimatables(): IAnimatable[];
  27996. /**
  27997. * Returns the texture used for reflections.
  27998. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27999. */
  28000. private _getReflectionTexture;
  28001. /**
  28002. * Returns an array of the actively used textures.
  28003. * @returns - Array of BaseTextures
  28004. */
  28005. getActiveTextures(): BaseTexture[];
  28006. /**
  28007. * Checks to see if a texture is used in the material.
  28008. * @param texture - Base texture to use.
  28009. * @returns - Boolean specifying if a texture is used in the material.
  28010. */
  28011. hasTexture(texture: BaseTexture): boolean;
  28012. /**
  28013. * Sets the required values to the prepass renderer.
  28014. * @param prePassRenderer defines the prepass renderer to setup
  28015. */
  28016. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28017. /**
  28018. * Disposes the resources of the material.
  28019. * @param forceDisposeEffect - Forces the disposal of effects.
  28020. * @param forceDisposeTextures - Forces the disposal of all textures.
  28021. */
  28022. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28023. }
  28024. }
  28025. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  28026. import { Nullable } from "babylonjs/types";
  28027. import { Scene } from "babylonjs/scene";
  28028. import { Color3 } from "babylonjs/Maths/math.color";
  28029. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  28030. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  28031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28032. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  28033. /**
  28034. * The Physically based material of BJS.
  28035. *
  28036. * This offers the main features of a standard PBR material.
  28037. * For more information, please refer to the documentation :
  28038. * https://doc.babylonjs.com/how_to/physically_based_rendering
  28039. */
  28040. export class PBRMaterial extends PBRBaseMaterial {
  28041. /**
  28042. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28043. */
  28044. static readonly PBRMATERIAL_OPAQUE: number;
  28045. /**
  28046. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28047. */
  28048. static readonly PBRMATERIAL_ALPHATEST: number;
  28049. /**
  28050. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28051. */
  28052. static readonly PBRMATERIAL_ALPHABLEND: number;
  28053. /**
  28054. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28055. * They are also discarded below the alpha cutoff threshold to improve performances.
  28056. */
  28057. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  28058. /**
  28059. * Defines the default value of how much AO map is occluding the analytical lights
  28060. * (point spot...).
  28061. */
  28062. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  28063. /**
  28064. * Intensity of the direct lights e.g. the four lights available in your scene.
  28065. * This impacts both the direct diffuse and specular highlights.
  28066. */
  28067. directIntensity: number;
  28068. /**
  28069. * Intensity of the emissive part of the material.
  28070. * This helps controlling the emissive effect without modifying the emissive color.
  28071. */
  28072. emissiveIntensity: number;
  28073. /**
  28074. * Intensity of the environment e.g. how much the environment will light the object
  28075. * either through harmonics for rough material or through the refelction for shiny ones.
  28076. */
  28077. environmentIntensity: number;
  28078. /**
  28079. * This is a special control allowing the reduction of the specular highlights coming from the
  28080. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  28081. */
  28082. specularIntensity: number;
  28083. /**
  28084. * Debug Control allowing disabling the bump map on this material.
  28085. */
  28086. disableBumpMap: boolean;
  28087. /**
  28088. * AKA Diffuse Texture in standard nomenclature.
  28089. */
  28090. albedoTexture: BaseTexture;
  28091. /**
  28092. * AKA Occlusion Texture in other nomenclature.
  28093. */
  28094. ambientTexture: BaseTexture;
  28095. /**
  28096. * AKA Occlusion Texture Intensity in other nomenclature.
  28097. */
  28098. ambientTextureStrength: number;
  28099. /**
  28100. * Defines how much the AO map is occluding the analytical lights (point spot...).
  28101. * 1 means it completely occludes it
  28102. * 0 mean it has no impact
  28103. */
  28104. ambientTextureImpactOnAnalyticalLights: number;
  28105. /**
  28106. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  28107. */
  28108. opacityTexture: BaseTexture;
  28109. /**
  28110. * Stores the reflection values in a texture.
  28111. */
  28112. reflectionTexture: Nullable<BaseTexture>;
  28113. /**
  28114. * Stores the emissive values in a texture.
  28115. */
  28116. emissiveTexture: BaseTexture;
  28117. /**
  28118. * AKA Specular texture in other nomenclature.
  28119. */
  28120. reflectivityTexture: BaseTexture;
  28121. /**
  28122. * Used to switch from specular/glossiness to metallic/roughness workflow.
  28123. */
  28124. metallicTexture: BaseTexture;
  28125. /**
  28126. * Specifies the metallic scalar of the metallic/roughness workflow.
  28127. * Can also be used to scale the metalness values of the metallic texture.
  28128. */
  28129. metallic: Nullable<number>;
  28130. /**
  28131. * Specifies the roughness scalar of the metallic/roughness workflow.
  28132. * Can also be used to scale the roughness values of the metallic texture.
  28133. */
  28134. roughness: Nullable<number>;
  28135. /**
  28136. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  28137. * By default the indexOfrefraction is used to compute F0;
  28138. *
  28139. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  28140. *
  28141. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  28142. * F90 = metallicReflectanceColor;
  28143. */
  28144. metallicF0Factor: number;
  28145. /**
  28146. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  28147. * By default the F90 is always 1;
  28148. *
  28149. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  28150. *
  28151. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  28152. * F90 = metallicReflectanceColor;
  28153. */
  28154. metallicReflectanceColor: Color3;
  28155. /**
  28156. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  28157. * This is multiply against the scalar values defined in the material.
  28158. */
  28159. metallicReflectanceTexture: Nullable<BaseTexture>;
  28160. /**
  28161. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  28162. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  28163. */
  28164. microSurfaceTexture: BaseTexture;
  28165. /**
  28166. * Stores surface normal data used to displace a mesh in a texture.
  28167. */
  28168. bumpTexture: BaseTexture;
  28169. /**
  28170. * Stores the pre-calculated light information of a mesh in a texture.
  28171. */
  28172. lightmapTexture: BaseTexture;
  28173. /**
  28174. * Stores the refracted light information in a texture.
  28175. */
  28176. get refractionTexture(): Nullable<BaseTexture>;
  28177. set refractionTexture(value: Nullable<BaseTexture>);
  28178. /**
  28179. * The color of a material in ambient lighting.
  28180. */
  28181. ambientColor: Color3;
  28182. /**
  28183. * AKA Diffuse Color in other nomenclature.
  28184. */
  28185. albedoColor: Color3;
  28186. /**
  28187. * AKA Specular Color in other nomenclature.
  28188. */
  28189. reflectivityColor: Color3;
  28190. /**
  28191. * The color reflected from the material.
  28192. */
  28193. reflectionColor: Color3;
  28194. /**
  28195. * The color emitted from the material.
  28196. */
  28197. emissiveColor: Color3;
  28198. /**
  28199. * AKA Glossiness in other nomenclature.
  28200. */
  28201. microSurface: number;
  28202. /**
  28203. * Index of refraction of the material base layer.
  28204. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  28205. *
  28206. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  28207. *
  28208. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  28209. */
  28210. get indexOfRefraction(): number;
  28211. set indexOfRefraction(value: number);
  28212. /**
  28213. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  28214. */
  28215. get invertRefractionY(): boolean;
  28216. set invertRefractionY(value: boolean);
  28217. /**
  28218. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  28219. * Materials half opaque for instance using refraction could benefit from this control.
  28220. */
  28221. get linkRefractionWithTransparency(): boolean;
  28222. set linkRefractionWithTransparency(value: boolean);
  28223. /**
  28224. * If true, the light map contains occlusion information instead of lighting info.
  28225. */
  28226. useLightmapAsShadowmap: boolean;
  28227. /**
  28228. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  28229. */
  28230. useAlphaFromAlbedoTexture: boolean;
  28231. /**
  28232. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  28233. */
  28234. forceAlphaTest: boolean;
  28235. /**
  28236. * Defines the alpha limits in alpha test mode.
  28237. */
  28238. alphaCutOff: number;
  28239. /**
  28240. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  28241. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  28242. */
  28243. useSpecularOverAlpha: boolean;
  28244. /**
  28245. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  28246. */
  28247. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  28248. /**
  28249. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  28250. */
  28251. useRoughnessFromMetallicTextureAlpha: boolean;
  28252. /**
  28253. * Specifies if the metallic texture contains the roughness information in its green channel.
  28254. */
  28255. useRoughnessFromMetallicTextureGreen: boolean;
  28256. /**
  28257. * Specifies if the metallic texture contains the metallness information in its blue channel.
  28258. */
  28259. useMetallnessFromMetallicTextureBlue: boolean;
  28260. /**
  28261. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  28262. */
  28263. useAmbientOcclusionFromMetallicTextureRed: boolean;
  28264. /**
  28265. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  28266. */
  28267. useAmbientInGrayScale: boolean;
  28268. /**
  28269. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  28270. * The material will try to infer what glossiness each pixel should be.
  28271. */
  28272. useAutoMicroSurfaceFromReflectivityMap: boolean;
  28273. /**
  28274. * BJS is using an harcoded light falloff based on a manually sets up range.
  28275. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28276. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28277. */
  28278. get usePhysicalLightFalloff(): boolean;
  28279. /**
  28280. * BJS is using an harcoded light falloff based on a manually sets up range.
  28281. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28282. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28283. */
  28284. set usePhysicalLightFalloff(value: boolean);
  28285. /**
  28286. * In order to support the falloff compatibility with gltf, a special mode has been added
  28287. * to reproduce the gltf light falloff.
  28288. */
  28289. get useGLTFLightFalloff(): boolean;
  28290. /**
  28291. * In order to support the falloff compatibility with gltf, a special mode has been added
  28292. * to reproduce the gltf light falloff.
  28293. */
  28294. set useGLTFLightFalloff(value: boolean);
  28295. /**
  28296. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28297. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28298. */
  28299. useRadianceOverAlpha: boolean;
  28300. /**
  28301. * Allows using an object space normal map (instead of tangent space).
  28302. */
  28303. useObjectSpaceNormalMap: boolean;
  28304. /**
  28305. * Allows using the bump map in parallax mode.
  28306. */
  28307. useParallax: boolean;
  28308. /**
  28309. * Allows using the bump map in parallax occlusion mode.
  28310. */
  28311. useParallaxOcclusion: boolean;
  28312. /**
  28313. * Controls the scale bias of the parallax mode.
  28314. */
  28315. parallaxScaleBias: number;
  28316. /**
  28317. * If sets to true, disables all the lights affecting the material.
  28318. */
  28319. disableLighting: boolean;
  28320. /**
  28321. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28322. */
  28323. forceIrradianceInFragment: boolean;
  28324. /**
  28325. * Number of Simultaneous lights allowed on the material.
  28326. */
  28327. maxSimultaneousLights: number;
  28328. /**
  28329. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28330. */
  28331. invertNormalMapX: boolean;
  28332. /**
  28333. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28334. */
  28335. invertNormalMapY: boolean;
  28336. /**
  28337. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28338. */
  28339. twoSidedLighting: boolean;
  28340. /**
  28341. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28342. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28343. */
  28344. useAlphaFresnel: boolean;
  28345. /**
  28346. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28347. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28348. */
  28349. useLinearAlphaFresnel: boolean;
  28350. /**
  28351. * Let user defines the brdf lookup texture used for IBL.
  28352. * A default 8bit version is embedded but you could point at :
  28353. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28354. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28355. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28356. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28357. */
  28358. environmentBRDFTexture: Nullable<BaseTexture>;
  28359. /**
  28360. * Force normal to face away from face.
  28361. */
  28362. forceNormalForward: boolean;
  28363. /**
  28364. * Enables specular anti aliasing in the PBR shader.
  28365. * It will both interacts on the Geometry for analytical and IBL lighting.
  28366. * It also prefilter the roughness map based on the bump values.
  28367. */
  28368. enableSpecularAntiAliasing: boolean;
  28369. /**
  28370. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28371. * makes the reflect vector face the model (under horizon).
  28372. */
  28373. useHorizonOcclusion: boolean;
  28374. /**
  28375. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28376. * too much the area relying on ambient texture to define their ambient occlusion.
  28377. */
  28378. useRadianceOcclusion: boolean;
  28379. /**
  28380. * If set to true, no lighting calculations will be applied.
  28381. */
  28382. unlit: boolean;
  28383. /**
  28384. * Gets the image processing configuration used either in this material.
  28385. */
  28386. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28387. /**
  28388. * Sets the Default image processing configuration used either in the this material.
  28389. *
  28390. * If sets to null, the scene one is in use.
  28391. */
  28392. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28393. /**
  28394. * Gets wether the color curves effect is enabled.
  28395. */
  28396. get cameraColorCurvesEnabled(): boolean;
  28397. /**
  28398. * Sets wether the color curves effect is enabled.
  28399. */
  28400. set cameraColorCurvesEnabled(value: boolean);
  28401. /**
  28402. * Gets wether the color grading effect is enabled.
  28403. */
  28404. get cameraColorGradingEnabled(): boolean;
  28405. /**
  28406. * Gets wether the color grading effect is enabled.
  28407. */
  28408. set cameraColorGradingEnabled(value: boolean);
  28409. /**
  28410. * Gets wether tonemapping is enabled or not.
  28411. */
  28412. get cameraToneMappingEnabled(): boolean;
  28413. /**
  28414. * Sets wether tonemapping is enabled or not
  28415. */
  28416. set cameraToneMappingEnabled(value: boolean);
  28417. /**
  28418. * The camera exposure used on this material.
  28419. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28420. * This corresponds to a photographic exposure.
  28421. */
  28422. get cameraExposure(): number;
  28423. /**
  28424. * The camera exposure used on this material.
  28425. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28426. * This corresponds to a photographic exposure.
  28427. */
  28428. set cameraExposure(value: number);
  28429. /**
  28430. * Gets The camera contrast used on this material.
  28431. */
  28432. get cameraContrast(): number;
  28433. /**
  28434. * Sets The camera contrast used on this material.
  28435. */
  28436. set cameraContrast(value: number);
  28437. /**
  28438. * Gets the Color Grading 2D Lookup Texture.
  28439. */
  28440. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28441. /**
  28442. * Sets the Color Grading 2D Lookup Texture.
  28443. */
  28444. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28445. /**
  28446. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28447. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28448. * 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;
  28449. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28450. */
  28451. get cameraColorCurves(): Nullable<ColorCurves>;
  28452. /**
  28453. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28454. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28455. * 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;
  28456. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28457. */
  28458. set cameraColorCurves(value: Nullable<ColorCurves>);
  28459. /**
  28460. * Instantiates a new PBRMaterial instance.
  28461. *
  28462. * @param name The material name
  28463. * @param scene The scene the material will be use in.
  28464. */
  28465. constructor(name: string, scene: Scene);
  28466. /**
  28467. * Returns the name of this material class.
  28468. */
  28469. getClassName(): string;
  28470. /**
  28471. * Makes a duplicate of the current material.
  28472. * @param name - name to use for the new material.
  28473. */
  28474. clone(name: string): PBRMaterial;
  28475. /**
  28476. * Serializes this PBR Material.
  28477. * @returns - An object with the serialized material.
  28478. */
  28479. serialize(): any;
  28480. /**
  28481. * Parses a PBR Material from a serialized object.
  28482. * @param source - Serialized object.
  28483. * @param scene - BJS scene instance.
  28484. * @param rootUrl - url for the scene object
  28485. * @returns - PBRMaterial
  28486. */
  28487. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28488. }
  28489. }
  28490. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28491. /** @hidden */
  28492. export var mrtFragmentDeclaration: {
  28493. name: string;
  28494. shader: string;
  28495. };
  28496. }
  28497. declare module "babylonjs/Shaders/geometry.fragment" {
  28498. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28499. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28500. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28501. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28502. /** @hidden */
  28503. export var geometryPixelShader: {
  28504. name: string;
  28505. shader: string;
  28506. };
  28507. }
  28508. declare module "babylonjs/Shaders/geometry.vertex" {
  28509. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28516. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28517. /** @hidden */
  28518. export var geometryVertexShader: {
  28519. name: string;
  28520. shader: string;
  28521. };
  28522. }
  28523. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28524. import { Matrix } from "babylonjs/Maths/math.vector";
  28525. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28527. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28528. import { Effect } from "babylonjs/Materials/effect";
  28529. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28530. import { Scene } from "babylonjs/scene";
  28531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28532. import { Nullable } from "babylonjs/types";
  28533. import "babylonjs/Shaders/geometry.fragment";
  28534. import "babylonjs/Shaders/geometry.vertex";
  28535. /** @hidden */
  28536. interface ISavedTransformationMatrix {
  28537. world: Matrix;
  28538. viewProjection: Matrix;
  28539. }
  28540. /**
  28541. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28542. */
  28543. export class GeometryBufferRenderer {
  28544. /**
  28545. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28546. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28547. */
  28548. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28549. /**
  28550. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28551. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28552. */
  28553. static readonly POSITION_TEXTURE_TYPE: number;
  28554. /**
  28555. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28556. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28557. */
  28558. static readonly VELOCITY_TEXTURE_TYPE: number;
  28559. /**
  28560. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28561. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28562. */
  28563. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28564. /**
  28565. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28566. * in order to compute objects velocities when enableVelocity is set to "true"
  28567. * @hidden
  28568. */
  28569. _previousTransformationMatrices: {
  28570. [index: number]: ISavedTransformationMatrix;
  28571. };
  28572. /**
  28573. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28574. * in order to compute objects velocities when enableVelocity is set to "true"
  28575. * @hidden
  28576. */
  28577. _previousBonesTransformationMatrices: {
  28578. [index: number]: Float32Array;
  28579. };
  28580. /**
  28581. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28582. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28583. */
  28584. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28585. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28586. renderTransparentMeshes: boolean;
  28587. private _scene;
  28588. private _resizeObserver;
  28589. private _multiRenderTarget;
  28590. private _ratio;
  28591. private _enablePosition;
  28592. private _enableVelocity;
  28593. private _enableReflectivity;
  28594. private _positionIndex;
  28595. private _velocityIndex;
  28596. private _reflectivityIndex;
  28597. private _depthNormalIndex;
  28598. private _linkedWithPrePass;
  28599. private _prePassRenderer;
  28600. private _attachments;
  28601. protected _effect: Effect;
  28602. protected _cachedDefines: string;
  28603. /**
  28604. * @hidden
  28605. * Sets up internal structures to share outputs with PrePassRenderer
  28606. * This method should only be called by the PrePassRenderer itself
  28607. */
  28608. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28609. /**
  28610. * @hidden
  28611. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28612. * This method should only be called by the PrePassRenderer itself
  28613. */
  28614. _unlinkPrePassRenderer(): void;
  28615. /**
  28616. * @hidden
  28617. * Resets the geometry buffer layout
  28618. */
  28619. _resetLayout(): void;
  28620. /**
  28621. * @hidden
  28622. * Replaces a texture in the geometry buffer renderer
  28623. * Useful when linking textures of the prepass renderer
  28624. */
  28625. _forceTextureType(geometryBufferType: number, index: number): void;
  28626. /**
  28627. * @hidden
  28628. * Sets texture attachments
  28629. * Useful when linking textures of the prepass renderer
  28630. */
  28631. _setAttachments(attachments: number[]): void;
  28632. /**
  28633. * @hidden
  28634. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28635. * Useful when linking textures of the prepass renderer
  28636. */
  28637. _linkInternalTexture(internalTexture: InternalTexture): void;
  28638. /**
  28639. * Gets the render list (meshes to be rendered) used in the G buffer.
  28640. */
  28641. get renderList(): Nullable<AbstractMesh[]>;
  28642. /**
  28643. * Set the render list (meshes to be rendered) used in the G buffer.
  28644. */
  28645. set renderList(meshes: Nullable<AbstractMesh[]>);
  28646. /**
  28647. * Gets wether or not G buffer are supported by the running hardware.
  28648. * This requires draw buffer supports
  28649. */
  28650. get isSupported(): boolean;
  28651. /**
  28652. * Returns the index of the given texture type in the G-Buffer textures array
  28653. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28654. * @returns the index of the given texture type in the G-Buffer textures array
  28655. */
  28656. getTextureIndex(textureType: number): number;
  28657. /**
  28658. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28659. */
  28660. get enablePosition(): boolean;
  28661. /**
  28662. * Sets whether or not objects positions are enabled for the G buffer.
  28663. */
  28664. set enablePosition(enable: boolean);
  28665. /**
  28666. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28667. */
  28668. get enableVelocity(): boolean;
  28669. /**
  28670. * Sets wether or not objects velocities are enabled for the G buffer.
  28671. */
  28672. set enableVelocity(enable: boolean);
  28673. /**
  28674. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28675. */
  28676. get enableReflectivity(): boolean;
  28677. /**
  28678. * Sets wether or not objects roughness are enabled for the G buffer.
  28679. */
  28680. set enableReflectivity(enable: boolean);
  28681. /**
  28682. * Gets the scene associated with the buffer.
  28683. */
  28684. get scene(): Scene;
  28685. /**
  28686. * Gets the ratio used by the buffer during its creation.
  28687. * How big is the buffer related to the main canvas.
  28688. */
  28689. get ratio(): number;
  28690. /** @hidden */
  28691. static _SceneComponentInitialization: (scene: Scene) => void;
  28692. /**
  28693. * Creates a new G Buffer for the scene
  28694. * @param scene The scene the buffer belongs to
  28695. * @param ratio How big is the buffer related to the main canvas.
  28696. */
  28697. constructor(scene: Scene, ratio?: number);
  28698. /**
  28699. * Checks wether everything is ready to render a submesh to the G buffer.
  28700. * @param subMesh the submesh to check readiness for
  28701. * @param useInstances is the mesh drawn using instance or not
  28702. * @returns true if ready otherwise false
  28703. */
  28704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28705. /**
  28706. * Gets the current underlying G Buffer.
  28707. * @returns the buffer
  28708. */
  28709. getGBuffer(): MultiRenderTarget;
  28710. /**
  28711. * Gets the number of samples used to render the buffer (anti aliasing).
  28712. */
  28713. get samples(): number;
  28714. /**
  28715. * Sets the number of samples used to render the buffer (anti aliasing).
  28716. */
  28717. set samples(value: number);
  28718. /**
  28719. * Disposes the renderer and frees up associated resources.
  28720. */
  28721. dispose(): void;
  28722. private _assignRenderTargetIndices;
  28723. protected _createRenderTargets(): void;
  28724. private _copyBonesTransformationMatrices;
  28725. }
  28726. }
  28727. declare module "babylonjs/Rendering/prePassRenderer" {
  28728. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28729. import { Scene } from "babylonjs/scene";
  28730. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28731. import { Effect } from "babylonjs/Materials/effect";
  28732. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28734. import { Material } from "babylonjs/Materials/material";
  28735. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28736. /**
  28737. * Renders a pre pass of the scene
  28738. * This means every mesh in the scene will be rendered to a render target texture
  28739. * And then this texture will be composited to the rendering canvas with post processes
  28740. * It is necessary for effects like subsurface scattering or deferred shading
  28741. */
  28742. export class PrePassRenderer {
  28743. /** @hidden */
  28744. static _SceneComponentInitialization: (scene: Scene) => void;
  28745. private _textureFormats;
  28746. /**
  28747. * To save performance, we can excluded skinned meshes from the prepass
  28748. */
  28749. excludedSkinnedMesh: AbstractMesh[];
  28750. /**
  28751. * Force material to be excluded from the prepass
  28752. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28753. * and you don't want a material to show in the effect.
  28754. */
  28755. excludedMaterials: Material[];
  28756. private _textureIndices;
  28757. private _scene;
  28758. private _engine;
  28759. private _isDirty;
  28760. /**
  28761. * Number of textures in the multi render target texture where the scene is directly rendered
  28762. */
  28763. mrtCount: number;
  28764. /**
  28765. * The render target where the scene is directly rendered
  28766. */
  28767. prePassRT: MultiRenderTarget;
  28768. private _multiRenderAttachments;
  28769. private _defaultAttachments;
  28770. private _clearAttachments;
  28771. private _postProcesses;
  28772. private readonly _clearColor;
  28773. /**
  28774. * Image processing post process for composition
  28775. */
  28776. imageProcessingPostProcess: ImageProcessingPostProcess;
  28777. /**
  28778. * Configuration for prepass effects
  28779. */
  28780. private _effectConfigurations;
  28781. private _mrtFormats;
  28782. private _mrtLayout;
  28783. private _enabled;
  28784. /**
  28785. * Indicates if the prepass is enabled
  28786. */
  28787. get enabled(): boolean;
  28788. /**
  28789. * How many samples are used for MSAA of the scene render target
  28790. */
  28791. get samples(): number;
  28792. set samples(n: number);
  28793. private _geometryBuffer;
  28794. private _useGeometryBufferFallback;
  28795. /**
  28796. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28797. */
  28798. get useGeometryBufferFallback(): boolean;
  28799. set useGeometryBufferFallback(value: boolean);
  28800. /**
  28801. * Instanciates a prepass renderer
  28802. * @param scene The scene
  28803. */
  28804. constructor(scene: Scene);
  28805. private _initializeAttachments;
  28806. private _createCompositionEffect;
  28807. /**
  28808. * Indicates if rendering a prepass is supported
  28809. */
  28810. get isSupported(): boolean;
  28811. /**
  28812. * Sets the proper output textures to draw in the engine.
  28813. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28814. * @param subMesh Submesh on which the effect is applied
  28815. */
  28816. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28817. /**
  28818. * @hidden
  28819. */
  28820. _beforeCameraDraw(): void;
  28821. /**
  28822. * @hidden
  28823. */
  28824. _afterCameraDraw(): void;
  28825. private _checkRTSize;
  28826. private _bindFrameBuffer;
  28827. /**
  28828. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28829. */
  28830. clear(): void;
  28831. private _setState;
  28832. private _updateGeometryBufferLayout;
  28833. /**
  28834. * Adds an effect configuration to the prepass.
  28835. * If an effect has already been added, it won't add it twice and will return the configuration
  28836. * already present.
  28837. * @param cfg the effect configuration
  28838. * @return the effect configuration now used by the prepass
  28839. */
  28840. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28841. /**
  28842. * Returns the index of a texture in the multi render target texture array.
  28843. * @param type Texture type
  28844. * @return The index
  28845. */
  28846. getIndex(type: number): number;
  28847. private _enable;
  28848. private _disable;
  28849. private _resetLayout;
  28850. private _resetPostProcessChain;
  28851. private _bindPostProcessChain;
  28852. /**
  28853. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28854. */
  28855. markAsDirty(): void;
  28856. /**
  28857. * Enables a texture on the MultiRenderTarget for prepass
  28858. */
  28859. private _enableTextures;
  28860. private _update;
  28861. private _markAllMaterialsAsPrePassDirty;
  28862. /**
  28863. * Disposes the prepass renderer.
  28864. */
  28865. dispose(): void;
  28866. }
  28867. }
  28868. declare module "babylonjs/PostProcesses/postProcess" {
  28869. import { Nullable } from "babylonjs/types";
  28870. import { SmartArray } from "babylonjs/Misc/smartArray";
  28871. import { Observable } from "babylonjs/Misc/observable";
  28872. import { Vector2 } from "babylonjs/Maths/math.vector";
  28873. import { Camera } from "babylonjs/Cameras/camera";
  28874. import { Effect } from "babylonjs/Materials/effect";
  28875. import "babylonjs/Shaders/postprocess.vertex";
  28876. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28877. import { Engine } from "babylonjs/Engines/engine";
  28878. import { Color4 } from "babylonjs/Maths/math.color";
  28879. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28880. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28881. import { Scene } from "babylonjs/scene";
  28882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28883. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28884. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28885. /**
  28886. * Size options for a post process
  28887. */
  28888. export type PostProcessOptions = {
  28889. width: number;
  28890. height: number;
  28891. };
  28892. /**
  28893. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28894. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28895. */
  28896. export class PostProcess {
  28897. /**
  28898. * Gets or sets the unique id of the post process
  28899. */
  28900. uniqueId: number;
  28901. /** Name of the PostProcess. */
  28902. name: string;
  28903. /**
  28904. * Width of the texture to apply the post process on
  28905. */
  28906. width: number;
  28907. /**
  28908. * Height of the texture to apply the post process on
  28909. */
  28910. height: number;
  28911. /**
  28912. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28913. */
  28914. nodeMaterialSource: Nullable<NodeMaterial>;
  28915. /**
  28916. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28917. * @hidden
  28918. */
  28919. _outputTexture: Nullable<InternalTexture>;
  28920. /**
  28921. * Sampling mode used by the shader
  28922. * See https://doc.babylonjs.com/classes/3.1/texture
  28923. */
  28924. renderTargetSamplingMode: number;
  28925. /**
  28926. * Clear color to use when screen clearing
  28927. */
  28928. clearColor: Color4;
  28929. /**
  28930. * If the buffer needs to be cleared before applying the post process. (default: true)
  28931. * Should be set to false if shader will overwrite all previous pixels.
  28932. */
  28933. autoClear: boolean;
  28934. /**
  28935. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28936. */
  28937. alphaMode: number;
  28938. /**
  28939. * Sets the setAlphaBlendConstants of the babylon engine
  28940. */
  28941. alphaConstants: Color4;
  28942. /**
  28943. * Animations to be used for the post processing
  28944. */
  28945. animations: import("babylonjs/Animations/animation").Animation[];
  28946. /**
  28947. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28948. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28949. */
  28950. enablePixelPerfectMode: boolean;
  28951. /**
  28952. * Force the postprocess to be applied without taking in account viewport
  28953. */
  28954. forceFullscreenViewport: boolean;
  28955. /**
  28956. * List of inspectable custom properties (used by the Inspector)
  28957. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28958. */
  28959. inspectableCustomProperties: IInspectable[];
  28960. /**
  28961. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28962. *
  28963. * | Value | Type | Description |
  28964. * | ----- | ----------------------------------- | ----------- |
  28965. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28966. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28967. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28968. *
  28969. */
  28970. scaleMode: number;
  28971. /**
  28972. * Force textures to be a power of two (default: false)
  28973. */
  28974. alwaysForcePOT: boolean;
  28975. private _samples;
  28976. /**
  28977. * Number of sample textures (default: 1)
  28978. */
  28979. get samples(): number;
  28980. set samples(n: number);
  28981. /**
  28982. * Modify the scale of the post process to be the same as the viewport (default: false)
  28983. */
  28984. adaptScaleToCurrentViewport: boolean;
  28985. private _camera;
  28986. protected _scene: Scene;
  28987. private _engine;
  28988. private _options;
  28989. private _reusable;
  28990. private _textureType;
  28991. private _textureFormat;
  28992. /**
  28993. * Smart array of input and output textures for the post process.
  28994. * @hidden
  28995. */
  28996. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28997. /**
  28998. * The index in _textures that corresponds to the output texture.
  28999. * @hidden
  29000. */
  29001. _currentRenderTextureInd: number;
  29002. private _effect;
  29003. private _samplers;
  29004. private _fragmentUrl;
  29005. private _vertexUrl;
  29006. private _parameters;
  29007. private _scaleRatio;
  29008. protected _indexParameters: any;
  29009. private _shareOutputWithPostProcess;
  29010. private _texelSize;
  29011. private _forcedOutputTexture;
  29012. /**
  29013. * Prepass configuration in case this post process needs a texture from prepass
  29014. * @hidden
  29015. */
  29016. _prePassEffectConfiguration: PrePassEffectConfiguration;
  29017. /**
  29018. * Returns the fragment url or shader name used in the post process.
  29019. * @returns the fragment url or name in the shader store.
  29020. */
  29021. getEffectName(): string;
  29022. /**
  29023. * An event triggered when the postprocess is activated.
  29024. */
  29025. onActivateObservable: Observable<Camera>;
  29026. private _onActivateObserver;
  29027. /**
  29028. * A function that is added to the onActivateObservable
  29029. */
  29030. set onActivate(callback: Nullable<(camera: Camera) => void>);
  29031. /**
  29032. * An event triggered when the postprocess changes its size.
  29033. */
  29034. onSizeChangedObservable: Observable<PostProcess>;
  29035. private _onSizeChangedObserver;
  29036. /**
  29037. * A function that is added to the onSizeChangedObservable
  29038. */
  29039. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  29040. /**
  29041. * An event triggered when the postprocess applies its effect.
  29042. */
  29043. onApplyObservable: Observable<Effect>;
  29044. private _onApplyObserver;
  29045. /**
  29046. * A function that is added to the onApplyObservable
  29047. */
  29048. set onApply(callback: (effect: Effect) => void);
  29049. /**
  29050. * An event triggered before rendering the postprocess
  29051. */
  29052. onBeforeRenderObservable: Observable<Effect>;
  29053. private _onBeforeRenderObserver;
  29054. /**
  29055. * A function that is added to the onBeforeRenderObservable
  29056. */
  29057. set onBeforeRender(callback: (effect: Effect) => void);
  29058. /**
  29059. * An event triggered after rendering the postprocess
  29060. */
  29061. onAfterRenderObservable: Observable<Effect>;
  29062. private _onAfterRenderObserver;
  29063. /**
  29064. * A function that is added to the onAfterRenderObservable
  29065. */
  29066. set onAfterRender(callback: (efect: Effect) => void);
  29067. /**
  29068. * 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
  29069. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  29070. */
  29071. get inputTexture(): InternalTexture;
  29072. set inputTexture(value: InternalTexture);
  29073. /**
  29074. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  29075. * the only way to unset it is to use this function to restore its internal state
  29076. */
  29077. restoreDefaultInputTexture(): void;
  29078. /**
  29079. * Gets the camera which post process is applied to.
  29080. * @returns The camera the post process is applied to.
  29081. */
  29082. getCamera(): Camera;
  29083. /**
  29084. * Gets the texel size of the postprocess.
  29085. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  29086. */
  29087. get texelSize(): Vector2;
  29088. /**
  29089. * Creates a new instance PostProcess
  29090. * @param name The name of the PostProcess.
  29091. * @param fragmentUrl The url of the fragment shader to be used.
  29092. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  29093. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  29094. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29095. * @param camera The camera to apply the render pass to.
  29096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29097. * @param engine The engine which the post process will be applied. (default: current engine)
  29098. * @param reusable If the post process can be reused on the same frame. (default: false)
  29099. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  29100. * @param textureType Type of textures used when performing the post process. (default: 0)
  29101. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  29102. * @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
  29103. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  29104. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  29105. */
  29106. 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);
  29107. /**
  29108. * Gets a string identifying the name of the class
  29109. * @returns "PostProcess" string
  29110. */
  29111. getClassName(): string;
  29112. /**
  29113. * Gets the engine which this post process belongs to.
  29114. * @returns The engine the post process was enabled with.
  29115. */
  29116. getEngine(): Engine;
  29117. /**
  29118. * The effect that is created when initializing the post process.
  29119. * @returns The created effect corresponding the the postprocess.
  29120. */
  29121. getEffect(): Effect;
  29122. /**
  29123. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  29124. * @param postProcess The post process to share the output with.
  29125. * @returns This post process.
  29126. */
  29127. shareOutputWith(postProcess: PostProcess): PostProcess;
  29128. /**
  29129. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  29130. * This should be called if the post process that shares output with this post process is disabled/disposed.
  29131. */
  29132. useOwnOutput(): void;
  29133. /**
  29134. * Updates the effect with the current post process compile time values and recompiles the shader.
  29135. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29136. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29137. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29138. * @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
  29139. * @param onCompiled Called when the shader has been compiled.
  29140. * @param onError Called if there is an error when compiling a shader.
  29141. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  29142. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  29143. */
  29144. 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;
  29145. /**
  29146. * The post process is reusable if it can be used multiple times within one frame.
  29147. * @returns If the post process is reusable
  29148. */
  29149. isReusable(): boolean;
  29150. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  29151. markTextureDirty(): void;
  29152. /**
  29153. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  29154. * 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.
  29155. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  29156. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  29157. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  29158. * @returns The target texture that was bound to be written to.
  29159. */
  29160. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  29161. /**
  29162. * If the post process is supported.
  29163. */
  29164. get isSupported(): boolean;
  29165. /**
  29166. * The aspect ratio of the output texture.
  29167. */
  29168. get aspectRatio(): number;
  29169. /**
  29170. * Get a value indicating if the post-process is ready to be used
  29171. * @returns true if the post-process is ready (shader is compiled)
  29172. */
  29173. isReady(): boolean;
  29174. /**
  29175. * Binds all textures and uniforms to the shader, this will be run on every pass.
  29176. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  29177. */
  29178. apply(): Nullable<Effect>;
  29179. private _disposeTextures;
  29180. /**
  29181. * Sets the required values to the prepass renderer.
  29182. * @param prePassRenderer defines the prepass renderer to setup.
  29183. * @returns true if the pre pass is needed.
  29184. */
  29185. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29186. /**
  29187. * Disposes the post process.
  29188. * @param camera The camera to dispose the post process on.
  29189. */
  29190. dispose(camera?: Camera): void;
  29191. /**
  29192. * Serializes the particle system to a JSON object
  29193. * @returns the JSON object
  29194. */
  29195. serialize(): any;
  29196. /**
  29197. * Creates a material from parsed material data
  29198. * @param parsedPostProcess defines parsed post process data
  29199. * @param scene defines the hosting scene
  29200. * @param rootUrl defines the root URL to use to load textures
  29201. * @returns a new post process
  29202. */
  29203. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  29204. }
  29205. }
  29206. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  29207. /** @hidden */
  29208. export var kernelBlurVaryingDeclaration: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  29214. /** @hidden */
  29215. export var kernelBlurFragment: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  29221. /** @hidden */
  29222. export var kernelBlurFragment2: {
  29223. name: string;
  29224. shader: string;
  29225. };
  29226. }
  29227. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  29228. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29229. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29230. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  29231. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  29232. /** @hidden */
  29233. export var kernelBlurPixelShader: {
  29234. name: string;
  29235. shader: string;
  29236. };
  29237. }
  29238. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  29239. /** @hidden */
  29240. export var kernelBlurVertex: {
  29241. name: string;
  29242. shader: string;
  29243. };
  29244. }
  29245. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  29246. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29247. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  29248. /** @hidden */
  29249. export var kernelBlurVertexShader: {
  29250. name: string;
  29251. shader: string;
  29252. };
  29253. }
  29254. declare module "babylonjs/PostProcesses/blurPostProcess" {
  29255. import { Vector2 } from "babylonjs/Maths/math.vector";
  29256. import { Nullable } from "babylonjs/types";
  29257. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  29258. import { Camera } from "babylonjs/Cameras/camera";
  29259. import { Effect } from "babylonjs/Materials/effect";
  29260. import { Engine } from "babylonjs/Engines/engine";
  29261. import "babylonjs/Shaders/kernelBlur.fragment";
  29262. import "babylonjs/Shaders/kernelBlur.vertex";
  29263. import { Scene } from "babylonjs/scene";
  29264. /**
  29265. * The Blur Post Process which blurs an image based on a kernel and direction.
  29266. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  29267. */
  29268. export class BlurPostProcess extends PostProcess {
  29269. private blockCompilation;
  29270. protected _kernel: number;
  29271. protected _idealKernel: number;
  29272. protected _packedFloat: boolean;
  29273. private _staticDefines;
  29274. /** The direction in which to blur the image. */
  29275. direction: Vector2;
  29276. /**
  29277. * Sets the length in pixels of the blur sample region
  29278. */
  29279. set kernel(v: number);
  29280. /**
  29281. * Gets the length in pixels of the blur sample region
  29282. */
  29283. get kernel(): number;
  29284. /**
  29285. * Sets wether or not the blur needs to unpack/repack floats
  29286. */
  29287. set packedFloat(v: boolean);
  29288. /**
  29289. * Gets wether or not the blur is unpacking/repacking floats
  29290. */
  29291. get packedFloat(): boolean;
  29292. /**
  29293. * Gets a string identifying the name of the class
  29294. * @returns "BlurPostProcess" string
  29295. */
  29296. getClassName(): string;
  29297. /**
  29298. * Creates a new instance BlurPostProcess
  29299. * @param name The name of the effect.
  29300. * @param direction The direction in which to blur the image.
  29301. * @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.
  29302. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29303. * @param camera The camera to apply the render pass to.
  29304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29305. * @param engine The engine which the post process will be applied. (default: current engine)
  29306. * @param reusable If the post process can be reused on the same frame. (default: false)
  29307. * @param textureType Type of textures used when performing the post process. (default: 0)
  29308. * @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)
  29309. */
  29310. 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);
  29311. /**
  29312. * Updates the effect with the current post process compile time values and recompiles the shader.
  29313. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29314. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29315. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29316. * @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
  29317. * @param onCompiled Called when the shader has been compiled.
  29318. * @param onError Called if there is an error when compiling a shader.
  29319. */
  29320. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29321. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29322. /**
  29323. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29324. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29325. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29326. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29327. * The gaps between physical kernels are compensated for in the weighting of the samples
  29328. * @param idealKernel Ideal blur kernel.
  29329. * @return Nearest best kernel.
  29330. */
  29331. protected _nearestBestKernel(idealKernel: number): number;
  29332. /**
  29333. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29334. * @param x The point on the Gaussian distribution to sample.
  29335. * @return the value of the Gaussian function at x.
  29336. */
  29337. protected _gaussianWeight(x: number): number;
  29338. /**
  29339. * Generates a string that can be used as a floating point number in GLSL.
  29340. * @param x Value to print.
  29341. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29342. * @return GLSL float string.
  29343. */
  29344. protected _glslFloat(x: number, decimalFigures?: number): string;
  29345. /** @hidden */
  29346. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29347. }
  29348. }
  29349. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29350. import { Scene } from "babylonjs/scene";
  29351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29352. import { Plane } from "babylonjs/Maths/math.plane";
  29353. /**
  29354. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29355. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29356. * You can then easily use it as a reflectionTexture on a flat surface.
  29357. * In case the surface is not a plane, please consider relying on reflection probes.
  29358. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29359. */
  29360. export class MirrorTexture extends RenderTargetTexture {
  29361. private scene;
  29362. /**
  29363. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29364. * 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.
  29365. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29366. */
  29367. mirrorPlane: Plane;
  29368. /**
  29369. * Define the blur ratio used to blur the reflection if needed.
  29370. */
  29371. set blurRatio(value: number);
  29372. get blurRatio(): number;
  29373. /**
  29374. * Define the adaptive blur kernel used to blur the reflection if needed.
  29375. * This will autocompute the closest best match for the `blurKernel`
  29376. */
  29377. set adaptiveBlurKernel(value: number);
  29378. /**
  29379. * Define the blur kernel used to blur the reflection if needed.
  29380. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29381. */
  29382. set blurKernel(value: number);
  29383. /**
  29384. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29385. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29386. */
  29387. set blurKernelX(value: number);
  29388. get blurKernelX(): number;
  29389. /**
  29390. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29391. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29392. */
  29393. set blurKernelY(value: number);
  29394. get blurKernelY(): number;
  29395. private _autoComputeBlurKernel;
  29396. protected _onRatioRescale(): void;
  29397. private _updateGammaSpace;
  29398. private _imageProcessingConfigChangeObserver;
  29399. private _transformMatrix;
  29400. private _mirrorMatrix;
  29401. private _savedViewMatrix;
  29402. private _blurX;
  29403. private _blurY;
  29404. private _adaptiveBlurKernel;
  29405. private _blurKernelX;
  29406. private _blurKernelY;
  29407. private _blurRatio;
  29408. /**
  29409. * Instantiates a Mirror Texture.
  29410. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29411. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29412. * You can then easily use it as a reflectionTexture on a flat surface.
  29413. * In case the surface is not a plane, please consider relying on reflection probes.
  29414. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29415. * @param name
  29416. * @param size
  29417. * @param scene
  29418. * @param generateMipMaps
  29419. * @param type
  29420. * @param samplingMode
  29421. * @param generateDepthBuffer
  29422. */
  29423. constructor(name: string, size: number | {
  29424. width: number;
  29425. height: number;
  29426. } | {
  29427. ratio: number;
  29428. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29429. private _preparePostProcesses;
  29430. /**
  29431. * Clone the mirror texture.
  29432. * @returns the cloned texture
  29433. */
  29434. clone(): MirrorTexture;
  29435. /**
  29436. * Serialize the texture to a JSON representation you could use in Parse later on
  29437. * @returns the serialized JSON representation
  29438. */
  29439. serialize(): any;
  29440. /**
  29441. * Dispose the texture and release its associated resources.
  29442. */
  29443. dispose(): void;
  29444. }
  29445. }
  29446. declare module "babylonjs/Materials/Textures/texture" {
  29447. import { Observable } from "babylonjs/Misc/observable";
  29448. import { Nullable } from "babylonjs/types";
  29449. import { Matrix } from "babylonjs/Maths/math.vector";
  29450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29451. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29452. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29453. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29454. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29456. import { Scene } from "babylonjs/scene";
  29457. /**
  29458. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29459. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29460. */
  29461. export class Texture extends BaseTexture {
  29462. /**
  29463. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29464. */
  29465. static SerializeBuffers: boolean;
  29466. /**
  29467. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  29468. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  29469. */
  29470. static ForceSerializeBuffers: boolean;
  29471. /** @hidden */
  29472. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29473. /** @hidden */
  29474. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29475. /** @hidden */
  29476. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29477. /** nearest is mag = nearest and min = nearest and mip = linear */
  29478. static readonly NEAREST_SAMPLINGMODE: number;
  29479. /** nearest is mag = nearest and min = nearest and mip = linear */
  29480. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29481. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29482. static readonly BILINEAR_SAMPLINGMODE: number;
  29483. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29484. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29485. /** Trilinear is mag = linear and min = linear and mip = linear */
  29486. static readonly TRILINEAR_SAMPLINGMODE: number;
  29487. /** Trilinear is mag = linear and min = linear and mip = linear */
  29488. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29489. /** mag = nearest and min = nearest and mip = nearest */
  29490. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29491. /** mag = nearest and min = linear and mip = nearest */
  29492. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29493. /** mag = nearest and min = linear and mip = linear */
  29494. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29495. /** mag = nearest and min = linear and mip = none */
  29496. static readonly NEAREST_LINEAR: number;
  29497. /** mag = nearest and min = nearest and mip = none */
  29498. static readonly NEAREST_NEAREST: number;
  29499. /** mag = linear and min = nearest and mip = nearest */
  29500. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29501. /** mag = linear and min = nearest and mip = linear */
  29502. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29503. /** mag = linear and min = linear and mip = none */
  29504. static readonly LINEAR_LINEAR: number;
  29505. /** mag = linear and min = nearest and mip = none */
  29506. static readonly LINEAR_NEAREST: number;
  29507. /** Explicit coordinates mode */
  29508. static readonly EXPLICIT_MODE: number;
  29509. /** Spherical coordinates mode */
  29510. static readonly SPHERICAL_MODE: number;
  29511. /** Planar coordinates mode */
  29512. static readonly PLANAR_MODE: number;
  29513. /** Cubic coordinates mode */
  29514. static readonly CUBIC_MODE: number;
  29515. /** Projection coordinates mode */
  29516. static readonly PROJECTION_MODE: number;
  29517. /** Inverse Cubic coordinates mode */
  29518. static readonly SKYBOX_MODE: number;
  29519. /** Inverse Cubic coordinates mode */
  29520. static readonly INVCUBIC_MODE: number;
  29521. /** Equirectangular coordinates mode */
  29522. static readonly EQUIRECTANGULAR_MODE: number;
  29523. /** Equirectangular Fixed coordinates mode */
  29524. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29525. /** Equirectangular Fixed Mirrored coordinates mode */
  29526. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29527. /** Texture is not repeating outside of 0..1 UVs */
  29528. static readonly CLAMP_ADDRESSMODE: number;
  29529. /** Texture is repeating outside of 0..1 UVs */
  29530. static readonly WRAP_ADDRESSMODE: number;
  29531. /** Texture is repeating and mirrored */
  29532. static readonly MIRROR_ADDRESSMODE: number;
  29533. /**
  29534. * 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
  29535. */
  29536. static UseSerializedUrlIfAny: boolean;
  29537. /**
  29538. * Define the url of the texture.
  29539. */
  29540. url: Nullable<string>;
  29541. /**
  29542. * Define an offset on the texture to offset the u coordinates of the UVs
  29543. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29544. */
  29545. uOffset: number;
  29546. /**
  29547. * Define an offset on the texture to offset the v coordinates of the UVs
  29548. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29549. */
  29550. vOffset: number;
  29551. /**
  29552. * Define an offset on the texture to scale the u coordinates of the UVs
  29553. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29554. */
  29555. uScale: number;
  29556. /**
  29557. * Define an offset on the texture to scale the v coordinates of the UVs
  29558. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29559. */
  29560. vScale: number;
  29561. /**
  29562. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29563. * @see https://doc.babylonjs.com/how_to/more_materials
  29564. */
  29565. uAng: number;
  29566. /**
  29567. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29568. * @see https://doc.babylonjs.com/how_to/more_materials
  29569. */
  29570. vAng: number;
  29571. /**
  29572. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29573. * @see https://doc.babylonjs.com/how_to/more_materials
  29574. */
  29575. wAng: number;
  29576. /**
  29577. * Defines the center of rotation (U)
  29578. */
  29579. uRotationCenter: number;
  29580. /**
  29581. * Defines the center of rotation (V)
  29582. */
  29583. vRotationCenter: number;
  29584. /**
  29585. * Defines the center of rotation (W)
  29586. */
  29587. wRotationCenter: number;
  29588. /**
  29589. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29590. */
  29591. homogeneousRotationInUVTransform: boolean;
  29592. /**
  29593. * Are mip maps generated for this texture or not.
  29594. */
  29595. get noMipmap(): boolean;
  29596. /**
  29597. * List of inspectable custom properties (used by the Inspector)
  29598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29599. */
  29600. inspectableCustomProperties: Nullable<IInspectable[]>;
  29601. private _noMipmap;
  29602. /** @hidden */
  29603. _invertY: boolean;
  29604. private _rowGenerationMatrix;
  29605. private _cachedTextureMatrix;
  29606. private _projectionModeMatrix;
  29607. private _t0;
  29608. private _t1;
  29609. private _t2;
  29610. private _cachedUOffset;
  29611. private _cachedVOffset;
  29612. private _cachedUScale;
  29613. private _cachedVScale;
  29614. private _cachedUAng;
  29615. private _cachedVAng;
  29616. private _cachedWAng;
  29617. private _cachedProjectionMatrixId;
  29618. private _cachedURotationCenter;
  29619. private _cachedVRotationCenter;
  29620. private _cachedWRotationCenter;
  29621. private _cachedHomogeneousRotationInUVTransform;
  29622. private _cachedCoordinatesMode;
  29623. /** @hidden */
  29624. protected _initialSamplingMode: number;
  29625. /** @hidden */
  29626. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29627. private _deleteBuffer;
  29628. protected _format: Nullable<number>;
  29629. private _delayedOnLoad;
  29630. private _delayedOnError;
  29631. private _mimeType?;
  29632. private _loaderOptions?;
  29633. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29634. get mimeType(): string | undefined;
  29635. /**
  29636. * Observable triggered once the texture has been loaded.
  29637. */
  29638. onLoadObservable: Observable<Texture>;
  29639. protected _isBlocking: boolean;
  29640. /**
  29641. * Is the texture preventing material to render while loading.
  29642. * If false, a default texture will be used instead of the loading one during the preparation step.
  29643. */
  29644. set isBlocking(value: boolean);
  29645. get isBlocking(): boolean;
  29646. /**
  29647. * Get the current sampling mode associated with the texture.
  29648. */
  29649. get samplingMode(): number;
  29650. /**
  29651. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29652. */
  29653. get invertY(): boolean;
  29654. /**
  29655. * Instantiates a new texture.
  29656. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29657. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29658. * @param url defines the url of the picture to load as a texture
  29659. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29660. * @param noMipmap defines if the texture will require mip maps or not
  29661. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29662. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29663. * @param onLoad defines a callback triggered when the texture has been loaded
  29664. * @param onError defines a callback triggered when an error occurred during the loading session
  29665. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29666. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29667. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29668. * @param mimeType defines an optional mime type information
  29669. * @param loaderOptions options to be passed to the loader
  29670. */
  29671. 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);
  29672. /**
  29673. * Update the url (and optional buffer) of this texture if url was null during construction.
  29674. * @param url the url of the texture
  29675. * @param buffer the buffer of the texture (defaults to null)
  29676. * @param onLoad callback called when the texture is loaded (defaults to null)
  29677. */
  29678. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29679. /**
  29680. * Finish the loading sequence of a texture flagged as delayed load.
  29681. * @hidden
  29682. */
  29683. delayLoad(): void;
  29684. private _prepareRowForTextureGeneration;
  29685. /**
  29686. * Checks if the texture has the same transform matrix than another texture
  29687. * @param texture texture to check against
  29688. * @returns true if the transforms are the same, else false
  29689. */
  29690. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29691. /**
  29692. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29693. * @returns the transform matrix of the texture.
  29694. */
  29695. getTextureMatrix(uBase?: number): Matrix;
  29696. /**
  29697. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29698. * @returns The reflection texture transform
  29699. */
  29700. getReflectionTextureMatrix(): Matrix;
  29701. /**
  29702. * Clones the texture.
  29703. * @returns the cloned texture
  29704. */
  29705. clone(): Texture;
  29706. /**
  29707. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29708. * @returns The JSON representation of the texture
  29709. */
  29710. serialize(): any;
  29711. /**
  29712. * Get the current class name of the texture useful for serialization or dynamic coding.
  29713. * @returns "Texture"
  29714. */
  29715. getClassName(): string;
  29716. /**
  29717. * Dispose the texture and release its associated resources.
  29718. */
  29719. dispose(): void;
  29720. /**
  29721. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29722. * @param parsedTexture Define the JSON representation of the texture
  29723. * @param scene Define the scene the parsed texture should be instantiated in
  29724. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29725. * @returns The parsed texture if successful
  29726. */
  29727. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29728. /**
  29729. * Creates a texture from its base 64 representation.
  29730. * @param data Define the base64 payload without the data: prefix
  29731. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29732. * @param scene Define the scene the texture should belong to
  29733. * @param noMipmap Forces the texture to not create mip map information if true
  29734. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29735. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29736. * @param onLoad define a callback triggered when the texture has been loaded
  29737. * @param onError define a callback triggered when an error occurred during the loading session
  29738. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29739. * @returns the created texture
  29740. */
  29741. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29742. /**
  29743. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29744. * @param data Define the base64 payload without the data: prefix
  29745. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29746. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29747. * @param scene Define the scene the texture should belong to
  29748. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29749. * @param noMipmap Forces the texture to not create mip map information if true
  29750. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29751. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29752. * @param onLoad define a callback triggered when the texture has been loaded
  29753. * @param onError define a callback triggered when an error occurred during the loading session
  29754. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29755. * @returns the created texture
  29756. */
  29757. 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;
  29758. }
  29759. }
  29760. declare module "babylonjs/PostProcesses/postProcessManager" {
  29761. import { Nullable } from "babylonjs/types";
  29762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29763. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29764. import { Scene } from "babylonjs/scene";
  29765. /**
  29766. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29767. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29768. */
  29769. export class PostProcessManager {
  29770. private _scene;
  29771. private _indexBuffer;
  29772. private _vertexBuffers;
  29773. /**
  29774. * Creates a new instance PostProcess
  29775. * @param scene The scene that the post process is associated with.
  29776. */
  29777. constructor(scene: Scene);
  29778. private _prepareBuffers;
  29779. private _buildIndexBuffer;
  29780. /**
  29781. * Rebuilds the vertex buffers of the manager.
  29782. * @hidden
  29783. */
  29784. _rebuild(): void;
  29785. /**
  29786. * Prepares a frame to be run through a post process.
  29787. * @param sourceTexture The input texture to the post procesess. (default: null)
  29788. * @param postProcesses An array of post processes to be run. (default: null)
  29789. * @returns True if the post processes were able to be run.
  29790. * @hidden
  29791. */
  29792. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29793. /**
  29794. * Manually render a set of post processes to a texture.
  29795. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29796. * @param postProcesses An array of post processes to be run.
  29797. * @param targetTexture The target texture to render to.
  29798. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29799. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29800. * @param lodLevel defines which lod of the texture to render to
  29801. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29802. */
  29803. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29804. /**
  29805. * Finalize the result of the output of the postprocesses.
  29806. * @param doNotPresent If true the result will not be displayed to the screen.
  29807. * @param targetTexture The target texture to render to.
  29808. * @param faceIndex The index of the face to bind the target texture to.
  29809. * @param postProcesses The array of post processes to render.
  29810. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29811. * @hidden
  29812. */
  29813. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29814. /**
  29815. * Disposes of the post process manager.
  29816. */
  29817. dispose(): void;
  29818. }
  29819. }
  29820. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29821. import { Observable } from "babylonjs/Misc/observable";
  29822. import { SmartArray } from "babylonjs/Misc/smartArray";
  29823. import { Nullable, Immutable } from "babylonjs/types";
  29824. import { Camera } from "babylonjs/Cameras/camera";
  29825. import { Scene } from "babylonjs/scene";
  29826. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29827. import { Color4 } from "babylonjs/Maths/math.color";
  29828. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29830. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29831. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29832. import { Texture } from "babylonjs/Materials/Textures/texture";
  29833. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29834. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29835. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29836. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29837. import { Engine } from "babylonjs/Engines/engine";
  29838. /**
  29839. * This Helps creating a texture that will be created from a camera in your scene.
  29840. * It is basically a dynamic texture that could be used to create special effects for instance.
  29841. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29842. */
  29843. export class RenderTargetTexture extends Texture {
  29844. /**
  29845. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29846. */
  29847. static readonly REFRESHRATE_RENDER_ONCE: number;
  29848. /**
  29849. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29850. */
  29851. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29852. /**
  29853. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29854. * the central point of your effect and can save a lot of performances.
  29855. */
  29856. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29857. /**
  29858. * Use this predicate to dynamically define the list of mesh you want to render.
  29859. * If set, the renderList property will be overwritten.
  29860. */
  29861. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29862. private _renderList;
  29863. /**
  29864. * Use this list to define the list of mesh you want to render.
  29865. */
  29866. get renderList(): Nullable<Array<AbstractMesh>>;
  29867. set renderList(value: Nullable<Array<AbstractMesh>>);
  29868. /**
  29869. * Use this function to overload the renderList array at rendering time.
  29870. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29871. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29872. * the cube (if the RTT is a cube, else layerOrFace=0).
  29873. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29874. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29875. * hold dummy elements!
  29876. */
  29877. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29878. private _hookArray;
  29879. /**
  29880. * Define if particles should be rendered in your texture.
  29881. */
  29882. renderParticles: boolean;
  29883. /**
  29884. * Define if sprites should be rendered in your texture.
  29885. */
  29886. renderSprites: boolean;
  29887. /**
  29888. * Define the camera used to render the texture.
  29889. */
  29890. activeCamera: Nullable<Camera>;
  29891. /**
  29892. * Override the mesh isReady function with your own one.
  29893. */
  29894. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29895. /**
  29896. * Override the render function of the texture with your own one.
  29897. */
  29898. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29899. /**
  29900. * Define if camera post processes should be use while rendering the texture.
  29901. */
  29902. useCameraPostProcesses: boolean;
  29903. /**
  29904. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29905. */
  29906. ignoreCameraViewport: boolean;
  29907. private _postProcessManager;
  29908. private _postProcesses;
  29909. private _resizeObserver;
  29910. /**
  29911. * An event triggered when the texture is unbind.
  29912. */
  29913. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29914. /**
  29915. * An event triggered when the texture is unbind.
  29916. */
  29917. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29918. private _onAfterUnbindObserver;
  29919. /**
  29920. * Set a after unbind callback in the texture.
  29921. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29922. */
  29923. set onAfterUnbind(callback: () => void);
  29924. /**
  29925. * An event triggered before rendering the texture
  29926. */
  29927. onBeforeRenderObservable: Observable<number>;
  29928. private _onBeforeRenderObserver;
  29929. /**
  29930. * Set a before render callback in the texture.
  29931. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29932. */
  29933. set onBeforeRender(callback: (faceIndex: number) => void);
  29934. /**
  29935. * An event triggered after rendering the texture
  29936. */
  29937. onAfterRenderObservable: Observable<number>;
  29938. private _onAfterRenderObserver;
  29939. /**
  29940. * Set a after render callback in the texture.
  29941. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29942. */
  29943. set onAfterRender(callback: (faceIndex: number) => void);
  29944. /**
  29945. * An event triggered after the texture clear
  29946. */
  29947. onClearObservable: Observable<Engine>;
  29948. private _onClearObserver;
  29949. /**
  29950. * Set a clear callback in the texture.
  29951. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29952. */
  29953. set onClear(callback: (Engine: Engine) => void);
  29954. /**
  29955. * An event triggered when the texture is resized.
  29956. */
  29957. onResizeObservable: Observable<RenderTargetTexture>;
  29958. /**
  29959. * Define the clear color of the Render Target if it should be different from the scene.
  29960. */
  29961. clearColor: Color4;
  29962. protected _size: number | {
  29963. width: number;
  29964. height: number;
  29965. layers?: number;
  29966. };
  29967. protected _initialSizeParameter: number | {
  29968. width: number;
  29969. height: number;
  29970. } | {
  29971. ratio: number;
  29972. };
  29973. protected _sizeRatio: Nullable<number>;
  29974. /** @hidden */
  29975. _generateMipMaps: boolean;
  29976. protected _renderingManager: RenderingManager;
  29977. /** @hidden */
  29978. _waitingRenderList?: string[];
  29979. protected _doNotChangeAspectRatio: boolean;
  29980. protected _currentRefreshId: number;
  29981. protected _refreshRate: number;
  29982. protected _textureMatrix: Matrix;
  29983. protected _samples: number;
  29984. protected _renderTargetOptions: RenderTargetCreationOptions;
  29985. /**
  29986. * Gets render target creation options that were used.
  29987. */
  29988. get renderTargetOptions(): RenderTargetCreationOptions;
  29989. protected _onRatioRescale(): void;
  29990. /**
  29991. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29992. * It must define where the camera used to render the texture is set
  29993. */
  29994. boundingBoxPosition: Vector3;
  29995. private _boundingBoxSize;
  29996. /**
  29997. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29998. * When defined, the cubemap will switch to local mode
  29999. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  30000. * @example https://www.babylonjs-playground.com/#RNASML
  30001. */
  30002. set boundingBoxSize(value: Vector3);
  30003. get boundingBoxSize(): Vector3;
  30004. /**
  30005. * In case the RTT has been created with a depth texture, get the associated
  30006. * depth texture.
  30007. * Otherwise, return null.
  30008. */
  30009. get depthStencilTexture(): Nullable<InternalTexture>;
  30010. /**
  30011. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  30012. * or used a shadow, depth texture...
  30013. * @param name The friendly name of the texture
  30014. * @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)
  30015. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  30016. * @param generateMipMaps True if mip maps need to be generated after render.
  30017. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  30018. * @param type The type of the buffer in the RTT (int, half float, float...)
  30019. * @param isCube True if a cube texture needs to be created
  30020. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  30021. * @param generateDepthBuffer True to generate a depth buffer
  30022. * @param generateStencilBuffer True to generate a stencil buffer
  30023. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  30024. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  30025. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30026. */
  30027. constructor(name: string, size: number | {
  30028. width: number;
  30029. height: number;
  30030. layers?: number;
  30031. } | {
  30032. ratio: number;
  30033. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  30034. /**
  30035. * Creates a depth stencil texture.
  30036. * This is only available in WebGL 2 or with the depth texture extension available.
  30037. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  30038. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  30039. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  30040. */
  30041. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  30042. private _processSizeParameter;
  30043. /**
  30044. * Define the number of samples to use in case of MSAA.
  30045. * It defaults to one meaning no MSAA has been enabled.
  30046. */
  30047. get samples(): number;
  30048. set samples(value: number);
  30049. /**
  30050. * Resets the refresh counter of the texture and start bak from scratch.
  30051. * Could be useful to regenerate the texture if it is setup to render only once.
  30052. */
  30053. resetRefreshCounter(): void;
  30054. /**
  30055. * Define the refresh rate of the texture or the rendering frequency.
  30056. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  30057. */
  30058. get refreshRate(): number;
  30059. set refreshRate(value: number);
  30060. /**
  30061. * Adds a post process to the render target rendering passes.
  30062. * @param postProcess define the post process to add
  30063. */
  30064. addPostProcess(postProcess: PostProcess): void;
  30065. /**
  30066. * Clear all the post processes attached to the render target
  30067. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  30068. */
  30069. clearPostProcesses(dispose?: boolean): void;
  30070. /**
  30071. * Remove one of the post process from the list of attached post processes to the texture
  30072. * @param postProcess define the post process to remove from the list
  30073. */
  30074. removePostProcess(postProcess: PostProcess): void;
  30075. /** @hidden */
  30076. _shouldRender(): boolean;
  30077. /**
  30078. * Gets the actual render size of the texture.
  30079. * @returns the width of the render size
  30080. */
  30081. getRenderSize(): number;
  30082. /**
  30083. * Gets the actual render width of the texture.
  30084. * @returns the width of the render size
  30085. */
  30086. getRenderWidth(): number;
  30087. /**
  30088. * Gets the actual render height of the texture.
  30089. * @returns the height of the render size
  30090. */
  30091. getRenderHeight(): number;
  30092. /**
  30093. * Gets the actual number of layers of the texture.
  30094. * @returns the number of layers
  30095. */
  30096. getRenderLayers(): number;
  30097. /**
  30098. * Get if the texture can be rescaled or not.
  30099. */
  30100. get canRescale(): boolean;
  30101. /**
  30102. * Resize the texture using a ratio.
  30103. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  30104. */
  30105. scale(ratio: number): void;
  30106. /**
  30107. * Get the texture reflection matrix used to rotate/transform the reflection.
  30108. * @returns the reflection matrix
  30109. */
  30110. getReflectionTextureMatrix(): Matrix;
  30111. /**
  30112. * Resize the texture to a new desired size.
  30113. * Be carrefull as it will recreate all the data in the new texture.
  30114. * @param size Define the new size. It can be:
  30115. * - a number for squared texture,
  30116. * - an object containing { width: number, height: number }
  30117. * - or an object containing a ratio { ratio: number }
  30118. */
  30119. resize(size: number | {
  30120. width: number;
  30121. height: number;
  30122. } | {
  30123. ratio: number;
  30124. }): void;
  30125. private _defaultRenderListPrepared;
  30126. /**
  30127. * Renders all the objects from the render list into the texture.
  30128. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  30129. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  30130. */
  30131. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  30132. private _bestReflectionRenderTargetDimension;
  30133. private _prepareRenderingManager;
  30134. /**
  30135. * @hidden
  30136. * @param faceIndex face index to bind to if this is a cubetexture
  30137. * @param layer defines the index of the texture to bind in the array
  30138. */
  30139. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  30140. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  30141. private renderToTarget;
  30142. /**
  30143. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30144. * This allowed control for front to back rendering or reversly depending of the special needs.
  30145. *
  30146. * @param renderingGroupId The rendering group id corresponding to its index
  30147. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30148. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30149. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30150. */
  30151. 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;
  30152. /**
  30153. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30154. *
  30155. * @param renderingGroupId The rendering group id corresponding to its index
  30156. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30157. */
  30158. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  30159. /**
  30160. * Clones the texture.
  30161. * @returns the cloned texture
  30162. */
  30163. clone(): RenderTargetTexture;
  30164. /**
  30165. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  30166. * @returns The JSON representation of the texture
  30167. */
  30168. serialize(): any;
  30169. /**
  30170. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  30171. */
  30172. disposeFramebufferObjects(): void;
  30173. /**
  30174. * Dispose the texture and release its associated resources.
  30175. */
  30176. dispose(): void;
  30177. /** @hidden */
  30178. _rebuild(): void;
  30179. /**
  30180. * Clear the info related to rendering groups preventing retention point in material dispose.
  30181. */
  30182. freeRenderingGroups(): void;
  30183. /**
  30184. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  30185. * @returns the view count
  30186. */
  30187. getViewCount(): number;
  30188. }
  30189. }
  30190. declare module "babylonjs/Misc/guid" {
  30191. /**
  30192. * Class used to manipulate GUIDs
  30193. */
  30194. export class GUID {
  30195. /**
  30196. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30197. * Be aware Math.random() could cause collisions, but:
  30198. * "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"
  30199. * @returns a pseudo random id
  30200. */
  30201. static RandomId(): string;
  30202. }
  30203. }
  30204. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30205. import { Nullable } from "babylonjs/types";
  30206. import { Scene } from "babylonjs/scene";
  30207. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30208. import { Material } from "babylonjs/Materials/material";
  30209. import { Effect } from "babylonjs/Materials/effect";
  30210. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30211. /**
  30212. * Options to be used when creating a shadow depth material
  30213. */
  30214. export interface IIOptionShadowDepthMaterial {
  30215. /** Variables in the vertex shader code that need to have their names remapped.
  30216. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30217. * "var_name" should be either: worldPos or vNormalW
  30218. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30219. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30220. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30221. */
  30222. remappedVariables?: string[];
  30223. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30224. standalone?: boolean;
  30225. }
  30226. /**
  30227. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30228. */
  30229. export class ShadowDepthWrapper {
  30230. private _scene;
  30231. private _options?;
  30232. private _baseMaterial;
  30233. private _onEffectCreatedObserver;
  30234. private _subMeshToEffect;
  30235. private _subMeshToDepthEffect;
  30236. private _meshes;
  30237. /** @hidden */
  30238. _matriceNames: any;
  30239. /** Gets the standalone status of the wrapper */
  30240. get standalone(): boolean;
  30241. /** Gets the base material the wrapper is built upon */
  30242. get baseMaterial(): Material;
  30243. /**
  30244. * Instantiate a new shadow depth wrapper.
  30245. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30246. * generate the shadow depth map. For more information, please refer to the documentation:
  30247. * https://doc.babylonjs.com/babylon101/shadows
  30248. * @param baseMaterial Material to wrap
  30249. * @param scene Define the scene the material belongs to
  30250. * @param options Options used to create the wrapper
  30251. */
  30252. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30253. /**
  30254. * Gets the effect to use to generate the depth map
  30255. * @param subMesh subMesh to get the effect for
  30256. * @param shadowGenerator shadow generator to get the effect for
  30257. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30258. */
  30259. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30260. /**
  30261. * Specifies that the submesh is ready to be used for depth rendering
  30262. * @param subMesh submesh to check
  30263. * @param defines the list of defines to take into account when checking the effect
  30264. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30265. * @param useInstances specifies that instances should be used
  30266. * @returns a boolean indicating that the submesh is ready or not
  30267. */
  30268. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30269. /**
  30270. * Disposes the resources
  30271. */
  30272. dispose(): void;
  30273. private _makeEffect;
  30274. }
  30275. }
  30276. declare module "babylonjs/Materials/material" {
  30277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30278. import { SmartArray } from "babylonjs/Misc/smartArray";
  30279. import { Observable } from "babylonjs/Misc/observable";
  30280. import { Nullable } from "babylonjs/types";
  30281. import { Scene } from "babylonjs/scene";
  30282. import { Matrix } from "babylonjs/Maths/math.vector";
  30283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30285. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30286. import { Effect } from "babylonjs/Materials/effect";
  30287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30288. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30289. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30290. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30291. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30292. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30293. import { Mesh } from "babylonjs/Meshes/mesh";
  30294. import { Animation } from "babylonjs/Animations/animation";
  30295. /**
  30296. * Options for compiling materials.
  30297. */
  30298. export interface IMaterialCompilationOptions {
  30299. /**
  30300. * Defines whether clip planes are enabled.
  30301. */
  30302. clipPlane: boolean;
  30303. /**
  30304. * Defines whether instances are enabled.
  30305. */
  30306. useInstances: boolean;
  30307. }
  30308. /**
  30309. * Options passed when calling customShaderNameResolve
  30310. */
  30311. export interface ICustomShaderNameResolveOptions {
  30312. /**
  30313. * 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
  30314. */
  30315. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30316. }
  30317. /**
  30318. * Base class for the main features of a material in Babylon.js
  30319. */
  30320. export class Material implements IAnimatable {
  30321. /**
  30322. * Returns the triangle fill mode
  30323. */
  30324. static readonly TriangleFillMode: number;
  30325. /**
  30326. * Returns the wireframe mode
  30327. */
  30328. static readonly WireFrameFillMode: number;
  30329. /**
  30330. * Returns the point fill mode
  30331. */
  30332. static readonly PointFillMode: number;
  30333. /**
  30334. * Returns the point list draw mode
  30335. */
  30336. static readonly PointListDrawMode: number;
  30337. /**
  30338. * Returns the line list draw mode
  30339. */
  30340. static readonly LineListDrawMode: number;
  30341. /**
  30342. * Returns the line loop draw mode
  30343. */
  30344. static readonly LineLoopDrawMode: number;
  30345. /**
  30346. * Returns the line strip draw mode
  30347. */
  30348. static readonly LineStripDrawMode: number;
  30349. /**
  30350. * Returns the triangle strip draw mode
  30351. */
  30352. static readonly TriangleStripDrawMode: number;
  30353. /**
  30354. * Returns the triangle fan draw mode
  30355. */
  30356. static readonly TriangleFanDrawMode: number;
  30357. /**
  30358. * Stores the clock-wise side orientation
  30359. */
  30360. static readonly ClockWiseSideOrientation: number;
  30361. /**
  30362. * Stores the counter clock-wise side orientation
  30363. */
  30364. static readonly CounterClockWiseSideOrientation: number;
  30365. /**
  30366. * The dirty texture flag value
  30367. */
  30368. static readonly TextureDirtyFlag: number;
  30369. /**
  30370. * The dirty light flag value
  30371. */
  30372. static readonly LightDirtyFlag: number;
  30373. /**
  30374. * The dirty fresnel flag value
  30375. */
  30376. static readonly FresnelDirtyFlag: number;
  30377. /**
  30378. * The dirty attribute flag value
  30379. */
  30380. static readonly AttributesDirtyFlag: number;
  30381. /**
  30382. * The dirty misc flag value
  30383. */
  30384. static readonly MiscDirtyFlag: number;
  30385. /**
  30386. * The dirty prepass flag value
  30387. */
  30388. static readonly PrePassDirtyFlag: number;
  30389. /**
  30390. * The all dirty flag value
  30391. */
  30392. static readonly AllDirtyFlag: number;
  30393. /**
  30394. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30395. */
  30396. static readonly MATERIAL_OPAQUE: number;
  30397. /**
  30398. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30399. */
  30400. static readonly MATERIAL_ALPHATEST: number;
  30401. /**
  30402. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30403. */
  30404. static readonly MATERIAL_ALPHABLEND: number;
  30405. /**
  30406. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30407. * They are also discarded below the alpha cutoff threshold to improve performances.
  30408. */
  30409. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30410. /**
  30411. * The Whiteout method is used to blend normals.
  30412. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30413. */
  30414. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30415. /**
  30416. * The Reoriented Normal Mapping method is used to blend normals.
  30417. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30418. */
  30419. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30420. /**
  30421. * Custom callback helping to override the default shader used in the material.
  30422. */
  30423. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30424. /**
  30425. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30426. */
  30427. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30428. /**
  30429. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30430. * This means that the material can keep using a previous shader while a new one is being compiled.
  30431. * This is mostly used when shader parallel compilation is supported (true by default)
  30432. */
  30433. allowShaderHotSwapping: boolean;
  30434. /**
  30435. * The ID of the material
  30436. */
  30437. id: string;
  30438. /**
  30439. * Gets or sets the unique id of the material
  30440. */
  30441. uniqueId: number;
  30442. /**
  30443. * The name of the material
  30444. */
  30445. name: string;
  30446. /**
  30447. * Gets or sets user defined metadata
  30448. */
  30449. metadata: any;
  30450. /**
  30451. * For internal use only. Please do not use.
  30452. */
  30453. reservedDataStore: any;
  30454. /**
  30455. * Specifies if the ready state should be checked on each call
  30456. */
  30457. checkReadyOnEveryCall: boolean;
  30458. /**
  30459. * Specifies if the ready state should be checked once
  30460. */
  30461. checkReadyOnlyOnce: boolean;
  30462. /**
  30463. * The state of the material
  30464. */
  30465. state: string;
  30466. /**
  30467. * If the material can be rendered to several textures with MRT extension
  30468. */
  30469. get canRenderToMRT(): boolean;
  30470. /**
  30471. * The alpha value of the material
  30472. */
  30473. protected _alpha: number;
  30474. /**
  30475. * List of inspectable custom properties (used by the Inspector)
  30476. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30477. */
  30478. inspectableCustomProperties: IInspectable[];
  30479. /**
  30480. * Sets the alpha value of the material
  30481. */
  30482. set alpha(value: number);
  30483. /**
  30484. * Gets the alpha value of the material
  30485. */
  30486. get alpha(): number;
  30487. /**
  30488. * Specifies if back face culling is enabled
  30489. */
  30490. protected _backFaceCulling: boolean;
  30491. /**
  30492. * Sets the back-face culling state
  30493. */
  30494. set backFaceCulling(value: boolean);
  30495. /**
  30496. * Gets the back-face culling state
  30497. */
  30498. get backFaceCulling(): boolean;
  30499. /**
  30500. * Stores the value for side orientation
  30501. */
  30502. sideOrientation: number;
  30503. /**
  30504. * Callback triggered when the material is compiled
  30505. */
  30506. onCompiled: Nullable<(effect: Effect) => void>;
  30507. /**
  30508. * Callback triggered when an error occurs
  30509. */
  30510. onError: Nullable<(effect: Effect, errors: string) => void>;
  30511. /**
  30512. * Callback triggered to get the render target textures
  30513. */
  30514. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30515. /**
  30516. * Gets a boolean indicating that current material needs to register RTT
  30517. */
  30518. get hasRenderTargetTextures(): boolean;
  30519. /**
  30520. * Specifies if the material should be serialized
  30521. */
  30522. doNotSerialize: boolean;
  30523. /**
  30524. * @hidden
  30525. */
  30526. _storeEffectOnSubMeshes: boolean;
  30527. /**
  30528. * Stores the animations for the material
  30529. */
  30530. animations: Nullable<Array<Animation>>;
  30531. /**
  30532. * An event triggered when the material is disposed
  30533. */
  30534. onDisposeObservable: Observable<Material>;
  30535. /**
  30536. * An observer which watches for dispose events
  30537. */
  30538. private _onDisposeObserver;
  30539. private _onUnBindObservable;
  30540. /**
  30541. * Called during a dispose event
  30542. */
  30543. set onDispose(callback: () => void);
  30544. private _onBindObservable;
  30545. /**
  30546. * An event triggered when the material is bound
  30547. */
  30548. get onBindObservable(): Observable<AbstractMesh>;
  30549. /**
  30550. * An observer which watches for bind events
  30551. */
  30552. private _onBindObserver;
  30553. /**
  30554. * Called during a bind event
  30555. */
  30556. set onBind(callback: (Mesh: AbstractMesh) => void);
  30557. /**
  30558. * An event triggered when the material is unbound
  30559. */
  30560. get onUnBindObservable(): Observable<Material>;
  30561. protected _onEffectCreatedObservable: Nullable<Observable<{
  30562. effect: Effect;
  30563. subMesh: Nullable<SubMesh>;
  30564. }>>;
  30565. /**
  30566. * An event triggered when the effect is (re)created
  30567. */
  30568. get onEffectCreatedObservable(): Observable<{
  30569. effect: Effect;
  30570. subMesh: Nullable<SubMesh>;
  30571. }>;
  30572. /**
  30573. * Stores the value of the alpha mode
  30574. */
  30575. private _alphaMode;
  30576. /**
  30577. * Sets the value of the alpha mode.
  30578. *
  30579. * | Value | Type | Description |
  30580. * | --- | --- | --- |
  30581. * | 0 | ALPHA_DISABLE | |
  30582. * | 1 | ALPHA_ADD | |
  30583. * | 2 | ALPHA_COMBINE | |
  30584. * | 3 | ALPHA_SUBTRACT | |
  30585. * | 4 | ALPHA_MULTIPLY | |
  30586. * | 5 | ALPHA_MAXIMIZED | |
  30587. * | 6 | ALPHA_ONEONE | |
  30588. * | 7 | ALPHA_PREMULTIPLIED | |
  30589. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30590. * | 9 | ALPHA_INTERPOLATE | |
  30591. * | 10 | ALPHA_SCREENMODE | |
  30592. *
  30593. */
  30594. set alphaMode(value: number);
  30595. /**
  30596. * Gets the value of the alpha mode
  30597. */
  30598. get alphaMode(): number;
  30599. /**
  30600. * Stores the state of the need depth pre-pass value
  30601. */
  30602. private _needDepthPrePass;
  30603. /**
  30604. * Sets the need depth pre-pass value
  30605. */
  30606. set needDepthPrePass(value: boolean);
  30607. /**
  30608. * Gets the depth pre-pass value
  30609. */
  30610. get needDepthPrePass(): boolean;
  30611. /**
  30612. * Specifies if depth writing should be disabled
  30613. */
  30614. disableDepthWrite: boolean;
  30615. /**
  30616. * Specifies if color writing should be disabled
  30617. */
  30618. disableColorWrite: boolean;
  30619. /**
  30620. * Specifies if depth writing should be forced
  30621. */
  30622. forceDepthWrite: boolean;
  30623. /**
  30624. * Specifies the depth function that should be used. 0 means the default engine function
  30625. */
  30626. depthFunction: number;
  30627. /**
  30628. * Specifies if there should be a separate pass for culling
  30629. */
  30630. separateCullingPass: boolean;
  30631. /**
  30632. * Stores the state specifing if fog should be enabled
  30633. */
  30634. private _fogEnabled;
  30635. /**
  30636. * Sets the state for enabling fog
  30637. */
  30638. set fogEnabled(value: boolean);
  30639. /**
  30640. * Gets the value of the fog enabled state
  30641. */
  30642. get fogEnabled(): boolean;
  30643. /**
  30644. * Stores the size of points
  30645. */
  30646. pointSize: number;
  30647. /**
  30648. * Stores the z offset value
  30649. */
  30650. zOffset: number;
  30651. get wireframe(): boolean;
  30652. /**
  30653. * Sets the state of wireframe mode
  30654. */
  30655. set wireframe(value: boolean);
  30656. /**
  30657. * Gets the value specifying if point clouds are enabled
  30658. */
  30659. get pointsCloud(): boolean;
  30660. /**
  30661. * Sets the state of point cloud mode
  30662. */
  30663. set pointsCloud(value: boolean);
  30664. /**
  30665. * Gets the material fill mode
  30666. */
  30667. get fillMode(): number;
  30668. /**
  30669. * Sets the material fill mode
  30670. */
  30671. set fillMode(value: number);
  30672. /**
  30673. * @hidden
  30674. * Stores the effects for the material
  30675. */
  30676. _effect: Nullable<Effect>;
  30677. /**
  30678. * Specifies if uniform buffers should be used
  30679. */
  30680. private _useUBO;
  30681. /**
  30682. * Stores a reference to the scene
  30683. */
  30684. private _scene;
  30685. /**
  30686. * Stores the fill mode state
  30687. */
  30688. private _fillMode;
  30689. /**
  30690. * Specifies if the depth write state should be cached
  30691. */
  30692. private _cachedDepthWriteState;
  30693. /**
  30694. * Specifies if the color write state should be cached
  30695. */
  30696. private _cachedColorWriteState;
  30697. /**
  30698. * Specifies if the depth function state should be cached
  30699. */
  30700. private _cachedDepthFunctionState;
  30701. /**
  30702. * Stores the uniform buffer
  30703. */
  30704. protected _uniformBuffer: UniformBuffer;
  30705. /** @hidden */
  30706. _indexInSceneMaterialArray: number;
  30707. /** @hidden */
  30708. meshMap: Nullable<{
  30709. [id: string]: AbstractMesh | undefined;
  30710. }>;
  30711. /**
  30712. * Creates a material instance
  30713. * @param name defines the name of the material
  30714. * @param scene defines the scene to reference
  30715. * @param doNotAdd specifies if the material should be added to the scene
  30716. */
  30717. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30718. /**
  30719. * Returns a string representation of the current material
  30720. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30721. * @returns a string with material information
  30722. */
  30723. toString(fullDetails?: boolean): string;
  30724. /**
  30725. * Gets the class name of the material
  30726. * @returns a string with the class name of the material
  30727. */
  30728. getClassName(): string;
  30729. /**
  30730. * Specifies if updates for the material been locked
  30731. */
  30732. get isFrozen(): boolean;
  30733. /**
  30734. * Locks updates for the material
  30735. */
  30736. freeze(): void;
  30737. /**
  30738. * Unlocks updates for the material
  30739. */
  30740. unfreeze(): void;
  30741. /**
  30742. * Specifies if the material is ready to be used
  30743. * @param mesh defines the mesh to check
  30744. * @param useInstances specifies if instances should be used
  30745. * @returns a boolean indicating if the material is ready to be used
  30746. */
  30747. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30748. /**
  30749. * Specifies that the submesh is ready to be used
  30750. * @param mesh defines the mesh to check
  30751. * @param subMesh defines which submesh to check
  30752. * @param useInstances specifies that instances should be used
  30753. * @returns a boolean indicating that the submesh is ready or not
  30754. */
  30755. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30756. /**
  30757. * Returns the material effect
  30758. * @returns the effect associated with the material
  30759. */
  30760. getEffect(): Nullable<Effect>;
  30761. /**
  30762. * Returns the current scene
  30763. * @returns a Scene
  30764. */
  30765. getScene(): Scene;
  30766. /**
  30767. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30768. */
  30769. protected _forceAlphaTest: boolean;
  30770. /**
  30771. * The transparency mode of the material.
  30772. */
  30773. protected _transparencyMode: Nullable<number>;
  30774. /**
  30775. * Gets the current transparency mode.
  30776. */
  30777. get transparencyMode(): Nullable<number>;
  30778. /**
  30779. * Sets the transparency mode of the material.
  30780. *
  30781. * | Value | Type | Description |
  30782. * | ----- | ----------------------------------- | ----------- |
  30783. * | 0 | OPAQUE | |
  30784. * | 1 | ALPHATEST | |
  30785. * | 2 | ALPHABLEND | |
  30786. * | 3 | ALPHATESTANDBLEND | |
  30787. *
  30788. */
  30789. set transparencyMode(value: Nullable<number>);
  30790. /**
  30791. * Returns true if alpha blending should be disabled.
  30792. */
  30793. protected get _disableAlphaBlending(): boolean;
  30794. /**
  30795. * Specifies whether or not this material should be rendered in alpha blend mode.
  30796. * @returns a boolean specifying if alpha blending is needed
  30797. */
  30798. needAlphaBlending(): boolean;
  30799. /**
  30800. * Specifies if the mesh will require alpha blending
  30801. * @param mesh defines the mesh to check
  30802. * @returns a boolean specifying if alpha blending is needed for the mesh
  30803. */
  30804. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30805. /**
  30806. * Specifies whether or not this material should be rendered in alpha test mode.
  30807. * @returns a boolean specifying if an alpha test is needed.
  30808. */
  30809. needAlphaTesting(): boolean;
  30810. /**
  30811. * Specifies if material alpha testing should be turned on for the mesh
  30812. * @param mesh defines the mesh to check
  30813. */
  30814. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30815. /**
  30816. * Gets the texture used for the alpha test
  30817. * @returns the texture to use for alpha testing
  30818. */
  30819. getAlphaTestTexture(): Nullable<BaseTexture>;
  30820. /**
  30821. * Marks the material to indicate that it needs to be re-calculated
  30822. */
  30823. markDirty(): void;
  30824. /** @hidden */
  30825. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30826. /**
  30827. * Binds the material to the mesh
  30828. * @param world defines the world transformation matrix
  30829. * @param mesh defines the mesh to bind the material to
  30830. */
  30831. bind(world: Matrix, mesh?: Mesh): void;
  30832. /**
  30833. * Binds the submesh to the material
  30834. * @param world defines the world transformation matrix
  30835. * @param mesh defines the mesh containing the submesh
  30836. * @param subMesh defines the submesh to bind the material to
  30837. */
  30838. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30839. /**
  30840. * Binds the world matrix to the material
  30841. * @param world defines the world transformation matrix
  30842. */
  30843. bindOnlyWorldMatrix(world: Matrix): void;
  30844. /**
  30845. * Binds the scene's uniform buffer to the effect.
  30846. * @param effect defines the effect to bind to the scene uniform buffer
  30847. * @param sceneUbo defines the uniform buffer storing scene data
  30848. */
  30849. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30850. /**
  30851. * Binds the view matrix to the effect
  30852. * @param effect defines the effect to bind the view matrix to
  30853. */
  30854. bindView(effect: Effect): void;
  30855. /**
  30856. * Binds the view projection matrix to the effect
  30857. * @param effect defines the effect to bind the view projection matrix to
  30858. */
  30859. bindViewProjection(effect: Effect): void;
  30860. /**
  30861. * Processes to execute after binding the material to a mesh
  30862. * @param mesh defines the rendered mesh
  30863. */
  30864. protected _afterBind(mesh?: Mesh): void;
  30865. /**
  30866. * Unbinds the material from the mesh
  30867. */
  30868. unbind(): void;
  30869. /**
  30870. * Gets the active textures from the material
  30871. * @returns an array of textures
  30872. */
  30873. getActiveTextures(): BaseTexture[];
  30874. /**
  30875. * Specifies if the material uses a texture
  30876. * @param texture defines the texture to check against the material
  30877. * @returns a boolean specifying if the material uses the texture
  30878. */
  30879. hasTexture(texture: BaseTexture): boolean;
  30880. /**
  30881. * Makes a duplicate of the material, and gives it a new name
  30882. * @param name defines the new name for the duplicated material
  30883. * @returns the cloned material
  30884. */
  30885. clone(name: string): Nullable<Material>;
  30886. /**
  30887. * Gets the meshes bound to the material
  30888. * @returns an array of meshes bound to the material
  30889. */
  30890. getBindedMeshes(): AbstractMesh[];
  30891. /**
  30892. * Force shader compilation
  30893. * @param mesh defines the mesh associated with this material
  30894. * @param onCompiled defines a function to execute once the material is compiled
  30895. * @param options defines the options to configure the compilation
  30896. * @param onError defines a function to execute if the material fails compiling
  30897. */
  30898. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30899. /**
  30900. * Force shader compilation
  30901. * @param mesh defines the mesh that will use this material
  30902. * @param options defines additional options for compiling the shaders
  30903. * @returns a promise that resolves when the compilation completes
  30904. */
  30905. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30906. private static readonly _AllDirtyCallBack;
  30907. private static readonly _ImageProcessingDirtyCallBack;
  30908. private static readonly _TextureDirtyCallBack;
  30909. private static readonly _FresnelDirtyCallBack;
  30910. private static readonly _MiscDirtyCallBack;
  30911. private static readonly _PrePassDirtyCallBack;
  30912. private static readonly _LightsDirtyCallBack;
  30913. private static readonly _AttributeDirtyCallBack;
  30914. private static _FresnelAndMiscDirtyCallBack;
  30915. private static _TextureAndMiscDirtyCallBack;
  30916. private static readonly _DirtyCallbackArray;
  30917. private static readonly _RunDirtyCallBacks;
  30918. /**
  30919. * Marks a define in the material to indicate that it needs to be re-computed
  30920. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30921. */
  30922. markAsDirty(flag: number): void;
  30923. /**
  30924. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30925. * @param func defines a function which checks material defines against the submeshes
  30926. */
  30927. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30928. /**
  30929. * Indicates that the scene should check if the rendering now needs a prepass
  30930. */
  30931. protected _markScenePrePassDirty(): void;
  30932. /**
  30933. * Indicates that we need to re-calculated for all submeshes
  30934. */
  30935. protected _markAllSubMeshesAsAllDirty(): void;
  30936. /**
  30937. * Indicates that image processing needs to be re-calculated for all submeshes
  30938. */
  30939. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30940. /**
  30941. * Indicates that textures need to be re-calculated for all submeshes
  30942. */
  30943. protected _markAllSubMeshesAsTexturesDirty(): void;
  30944. /**
  30945. * Indicates that fresnel needs to be re-calculated for all submeshes
  30946. */
  30947. protected _markAllSubMeshesAsFresnelDirty(): void;
  30948. /**
  30949. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30950. */
  30951. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30952. /**
  30953. * Indicates that lights need to be re-calculated for all submeshes
  30954. */
  30955. protected _markAllSubMeshesAsLightsDirty(): void;
  30956. /**
  30957. * Indicates that attributes need to be re-calculated for all submeshes
  30958. */
  30959. protected _markAllSubMeshesAsAttributesDirty(): void;
  30960. /**
  30961. * Indicates that misc needs to be re-calculated for all submeshes
  30962. */
  30963. protected _markAllSubMeshesAsMiscDirty(): void;
  30964. /**
  30965. * Indicates that prepass needs to be re-calculated for all submeshes
  30966. */
  30967. protected _markAllSubMeshesAsPrePassDirty(): void;
  30968. /**
  30969. * Indicates that textures and misc need to be re-calculated for all submeshes
  30970. */
  30971. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30972. /**
  30973. * Sets the required values to the prepass renderer.
  30974. * @param prePassRenderer defines the prepass renderer to setup.
  30975. * @returns true if the pre pass is needed.
  30976. */
  30977. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30978. /**
  30979. * Disposes the material
  30980. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30981. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30982. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30983. */
  30984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30985. /** @hidden */
  30986. private releaseVertexArrayObject;
  30987. /**
  30988. * Serializes this material
  30989. * @returns the serialized material object
  30990. */
  30991. serialize(): any;
  30992. /**
  30993. * Creates a material from parsed material data
  30994. * @param parsedMaterial defines parsed material data
  30995. * @param scene defines the hosting scene
  30996. * @param rootUrl defines the root URL to use to load textures
  30997. * @returns a new material
  30998. */
  30999. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31000. }
  31001. }
  31002. declare module "babylonjs/Materials/multiMaterial" {
  31003. import { Nullable } from "babylonjs/types";
  31004. import { Scene } from "babylonjs/scene";
  31005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31008. import { Material } from "babylonjs/Materials/material";
  31009. /**
  31010. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31011. * separate meshes. This can be use to improve performances.
  31012. * @see https://doc.babylonjs.com/how_to/multi_materials
  31013. */
  31014. export class MultiMaterial extends Material {
  31015. private _subMaterials;
  31016. /**
  31017. * Gets or Sets the list of Materials used within the multi material.
  31018. * They need to be ordered according to the submeshes order in the associated mesh
  31019. */
  31020. get subMaterials(): Nullable<Material>[];
  31021. set subMaterials(value: Nullable<Material>[]);
  31022. /**
  31023. * Function used to align with Node.getChildren()
  31024. * @returns the list of Materials used within the multi material
  31025. */
  31026. getChildren(): Nullable<Material>[];
  31027. /**
  31028. * Instantiates a new Multi Material
  31029. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31030. * separate meshes. This can be use to improve performances.
  31031. * @see https://doc.babylonjs.com/how_to/multi_materials
  31032. * @param name Define the name in the scene
  31033. * @param scene Define the scene the material belongs to
  31034. */
  31035. constructor(name: string, scene: Scene);
  31036. private _hookArray;
  31037. /**
  31038. * Get one of the submaterial by its index in the submaterials array
  31039. * @param index The index to look the sub material at
  31040. * @returns The Material if the index has been defined
  31041. */
  31042. getSubMaterial(index: number): Nullable<Material>;
  31043. /**
  31044. * Get the list of active textures for the whole sub materials list.
  31045. * @returns All the textures that will be used during the rendering
  31046. */
  31047. getActiveTextures(): BaseTexture[];
  31048. /**
  31049. * Gets the current class name of the material e.g. "MultiMaterial"
  31050. * Mainly use in serialization.
  31051. * @returns the class name
  31052. */
  31053. getClassName(): string;
  31054. /**
  31055. * Checks if the material is ready to render the requested sub mesh
  31056. * @param mesh Define the mesh the submesh belongs to
  31057. * @param subMesh Define the sub mesh to look readyness for
  31058. * @param useInstances Define whether or not the material is used with instances
  31059. * @returns true if ready, otherwise false
  31060. */
  31061. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31062. /**
  31063. * Clones the current material and its related sub materials
  31064. * @param name Define the name of the newly cloned material
  31065. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31066. * @returns the cloned material
  31067. */
  31068. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31069. /**
  31070. * Serializes the materials into a JSON representation.
  31071. * @returns the JSON representation
  31072. */
  31073. serialize(): any;
  31074. /**
  31075. * Dispose the material and release its associated resources
  31076. * @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)
  31077. * @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)
  31078. * @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)
  31079. */
  31080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31081. /**
  31082. * Creates a MultiMaterial from parsed MultiMaterial data.
  31083. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31084. * @param scene defines the hosting scene
  31085. * @returns a new MultiMaterial
  31086. */
  31087. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31088. }
  31089. }
  31090. declare module "babylonjs/Meshes/subMesh" {
  31091. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31092. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31093. import { Engine } from "babylonjs/Engines/engine";
  31094. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31095. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31096. import { Effect } from "babylonjs/Materials/effect";
  31097. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31098. import { Plane } from "babylonjs/Maths/math.plane";
  31099. import { Collider } from "babylonjs/Collisions/collider";
  31100. import { Material } from "babylonjs/Materials/material";
  31101. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31103. import { Mesh } from "babylonjs/Meshes/mesh";
  31104. import { Ray } from "babylonjs/Culling/ray";
  31105. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31106. /**
  31107. * Defines a subdivision inside a mesh
  31108. */
  31109. export class SubMesh implements ICullable {
  31110. /** the material index to use */
  31111. materialIndex: number;
  31112. /** vertex index start */
  31113. verticesStart: number;
  31114. /** vertices count */
  31115. verticesCount: number;
  31116. /** index start */
  31117. indexStart: number;
  31118. /** indices count */
  31119. indexCount: number;
  31120. /** @hidden */
  31121. _materialDefines: Nullable<MaterialDefines>;
  31122. /** @hidden */
  31123. _materialEffect: Nullable<Effect>;
  31124. /** @hidden */
  31125. _effectOverride: Nullable<Effect>;
  31126. /**
  31127. * Gets material defines used by the effect associated to the sub mesh
  31128. */
  31129. get materialDefines(): Nullable<MaterialDefines>;
  31130. /**
  31131. * Sets material defines used by the effect associated to the sub mesh
  31132. */
  31133. set materialDefines(defines: Nullable<MaterialDefines>);
  31134. /**
  31135. * Gets associated effect
  31136. */
  31137. get effect(): Nullable<Effect>;
  31138. /**
  31139. * Sets associated effect (effect used to render this submesh)
  31140. * @param effect defines the effect to associate with
  31141. * @param defines defines the set of defines used to compile this effect
  31142. */
  31143. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31144. /** @hidden */
  31145. _linesIndexCount: number;
  31146. private _mesh;
  31147. private _renderingMesh;
  31148. private _boundingInfo;
  31149. private _linesIndexBuffer;
  31150. /** @hidden */
  31151. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31152. /** @hidden */
  31153. _trianglePlanes: Plane[];
  31154. /** @hidden */
  31155. _lastColliderTransformMatrix: Nullable<Matrix>;
  31156. /** @hidden */
  31157. _renderId: number;
  31158. /** @hidden */
  31159. _alphaIndex: number;
  31160. /** @hidden */
  31161. _distanceToCamera: number;
  31162. /** @hidden */
  31163. _id: number;
  31164. private _currentMaterial;
  31165. /**
  31166. * Add a new submesh to a mesh
  31167. * @param materialIndex defines the material index to use
  31168. * @param verticesStart defines vertex index start
  31169. * @param verticesCount defines vertices count
  31170. * @param indexStart defines index start
  31171. * @param indexCount defines indices count
  31172. * @param mesh defines the parent mesh
  31173. * @param renderingMesh defines an optional rendering mesh
  31174. * @param createBoundingBox defines if bounding box should be created for this submesh
  31175. * @returns the new submesh
  31176. */
  31177. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31178. /**
  31179. * Creates a new submesh
  31180. * @param materialIndex defines the material index to use
  31181. * @param verticesStart defines vertex index start
  31182. * @param verticesCount defines vertices count
  31183. * @param indexStart defines index start
  31184. * @param indexCount defines indices count
  31185. * @param mesh defines the parent mesh
  31186. * @param renderingMesh defines an optional rendering mesh
  31187. * @param createBoundingBox defines if bounding box should be created for this submesh
  31188. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31189. */
  31190. constructor(
  31191. /** the material index to use */
  31192. materialIndex: number,
  31193. /** vertex index start */
  31194. verticesStart: number,
  31195. /** vertices count */
  31196. verticesCount: number,
  31197. /** index start */
  31198. indexStart: number,
  31199. /** indices count */
  31200. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31201. /**
  31202. * Returns true if this submesh covers the entire parent mesh
  31203. * @ignorenaming
  31204. */
  31205. get IsGlobal(): boolean;
  31206. /**
  31207. * Returns the submesh BoudingInfo object
  31208. * @returns current bounding info (or mesh's one if the submesh is global)
  31209. */
  31210. getBoundingInfo(): BoundingInfo;
  31211. /**
  31212. * Sets the submesh BoundingInfo
  31213. * @param boundingInfo defines the new bounding info to use
  31214. * @returns the SubMesh
  31215. */
  31216. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31217. /**
  31218. * Returns the mesh of the current submesh
  31219. * @return the parent mesh
  31220. */
  31221. getMesh(): AbstractMesh;
  31222. /**
  31223. * Returns the rendering mesh of the submesh
  31224. * @returns the rendering mesh (could be different from parent mesh)
  31225. */
  31226. getRenderingMesh(): Mesh;
  31227. /**
  31228. * Returns the replacement mesh of the submesh
  31229. * @returns the replacement mesh (could be different from parent mesh)
  31230. */
  31231. getReplacementMesh(): Nullable<AbstractMesh>;
  31232. /**
  31233. * Returns the effective mesh of the submesh
  31234. * @returns the effective mesh (could be different from parent mesh)
  31235. */
  31236. getEffectiveMesh(): AbstractMesh;
  31237. /**
  31238. * Returns the submesh material
  31239. * @returns null or the current material
  31240. */
  31241. getMaterial(): Nullable<Material>;
  31242. private _IsMultiMaterial;
  31243. /**
  31244. * Sets a new updated BoundingInfo object to the submesh
  31245. * @param data defines an optional position array to use to determine the bounding info
  31246. * @returns the SubMesh
  31247. */
  31248. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31249. /** @hidden */
  31250. _checkCollision(collider: Collider): boolean;
  31251. /**
  31252. * Updates the submesh BoundingInfo
  31253. * @param world defines the world matrix to use to update the bounding info
  31254. * @returns the submesh
  31255. */
  31256. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31257. /**
  31258. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31259. * @param frustumPlanes defines the frustum planes
  31260. * @returns true if the submesh is intersecting with the frustum
  31261. */
  31262. isInFrustum(frustumPlanes: Plane[]): boolean;
  31263. /**
  31264. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31265. * @param frustumPlanes defines the frustum planes
  31266. * @returns true if the submesh is inside the frustum
  31267. */
  31268. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31269. /**
  31270. * Renders the submesh
  31271. * @param enableAlphaMode defines if alpha needs to be used
  31272. * @returns the submesh
  31273. */
  31274. render(enableAlphaMode: boolean): SubMesh;
  31275. /**
  31276. * @hidden
  31277. */
  31278. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31279. /**
  31280. * Checks if the submesh intersects with a ray
  31281. * @param ray defines the ray to test
  31282. * @returns true is the passed ray intersects the submesh bounding box
  31283. */
  31284. canIntersects(ray: Ray): boolean;
  31285. /**
  31286. * Intersects current submesh with a ray
  31287. * @param ray defines the ray to test
  31288. * @param positions defines mesh's positions array
  31289. * @param indices defines mesh's indices array
  31290. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31291. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31292. * @returns intersection info or null if no intersection
  31293. */
  31294. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31295. /** @hidden */
  31296. private _intersectLines;
  31297. /** @hidden */
  31298. private _intersectUnIndexedLines;
  31299. /** @hidden */
  31300. private _intersectTriangles;
  31301. /** @hidden */
  31302. private _intersectUnIndexedTriangles;
  31303. /** @hidden */
  31304. _rebuild(): void;
  31305. /**
  31306. * Creates a new submesh from the passed mesh
  31307. * @param newMesh defines the new hosting mesh
  31308. * @param newRenderingMesh defines an optional rendering mesh
  31309. * @returns the new submesh
  31310. */
  31311. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31312. /**
  31313. * Release associated resources
  31314. */
  31315. dispose(): void;
  31316. /**
  31317. * Gets the class name
  31318. * @returns the string "SubMesh".
  31319. */
  31320. getClassName(): string;
  31321. /**
  31322. * Creates a new submesh from indices data
  31323. * @param materialIndex the index of the main mesh material
  31324. * @param startIndex the index where to start the copy in the mesh indices array
  31325. * @param indexCount the number of indices to copy then from the startIndex
  31326. * @param mesh the main mesh to create the submesh from
  31327. * @param renderingMesh the optional rendering mesh
  31328. * @returns a new submesh
  31329. */
  31330. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31331. }
  31332. }
  31333. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31334. /**
  31335. * Class used to represent data loading progression
  31336. */
  31337. export class SceneLoaderFlags {
  31338. private static _ForceFullSceneLoadingForIncremental;
  31339. private static _ShowLoadingScreen;
  31340. private static _CleanBoneMatrixWeights;
  31341. private static _loggingLevel;
  31342. /**
  31343. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31344. */
  31345. static get ForceFullSceneLoadingForIncremental(): boolean;
  31346. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31347. /**
  31348. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31349. */
  31350. static get ShowLoadingScreen(): boolean;
  31351. static set ShowLoadingScreen(value: boolean);
  31352. /**
  31353. * Defines the current logging level (while loading the scene)
  31354. * @ignorenaming
  31355. */
  31356. static get loggingLevel(): number;
  31357. static set loggingLevel(value: number);
  31358. /**
  31359. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31360. */
  31361. static get CleanBoneMatrixWeights(): boolean;
  31362. static set CleanBoneMatrixWeights(value: boolean);
  31363. }
  31364. }
  31365. declare module "babylonjs/Meshes/geometry" {
  31366. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31367. import { Scene } from "babylonjs/scene";
  31368. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31369. import { Engine } from "babylonjs/Engines/engine";
  31370. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31371. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31372. import { Effect } from "babylonjs/Materials/effect";
  31373. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31374. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31375. import { Mesh } from "babylonjs/Meshes/mesh";
  31376. /**
  31377. * Class used to store geometry data (vertex buffers + index buffer)
  31378. */
  31379. export class Geometry implements IGetSetVerticesData {
  31380. /**
  31381. * Gets or sets the ID of the geometry
  31382. */
  31383. id: string;
  31384. /**
  31385. * Gets or sets the unique ID of the geometry
  31386. */
  31387. uniqueId: number;
  31388. /**
  31389. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31390. */
  31391. delayLoadState: number;
  31392. /**
  31393. * Gets the file containing the data to load when running in delay load state
  31394. */
  31395. delayLoadingFile: Nullable<string>;
  31396. /**
  31397. * Callback called when the geometry is updated
  31398. */
  31399. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31400. private _scene;
  31401. private _engine;
  31402. private _meshes;
  31403. private _totalVertices;
  31404. /** @hidden */
  31405. _indices: IndicesArray;
  31406. /** @hidden */
  31407. _vertexBuffers: {
  31408. [key: string]: VertexBuffer;
  31409. };
  31410. private _isDisposed;
  31411. private _extend;
  31412. private _boundingBias;
  31413. /** @hidden */
  31414. _delayInfo: Array<string>;
  31415. private _indexBuffer;
  31416. private _indexBufferIsUpdatable;
  31417. /** @hidden */
  31418. _boundingInfo: Nullable<BoundingInfo>;
  31419. /** @hidden */
  31420. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31421. /** @hidden */
  31422. _softwareSkinningFrameId: number;
  31423. private _vertexArrayObjects;
  31424. private _updatable;
  31425. /** @hidden */
  31426. _positions: Nullable<Vector3[]>;
  31427. private _positionsCache;
  31428. /**
  31429. * 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
  31430. */
  31431. get boundingBias(): Vector2;
  31432. /**
  31433. * 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
  31434. */
  31435. set boundingBias(value: Vector2);
  31436. /**
  31437. * Static function used to attach a new empty geometry to a mesh
  31438. * @param mesh defines the mesh to attach the geometry to
  31439. * @returns the new Geometry
  31440. */
  31441. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31442. /** Get the list of meshes using this geometry */
  31443. get meshes(): Mesh[];
  31444. /**
  31445. * 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
  31446. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31447. */
  31448. useBoundingInfoFromGeometry: boolean;
  31449. /**
  31450. * Creates a new geometry
  31451. * @param id defines the unique ID
  31452. * @param scene defines the hosting scene
  31453. * @param vertexData defines the VertexData used to get geometry data
  31454. * @param updatable defines if geometry must be updatable (false by default)
  31455. * @param mesh defines the mesh that will be associated with the geometry
  31456. */
  31457. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31458. /**
  31459. * Gets the current extend of the geometry
  31460. */
  31461. get extend(): {
  31462. minimum: Vector3;
  31463. maximum: Vector3;
  31464. };
  31465. /**
  31466. * Gets the hosting scene
  31467. * @returns the hosting Scene
  31468. */
  31469. getScene(): Scene;
  31470. /**
  31471. * Gets the hosting engine
  31472. * @returns the hosting Engine
  31473. */
  31474. getEngine(): Engine;
  31475. /**
  31476. * Defines if the geometry is ready to use
  31477. * @returns true if the geometry is ready to be used
  31478. */
  31479. isReady(): boolean;
  31480. /**
  31481. * Gets a value indicating that the geometry should not be serialized
  31482. */
  31483. get doNotSerialize(): boolean;
  31484. /** @hidden */
  31485. _rebuild(): void;
  31486. /**
  31487. * Affects all geometry data in one call
  31488. * @param vertexData defines the geometry data
  31489. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31490. */
  31491. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31492. /**
  31493. * Set specific vertex data
  31494. * @param kind defines the data kind (Position, normal, etc...)
  31495. * @param data defines the vertex data to use
  31496. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31497. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31498. */
  31499. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31500. /**
  31501. * Removes a specific vertex data
  31502. * @param kind defines the data kind (Position, normal, etc...)
  31503. */
  31504. removeVerticesData(kind: string): void;
  31505. /**
  31506. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31507. * @param buffer defines the vertex buffer to use
  31508. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31509. */
  31510. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31511. /**
  31512. * Update a specific vertex buffer
  31513. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31514. * It will do nothing if the buffer is not updatable
  31515. * @param kind defines the data kind (Position, normal, etc...)
  31516. * @param data defines the data to use
  31517. * @param offset defines the offset in the target buffer where to store the data
  31518. * @param useBytes set to true if the offset is in bytes
  31519. */
  31520. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31521. /**
  31522. * Update a specific vertex buffer
  31523. * This function will create a new buffer if the current one is not updatable
  31524. * @param kind defines the data kind (Position, normal, etc...)
  31525. * @param data defines the data to use
  31526. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31527. */
  31528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31529. private _updateBoundingInfo;
  31530. /** @hidden */
  31531. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31532. /**
  31533. * Gets total number of vertices
  31534. * @returns the total number of vertices
  31535. */
  31536. getTotalVertices(): number;
  31537. /**
  31538. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31539. * @param kind defines the data kind (Position, normal, etc...)
  31540. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31542. * @returns a float array containing vertex data
  31543. */
  31544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31545. /**
  31546. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31547. * @param kind defines the data kind (Position, normal, etc...)
  31548. * @returns true if the vertex buffer with the specified kind is updatable
  31549. */
  31550. isVertexBufferUpdatable(kind: string): boolean;
  31551. /**
  31552. * Gets a specific vertex buffer
  31553. * @param kind defines the data kind (Position, normal, etc...)
  31554. * @returns a VertexBuffer
  31555. */
  31556. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31557. /**
  31558. * Returns all vertex buffers
  31559. * @return an object holding all vertex buffers indexed by kind
  31560. */
  31561. getVertexBuffers(): Nullable<{
  31562. [key: string]: VertexBuffer;
  31563. }>;
  31564. /**
  31565. * Gets a boolean indicating if specific vertex buffer is present
  31566. * @param kind defines the data kind (Position, normal, etc...)
  31567. * @returns true if data is present
  31568. */
  31569. isVerticesDataPresent(kind: string): boolean;
  31570. /**
  31571. * Gets a list of all attached data kinds (Position, normal, etc...)
  31572. * @returns a list of string containing all kinds
  31573. */
  31574. getVerticesDataKinds(): string[];
  31575. /**
  31576. * Update index buffer
  31577. * @param indices defines the indices to store in the index buffer
  31578. * @param offset defines the offset in the target buffer where to store the data
  31579. * @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)
  31580. */
  31581. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31582. /**
  31583. * Creates a new index buffer
  31584. * @param indices defines the indices to store in the index buffer
  31585. * @param totalVertices defines the total number of vertices (could be null)
  31586. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31587. */
  31588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31589. /**
  31590. * Return the total number of indices
  31591. * @returns the total number of indices
  31592. */
  31593. getTotalIndices(): number;
  31594. /**
  31595. * Gets the index buffer array
  31596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31598. * @returns the index buffer array
  31599. */
  31600. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31601. /**
  31602. * Gets the index buffer
  31603. * @return the index buffer
  31604. */
  31605. getIndexBuffer(): Nullable<DataBuffer>;
  31606. /** @hidden */
  31607. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31608. /**
  31609. * Release the associated resources for a specific mesh
  31610. * @param mesh defines the source mesh
  31611. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31612. */
  31613. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31614. /**
  31615. * Apply current geometry to a given mesh
  31616. * @param mesh defines the mesh to apply geometry to
  31617. */
  31618. applyToMesh(mesh: Mesh): void;
  31619. private _updateExtend;
  31620. private _applyToMesh;
  31621. private notifyUpdate;
  31622. /**
  31623. * Load the geometry if it was flagged as delay loaded
  31624. * @param scene defines the hosting scene
  31625. * @param onLoaded defines a callback called when the geometry is loaded
  31626. */
  31627. load(scene: Scene, onLoaded?: () => void): void;
  31628. private _queueLoad;
  31629. /**
  31630. * Invert the geometry to move from a right handed system to a left handed one.
  31631. */
  31632. toLeftHanded(): void;
  31633. /** @hidden */
  31634. _resetPointsArrayCache(): void;
  31635. /** @hidden */
  31636. _generatePointsArray(): boolean;
  31637. /**
  31638. * Gets a value indicating if the geometry is disposed
  31639. * @returns true if the geometry was disposed
  31640. */
  31641. isDisposed(): boolean;
  31642. private _disposeVertexArrayObjects;
  31643. /**
  31644. * Free all associated resources
  31645. */
  31646. dispose(): void;
  31647. /**
  31648. * Clone the current geometry into a new geometry
  31649. * @param id defines the unique ID of the new geometry
  31650. * @returns a new geometry object
  31651. */
  31652. copy(id: string): Geometry;
  31653. /**
  31654. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31655. * @return a JSON representation of the current geometry data (without the vertices data)
  31656. */
  31657. serialize(): any;
  31658. private toNumberArray;
  31659. /**
  31660. * Serialize all vertices data into a JSON oject
  31661. * @returns a JSON representation of the current geometry data
  31662. */
  31663. serializeVerticeData(): any;
  31664. /**
  31665. * Extracts a clone of a mesh geometry
  31666. * @param mesh defines the source mesh
  31667. * @param id defines the unique ID of the new geometry object
  31668. * @returns the new geometry object
  31669. */
  31670. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31671. /**
  31672. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31673. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31674. * Be aware Math.random() could cause collisions, but:
  31675. * "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"
  31676. * @returns a string containing a new GUID
  31677. */
  31678. static RandomId(): string;
  31679. /** @hidden */
  31680. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31681. private static _CleanMatricesWeights;
  31682. /**
  31683. * Create a new geometry from persisted data (Using .babylon file format)
  31684. * @param parsedVertexData defines the persisted data
  31685. * @param scene defines the hosting scene
  31686. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31687. * @returns the new geometry object
  31688. */
  31689. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31690. }
  31691. }
  31692. declare module "babylonjs/Meshes/mesh.vertexData" {
  31693. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31694. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31695. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31696. import { Geometry } from "babylonjs/Meshes/geometry";
  31697. import { Mesh } from "babylonjs/Meshes/mesh";
  31698. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31699. /**
  31700. * Define an interface for all classes that will get and set the data on vertices
  31701. */
  31702. export interface IGetSetVerticesData {
  31703. /**
  31704. * Gets a boolean indicating if specific vertex data is present
  31705. * @param kind defines the vertex data kind to use
  31706. * @returns true is data kind is present
  31707. */
  31708. isVerticesDataPresent(kind: string): boolean;
  31709. /**
  31710. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31711. * @param kind defines the data kind (Position, normal, etc...)
  31712. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31713. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31714. * @returns a float array containing vertex data
  31715. */
  31716. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31717. /**
  31718. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31719. * @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.
  31720. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31721. * @returns the indices array or an empty array if the mesh has no geometry
  31722. */
  31723. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31724. /**
  31725. * Set specific vertex data
  31726. * @param kind defines the data kind (Position, normal, etc...)
  31727. * @param data defines the vertex data to use
  31728. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31729. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31730. */
  31731. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31732. /**
  31733. * Update a specific associated vertex buffer
  31734. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31735. * - VertexBuffer.PositionKind
  31736. * - VertexBuffer.UVKind
  31737. * - VertexBuffer.UV2Kind
  31738. * - VertexBuffer.UV3Kind
  31739. * - VertexBuffer.UV4Kind
  31740. * - VertexBuffer.UV5Kind
  31741. * - VertexBuffer.UV6Kind
  31742. * - VertexBuffer.ColorKind
  31743. * - VertexBuffer.MatricesIndicesKind
  31744. * - VertexBuffer.MatricesIndicesExtraKind
  31745. * - VertexBuffer.MatricesWeightsKind
  31746. * - VertexBuffer.MatricesWeightsExtraKind
  31747. * @param data defines the data source
  31748. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31749. * @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)
  31750. */
  31751. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31752. /**
  31753. * Creates a new index buffer
  31754. * @param indices defines the indices to store in the index buffer
  31755. * @param totalVertices defines the total number of vertices (could be null)
  31756. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31757. */
  31758. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31759. }
  31760. /**
  31761. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31762. */
  31763. export class VertexData {
  31764. /**
  31765. * Mesh side orientation : usually the external or front surface
  31766. */
  31767. static readonly FRONTSIDE: number;
  31768. /**
  31769. * Mesh side orientation : usually the internal or back surface
  31770. */
  31771. static readonly BACKSIDE: number;
  31772. /**
  31773. * Mesh side orientation : both internal and external or front and back surfaces
  31774. */
  31775. static readonly DOUBLESIDE: number;
  31776. /**
  31777. * Mesh side orientation : by default, `FRONTSIDE`
  31778. */
  31779. static readonly DEFAULTSIDE: number;
  31780. /**
  31781. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31782. */
  31783. positions: Nullable<FloatArray>;
  31784. /**
  31785. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31786. */
  31787. normals: Nullable<FloatArray>;
  31788. /**
  31789. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31790. */
  31791. tangents: Nullable<FloatArray>;
  31792. /**
  31793. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31794. */
  31795. uvs: Nullable<FloatArray>;
  31796. /**
  31797. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31798. */
  31799. uvs2: Nullable<FloatArray>;
  31800. /**
  31801. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31802. */
  31803. uvs3: Nullable<FloatArray>;
  31804. /**
  31805. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31806. */
  31807. uvs4: Nullable<FloatArray>;
  31808. /**
  31809. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31810. */
  31811. uvs5: Nullable<FloatArray>;
  31812. /**
  31813. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31814. */
  31815. uvs6: Nullable<FloatArray>;
  31816. /**
  31817. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31818. */
  31819. colors: Nullable<FloatArray>;
  31820. /**
  31821. * 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).
  31822. */
  31823. matricesIndices: Nullable<FloatArray>;
  31824. /**
  31825. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31826. */
  31827. matricesWeights: Nullable<FloatArray>;
  31828. /**
  31829. * An array extending the number of possible indices
  31830. */
  31831. matricesIndicesExtra: Nullable<FloatArray>;
  31832. /**
  31833. * An array extending the number of possible weights when the number of indices is extended
  31834. */
  31835. matricesWeightsExtra: Nullable<FloatArray>;
  31836. /**
  31837. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31838. */
  31839. indices: Nullable<IndicesArray>;
  31840. /**
  31841. * Uses the passed data array to set the set the values for the specified kind of data
  31842. * @param data a linear array of floating numbers
  31843. * @param kind the type of data that is being set, eg positions, colors etc
  31844. */
  31845. set(data: FloatArray, kind: string): void;
  31846. /**
  31847. * Associates the vertexData to the passed Mesh.
  31848. * Sets it as updatable or not (default `false`)
  31849. * @param mesh the mesh the vertexData is applied to
  31850. * @param updatable when used and having the value true allows new data to update the vertexData
  31851. * @returns the VertexData
  31852. */
  31853. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31854. /**
  31855. * Associates the vertexData to the passed Geometry.
  31856. * Sets it as updatable or not (default `false`)
  31857. * @param geometry the geometry the vertexData is applied to
  31858. * @param updatable when used and having the value true allows new data to update the vertexData
  31859. * @returns VertexData
  31860. */
  31861. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31862. /**
  31863. * Updates the associated mesh
  31864. * @param mesh the mesh to be updated
  31865. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31866. * @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
  31867. * @returns VertexData
  31868. */
  31869. updateMesh(mesh: Mesh): VertexData;
  31870. /**
  31871. * Updates the associated geometry
  31872. * @param geometry the geometry to be updated
  31873. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31874. * @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
  31875. * @returns VertexData.
  31876. */
  31877. updateGeometry(geometry: Geometry): VertexData;
  31878. private _applyTo;
  31879. private _update;
  31880. /**
  31881. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31882. * @param matrix the transforming matrix
  31883. * @returns the VertexData
  31884. */
  31885. transform(matrix: Matrix): VertexData;
  31886. /**
  31887. * Merges the passed VertexData into the current one
  31888. * @param other the VertexData to be merged into the current one
  31889. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31890. * @returns the modified VertexData
  31891. */
  31892. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31893. private _mergeElement;
  31894. private _validate;
  31895. /**
  31896. * Serializes the VertexData
  31897. * @returns a serialized object
  31898. */
  31899. serialize(): any;
  31900. /**
  31901. * Extracts the vertexData from a mesh
  31902. * @param mesh the mesh from which to extract the VertexData
  31903. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31904. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31905. * @returns the object VertexData associated to the passed mesh
  31906. */
  31907. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31908. /**
  31909. * Extracts the vertexData from the geometry
  31910. * @param geometry the geometry from which to extract the VertexData
  31911. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31912. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31913. * @returns the object VertexData associated to the passed mesh
  31914. */
  31915. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31916. private static _ExtractFrom;
  31917. /**
  31918. * Creates the VertexData for a Ribbon
  31919. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31920. * * pathArray array of paths, each of which an array of successive Vector3
  31921. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31922. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31923. * * 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
  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. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31928. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31929. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31930. * @returns the VertexData of the ribbon
  31931. */
  31932. static CreateRibbon(options: {
  31933. pathArray: Vector3[][];
  31934. closeArray?: boolean;
  31935. closePath?: boolean;
  31936. offset?: number;
  31937. sideOrientation?: number;
  31938. frontUVs?: Vector4;
  31939. backUVs?: Vector4;
  31940. invertUV?: boolean;
  31941. uvs?: Vector2[];
  31942. colors?: Color4[];
  31943. }): VertexData;
  31944. /**
  31945. * Creates the VertexData for a box
  31946. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31947. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31948. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31949. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31950. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31951. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31952. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31954. * * 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)
  31955. * * 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)
  31956. * @returns the VertexData of the box
  31957. */
  31958. static CreateBox(options: {
  31959. size?: number;
  31960. width?: number;
  31961. height?: number;
  31962. depth?: number;
  31963. faceUV?: Vector4[];
  31964. faceColors?: Color4[];
  31965. sideOrientation?: number;
  31966. frontUVs?: Vector4;
  31967. backUVs?: Vector4;
  31968. }): VertexData;
  31969. /**
  31970. * Creates the VertexData for a tiled box
  31971. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31972. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31973. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31974. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31975. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31976. * @returns the VertexData of the box
  31977. */
  31978. static CreateTiledBox(options: {
  31979. pattern?: number;
  31980. width?: number;
  31981. height?: number;
  31982. depth?: number;
  31983. tileSize?: number;
  31984. tileWidth?: number;
  31985. tileHeight?: number;
  31986. alignHorizontal?: number;
  31987. alignVertical?: number;
  31988. faceUV?: Vector4[];
  31989. faceColors?: Color4[];
  31990. sideOrientation?: number;
  31991. }): VertexData;
  31992. /**
  31993. * Creates the VertexData for a tiled plane
  31994. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31995. * * pattern a limited pattern arrangement depending on the number
  31996. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31997. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31998. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  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 tiled plane
  32003. */
  32004. static CreateTiledPlane(options: {
  32005. pattern?: number;
  32006. tileSize?: number;
  32007. tileWidth?: number;
  32008. tileHeight?: number;
  32009. size?: number;
  32010. width?: number;
  32011. height?: number;
  32012. alignHorizontal?: number;
  32013. alignVertical?: number;
  32014. sideOrientation?: number;
  32015. frontUVs?: Vector4;
  32016. backUVs?: Vector4;
  32017. }): VertexData;
  32018. /**
  32019. * Creates the VertexData for an ellipsoid, defaults to a sphere
  32020. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32021. * * segments sets the number of horizontal strips optional, default 32
  32022. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  32023. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  32024. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  32025. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  32026. * * 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
  32027. * * 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
  32028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32029. * * 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)
  32030. * * 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)
  32031. * @returns the VertexData of the ellipsoid
  32032. */
  32033. static CreateSphere(options: {
  32034. segments?: number;
  32035. diameter?: number;
  32036. diameterX?: number;
  32037. diameterY?: number;
  32038. diameterZ?: number;
  32039. arc?: number;
  32040. slice?: number;
  32041. sideOrientation?: number;
  32042. frontUVs?: Vector4;
  32043. backUVs?: Vector4;
  32044. }): VertexData;
  32045. /**
  32046. * Creates the VertexData for a cylinder, cone or prism
  32047. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32048. * * height sets the height (y direction) of the cylinder, optional, default 2
  32049. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  32050. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  32051. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  32052. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32053. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  32054. * * 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
  32055. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32056. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32057. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  32058. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  32059. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32060. * * 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)
  32061. * * 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)
  32062. * @returns the VertexData of the cylinder, cone or prism
  32063. */
  32064. static CreateCylinder(options: {
  32065. height?: number;
  32066. diameterTop?: number;
  32067. diameterBottom?: number;
  32068. diameter?: number;
  32069. tessellation?: number;
  32070. subdivisions?: number;
  32071. arc?: number;
  32072. faceColors?: Color4[];
  32073. faceUV?: Vector4[];
  32074. hasRings?: boolean;
  32075. enclose?: boolean;
  32076. sideOrientation?: number;
  32077. frontUVs?: Vector4;
  32078. backUVs?: Vector4;
  32079. }): VertexData;
  32080. /**
  32081. * Creates the VertexData for a torus
  32082. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32083. * * diameter the diameter of the torus, optional default 1
  32084. * * thickness the diameter of the tube forming the torus, optional default 0.5
  32085. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32087. * * 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)
  32088. * * 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)
  32089. * @returns the VertexData of the torus
  32090. */
  32091. static CreateTorus(options: {
  32092. diameter?: number;
  32093. thickness?: number;
  32094. tessellation?: number;
  32095. sideOrientation?: number;
  32096. frontUVs?: Vector4;
  32097. backUVs?: Vector4;
  32098. }): VertexData;
  32099. /**
  32100. * Creates the VertexData of the LineSystem
  32101. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  32102. * - lines an array of lines, each line being an array of successive Vector3
  32103. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  32104. * @returns the VertexData of the LineSystem
  32105. */
  32106. static CreateLineSystem(options: {
  32107. lines: Vector3[][];
  32108. colors?: Nullable<Color4[][]>;
  32109. }): VertexData;
  32110. /**
  32111. * Create the VertexData for a DashedLines
  32112. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  32113. * - points an array successive Vector3
  32114. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  32115. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  32116. * - dashNb the intended total number of dashes, optional, default 200
  32117. * @returns the VertexData for the DashedLines
  32118. */
  32119. static CreateDashedLines(options: {
  32120. points: Vector3[];
  32121. dashSize?: number;
  32122. gapSize?: number;
  32123. dashNb?: number;
  32124. }): VertexData;
  32125. /**
  32126. * Creates the VertexData for a Ground
  32127. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32128. * - width the width (x direction) of the ground, optional, default 1
  32129. * - height the height (z direction) of the ground, optional, default 1
  32130. * - subdivisions the number of subdivisions per side, optional, default 1
  32131. * @returns the VertexData of the Ground
  32132. */
  32133. static CreateGround(options: {
  32134. width?: number;
  32135. height?: number;
  32136. subdivisions?: number;
  32137. subdivisionsX?: number;
  32138. subdivisionsY?: number;
  32139. }): VertexData;
  32140. /**
  32141. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  32142. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32143. * * xmin the ground minimum X coordinate, optional, default -1
  32144. * * zmin the ground minimum Z coordinate, optional, default -1
  32145. * * xmax the ground maximum X coordinate, optional, default 1
  32146. * * zmax the ground maximum Z coordinate, optional, default 1
  32147. * * 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}
  32148. * * 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}
  32149. * @returns the VertexData of the TiledGround
  32150. */
  32151. static CreateTiledGround(options: {
  32152. xmin: number;
  32153. zmin: number;
  32154. xmax: number;
  32155. zmax: number;
  32156. subdivisions?: {
  32157. w: number;
  32158. h: number;
  32159. };
  32160. precision?: {
  32161. w: number;
  32162. h: number;
  32163. };
  32164. }): VertexData;
  32165. /**
  32166. * Creates the VertexData of the Ground designed from a heightmap
  32167. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  32168. * * width the width (x direction) of the ground
  32169. * * height the height (z direction) of the ground
  32170. * * subdivisions the number of subdivisions per side
  32171. * * minHeight the minimum altitude on the ground, optional, default 0
  32172. * * maxHeight the maximum altitude on the ground, optional default 1
  32173. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  32174. * * buffer the array holding the image color data
  32175. * * bufferWidth the width of image
  32176. * * bufferHeight the height of image
  32177. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  32178. * @returns the VertexData of the Ground designed from a heightmap
  32179. */
  32180. static CreateGroundFromHeightMap(options: {
  32181. width: number;
  32182. height: number;
  32183. subdivisions: number;
  32184. minHeight: number;
  32185. maxHeight: number;
  32186. colorFilter: Color3;
  32187. buffer: Uint8Array;
  32188. bufferWidth: number;
  32189. bufferHeight: number;
  32190. alphaFilter: number;
  32191. }): VertexData;
  32192. /**
  32193. * Creates the VertexData for a Plane
  32194. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  32195. * * size sets the width and height of the plane to the value of size, optional default 1
  32196. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  32197. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  32198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32199. * * 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)
  32200. * * 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)
  32201. * @returns the VertexData of the box
  32202. */
  32203. static CreatePlane(options: {
  32204. size?: number;
  32205. width?: number;
  32206. height?: number;
  32207. sideOrientation?: number;
  32208. frontUVs?: Vector4;
  32209. backUVs?: Vector4;
  32210. }): VertexData;
  32211. /**
  32212. * Creates the VertexData of the Disc or regular Polygon
  32213. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  32214. * * radius the radius of the disc, optional default 0.5
  32215. * * tessellation the number of polygon sides, optional, default 64
  32216. * * 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
  32217. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32218. * * 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)
  32219. * * 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)
  32220. * @returns the VertexData of the box
  32221. */
  32222. static CreateDisc(options: {
  32223. radius?: number;
  32224. tessellation?: number;
  32225. arc?: number;
  32226. sideOrientation?: number;
  32227. frontUVs?: Vector4;
  32228. backUVs?: Vector4;
  32229. }): VertexData;
  32230. /**
  32231. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  32232. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  32233. * @param polygon a mesh built from polygonTriangulation.build()
  32234. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32235. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32236. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32237. * @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)
  32238. * @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)
  32239. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  32240. * @returns the VertexData of the Polygon
  32241. */
  32242. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  32243. /**
  32244. * Creates the VertexData of the IcoSphere
  32245. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  32246. * * radius the radius of the IcoSphere, optional default 1
  32247. * * radiusX allows stretching in the x direction, optional, default radius
  32248. * * radiusY allows stretching in the y direction, optional, default radius
  32249. * * radiusZ allows stretching in the z direction, optional, default radius
  32250. * * flat when true creates a flat shaded mesh, optional, default true
  32251. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32252. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32253. * * 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)
  32254. * * 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)
  32255. * @returns the VertexData of the IcoSphere
  32256. */
  32257. static CreateIcoSphere(options: {
  32258. radius?: number;
  32259. radiusX?: number;
  32260. radiusY?: number;
  32261. radiusZ?: number;
  32262. flat?: boolean;
  32263. subdivisions?: number;
  32264. sideOrientation?: number;
  32265. frontUVs?: Vector4;
  32266. backUVs?: Vector4;
  32267. }): VertexData;
  32268. /**
  32269. * Creates the VertexData for a Polyhedron
  32270. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  32271. * * type provided types are:
  32272. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  32273. * * 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)
  32274. * * size the size of the IcoSphere, optional default 1
  32275. * * sizeX allows stretching in the x direction, optional, default size
  32276. * * sizeY allows stretching in the y direction, optional, default size
  32277. * * sizeZ allows stretching in the z direction, optional, default size
  32278. * * 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
  32279. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32280. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32281. * * flat when true creates a flat shaded mesh, optional, default true
  32282. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32283. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32284. * * 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)
  32285. * * 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)
  32286. * @returns the VertexData of the Polyhedron
  32287. */
  32288. static CreatePolyhedron(options: {
  32289. type?: number;
  32290. size?: number;
  32291. sizeX?: number;
  32292. sizeY?: number;
  32293. sizeZ?: number;
  32294. custom?: any;
  32295. faceUV?: Vector4[];
  32296. faceColors?: Color4[];
  32297. flat?: boolean;
  32298. sideOrientation?: number;
  32299. frontUVs?: Vector4;
  32300. backUVs?: Vector4;
  32301. }): VertexData;
  32302. /**
  32303. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32304. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32305. * @returns the VertexData of the Capsule
  32306. */
  32307. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32308. /**
  32309. * Creates the VertexData for a TorusKnot
  32310. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32311. * * radius the radius of the torus knot, optional, default 2
  32312. * * tube the thickness of the tube, optional, default 0.5
  32313. * * radialSegments the number of sides on each tube segments, optional, default 32
  32314. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32315. * * p the number of windings around the z axis, optional, default 2
  32316. * * q the number of windings around the x axis, optional, default 3
  32317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32318. * * 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)
  32319. * * 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)
  32320. * @returns the VertexData of the Torus Knot
  32321. */
  32322. static CreateTorusKnot(options: {
  32323. radius?: number;
  32324. tube?: number;
  32325. radialSegments?: number;
  32326. tubularSegments?: number;
  32327. p?: number;
  32328. q?: number;
  32329. sideOrientation?: number;
  32330. frontUVs?: Vector4;
  32331. backUVs?: Vector4;
  32332. }): VertexData;
  32333. /**
  32334. * Compute normals for given positions and indices
  32335. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32336. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32337. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32338. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32339. * * facetNormals : optional array of facet normals (vector3)
  32340. * * facetPositions : optional array of facet positions (vector3)
  32341. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32342. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32343. * * bInfo : optional bounding info, required for facetPartitioning computation
  32344. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32345. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32346. * * useRightHandedSystem: optional boolean to for right handed system computation
  32347. * * depthSort : optional boolean to enable the facet depth sort computation
  32348. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32349. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32350. */
  32351. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32352. facetNormals?: any;
  32353. facetPositions?: any;
  32354. facetPartitioning?: any;
  32355. ratio?: number;
  32356. bInfo?: any;
  32357. bbSize?: Vector3;
  32358. subDiv?: any;
  32359. useRightHandedSystem?: boolean;
  32360. depthSort?: boolean;
  32361. distanceTo?: Vector3;
  32362. depthSortedFacets?: any;
  32363. }): void;
  32364. /** @hidden */
  32365. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32366. /**
  32367. * Applies VertexData created from the imported parameters to the geometry
  32368. * @param parsedVertexData the parsed data from an imported file
  32369. * @param geometry the geometry to apply the VertexData to
  32370. */
  32371. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32372. }
  32373. }
  32374. declare module "babylonjs/Morph/morphTarget" {
  32375. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32376. import { Observable } from "babylonjs/Misc/observable";
  32377. import { Nullable, FloatArray } from "babylonjs/types";
  32378. import { Scene } from "babylonjs/scene";
  32379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32380. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32381. /**
  32382. * Defines a target to use with MorphTargetManager
  32383. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32384. */
  32385. export class MorphTarget implements IAnimatable {
  32386. /** defines the name of the target */
  32387. name: string;
  32388. /**
  32389. * Gets or sets the list of animations
  32390. */
  32391. animations: import("babylonjs/Animations/animation").Animation[];
  32392. private _scene;
  32393. private _positions;
  32394. private _normals;
  32395. private _tangents;
  32396. private _uvs;
  32397. private _influence;
  32398. private _uniqueId;
  32399. /**
  32400. * Observable raised when the influence changes
  32401. */
  32402. onInfluenceChanged: Observable<boolean>;
  32403. /** @hidden */
  32404. _onDataLayoutChanged: Observable<void>;
  32405. /**
  32406. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32407. */
  32408. get influence(): number;
  32409. set influence(influence: number);
  32410. /**
  32411. * Gets or sets the id of the morph Target
  32412. */
  32413. id: string;
  32414. private _animationPropertiesOverride;
  32415. /**
  32416. * Gets or sets the animation properties override
  32417. */
  32418. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32419. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32420. /**
  32421. * Creates a new MorphTarget
  32422. * @param name defines the name of the target
  32423. * @param influence defines the influence to use
  32424. * @param scene defines the scene the morphtarget belongs to
  32425. */
  32426. constructor(
  32427. /** defines the name of the target */
  32428. name: string, influence?: number, scene?: Nullable<Scene>);
  32429. /**
  32430. * Gets the unique ID of this manager
  32431. */
  32432. get uniqueId(): number;
  32433. /**
  32434. * Gets a boolean defining if the target contains position data
  32435. */
  32436. get hasPositions(): boolean;
  32437. /**
  32438. * Gets a boolean defining if the target contains normal data
  32439. */
  32440. get hasNormals(): boolean;
  32441. /**
  32442. * Gets a boolean defining if the target contains tangent data
  32443. */
  32444. get hasTangents(): boolean;
  32445. /**
  32446. * Gets a boolean defining if the target contains texture coordinates data
  32447. */
  32448. get hasUVs(): boolean;
  32449. /**
  32450. * Affects position data to this target
  32451. * @param data defines the position data to use
  32452. */
  32453. setPositions(data: Nullable<FloatArray>): void;
  32454. /**
  32455. * Gets the position data stored in this target
  32456. * @returns a FloatArray containing the position data (or null if not present)
  32457. */
  32458. getPositions(): Nullable<FloatArray>;
  32459. /**
  32460. * Affects normal data to this target
  32461. * @param data defines the normal data to use
  32462. */
  32463. setNormals(data: Nullable<FloatArray>): void;
  32464. /**
  32465. * Gets the normal data stored in this target
  32466. * @returns a FloatArray containing the normal data (or null if not present)
  32467. */
  32468. getNormals(): Nullable<FloatArray>;
  32469. /**
  32470. * Affects tangent data to this target
  32471. * @param data defines the tangent data to use
  32472. */
  32473. setTangents(data: Nullable<FloatArray>): void;
  32474. /**
  32475. * Gets the tangent data stored in this target
  32476. * @returns a FloatArray containing the tangent data (or null if not present)
  32477. */
  32478. getTangents(): Nullable<FloatArray>;
  32479. /**
  32480. * Affects texture coordinates data to this target
  32481. * @param data defines the texture coordinates data to use
  32482. */
  32483. setUVs(data: Nullable<FloatArray>): void;
  32484. /**
  32485. * Gets the texture coordinates data stored in this target
  32486. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32487. */
  32488. getUVs(): Nullable<FloatArray>;
  32489. /**
  32490. * Clone the current target
  32491. * @returns a new MorphTarget
  32492. */
  32493. clone(): MorphTarget;
  32494. /**
  32495. * Serializes the current target into a Serialization object
  32496. * @returns the serialized object
  32497. */
  32498. serialize(): any;
  32499. /**
  32500. * Returns the string "MorphTarget"
  32501. * @returns "MorphTarget"
  32502. */
  32503. getClassName(): string;
  32504. /**
  32505. * Creates a new target from serialized data
  32506. * @param serializationObject defines the serialized data to use
  32507. * @returns a new MorphTarget
  32508. */
  32509. static Parse(serializationObject: any): MorphTarget;
  32510. /**
  32511. * Creates a MorphTarget from mesh data
  32512. * @param mesh defines the source mesh
  32513. * @param name defines the name to use for the new target
  32514. * @param influence defines the influence to attach to the target
  32515. * @returns a new MorphTarget
  32516. */
  32517. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32518. }
  32519. }
  32520. declare module "babylonjs/Morph/morphTargetManager" {
  32521. import { Nullable } from "babylonjs/types";
  32522. import { Scene } from "babylonjs/scene";
  32523. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32524. /**
  32525. * This class is used to deform meshes using morphing between different targets
  32526. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32527. */
  32528. export class MorphTargetManager {
  32529. private _targets;
  32530. private _targetInfluenceChangedObservers;
  32531. private _targetDataLayoutChangedObservers;
  32532. private _activeTargets;
  32533. private _scene;
  32534. private _influences;
  32535. private _supportsNormals;
  32536. private _supportsTangents;
  32537. private _supportsUVs;
  32538. private _vertexCount;
  32539. private _uniqueId;
  32540. private _tempInfluences;
  32541. /**
  32542. * Gets or sets a boolean indicating if normals must be morphed
  32543. */
  32544. enableNormalMorphing: boolean;
  32545. /**
  32546. * Gets or sets a boolean indicating if tangents must be morphed
  32547. */
  32548. enableTangentMorphing: boolean;
  32549. /**
  32550. * Gets or sets a boolean indicating if UV must be morphed
  32551. */
  32552. enableUVMorphing: boolean;
  32553. /**
  32554. * Creates a new MorphTargetManager
  32555. * @param scene defines the current scene
  32556. */
  32557. constructor(scene?: Nullable<Scene>);
  32558. /**
  32559. * Gets the unique ID of this manager
  32560. */
  32561. get uniqueId(): number;
  32562. /**
  32563. * Gets the number of vertices handled by this manager
  32564. */
  32565. get vertexCount(): number;
  32566. /**
  32567. * Gets a boolean indicating if this manager supports morphing of normals
  32568. */
  32569. get supportsNormals(): boolean;
  32570. /**
  32571. * Gets a boolean indicating if this manager supports morphing of tangents
  32572. */
  32573. get supportsTangents(): boolean;
  32574. /**
  32575. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32576. */
  32577. get supportsUVs(): boolean;
  32578. /**
  32579. * Gets the number of targets stored in this manager
  32580. */
  32581. get numTargets(): number;
  32582. /**
  32583. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32584. */
  32585. get numInfluencers(): number;
  32586. /**
  32587. * Gets the list of influences (one per target)
  32588. */
  32589. get influences(): Float32Array;
  32590. /**
  32591. * Gets the active target at specified index. An active target is a target with an influence > 0
  32592. * @param index defines the index to check
  32593. * @returns the requested target
  32594. */
  32595. getActiveTarget(index: number): MorphTarget;
  32596. /**
  32597. * Gets the target at specified index
  32598. * @param index defines the index to check
  32599. * @returns the requested target
  32600. */
  32601. getTarget(index: number): MorphTarget;
  32602. /**
  32603. * Add a new target to this manager
  32604. * @param target defines the target to add
  32605. */
  32606. addTarget(target: MorphTarget): void;
  32607. /**
  32608. * Removes a target from the manager
  32609. * @param target defines the target to remove
  32610. */
  32611. removeTarget(target: MorphTarget): void;
  32612. /**
  32613. * Clone the current manager
  32614. * @returns a new MorphTargetManager
  32615. */
  32616. clone(): MorphTargetManager;
  32617. /**
  32618. * Serializes the current manager into a Serialization object
  32619. * @returns the serialized object
  32620. */
  32621. serialize(): any;
  32622. private _syncActiveTargets;
  32623. /**
  32624. * Syncrhonize the targets with all the meshes using this morph target manager
  32625. */
  32626. synchronize(): void;
  32627. /**
  32628. * Creates a new MorphTargetManager from serialized data
  32629. * @param serializationObject defines the serialized data
  32630. * @param scene defines the hosting scene
  32631. * @returns the new MorphTargetManager
  32632. */
  32633. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32634. }
  32635. }
  32636. declare module "babylonjs/Meshes/meshLODLevel" {
  32637. import { Mesh } from "babylonjs/Meshes/mesh";
  32638. import { Nullable } from "babylonjs/types";
  32639. /**
  32640. * Class used to represent a specific level of detail of a mesh
  32641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32642. */
  32643. export class MeshLODLevel {
  32644. /** Defines the distance where this level should start being displayed */
  32645. distance: number;
  32646. /** Defines the mesh to use to render this level */
  32647. mesh: Nullable<Mesh>;
  32648. /**
  32649. * Creates a new LOD level
  32650. * @param distance defines the distance where this level should star being displayed
  32651. * @param mesh defines the mesh to use to render this level
  32652. */
  32653. constructor(
  32654. /** Defines the distance where this level should start being displayed */
  32655. distance: number,
  32656. /** Defines the mesh to use to render this level */
  32657. mesh: Nullable<Mesh>);
  32658. }
  32659. }
  32660. declare module "babylonjs/Misc/canvasGenerator" {
  32661. /**
  32662. * Helper class used to generate a canvas to manipulate images
  32663. */
  32664. export class CanvasGenerator {
  32665. /**
  32666. * Create a new canvas (or offscreen canvas depending on the context)
  32667. * @param width defines the expected width
  32668. * @param height defines the expected height
  32669. * @return a new canvas or offscreen canvas
  32670. */
  32671. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32672. }
  32673. }
  32674. declare module "babylonjs/Meshes/groundMesh" {
  32675. import { Scene } from "babylonjs/scene";
  32676. import { Vector3 } from "babylonjs/Maths/math.vector";
  32677. import { Mesh } from "babylonjs/Meshes/mesh";
  32678. /**
  32679. * Mesh representing the gorund
  32680. */
  32681. export class GroundMesh extends Mesh {
  32682. /** If octree should be generated */
  32683. generateOctree: boolean;
  32684. private _heightQuads;
  32685. /** @hidden */
  32686. _subdivisionsX: number;
  32687. /** @hidden */
  32688. _subdivisionsY: number;
  32689. /** @hidden */
  32690. _width: number;
  32691. /** @hidden */
  32692. _height: number;
  32693. /** @hidden */
  32694. _minX: number;
  32695. /** @hidden */
  32696. _maxX: number;
  32697. /** @hidden */
  32698. _minZ: number;
  32699. /** @hidden */
  32700. _maxZ: number;
  32701. constructor(name: string, scene: Scene);
  32702. /**
  32703. * "GroundMesh"
  32704. * @returns "GroundMesh"
  32705. */
  32706. getClassName(): string;
  32707. /**
  32708. * The minimum of x and y subdivisions
  32709. */
  32710. get subdivisions(): number;
  32711. /**
  32712. * X subdivisions
  32713. */
  32714. get subdivisionsX(): number;
  32715. /**
  32716. * Y subdivisions
  32717. */
  32718. get subdivisionsY(): number;
  32719. /**
  32720. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32721. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32722. * @param chunksCount the number of subdivisions for x and y
  32723. * @param octreeBlocksSize (Default: 32)
  32724. */
  32725. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32726. /**
  32727. * Returns a height (y) value in the Worl system :
  32728. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32729. * @param x x coordinate
  32730. * @param z z coordinate
  32731. * @returns the ground y position if (x, z) are outside the ground surface.
  32732. */
  32733. getHeightAtCoordinates(x: number, z: number): number;
  32734. /**
  32735. * Returns a normalized vector (Vector3) orthogonal to the ground
  32736. * at the ground coordinates (x, z) expressed in the World system.
  32737. * @param x x coordinate
  32738. * @param z z coordinate
  32739. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32740. */
  32741. getNormalAtCoordinates(x: number, z: number): Vector3;
  32742. /**
  32743. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32744. * at the ground coordinates (x, z) expressed in the World system.
  32745. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32746. * @param x x coordinate
  32747. * @param z z coordinate
  32748. * @param ref vector to store the result
  32749. * @returns the GroundMesh.
  32750. */
  32751. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32752. /**
  32753. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32754. * if the ground has been updated.
  32755. * This can be used in the render loop.
  32756. * @returns the GroundMesh.
  32757. */
  32758. updateCoordinateHeights(): GroundMesh;
  32759. private _getFacetAt;
  32760. private _initHeightQuads;
  32761. private _computeHeightQuads;
  32762. /**
  32763. * Serializes this ground mesh
  32764. * @param serializationObject object to write serialization to
  32765. */
  32766. serialize(serializationObject: any): void;
  32767. /**
  32768. * Parses a serialized ground mesh
  32769. * @param parsedMesh the serialized mesh
  32770. * @param scene the scene to create the ground mesh in
  32771. * @returns the created ground mesh
  32772. */
  32773. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32774. }
  32775. }
  32776. declare module "babylonjs/Physics/physicsJoint" {
  32777. import { Vector3 } from "babylonjs/Maths/math.vector";
  32778. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32779. /**
  32780. * Interface for Physics-Joint data
  32781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32782. */
  32783. export interface PhysicsJointData {
  32784. /**
  32785. * The main pivot of the joint
  32786. */
  32787. mainPivot?: Vector3;
  32788. /**
  32789. * The connected pivot of the joint
  32790. */
  32791. connectedPivot?: Vector3;
  32792. /**
  32793. * The main axis of the joint
  32794. */
  32795. mainAxis?: Vector3;
  32796. /**
  32797. * The connected axis of the joint
  32798. */
  32799. connectedAxis?: Vector3;
  32800. /**
  32801. * The collision of the joint
  32802. */
  32803. collision?: boolean;
  32804. /**
  32805. * Native Oimo/Cannon/Energy data
  32806. */
  32807. nativeParams?: any;
  32808. }
  32809. /**
  32810. * This is a holder class for the physics joint created by the physics plugin
  32811. * It holds a set of functions to control the underlying joint
  32812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32813. */
  32814. export class PhysicsJoint {
  32815. /**
  32816. * The type of the physics joint
  32817. */
  32818. type: number;
  32819. /**
  32820. * The data for the physics joint
  32821. */
  32822. jointData: PhysicsJointData;
  32823. private _physicsJoint;
  32824. protected _physicsPlugin: IPhysicsEnginePlugin;
  32825. /**
  32826. * Initializes the physics joint
  32827. * @param type The type of the physics joint
  32828. * @param jointData The data for the physics joint
  32829. */
  32830. constructor(
  32831. /**
  32832. * The type of the physics joint
  32833. */
  32834. type: number,
  32835. /**
  32836. * The data for the physics joint
  32837. */
  32838. jointData: PhysicsJointData);
  32839. /**
  32840. * Gets the physics joint
  32841. */
  32842. get physicsJoint(): any;
  32843. /**
  32844. * Sets the physics joint
  32845. */
  32846. set physicsJoint(newJoint: any);
  32847. /**
  32848. * Sets the physics plugin
  32849. */
  32850. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32851. /**
  32852. * Execute a function that is physics-plugin specific.
  32853. * @param {Function} func the function that will be executed.
  32854. * It accepts two parameters: the physics world and the physics joint
  32855. */
  32856. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32857. /**
  32858. * Distance-Joint type
  32859. */
  32860. static DistanceJoint: number;
  32861. /**
  32862. * Hinge-Joint type
  32863. */
  32864. static HingeJoint: number;
  32865. /**
  32866. * Ball-and-Socket joint type
  32867. */
  32868. static BallAndSocketJoint: number;
  32869. /**
  32870. * Wheel-Joint type
  32871. */
  32872. static WheelJoint: number;
  32873. /**
  32874. * Slider-Joint type
  32875. */
  32876. static SliderJoint: number;
  32877. /**
  32878. * Prismatic-Joint type
  32879. */
  32880. static PrismaticJoint: number;
  32881. /**
  32882. * Universal-Joint type
  32883. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32884. */
  32885. static UniversalJoint: number;
  32886. /**
  32887. * Hinge-Joint 2 type
  32888. */
  32889. static Hinge2Joint: number;
  32890. /**
  32891. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32892. */
  32893. static PointToPointJoint: number;
  32894. /**
  32895. * Spring-Joint type
  32896. */
  32897. static SpringJoint: number;
  32898. /**
  32899. * Lock-Joint type
  32900. */
  32901. static LockJoint: number;
  32902. }
  32903. /**
  32904. * A class representing a physics distance joint
  32905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32906. */
  32907. export class DistanceJoint extends PhysicsJoint {
  32908. /**
  32909. *
  32910. * @param jointData The data for the Distance-Joint
  32911. */
  32912. constructor(jointData: DistanceJointData);
  32913. /**
  32914. * Update the predefined distance.
  32915. * @param maxDistance The maximum preferred distance
  32916. * @param minDistance The minimum preferred distance
  32917. */
  32918. updateDistance(maxDistance: number, minDistance?: number): void;
  32919. }
  32920. /**
  32921. * Represents a Motor-Enabled Joint
  32922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32923. */
  32924. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32925. /**
  32926. * Initializes the Motor-Enabled Joint
  32927. * @param type The type of the joint
  32928. * @param jointData The physica joint data for the joint
  32929. */
  32930. constructor(type: number, jointData: PhysicsJointData);
  32931. /**
  32932. * Set the motor values.
  32933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32934. * @param force the force to apply
  32935. * @param maxForce max force for this motor.
  32936. */
  32937. setMotor(force?: number, maxForce?: number): void;
  32938. /**
  32939. * Set the motor's limits.
  32940. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32941. * @param upperLimit The upper limit of the motor
  32942. * @param lowerLimit The lower limit of the motor
  32943. */
  32944. setLimit(upperLimit: number, lowerLimit?: number): void;
  32945. }
  32946. /**
  32947. * This class represents a single physics Hinge-Joint
  32948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32949. */
  32950. export class HingeJoint extends MotorEnabledJoint {
  32951. /**
  32952. * Initializes the Hinge-Joint
  32953. * @param jointData The joint data for the Hinge-Joint
  32954. */
  32955. constructor(jointData: PhysicsJointData);
  32956. /**
  32957. * Set the motor values.
  32958. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32959. * @param {number} force the force to apply
  32960. * @param {number} maxForce max force for this motor.
  32961. */
  32962. setMotor(force?: number, maxForce?: number): void;
  32963. /**
  32964. * Set the motor's limits.
  32965. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32966. * @param upperLimit The upper limit of the motor
  32967. * @param lowerLimit The lower limit of the motor
  32968. */
  32969. setLimit(upperLimit: number, lowerLimit?: number): void;
  32970. }
  32971. /**
  32972. * This class represents a dual hinge physics joint (same as wheel joint)
  32973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32974. */
  32975. export class Hinge2Joint extends MotorEnabledJoint {
  32976. /**
  32977. * Initializes the Hinge2-Joint
  32978. * @param jointData The joint data for the Hinge2-Joint
  32979. */
  32980. constructor(jointData: PhysicsJointData);
  32981. /**
  32982. * Set the motor values.
  32983. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32984. * @param {number} targetSpeed the speed the motor is to reach
  32985. * @param {number} maxForce max force for this motor.
  32986. * @param {motorIndex} the motor's index, 0 or 1.
  32987. */
  32988. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32989. /**
  32990. * Set the motor limits.
  32991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32992. * @param {number} upperLimit the upper limit
  32993. * @param {number} lowerLimit lower limit
  32994. * @param {motorIndex} the motor's index, 0 or 1.
  32995. */
  32996. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32997. }
  32998. /**
  32999. * Interface for a motor enabled joint
  33000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33001. */
  33002. export interface IMotorEnabledJoint {
  33003. /**
  33004. * Physics joint
  33005. */
  33006. physicsJoint: any;
  33007. /**
  33008. * Sets the motor of the motor-enabled joint
  33009. * @param force The force of the motor
  33010. * @param maxForce The maximum force of the motor
  33011. * @param motorIndex The index of the motor
  33012. */
  33013. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33014. /**
  33015. * Sets the limit of the motor
  33016. * @param upperLimit The upper limit of the motor
  33017. * @param lowerLimit The lower limit of the motor
  33018. * @param motorIndex The index of the motor
  33019. */
  33020. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33021. }
  33022. /**
  33023. * Joint data for a Distance-Joint
  33024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33025. */
  33026. export interface DistanceJointData extends PhysicsJointData {
  33027. /**
  33028. * Max distance the 2 joint objects can be apart
  33029. */
  33030. maxDistance: number;
  33031. }
  33032. /**
  33033. * Joint data from a spring joint
  33034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33035. */
  33036. export interface SpringJointData extends PhysicsJointData {
  33037. /**
  33038. * Length of the spring
  33039. */
  33040. length: number;
  33041. /**
  33042. * Stiffness of the spring
  33043. */
  33044. stiffness: number;
  33045. /**
  33046. * Damping of the spring
  33047. */
  33048. damping: number;
  33049. /** this callback will be called when applying the force to the impostors. */
  33050. forceApplicationCallback: () => void;
  33051. }
  33052. }
  33053. declare module "babylonjs/Physics/physicsRaycastResult" {
  33054. import { Vector3 } from "babylonjs/Maths/math.vector";
  33055. /**
  33056. * Holds the data for the raycast result
  33057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33058. */
  33059. export class PhysicsRaycastResult {
  33060. private _hasHit;
  33061. private _hitDistance;
  33062. private _hitNormalWorld;
  33063. private _hitPointWorld;
  33064. private _rayFromWorld;
  33065. private _rayToWorld;
  33066. /**
  33067. * Gets if there was a hit
  33068. */
  33069. get hasHit(): boolean;
  33070. /**
  33071. * Gets the distance from the hit
  33072. */
  33073. get hitDistance(): number;
  33074. /**
  33075. * Gets the hit normal/direction in the world
  33076. */
  33077. get hitNormalWorld(): Vector3;
  33078. /**
  33079. * Gets the hit point in the world
  33080. */
  33081. get hitPointWorld(): Vector3;
  33082. /**
  33083. * Gets the ray "start point" of the ray in the world
  33084. */
  33085. get rayFromWorld(): Vector3;
  33086. /**
  33087. * Gets the ray "end point" of the ray in the world
  33088. */
  33089. get rayToWorld(): Vector3;
  33090. /**
  33091. * Sets the hit data (normal & point in world space)
  33092. * @param hitNormalWorld defines the normal in world space
  33093. * @param hitPointWorld defines the point in world space
  33094. */
  33095. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33096. /**
  33097. * Sets the distance from the start point to the hit point
  33098. * @param distance
  33099. */
  33100. setHitDistance(distance: number): void;
  33101. /**
  33102. * Calculates the distance manually
  33103. */
  33104. calculateHitDistance(): void;
  33105. /**
  33106. * Resets all the values to default
  33107. * @param from The from point on world space
  33108. * @param to The to point on world space
  33109. */
  33110. reset(from?: Vector3, to?: Vector3): void;
  33111. }
  33112. /**
  33113. * Interface for the size containing width and height
  33114. */
  33115. interface IXYZ {
  33116. /**
  33117. * X
  33118. */
  33119. x: number;
  33120. /**
  33121. * Y
  33122. */
  33123. y: number;
  33124. /**
  33125. * Z
  33126. */
  33127. z: number;
  33128. }
  33129. }
  33130. declare module "babylonjs/Physics/IPhysicsEngine" {
  33131. import { Nullable } from "babylonjs/types";
  33132. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33134. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33135. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33136. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33137. /**
  33138. * Interface used to describe a physics joint
  33139. */
  33140. export interface PhysicsImpostorJoint {
  33141. /** Defines the main impostor to which the joint is linked */
  33142. mainImpostor: PhysicsImpostor;
  33143. /** Defines the impostor that is connected to the main impostor using this joint */
  33144. connectedImpostor: PhysicsImpostor;
  33145. /** Defines the joint itself */
  33146. joint: PhysicsJoint;
  33147. }
  33148. /** @hidden */
  33149. export interface IPhysicsEnginePlugin {
  33150. world: any;
  33151. name: string;
  33152. setGravity(gravity: Vector3): void;
  33153. setTimeStep(timeStep: number): void;
  33154. getTimeStep(): number;
  33155. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33156. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33157. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33158. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33159. removePhysicsBody(impostor: PhysicsImpostor): void;
  33160. generateJoint(joint: PhysicsImpostorJoint): void;
  33161. removeJoint(joint: PhysicsImpostorJoint): void;
  33162. isSupported(): boolean;
  33163. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33164. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33165. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33166. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33167. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33168. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33169. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33170. getBodyMass(impostor: PhysicsImpostor): number;
  33171. getBodyFriction(impostor: PhysicsImpostor): number;
  33172. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33173. getBodyRestitution(impostor: PhysicsImpostor): number;
  33174. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33175. getBodyPressure?(impostor: PhysicsImpostor): number;
  33176. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33177. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33178. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33179. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33180. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33181. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33182. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33183. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33184. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33185. sleepBody(impostor: PhysicsImpostor): void;
  33186. wakeUpBody(impostor: PhysicsImpostor): void;
  33187. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33188. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33189. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33190. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33191. getRadius(impostor: PhysicsImpostor): number;
  33192. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33193. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33194. dispose(): void;
  33195. }
  33196. /**
  33197. * Interface used to define a physics engine
  33198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33199. */
  33200. export interface IPhysicsEngine {
  33201. /**
  33202. * Gets the gravity vector used by the simulation
  33203. */
  33204. gravity: Vector3;
  33205. /**
  33206. * Sets the gravity vector used by the simulation
  33207. * @param gravity defines the gravity vector to use
  33208. */
  33209. setGravity(gravity: Vector3): void;
  33210. /**
  33211. * Set the time step of the physics engine.
  33212. * Default is 1/60.
  33213. * To slow it down, enter 1/600 for example.
  33214. * To speed it up, 1/30
  33215. * @param newTimeStep the new timestep to apply to this world.
  33216. */
  33217. setTimeStep(newTimeStep: number): void;
  33218. /**
  33219. * Get the time step of the physics engine.
  33220. * @returns the current time step
  33221. */
  33222. getTimeStep(): number;
  33223. /**
  33224. * Set the sub time step of the physics engine.
  33225. * Default is 0 meaning there is no sub steps
  33226. * To increase physics resolution precision, set a small value (like 1 ms)
  33227. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33228. */
  33229. setSubTimeStep(subTimeStep: number): void;
  33230. /**
  33231. * Get the sub time step of the physics engine.
  33232. * @returns the current sub time step
  33233. */
  33234. getSubTimeStep(): number;
  33235. /**
  33236. * Release all resources
  33237. */
  33238. dispose(): void;
  33239. /**
  33240. * Gets the name of the current physics plugin
  33241. * @returns the name of the plugin
  33242. */
  33243. getPhysicsPluginName(): string;
  33244. /**
  33245. * Adding a new impostor for the impostor tracking.
  33246. * This will be done by the impostor itself.
  33247. * @param impostor the impostor to add
  33248. */
  33249. addImpostor(impostor: PhysicsImpostor): void;
  33250. /**
  33251. * Remove an impostor from the engine.
  33252. * This impostor and its mesh will not longer be updated by the physics engine.
  33253. * @param impostor the impostor to remove
  33254. */
  33255. removeImpostor(impostor: PhysicsImpostor): void;
  33256. /**
  33257. * Add a joint to the physics engine
  33258. * @param mainImpostor defines the main impostor to which the joint is added.
  33259. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33260. * @param joint defines the joint that will connect both impostors.
  33261. */
  33262. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33263. /**
  33264. * Removes a joint from the simulation
  33265. * @param mainImpostor defines the impostor used with the joint
  33266. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33267. * @param joint defines the joint to remove
  33268. */
  33269. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33270. /**
  33271. * Gets the current plugin used to run the simulation
  33272. * @returns current plugin
  33273. */
  33274. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33275. /**
  33276. * Gets the list of physic impostors
  33277. * @returns an array of PhysicsImpostor
  33278. */
  33279. getImpostors(): Array<PhysicsImpostor>;
  33280. /**
  33281. * Gets the impostor for a physics enabled object
  33282. * @param object defines the object impersonated by the impostor
  33283. * @returns the PhysicsImpostor or null if not found
  33284. */
  33285. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33286. /**
  33287. * Gets the impostor for a physics body object
  33288. * @param body defines physics body used by the impostor
  33289. * @returns the PhysicsImpostor or null if not found
  33290. */
  33291. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33292. /**
  33293. * Does a raycast in the physics world
  33294. * @param from when should the ray start?
  33295. * @param to when should the ray end?
  33296. * @returns PhysicsRaycastResult
  33297. */
  33298. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33299. /**
  33300. * Called by the scene. No need to call it.
  33301. * @param delta defines the timespam between frames
  33302. */
  33303. _step(delta: number): void;
  33304. }
  33305. }
  33306. declare module "babylonjs/Physics/physicsImpostor" {
  33307. import { Nullable, IndicesArray } from "babylonjs/types";
  33308. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33309. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33311. import { Scene } from "babylonjs/scene";
  33312. import { Bone } from "babylonjs/Bones/bone";
  33313. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33314. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33315. import { Space } from "babylonjs/Maths/math.axis";
  33316. /**
  33317. * The interface for the physics imposter parameters
  33318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33319. */
  33320. export interface PhysicsImpostorParameters {
  33321. /**
  33322. * The mass of the physics imposter
  33323. */
  33324. mass: number;
  33325. /**
  33326. * The friction of the physics imposter
  33327. */
  33328. friction?: number;
  33329. /**
  33330. * The coefficient of restitution of the physics imposter
  33331. */
  33332. restitution?: number;
  33333. /**
  33334. * The native options of the physics imposter
  33335. */
  33336. nativeOptions?: any;
  33337. /**
  33338. * Specifies if the parent should be ignored
  33339. */
  33340. ignoreParent?: boolean;
  33341. /**
  33342. * Specifies if bi-directional transformations should be disabled
  33343. */
  33344. disableBidirectionalTransformation?: boolean;
  33345. /**
  33346. * The pressure inside the physics imposter, soft object only
  33347. */
  33348. pressure?: number;
  33349. /**
  33350. * The stiffness the physics imposter, soft object only
  33351. */
  33352. stiffness?: number;
  33353. /**
  33354. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33355. */
  33356. velocityIterations?: number;
  33357. /**
  33358. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33359. */
  33360. positionIterations?: number;
  33361. /**
  33362. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33363. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33364. * Add to fix multiple points
  33365. */
  33366. fixedPoints?: number;
  33367. /**
  33368. * The collision margin around a soft object
  33369. */
  33370. margin?: number;
  33371. /**
  33372. * The collision margin around a soft object
  33373. */
  33374. damping?: number;
  33375. /**
  33376. * The path for a rope based on an extrusion
  33377. */
  33378. path?: any;
  33379. /**
  33380. * The shape of an extrusion used for a rope based on an extrusion
  33381. */
  33382. shape?: any;
  33383. }
  33384. /**
  33385. * Interface for a physics-enabled object
  33386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33387. */
  33388. export interface IPhysicsEnabledObject {
  33389. /**
  33390. * The position of the physics-enabled object
  33391. */
  33392. position: Vector3;
  33393. /**
  33394. * The rotation of the physics-enabled object
  33395. */
  33396. rotationQuaternion: Nullable<Quaternion>;
  33397. /**
  33398. * The scale of the physics-enabled object
  33399. */
  33400. scaling: Vector3;
  33401. /**
  33402. * The rotation of the physics-enabled object
  33403. */
  33404. rotation?: Vector3;
  33405. /**
  33406. * The parent of the physics-enabled object
  33407. */
  33408. parent?: any;
  33409. /**
  33410. * The bounding info of the physics-enabled object
  33411. * @returns The bounding info of the physics-enabled object
  33412. */
  33413. getBoundingInfo(): BoundingInfo;
  33414. /**
  33415. * Computes the world matrix
  33416. * @param force Specifies if the world matrix should be computed by force
  33417. * @returns A world matrix
  33418. */
  33419. computeWorldMatrix(force: boolean): Matrix;
  33420. /**
  33421. * Gets the world matrix
  33422. * @returns A world matrix
  33423. */
  33424. getWorldMatrix?(): Matrix;
  33425. /**
  33426. * Gets the child meshes
  33427. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33428. * @returns An array of abstract meshes
  33429. */
  33430. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33431. /**
  33432. * Gets the vertex data
  33433. * @param kind The type of vertex data
  33434. * @returns A nullable array of numbers, or a float32 array
  33435. */
  33436. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33437. /**
  33438. * Gets the indices from the mesh
  33439. * @returns A nullable array of index arrays
  33440. */
  33441. getIndices?(): Nullable<IndicesArray>;
  33442. /**
  33443. * Gets the scene from the mesh
  33444. * @returns the indices array or null
  33445. */
  33446. getScene?(): Scene;
  33447. /**
  33448. * Gets the absolute position from the mesh
  33449. * @returns the absolute position
  33450. */
  33451. getAbsolutePosition(): Vector3;
  33452. /**
  33453. * Gets the absolute pivot point from the mesh
  33454. * @returns the absolute pivot point
  33455. */
  33456. getAbsolutePivotPoint(): Vector3;
  33457. /**
  33458. * Rotates the mesh
  33459. * @param axis The axis of rotation
  33460. * @param amount The amount of rotation
  33461. * @param space The space of the rotation
  33462. * @returns The rotation transform node
  33463. */
  33464. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33465. /**
  33466. * Translates the mesh
  33467. * @param axis The axis of translation
  33468. * @param distance The distance of translation
  33469. * @param space The space of the translation
  33470. * @returns The transform node
  33471. */
  33472. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33473. /**
  33474. * Sets the absolute position of the mesh
  33475. * @param absolutePosition The absolute position of the mesh
  33476. * @returns The transform node
  33477. */
  33478. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33479. /**
  33480. * Gets the class name of the mesh
  33481. * @returns The class name
  33482. */
  33483. getClassName(): string;
  33484. }
  33485. /**
  33486. * Represents a physics imposter
  33487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33488. */
  33489. export class PhysicsImpostor {
  33490. /**
  33491. * The physics-enabled object used as the physics imposter
  33492. */
  33493. object: IPhysicsEnabledObject;
  33494. /**
  33495. * The type of the physics imposter
  33496. */
  33497. type: number;
  33498. private _options;
  33499. private _scene?;
  33500. /**
  33501. * The default object size of the imposter
  33502. */
  33503. static DEFAULT_OBJECT_SIZE: Vector3;
  33504. /**
  33505. * The identity quaternion of the imposter
  33506. */
  33507. static IDENTITY_QUATERNION: Quaternion;
  33508. /** @hidden */
  33509. _pluginData: any;
  33510. private _physicsEngine;
  33511. private _physicsBody;
  33512. private _bodyUpdateRequired;
  33513. private _onBeforePhysicsStepCallbacks;
  33514. private _onAfterPhysicsStepCallbacks;
  33515. /** @hidden */
  33516. _onPhysicsCollideCallbacks: Array<{
  33517. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33518. otherImpostors: Array<PhysicsImpostor>;
  33519. }>;
  33520. private _deltaPosition;
  33521. private _deltaRotation;
  33522. private _deltaRotationConjugated;
  33523. /** @hidden */
  33524. _isFromLine: boolean;
  33525. private _parent;
  33526. private _isDisposed;
  33527. private static _tmpVecs;
  33528. private static _tmpQuat;
  33529. /**
  33530. * Specifies if the physics imposter is disposed
  33531. */
  33532. get isDisposed(): boolean;
  33533. /**
  33534. * Gets the mass of the physics imposter
  33535. */
  33536. get mass(): number;
  33537. set mass(value: number);
  33538. /**
  33539. * Gets the coefficient of friction
  33540. */
  33541. get friction(): number;
  33542. /**
  33543. * Sets the coefficient of friction
  33544. */
  33545. set friction(value: number);
  33546. /**
  33547. * Gets the coefficient of restitution
  33548. */
  33549. get restitution(): number;
  33550. /**
  33551. * Sets the coefficient of restitution
  33552. */
  33553. set restitution(value: number);
  33554. /**
  33555. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33556. */
  33557. get pressure(): number;
  33558. /**
  33559. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33560. */
  33561. set pressure(value: number);
  33562. /**
  33563. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33564. */
  33565. get stiffness(): number;
  33566. /**
  33567. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33568. */
  33569. set stiffness(value: number);
  33570. /**
  33571. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33572. */
  33573. get velocityIterations(): number;
  33574. /**
  33575. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33576. */
  33577. set velocityIterations(value: number);
  33578. /**
  33579. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33580. */
  33581. get positionIterations(): number;
  33582. /**
  33583. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33584. */
  33585. set positionIterations(value: number);
  33586. /**
  33587. * The unique id of the physics imposter
  33588. * set by the physics engine when adding this impostor to the array
  33589. */
  33590. uniqueId: number;
  33591. /**
  33592. * @hidden
  33593. */
  33594. soft: boolean;
  33595. /**
  33596. * @hidden
  33597. */
  33598. segments: number;
  33599. private _joints;
  33600. /**
  33601. * Initializes the physics imposter
  33602. * @param object The physics-enabled object used as the physics imposter
  33603. * @param type The type of the physics imposter
  33604. * @param _options The options for the physics imposter
  33605. * @param _scene The Babylon scene
  33606. */
  33607. constructor(
  33608. /**
  33609. * The physics-enabled object used as the physics imposter
  33610. */
  33611. object: IPhysicsEnabledObject,
  33612. /**
  33613. * The type of the physics imposter
  33614. */
  33615. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33616. /**
  33617. * This function will completly initialize this impostor.
  33618. * It will create a new body - but only if this mesh has no parent.
  33619. * If it has, this impostor will not be used other than to define the impostor
  33620. * of the child mesh.
  33621. * @hidden
  33622. */
  33623. _init(): void;
  33624. private _getPhysicsParent;
  33625. /**
  33626. * Should a new body be generated.
  33627. * @returns boolean specifying if body initialization is required
  33628. */
  33629. isBodyInitRequired(): boolean;
  33630. /**
  33631. * Sets the updated scaling
  33632. * @param updated Specifies if the scaling is updated
  33633. */
  33634. setScalingUpdated(): void;
  33635. /**
  33636. * Force a regeneration of this or the parent's impostor's body.
  33637. * Use under cautious - This will remove all joints already implemented.
  33638. */
  33639. forceUpdate(): void;
  33640. /**
  33641. * Gets the body that holds this impostor. Either its own, or its parent.
  33642. */
  33643. get physicsBody(): any;
  33644. /**
  33645. * Get the parent of the physics imposter
  33646. * @returns Physics imposter or null
  33647. */
  33648. get parent(): Nullable<PhysicsImpostor>;
  33649. /**
  33650. * Sets the parent of the physics imposter
  33651. */
  33652. set parent(value: Nullable<PhysicsImpostor>);
  33653. /**
  33654. * Set the physics body. Used mainly by the physics engine/plugin
  33655. */
  33656. set physicsBody(physicsBody: any);
  33657. /**
  33658. * Resets the update flags
  33659. */
  33660. resetUpdateFlags(): void;
  33661. /**
  33662. * Gets the object extend size
  33663. * @returns the object extend size
  33664. */
  33665. getObjectExtendSize(): Vector3;
  33666. /**
  33667. * Gets the object center
  33668. * @returns The object center
  33669. */
  33670. getObjectCenter(): Vector3;
  33671. /**
  33672. * Get a specific parameter from the options parameters
  33673. * @param paramName The object parameter name
  33674. * @returns The object parameter
  33675. */
  33676. getParam(paramName: string): any;
  33677. /**
  33678. * Sets a specific parameter in the options given to the physics plugin
  33679. * @param paramName The parameter name
  33680. * @param value The value of the parameter
  33681. */
  33682. setParam(paramName: string, value: number): void;
  33683. /**
  33684. * Specifically change the body's mass option. Won't recreate the physics body object
  33685. * @param mass The mass of the physics imposter
  33686. */
  33687. setMass(mass: number): void;
  33688. /**
  33689. * Gets the linear velocity
  33690. * @returns linear velocity or null
  33691. */
  33692. getLinearVelocity(): Nullable<Vector3>;
  33693. /**
  33694. * Sets the linear velocity
  33695. * @param velocity linear velocity or null
  33696. */
  33697. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33698. /**
  33699. * Gets the angular velocity
  33700. * @returns angular velocity or null
  33701. */
  33702. getAngularVelocity(): Nullable<Vector3>;
  33703. /**
  33704. * Sets the angular velocity
  33705. * @param velocity The velocity or null
  33706. */
  33707. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33708. /**
  33709. * Execute a function with the physics plugin native code
  33710. * Provide a function the will have two variables - the world object and the physics body object
  33711. * @param func The function to execute with the physics plugin native code
  33712. */
  33713. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33714. /**
  33715. * Register a function that will be executed before the physics world is stepping forward
  33716. * @param func The function to execute before the physics world is stepped forward
  33717. */
  33718. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33719. /**
  33720. * Unregister a function that will be executed before the physics world is stepping forward
  33721. * @param func The function to execute before the physics world is stepped forward
  33722. */
  33723. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33724. /**
  33725. * Register a function that will be executed after the physics step
  33726. * @param func The function to execute after physics step
  33727. */
  33728. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33729. /**
  33730. * Unregisters a function that will be executed after the physics step
  33731. * @param func The function to execute after physics step
  33732. */
  33733. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33734. /**
  33735. * register a function that will be executed when this impostor collides against a different body
  33736. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33737. * @param func Callback that is executed on collision
  33738. */
  33739. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33740. /**
  33741. * Unregisters the physics imposter on contact
  33742. * @param collideAgainst The physics object to collide against
  33743. * @param func Callback to execute on collision
  33744. */
  33745. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33746. private _tmpQuat;
  33747. private _tmpQuat2;
  33748. /**
  33749. * Get the parent rotation
  33750. * @returns The parent rotation
  33751. */
  33752. getParentsRotation(): Quaternion;
  33753. /**
  33754. * this function is executed by the physics engine.
  33755. */
  33756. beforeStep: () => void;
  33757. /**
  33758. * this function is executed by the physics engine
  33759. */
  33760. afterStep: () => void;
  33761. /**
  33762. * Legacy collision detection event support
  33763. */
  33764. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33765. /**
  33766. * event and body object due to cannon's event-based architecture.
  33767. */
  33768. onCollide: (e: {
  33769. body: any;
  33770. point: Nullable<Vector3>;
  33771. }) => void;
  33772. /**
  33773. * Apply a force
  33774. * @param force The force to apply
  33775. * @param contactPoint The contact point for the force
  33776. * @returns The physics imposter
  33777. */
  33778. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33779. /**
  33780. * Apply an impulse
  33781. * @param force The impulse force
  33782. * @param contactPoint The contact point for the impulse force
  33783. * @returns The physics imposter
  33784. */
  33785. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33786. /**
  33787. * A help function to create a joint
  33788. * @param otherImpostor A physics imposter used to create a joint
  33789. * @param jointType The type of joint
  33790. * @param jointData The data for the joint
  33791. * @returns The physics imposter
  33792. */
  33793. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33794. /**
  33795. * Add a joint to this impostor with a different impostor
  33796. * @param otherImpostor A physics imposter used to add a joint
  33797. * @param joint The joint to add
  33798. * @returns The physics imposter
  33799. */
  33800. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33801. /**
  33802. * Add an anchor to a cloth impostor
  33803. * @param otherImpostor rigid impostor to anchor to
  33804. * @param width ratio across width from 0 to 1
  33805. * @param height ratio up height from 0 to 1
  33806. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33807. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33808. * @returns impostor the soft imposter
  33809. */
  33810. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33811. /**
  33812. * Add a hook to a rope impostor
  33813. * @param otherImpostor rigid impostor to anchor to
  33814. * @param length ratio across rope from 0 to 1
  33815. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33816. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33817. * @returns impostor the rope imposter
  33818. */
  33819. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33820. /**
  33821. * Will keep this body still, in a sleep mode.
  33822. * @returns the physics imposter
  33823. */
  33824. sleep(): PhysicsImpostor;
  33825. /**
  33826. * Wake the body up.
  33827. * @returns The physics imposter
  33828. */
  33829. wakeUp(): PhysicsImpostor;
  33830. /**
  33831. * Clones the physics imposter
  33832. * @param newObject The physics imposter clones to this physics-enabled object
  33833. * @returns A nullable physics imposter
  33834. */
  33835. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33836. /**
  33837. * Disposes the physics imposter
  33838. */
  33839. dispose(): void;
  33840. /**
  33841. * Sets the delta position
  33842. * @param position The delta position amount
  33843. */
  33844. setDeltaPosition(position: Vector3): void;
  33845. /**
  33846. * Sets the delta rotation
  33847. * @param rotation The delta rotation amount
  33848. */
  33849. setDeltaRotation(rotation: Quaternion): void;
  33850. /**
  33851. * Gets the box size of the physics imposter and stores the result in the input parameter
  33852. * @param result Stores the box size
  33853. * @returns The physics imposter
  33854. */
  33855. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33856. /**
  33857. * Gets the radius of the physics imposter
  33858. * @returns Radius of the physics imposter
  33859. */
  33860. getRadius(): number;
  33861. /**
  33862. * Sync a bone with this impostor
  33863. * @param bone The bone to sync to the impostor.
  33864. * @param boneMesh The mesh that the bone is influencing.
  33865. * @param jointPivot The pivot of the joint / bone in local space.
  33866. * @param distToJoint Optional distance from the impostor to the joint.
  33867. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33868. */
  33869. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33870. /**
  33871. * Sync impostor to a bone
  33872. * @param bone The bone that the impostor will be synced to.
  33873. * @param boneMesh The mesh that the bone is influencing.
  33874. * @param jointPivot The pivot of the joint / bone in local space.
  33875. * @param distToJoint Optional distance from the impostor to the joint.
  33876. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33877. * @param boneAxis Optional vector3 axis the bone is aligned with
  33878. */
  33879. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33880. /**
  33881. * No-Imposter type
  33882. */
  33883. static NoImpostor: number;
  33884. /**
  33885. * Sphere-Imposter type
  33886. */
  33887. static SphereImpostor: number;
  33888. /**
  33889. * Box-Imposter type
  33890. */
  33891. static BoxImpostor: number;
  33892. /**
  33893. * Plane-Imposter type
  33894. */
  33895. static PlaneImpostor: number;
  33896. /**
  33897. * Mesh-imposter type
  33898. */
  33899. static MeshImpostor: number;
  33900. /**
  33901. * Capsule-Impostor type (Ammo.js plugin only)
  33902. */
  33903. static CapsuleImpostor: number;
  33904. /**
  33905. * Cylinder-Imposter type
  33906. */
  33907. static CylinderImpostor: number;
  33908. /**
  33909. * Particle-Imposter type
  33910. */
  33911. static ParticleImpostor: number;
  33912. /**
  33913. * Heightmap-Imposter type
  33914. */
  33915. static HeightmapImpostor: number;
  33916. /**
  33917. * ConvexHull-Impostor type (Ammo.js plugin only)
  33918. */
  33919. static ConvexHullImpostor: number;
  33920. /**
  33921. * Custom-Imposter type (Ammo.js plugin only)
  33922. */
  33923. static CustomImpostor: number;
  33924. /**
  33925. * Rope-Imposter type
  33926. */
  33927. static RopeImpostor: number;
  33928. /**
  33929. * Cloth-Imposter type
  33930. */
  33931. static ClothImpostor: number;
  33932. /**
  33933. * Softbody-Imposter type
  33934. */
  33935. static SoftbodyImpostor: number;
  33936. }
  33937. }
  33938. declare module "babylonjs/Meshes/mesh" {
  33939. import { Observable } from "babylonjs/Misc/observable";
  33940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33941. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33942. import { Camera } from "babylonjs/Cameras/camera";
  33943. import { Scene } from "babylonjs/scene";
  33944. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33945. import { Color4 } from "babylonjs/Maths/math.color";
  33946. import { Engine } from "babylonjs/Engines/engine";
  33947. import { Node } from "babylonjs/node";
  33948. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33949. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33950. import { Buffer } from "babylonjs/Meshes/buffer";
  33951. import { Geometry } from "babylonjs/Meshes/geometry";
  33952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33953. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33954. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33955. import { Effect } from "babylonjs/Materials/effect";
  33956. import { Material } from "babylonjs/Materials/material";
  33957. import { Skeleton } from "babylonjs/Bones/skeleton";
  33958. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33959. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33960. import { Path3D } from "babylonjs/Maths/math.path";
  33961. import { Plane } from "babylonjs/Maths/math.plane";
  33962. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33963. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33964. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33965. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33966. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33967. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33968. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33969. /**
  33970. * @hidden
  33971. **/
  33972. export class _CreationDataStorage {
  33973. closePath?: boolean;
  33974. closeArray?: boolean;
  33975. idx: number[];
  33976. dashSize: number;
  33977. gapSize: number;
  33978. path3D: Path3D;
  33979. pathArray: Vector3[][];
  33980. arc: number;
  33981. radius: number;
  33982. cap: number;
  33983. tessellation: number;
  33984. }
  33985. /**
  33986. * @hidden
  33987. **/
  33988. class _InstanceDataStorage {
  33989. visibleInstances: any;
  33990. batchCache: _InstancesBatch;
  33991. instancesBufferSize: number;
  33992. instancesBuffer: Nullable<Buffer>;
  33993. instancesData: Float32Array;
  33994. overridenInstanceCount: number;
  33995. isFrozen: boolean;
  33996. previousBatch: Nullable<_InstancesBatch>;
  33997. hardwareInstancedRendering: boolean;
  33998. sideOrientation: number;
  33999. manualUpdate: boolean;
  34000. previousRenderId: number;
  34001. }
  34002. /**
  34003. * @hidden
  34004. **/
  34005. export class _InstancesBatch {
  34006. mustReturn: boolean;
  34007. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  34008. renderSelf: boolean[];
  34009. hardwareInstancedRendering: boolean[];
  34010. }
  34011. /**
  34012. * @hidden
  34013. **/
  34014. class _ThinInstanceDataStorage {
  34015. instancesCount: number;
  34016. matrixBuffer: Nullable<Buffer>;
  34017. matrixBufferSize: number;
  34018. matrixData: Nullable<Float32Array>;
  34019. boundingVectors: Array<Vector3>;
  34020. worldMatrices: Nullable<Matrix[]>;
  34021. }
  34022. /**
  34023. * Class used to represent renderable models
  34024. */
  34025. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34026. /**
  34027. * Mesh side orientation : usually the external or front surface
  34028. */
  34029. static readonly FRONTSIDE: number;
  34030. /**
  34031. * Mesh side orientation : usually the internal or back surface
  34032. */
  34033. static readonly BACKSIDE: number;
  34034. /**
  34035. * Mesh side orientation : both internal and external or front and back surfaces
  34036. */
  34037. static readonly DOUBLESIDE: number;
  34038. /**
  34039. * Mesh side orientation : by default, `FRONTSIDE`
  34040. */
  34041. static readonly DEFAULTSIDE: number;
  34042. /**
  34043. * Mesh cap setting : no cap
  34044. */
  34045. static readonly NO_CAP: number;
  34046. /**
  34047. * Mesh cap setting : one cap at the beginning of the mesh
  34048. */
  34049. static readonly CAP_START: number;
  34050. /**
  34051. * Mesh cap setting : one cap at the end of the mesh
  34052. */
  34053. static readonly CAP_END: number;
  34054. /**
  34055. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34056. */
  34057. static readonly CAP_ALL: number;
  34058. /**
  34059. * Mesh pattern setting : no flip or rotate
  34060. */
  34061. static readonly NO_FLIP: number;
  34062. /**
  34063. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34064. */
  34065. static readonly FLIP_TILE: number;
  34066. /**
  34067. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34068. */
  34069. static readonly ROTATE_TILE: number;
  34070. /**
  34071. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34072. */
  34073. static readonly FLIP_ROW: number;
  34074. /**
  34075. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34076. */
  34077. static readonly ROTATE_ROW: number;
  34078. /**
  34079. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34080. */
  34081. static readonly FLIP_N_ROTATE_TILE: number;
  34082. /**
  34083. * Mesh pattern setting : rotate pattern and rotate
  34084. */
  34085. static readonly FLIP_N_ROTATE_ROW: number;
  34086. /**
  34087. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34088. */
  34089. static readonly CENTER: number;
  34090. /**
  34091. * Mesh tile positioning : part tiles on left
  34092. */
  34093. static readonly LEFT: number;
  34094. /**
  34095. * Mesh tile positioning : part tiles on right
  34096. */
  34097. static readonly RIGHT: number;
  34098. /**
  34099. * Mesh tile positioning : part tiles on top
  34100. */
  34101. static readonly TOP: number;
  34102. /**
  34103. * Mesh tile positioning : part tiles on bottom
  34104. */
  34105. static readonly BOTTOM: number;
  34106. /**
  34107. * Gets the default side orientation.
  34108. * @param orientation the orientation to value to attempt to get
  34109. * @returns the default orientation
  34110. * @hidden
  34111. */
  34112. static _GetDefaultSideOrientation(orientation?: number): number;
  34113. private _internalMeshDataInfo;
  34114. get computeBonesUsingShaders(): boolean;
  34115. set computeBonesUsingShaders(value: boolean);
  34116. /**
  34117. * An event triggered before rendering the mesh
  34118. */
  34119. get onBeforeRenderObservable(): Observable<Mesh>;
  34120. /**
  34121. * An event triggered before binding the mesh
  34122. */
  34123. get onBeforeBindObservable(): Observable<Mesh>;
  34124. /**
  34125. * An event triggered after rendering the mesh
  34126. */
  34127. get onAfterRenderObservable(): Observable<Mesh>;
  34128. /**
  34129. * An event triggered before drawing the mesh
  34130. */
  34131. get onBeforeDrawObservable(): Observable<Mesh>;
  34132. private _onBeforeDrawObserver;
  34133. /**
  34134. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34135. */
  34136. set onBeforeDraw(callback: () => void);
  34137. get hasInstances(): boolean;
  34138. get hasThinInstances(): boolean;
  34139. /**
  34140. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34141. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34142. */
  34143. delayLoadState: number;
  34144. /**
  34145. * Gets the list of instances created from this mesh
  34146. * it is not supposed to be modified manually.
  34147. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34148. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34149. */
  34150. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34151. /**
  34152. * Gets the file containing delay loading data for this mesh
  34153. */
  34154. delayLoadingFile: string;
  34155. /** @hidden */
  34156. _binaryInfo: any;
  34157. /**
  34158. * User defined function used to change how LOD level selection is done
  34159. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34160. */
  34161. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34162. /**
  34163. * Gets or sets the morph target manager
  34164. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34165. */
  34166. get morphTargetManager(): Nullable<MorphTargetManager>;
  34167. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34168. /** @hidden */
  34169. _creationDataStorage: Nullable<_CreationDataStorage>;
  34170. /** @hidden */
  34171. _geometry: Nullable<Geometry>;
  34172. /** @hidden */
  34173. _delayInfo: Array<string>;
  34174. /** @hidden */
  34175. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34176. /** @hidden */
  34177. _instanceDataStorage: _InstanceDataStorage;
  34178. /** @hidden */
  34179. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34180. private _effectiveMaterial;
  34181. /** @hidden */
  34182. _shouldGenerateFlatShading: boolean;
  34183. /** @hidden */
  34184. _originalBuilderSideOrientation: number;
  34185. /**
  34186. * Use this property to change the original side orientation defined at construction time
  34187. */
  34188. overrideMaterialSideOrientation: Nullable<number>;
  34189. /**
  34190. * Gets the source mesh (the one used to clone this one from)
  34191. */
  34192. get source(): Nullable<Mesh>;
  34193. /**
  34194. * Gets the list of clones of this mesh
  34195. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34196. * Note that useClonedMeshMap=true is the default setting
  34197. */
  34198. get cloneMeshMap(): Nullable<{
  34199. [id: string]: Mesh | undefined;
  34200. }>;
  34201. /**
  34202. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34203. */
  34204. get isUnIndexed(): boolean;
  34205. set isUnIndexed(value: boolean);
  34206. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34207. get worldMatrixInstancedBuffer(): Float32Array;
  34208. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34209. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34210. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34211. /**
  34212. * @constructor
  34213. * @param name The value used by scene.getMeshByName() to do a lookup.
  34214. * @param scene The scene to add this mesh to.
  34215. * @param parent The parent of this mesh, if it has one
  34216. * @param source An optional Mesh from which geometry is shared, cloned.
  34217. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34218. * When false, achieved by calling a clone(), also passing False.
  34219. * This will make creation of children, recursive.
  34220. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34221. */
  34222. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34223. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34224. doNotInstantiate: boolean;
  34225. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34226. /**
  34227. * Gets the class name
  34228. * @returns the string "Mesh".
  34229. */
  34230. getClassName(): string;
  34231. /** @hidden */
  34232. get _isMesh(): boolean;
  34233. /**
  34234. * Returns a description of this mesh
  34235. * @param fullDetails define if full details about this mesh must be used
  34236. * @returns a descriptive string representing this mesh
  34237. */
  34238. toString(fullDetails?: boolean): string;
  34239. /** @hidden */
  34240. _unBindEffect(): void;
  34241. /**
  34242. * Gets a boolean indicating if this mesh has LOD
  34243. */
  34244. get hasLODLevels(): boolean;
  34245. /**
  34246. * Gets the list of MeshLODLevel associated with the current mesh
  34247. * @returns an array of MeshLODLevel
  34248. */
  34249. getLODLevels(): MeshLODLevel[];
  34250. private _sortLODLevels;
  34251. /**
  34252. * Add a mesh as LOD level triggered at the given distance.
  34253. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34254. * @param distance The distance from the center of the object to show this level
  34255. * @param mesh The mesh to be added as LOD level (can be null)
  34256. * @return This mesh (for chaining)
  34257. */
  34258. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34259. /**
  34260. * Returns the LOD level mesh at the passed distance or null if not found.
  34261. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34262. * @param distance The distance from the center of the object to show this level
  34263. * @returns a Mesh or `null`
  34264. */
  34265. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34266. /**
  34267. * Remove a mesh from the LOD array
  34268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34269. * @param mesh defines the mesh to be removed
  34270. * @return This mesh (for chaining)
  34271. */
  34272. removeLODLevel(mesh: Mesh): Mesh;
  34273. /**
  34274. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34275. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34276. * @param camera defines the camera to use to compute distance
  34277. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34278. * @return This mesh (for chaining)
  34279. */
  34280. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34281. /**
  34282. * Gets the mesh internal Geometry object
  34283. */
  34284. get geometry(): Nullable<Geometry>;
  34285. /**
  34286. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34287. * @returns the total number of vertices
  34288. */
  34289. getTotalVertices(): number;
  34290. /**
  34291. * Returns the content of an associated vertex buffer
  34292. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34293. * - VertexBuffer.PositionKind
  34294. * - VertexBuffer.UVKind
  34295. * - VertexBuffer.UV2Kind
  34296. * - VertexBuffer.UV3Kind
  34297. * - VertexBuffer.UV4Kind
  34298. * - VertexBuffer.UV5Kind
  34299. * - VertexBuffer.UV6Kind
  34300. * - VertexBuffer.ColorKind
  34301. * - VertexBuffer.MatricesIndicesKind
  34302. * - VertexBuffer.MatricesIndicesExtraKind
  34303. * - VertexBuffer.MatricesWeightsKind
  34304. * - VertexBuffer.MatricesWeightsExtraKind
  34305. * @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
  34306. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34307. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34308. */
  34309. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34310. /**
  34311. * Returns the mesh VertexBuffer object from the requested `kind`
  34312. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34313. * - VertexBuffer.PositionKind
  34314. * - VertexBuffer.NormalKind
  34315. * - VertexBuffer.UVKind
  34316. * - VertexBuffer.UV2Kind
  34317. * - VertexBuffer.UV3Kind
  34318. * - VertexBuffer.UV4Kind
  34319. * - VertexBuffer.UV5Kind
  34320. * - VertexBuffer.UV6Kind
  34321. * - VertexBuffer.ColorKind
  34322. * - VertexBuffer.MatricesIndicesKind
  34323. * - VertexBuffer.MatricesIndicesExtraKind
  34324. * - VertexBuffer.MatricesWeightsKind
  34325. * - VertexBuffer.MatricesWeightsExtraKind
  34326. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34327. */
  34328. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34329. /**
  34330. * Tests if a specific vertex buffer is associated with this mesh
  34331. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34332. * - VertexBuffer.PositionKind
  34333. * - VertexBuffer.NormalKind
  34334. * - VertexBuffer.UVKind
  34335. * - VertexBuffer.UV2Kind
  34336. * - VertexBuffer.UV3Kind
  34337. * - VertexBuffer.UV4Kind
  34338. * - VertexBuffer.UV5Kind
  34339. * - VertexBuffer.UV6Kind
  34340. * - VertexBuffer.ColorKind
  34341. * - VertexBuffer.MatricesIndicesKind
  34342. * - VertexBuffer.MatricesIndicesExtraKind
  34343. * - VertexBuffer.MatricesWeightsKind
  34344. * - VertexBuffer.MatricesWeightsExtraKind
  34345. * @returns a boolean
  34346. */
  34347. isVerticesDataPresent(kind: string): boolean;
  34348. /**
  34349. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34350. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34351. * - VertexBuffer.PositionKind
  34352. * - VertexBuffer.UVKind
  34353. * - VertexBuffer.UV2Kind
  34354. * - VertexBuffer.UV3Kind
  34355. * - VertexBuffer.UV4Kind
  34356. * - VertexBuffer.UV5Kind
  34357. * - VertexBuffer.UV6Kind
  34358. * - VertexBuffer.ColorKind
  34359. * - VertexBuffer.MatricesIndicesKind
  34360. * - VertexBuffer.MatricesIndicesExtraKind
  34361. * - VertexBuffer.MatricesWeightsKind
  34362. * - VertexBuffer.MatricesWeightsExtraKind
  34363. * @returns a boolean
  34364. */
  34365. isVertexBufferUpdatable(kind: string): boolean;
  34366. /**
  34367. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34368. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34369. * - VertexBuffer.PositionKind
  34370. * - VertexBuffer.NormalKind
  34371. * - VertexBuffer.UVKind
  34372. * - VertexBuffer.UV2Kind
  34373. * - VertexBuffer.UV3Kind
  34374. * - VertexBuffer.UV4Kind
  34375. * - VertexBuffer.UV5Kind
  34376. * - VertexBuffer.UV6Kind
  34377. * - VertexBuffer.ColorKind
  34378. * - VertexBuffer.MatricesIndicesKind
  34379. * - VertexBuffer.MatricesIndicesExtraKind
  34380. * - VertexBuffer.MatricesWeightsKind
  34381. * - VertexBuffer.MatricesWeightsExtraKind
  34382. * @returns an array of strings
  34383. */
  34384. getVerticesDataKinds(): string[];
  34385. /**
  34386. * Returns a positive integer : the total number of indices in this mesh geometry.
  34387. * @returns the numner of indices or zero if the mesh has no geometry.
  34388. */
  34389. getTotalIndices(): number;
  34390. /**
  34391. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34392. * @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.
  34393. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34394. * @returns the indices array or an empty array if the mesh has no geometry
  34395. */
  34396. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34397. get isBlocked(): boolean;
  34398. /**
  34399. * Determine if the current mesh is ready to be rendered
  34400. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34401. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34402. * @returns true if all associated assets are ready (material, textures, shaders)
  34403. */
  34404. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34405. /**
  34406. * 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.
  34407. */
  34408. get areNormalsFrozen(): boolean;
  34409. /**
  34410. * 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.
  34411. * @returns the current mesh
  34412. */
  34413. freezeNormals(): Mesh;
  34414. /**
  34415. * 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
  34416. * @returns the current mesh
  34417. */
  34418. unfreezeNormals(): Mesh;
  34419. /**
  34420. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34421. */
  34422. set overridenInstanceCount(count: number);
  34423. /** @hidden */
  34424. _preActivate(): Mesh;
  34425. /** @hidden */
  34426. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34427. /** @hidden */
  34428. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34429. protected _afterComputeWorldMatrix(): void;
  34430. /** @hidden */
  34431. _postActivate(): void;
  34432. /**
  34433. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34434. * This means the mesh underlying bounding box and sphere are recomputed.
  34435. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34436. * @returns the current mesh
  34437. */
  34438. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34439. /** @hidden */
  34440. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34441. /**
  34442. * This function will subdivide the mesh into multiple submeshes
  34443. * @param count defines the expected number of submeshes
  34444. */
  34445. subdivide(count: number): void;
  34446. /**
  34447. * Copy a FloatArray into a specific associated vertex buffer
  34448. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34449. * - VertexBuffer.PositionKind
  34450. * - VertexBuffer.UVKind
  34451. * - VertexBuffer.UV2Kind
  34452. * - VertexBuffer.UV3Kind
  34453. * - VertexBuffer.UV4Kind
  34454. * - VertexBuffer.UV5Kind
  34455. * - VertexBuffer.UV6Kind
  34456. * - VertexBuffer.ColorKind
  34457. * - VertexBuffer.MatricesIndicesKind
  34458. * - VertexBuffer.MatricesIndicesExtraKind
  34459. * - VertexBuffer.MatricesWeightsKind
  34460. * - VertexBuffer.MatricesWeightsExtraKind
  34461. * @param data defines the data source
  34462. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34463. * @param stride defines the data stride size (can be null)
  34464. * @returns the current mesh
  34465. */
  34466. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34467. /**
  34468. * Delete a vertex buffer associated with this mesh
  34469. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34470. * - VertexBuffer.PositionKind
  34471. * - VertexBuffer.UVKind
  34472. * - VertexBuffer.UV2Kind
  34473. * - VertexBuffer.UV3Kind
  34474. * - VertexBuffer.UV4Kind
  34475. * - VertexBuffer.UV5Kind
  34476. * - VertexBuffer.UV6Kind
  34477. * - VertexBuffer.ColorKind
  34478. * - VertexBuffer.MatricesIndicesKind
  34479. * - VertexBuffer.MatricesIndicesExtraKind
  34480. * - VertexBuffer.MatricesWeightsKind
  34481. * - VertexBuffer.MatricesWeightsExtraKind
  34482. */
  34483. removeVerticesData(kind: string): void;
  34484. /**
  34485. * Flags an associated vertex buffer as updatable
  34486. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34487. * - VertexBuffer.PositionKind
  34488. * - VertexBuffer.UVKind
  34489. * - VertexBuffer.UV2Kind
  34490. * - VertexBuffer.UV3Kind
  34491. * - VertexBuffer.UV4Kind
  34492. * - VertexBuffer.UV5Kind
  34493. * - VertexBuffer.UV6Kind
  34494. * - VertexBuffer.ColorKind
  34495. * - VertexBuffer.MatricesIndicesKind
  34496. * - VertexBuffer.MatricesIndicesExtraKind
  34497. * - VertexBuffer.MatricesWeightsKind
  34498. * - VertexBuffer.MatricesWeightsExtraKind
  34499. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34500. */
  34501. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34502. /**
  34503. * Sets the mesh global Vertex Buffer
  34504. * @param buffer defines the buffer to use
  34505. * @returns the current mesh
  34506. */
  34507. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34508. /**
  34509. * Update a specific associated vertex buffer
  34510. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34511. * - VertexBuffer.PositionKind
  34512. * - VertexBuffer.UVKind
  34513. * - VertexBuffer.UV2Kind
  34514. * - VertexBuffer.UV3Kind
  34515. * - VertexBuffer.UV4Kind
  34516. * - VertexBuffer.UV5Kind
  34517. * - VertexBuffer.UV6Kind
  34518. * - VertexBuffer.ColorKind
  34519. * - VertexBuffer.MatricesIndicesKind
  34520. * - VertexBuffer.MatricesIndicesExtraKind
  34521. * - VertexBuffer.MatricesWeightsKind
  34522. * - VertexBuffer.MatricesWeightsExtraKind
  34523. * @param data defines the data source
  34524. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34525. * @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)
  34526. * @returns the current mesh
  34527. */
  34528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34529. /**
  34530. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34531. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34532. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34533. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34534. * @returns the current mesh
  34535. */
  34536. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34537. /**
  34538. * Creates a un-shared specific occurence of the geometry for the mesh.
  34539. * @returns the current mesh
  34540. */
  34541. makeGeometryUnique(): Mesh;
  34542. /**
  34543. * Set the index buffer of this mesh
  34544. * @param indices defines the source data
  34545. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34546. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34547. * @returns the current mesh
  34548. */
  34549. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34550. /**
  34551. * Update the current index buffer
  34552. * @param indices defines the source data
  34553. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34554. * @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)
  34555. * @returns the current mesh
  34556. */
  34557. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34558. /**
  34559. * Invert the geometry to move from a right handed system to a left handed one.
  34560. * @returns the current mesh
  34561. */
  34562. toLeftHanded(): Mesh;
  34563. /** @hidden */
  34564. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34565. /** @hidden */
  34566. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34567. /**
  34568. * Registers for this mesh a javascript function called just before the rendering process
  34569. * @param func defines the function to call before rendering this mesh
  34570. * @returns the current mesh
  34571. */
  34572. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34573. /**
  34574. * Disposes a previously registered javascript function called before the rendering
  34575. * @param func defines the function to remove
  34576. * @returns the current mesh
  34577. */
  34578. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34579. /**
  34580. * Registers for this mesh a javascript function called just after the rendering is complete
  34581. * @param func defines the function to call after rendering this mesh
  34582. * @returns the current mesh
  34583. */
  34584. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34585. /**
  34586. * Disposes a previously registered javascript function called after the rendering.
  34587. * @param func defines the function to remove
  34588. * @returns the current mesh
  34589. */
  34590. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34591. /** @hidden */
  34592. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34593. /** @hidden */
  34594. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34595. /** @hidden */
  34596. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34597. /** @hidden */
  34598. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34599. /** @hidden */
  34600. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34601. /** @hidden */
  34602. _rebuild(): void;
  34603. /** @hidden */
  34604. _freeze(): void;
  34605. /** @hidden */
  34606. _unFreeze(): void;
  34607. /**
  34608. * 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
  34609. * @param subMesh defines the subMesh to render
  34610. * @param enableAlphaMode defines if alpha mode can be changed
  34611. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34612. * @returns the current mesh
  34613. */
  34614. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34615. private _onBeforeDraw;
  34616. /**
  34617. * Renormalize the mesh and patch it up if there are no weights
  34618. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34619. * However in the case of zero weights then we set just a single influence to 1.
  34620. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34621. */
  34622. cleanMatrixWeights(): void;
  34623. private normalizeSkinFourWeights;
  34624. private normalizeSkinWeightsAndExtra;
  34625. /**
  34626. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34627. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34628. * the user know there was an issue with importing the mesh
  34629. * @returns a validation object with skinned, valid and report string
  34630. */
  34631. validateSkinning(): {
  34632. skinned: boolean;
  34633. valid: boolean;
  34634. report: string;
  34635. };
  34636. /** @hidden */
  34637. _checkDelayState(): Mesh;
  34638. private _queueLoad;
  34639. /**
  34640. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34641. * A mesh is in the frustum if its bounding box intersects the frustum
  34642. * @param frustumPlanes defines the frustum to test
  34643. * @returns true if the mesh is in the frustum planes
  34644. */
  34645. isInFrustum(frustumPlanes: Plane[]): boolean;
  34646. /**
  34647. * Sets the mesh material by the material or multiMaterial `id` property
  34648. * @param id is a string identifying the material or the multiMaterial
  34649. * @returns the current mesh
  34650. */
  34651. setMaterialByID(id: string): Mesh;
  34652. /**
  34653. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34654. * @returns an array of IAnimatable
  34655. */
  34656. getAnimatables(): IAnimatable[];
  34657. /**
  34658. * Modifies the mesh geometry according to the passed transformation matrix.
  34659. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34660. * The mesh normals are modified using the same transformation.
  34661. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34662. * @param transform defines the transform matrix to use
  34663. * @see https://doc.babylonjs.com/resources/baking_transformations
  34664. * @returns the current mesh
  34665. */
  34666. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34667. /**
  34668. * Modifies the mesh geometry according to its own current World Matrix.
  34669. * The mesh World Matrix is then reset.
  34670. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34671. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34672. * @see https://doc.babylonjs.com/resources/baking_transformations
  34673. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34674. * @returns the current mesh
  34675. */
  34676. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34677. /** @hidden */
  34678. get _positions(): Nullable<Vector3[]>;
  34679. /** @hidden */
  34680. _resetPointsArrayCache(): Mesh;
  34681. /** @hidden */
  34682. _generatePointsArray(): boolean;
  34683. /**
  34684. * Returns a new Mesh object generated from the current mesh properties.
  34685. * This method must not get confused with createInstance()
  34686. * @param name is a string, the name given to the new mesh
  34687. * @param newParent can be any Node object (default `null`)
  34688. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34689. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34690. * @returns a new mesh
  34691. */
  34692. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34693. /**
  34694. * Releases resources associated with this mesh.
  34695. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34696. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34697. */
  34698. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34699. /** @hidden */
  34700. _disposeInstanceSpecificData(): void;
  34701. /** @hidden */
  34702. _disposeThinInstanceSpecificData(): void;
  34703. /**
  34704. * Modifies the mesh geometry according to a displacement map.
  34705. * 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.
  34706. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34707. * @param url is a string, the URL from the image file is to be downloaded.
  34708. * @param minHeight is the lower limit of the displacement.
  34709. * @param maxHeight is the upper limit of the displacement.
  34710. * @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.
  34711. * @param uvOffset is an optional vector2 used to offset UV.
  34712. * @param uvScale is an optional vector2 used to scale UV.
  34713. * @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.
  34714. * @returns the Mesh.
  34715. */
  34716. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34717. /**
  34718. * Modifies the mesh geometry according to a displacementMap buffer.
  34719. * 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.
  34720. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34721. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34722. * @param heightMapWidth is the width of the buffer image.
  34723. * @param heightMapHeight is the height of the buffer image.
  34724. * @param minHeight is the lower limit of the displacement.
  34725. * @param maxHeight is the upper limit of the displacement.
  34726. * @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.
  34727. * @param uvOffset is an optional vector2 used to offset UV.
  34728. * @param uvScale is an optional vector2 used to scale UV.
  34729. * @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.
  34730. * @returns the Mesh.
  34731. */
  34732. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34733. /**
  34734. * Modify the mesh to get a flat shading rendering.
  34735. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34736. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34737. * @returns current mesh
  34738. */
  34739. convertToFlatShadedMesh(): Mesh;
  34740. /**
  34741. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34742. * In other words, more vertices, no more indices and a single bigger VBO.
  34743. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34744. * @returns current mesh
  34745. */
  34746. convertToUnIndexedMesh(): Mesh;
  34747. /**
  34748. * Inverses facet orientations.
  34749. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34750. * @param flipNormals will also inverts the normals
  34751. * @returns current mesh
  34752. */
  34753. flipFaces(flipNormals?: boolean): Mesh;
  34754. /**
  34755. * Increase the number of facets and hence vertices in a mesh
  34756. * Vertex normals are interpolated from existing vertex normals
  34757. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34758. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34759. */
  34760. increaseVertices(numberPerEdge: number): void;
  34761. /**
  34762. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34763. * This will undo any application of covertToFlatShadedMesh
  34764. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34765. */
  34766. forceSharedVertices(): void;
  34767. /** @hidden */
  34768. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34769. /** @hidden */
  34770. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34771. /**
  34772. * Creates a new InstancedMesh object from the mesh model.
  34773. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34774. * @param name defines the name of the new instance
  34775. * @returns a new InstancedMesh
  34776. */
  34777. createInstance(name: string): InstancedMesh;
  34778. /**
  34779. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34780. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34781. * @returns the current mesh
  34782. */
  34783. synchronizeInstances(): Mesh;
  34784. /**
  34785. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34786. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34787. * This should be used together with the simplification to avoid disappearing triangles.
  34788. * @param successCallback an optional success callback to be called after the optimization finished.
  34789. * @returns the current mesh
  34790. */
  34791. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34792. /**
  34793. * Serialize current mesh
  34794. * @param serializationObject defines the object which will receive the serialization data
  34795. */
  34796. serialize(serializationObject: any): void;
  34797. /** @hidden */
  34798. _syncGeometryWithMorphTargetManager(): void;
  34799. /** @hidden */
  34800. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34801. /**
  34802. * Returns a new Mesh object parsed from the source provided.
  34803. * @param parsedMesh is the source
  34804. * @param scene defines the hosting scene
  34805. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34806. * @returns a new Mesh
  34807. */
  34808. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34809. /**
  34810. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34812. * @param name defines the name of the mesh to create
  34813. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34814. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34815. * @param closePath creates a seam between the first and the last points of each path of the path array
  34816. * @param offset is taken in account only if the `pathArray` is containing a single path
  34817. * @param scene defines the hosting scene
  34818. * @param updatable defines if the mesh must be flagged as updatable
  34819. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34820. * @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)
  34821. * @returns a new Mesh
  34822. */
  34823. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34824. /**
  34825. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34826. * @param name defines the name of the mesh to create
  34827. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34828. * @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
  34829. * @param scene defines the hosting scene
  34830. * @param updatable defines if the mesh must be flagged as updatable
  34831. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34832. * @returns a new Mesh
  34833. */
  34834. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34835. /**
  34836. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34837. * @param name defines the name of the mesh to create
  34838. * @param size sets the size (float) of each box side (default 1)
  34839. * @param scene defines the hosting scene
  34840. * @param updatable defines if the mesh must be flagged as updatable
  34841. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34842. * @returns a new Mesh
  34843. */
  34844. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34845. /**
  34846. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34847. * @param name defines the name of the mesh to create
  34848. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34849. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34850. * @param scene defines the hosting scene
  34851. * @param updatable defines if the mesh must be flagged as updatable
  34852. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34853. * @returns a new Mesh
  34854. */
  34855. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34856. /**
  34857. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34858. * @param name defines the name of the mesh to create
  34859. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34860. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34861. * @param scene defines the hosting scene
  34862. * @returns a new Mesh
  34863. */
  34864. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34865. /**
  34866. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34867. * @param name defines the name of the mesh to create
  34868. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34869. * @param diameterTop set the top cap diameter (floats, default 1)
  34870. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34871. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34872. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34873. * @param scene defines the hosting scene
  34874. * @param updatable defines if the mesh must be flagged as updatable
  34875. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34876. * @returns a new Mesh
  34877. */
  34878. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34879. /**
  34880. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34881. * @param name defines the name of the mesh to create
  34882. * @param diameter sets the diameter size (float) of the torus (default 1)
  34883. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34884. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34885. * @param scene defines the hosting scene
  34886. * @param updatable defines if the mesh must be flagged as updatable
  34887. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34888. * @returns a new Mesh
  34889. */
  34890. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34891. /**
  34892. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34893. * @param name defines the name of the mesh to create
  34894. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34895. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34896. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34897. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34898. * @param p the number of windings on X axis (positive integers, default 2)
  34899. * @param q the number of windings on Y axis (positive integers, default 3)
  34900. * @param scene defines the hosting scene
  34901. * @param updatable defines if the mesh must be flagged as updatable
  34902. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34903. * @returns a new Mesh
  34904. */
  34905. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34906. /**
  34907. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34908. * @param name defines the name of the mesh to create
  34909. * @param points is an array successive Vector3
  34910. * @param scene defines the hosting scene
  34911. * @param updatable defines if the mesh must be flagged as updatable
  34912. * @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).
  34913. * @returns a new Mesh
  34914. */
  34915. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34916. /**
  34917. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34918. * @param name defines the name of the mesh to create
  34919. * @param points is an array successive Vector3
  34920. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34921. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34922. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34923. * @param scene defines the hosting scene
  34924. * @param updatable defines if the mesh must be flagged as updatable
  34925. * @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)
  34926. * @returns a new Mesh
  34927. */
  34928. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34929. /**
  34930. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34931. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34932. * 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.
  34933. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34934. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34935. * Remember you can only change the shape positions, not their number when updating a polygon.
  34936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34937. * @param name defines the name of the mesh to create
  34938. * @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
  34939. * @param scene defines the hosting scene
  34940. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34941. * @param updatable defines if the mesh must be flagged as updatable
  34942. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34943. * @param earcutInjection can be used to inject your own earcut reference
  34944. * @returns a new Mesh
  34945. */
  34946. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34947. /**
  34948. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34950. * @param name defines the name of the mesh to create
  34951. * @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
  34952. * @param depth defines the height of extrusion
  34953. * @param scene defines the hosting scene
  34954. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34955. * @param updatable defines if the mesh must be flagged as updatable
  34956. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34957. * @param earcutInjection can be used to inject your own earcut reference
  34958. * @returns a new Mesh
  34959. */
  34960. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34961. /**
  34962. * Creates an extruded shape mesh.
  34963. * 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
  34964. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34966. * @param name defines the name of the mesh to create
  34967. * @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
  34968. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34969. * @param scale is the value to scale the shape
  34970. * @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
  34971. * @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
  34972. * @param scene defines the hosting scene
  34973. * @param updatable defines if the mesh must be flagged as updatable
  34974. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34975. * @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)
  34976. * @returns a new Mesh
  34977. */
  34978. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34979. /**
  34980. * Creates an custom extruded shape mesh.
  34981. * The custom extrusion is a parametric shape.
  34982. * It has no predefined shape. Its final shape will depend on the input parameters.
  34983. * Please consider using the same method from the MeshBuilder class instead
  34984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34985. * @param name defines the name of the mesh to create
  34986. * @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
  34987. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34988. * @param scaleFunction is a custom Javascript function called on each path point
  34989. * @param rotationFunction is a custom Javascript function called on each path point
  34990. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34991. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34992. * @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
  34993. * @param scene defines the hosting scene
  34994. * @param updatable defines if the mesh must be flagged as updatable
  34995. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34996. * @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)
  34997. * @returns a new Mesh
  34998. */
  34999. 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;
  35000. /**
  35001. * Creates lathe mesh.
  35002. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  35003. * Please consider using the same method from the MeshBuilder class instead
  35004. * @param name defines the name of the mesh to create
  35005. * @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
  35006. * @param radius is the radius value of the lathe
  35007. * @param tessellation is the side number of the lathe.
  35008. * @param scene defines the hosting scene
  35009. * @param updatable defines if the mesh must be flagged as updatable
  35010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35011. * @returns a new Mesh
  35012. */
  35013. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35014. /**
  35015. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35016. * @param name defines the name of the mesh to create
  35017. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35018. * @param scene defines the hosting scene
  35019. * @param updatable defines if the mesh must be flagged as updatable
  35020. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35021. * @returns a new Mesh
  35022. */
  35023. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35024. /**
  35025. * Creates a ground mesh.
  35026. * Please consider using the same method from the MeshBuilder class instead
  35027. * @param name defines the name of the mesh to create
  35028. * @param width set the width of the ground
  35029. * @param height set the height of the ground
  35030. * @param subdivisions sets the number of subdivisions per side
  35031. * @param scene defines the hosting scene
  35032. * @param updatable defines if the mesh must be flagged as updatable
  35033. * @returns a new Mesh
  35034. */
  35035. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35036. /**
  35037. * Creates a tiled ground mesh.
  35038. * Please consider using the same method from the MeshBuilder class instead
  35039. * @param name defines the name of the mesh to create
  35040. * @param xmin set the ground minimum X coordinate
  35041. * @param zmin set the ground minimum Y coordinate
  35042. * @param xmax set the ground maximum X coordinate
  35043. * @param zmax set the ground maximum Z coordinate
  35044. * @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
  35045. * @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
  35046. * @param scene defines the hosting scene
  35047. * @param updatable defines if the mesh must be flagged as updatable
  35048. * @returns a new Mesh
  35049. */
  35050. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35051. w: number;
  35052. h: number;
  35053. }, precision: {
  35054. w: number;
  35055. h: number;
  35056. }, scene: Scene, updatable?: boolean): Mesh;
  35057. /**
  35058. * Creates a ground mesh from a height map.
  35059. * Please consider using the same method from the MeshBuilder class instead
  35060. * @see https://doc.babylonjs.com/babylon101/height_map
  35061. * @param name defines the name of the mesh to create
  35062. * @param url sets the URL of the height map image resource
  35063. * @param width set the ground width size
  35064. * @param height set the ground height size
  35065. * @param subdivisions sets the number of subdivision per side
  35066. * @param minHeight is the minimum altitude on the ground
  35067. * @param maxHeight is the maximum altitude on the ground
  35068. * @param scene defines the hosting scene
  35069. * @param updatable defines if the mesh must be flagged as updatable
  35070. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35071. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35072. * @returns a new Mesh
  35073. */
  35074. 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;
  35075. /**
  35076. * Creates a tube mesh.
  35077. * The tube is a parametric shape.
  35078. * It has no predefined shape. Its final shape will depend on the input parameters.
  35079. * Please consider using the same method from the MeshBuilder class instead
  35080. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35081. * @param name defines the name of the mesh to create
  35082. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35083. * @param radius sets the tube radius size
  35084. * @param tessellation is the number of sides on the tubular surface
  35085. * @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
  35086. * @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
  35087. * @param scene defines the hosting scene
  35088. * @param updatable defines if the mesh must be flagged as updatable
  35089. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35090. * @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)
  35091. * @returns a new Mesh
  35092. */
  35093. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35094. (i: number, distance: number): number;
  35095. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35096. /**
  35097. * Creates a polyhedron mesh.
  35098. * Please consider using the same method from the MeshBuilder class instead.
  35099. * * 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
  35100. * * The parameter `size` (positive float, default 1) sets the polygon size
  35101. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35102. * * 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`
  35103. * * 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
  35104. * * 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)`)
  35105. * * 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
  35106. * * 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
  35107. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35110. * @param name defines the name of the mesh to create
  35111. * @param options defines the options used to create the mesh
  35112. * @param scene defines the hosting scene
  35113. * @returns a new Mesh
  35114. */
  35115. static CreatePolyhedron(name: string, options: {
  35116. type?: number;
  35117. size?: number;
  35118. sizeX?: number;
  35119. sizeY?: number;
  35120. sizeZ?: number;
  35121. custom?: any;
  35122. faceUV?: Vector4[];
  35123. faceColors?: Color4[];
  35124. updatable?: boolean;
  35125. sideOrientation?: number;
  35126. }, scene: Scene): Mesh;
  35127. /**
  35128. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35129. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35130. * * 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`)
  35131. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35132. * * 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
  35133. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35136. * @param name defines the name of the mesh
  35137. * @param options defines the options used to create the mesh
  35138. * @param scene defines the hosting scene
  35139. * @returns a new Mesh
  35140. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35141. */
  35142. static CreateIcoSphere(name: string, options: {
  35143. radius?: number;
  35144. flat?: boolean;
  35145. subdivisions?: number;
  35146. sideOrientation?: number;
  35147. updatable?: boolean;
  35148. }, scene: Scene): Mesh;
  35149. /**
  35150. * Creates a decal mesh.
  35151. * Please consider using the same method from the MeshBuilder class instead.
  35152. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35153. * @param name defines the name of the mesh
  35154. * @param sourceMesh defines the mesh receiving the decal
  35155. * @param position sets the position of the decal in world coordinates
  35156. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35157. * @param size sets the decal scaling
  35158. * @param angle sets the angle to rotate the decal
  35159. * @returns a new Mesh
  35160. */
  35161. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35162. /** Creates a Capsule Mesh
  35163. * @param name defines the name of the mesh.
  35164. * @param options the constructors options used to shape the mesh.
  35165. * @param scene defines the scene the mesh is scoped to.
  35166. * @returns the capsule mesh
  35167. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35168. */
  35169. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35170. /**
  35171. * Prepare internal position array for software CPU skinning
  35172. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35173. */
  35174. setPositionsForCPUSkinning(): Float32Array;
  35175. /**
  35176. * Prepare internal normal array for software CPU skinning
  35177. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35178. */
  35179. setNormalsForCPUSkinning(): Float32Array;
  35180. /**
  35181. * Updates the vertex buffer by applying transformation from the bones
  35182. * @param skeleton defines the skeleton to apply to current mesh
  35183. * @returns the current mesh
  35184. */
  35185. applySkeleton(skeleton: Skeleton): Mesh;
  35186. /**
  35187. * 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
  35188. * @param meshes defines the list of meshes to scan
  35189. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35190. */
  35191. static MinMax(meshes: AbstractMesh[]): {
  35192. min: Vector3;
  35193. max: Vector3;
  35194. };
  35195. /**
  35196. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35197. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35198. * @returns a vector3
  35199. */
  35200. static Center(meshesOrMinMaxVector: {
  35201. min: Vector3;
  35202. max: Vector3;
  35203. } | AbstractMesh[]): Vector3;
  35204. /**
  35205. * Merge the array of meshes into a single mesh for performance reasons.
  35206. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35207. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35208. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35209. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35210. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35211. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35212. * @returns a new mesh
  35213. */
  35214. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35215. /** @hidden */
  35216. addInstance(instance: InstancedMesh): void;
  35217. /** @hidden */
  35218. removeInstance(instance: InstancedMesh): void;
  35219. }
  35220. }
  35221. declare module "babylonjs/Cameras/camera" {
  35222. import { SmartArray } from "babylonjs/Misc/smartArray";
  35223. import { Observable } from "babylonjs/Misc/observable";
  35224. import { Nullable } from "babylonjs/types";
  35225. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35226. import { Scene } from "babylonjs/scene";
  35227. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  35228. import { Node } from "babylonjs/node";
  35229. import { Mesh } from "babylonjs/Meshes/mesh";
  35230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35231. import { ICullable } from "babylonjs/Culling/boundingInfo";
  35232. import { Viewport } from "babylonjs/Maths/math.viewport";
  35233. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35235. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  35236. import { Ray } from "babylonjs/Culling/ray";
  35237. /**
  35238. * This is the base class of all the camera used in the application.
  35239. * @see https://doc.babylonjs.com/features/cameras
  35240. */
  35241. export class Camera extends Node {
  35242. /** @hidden */
  35243. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  35244. /**
  35245. * This is the default projection mode used by the cameras.
  35246. * It helps recreating a feeling of perspective and better appreciate depth.
  35247. * This is the best way to simulate real life cameras.
  35248. */
  35249. static readonly PERSPECTIVE_CAMERA: number;
  35250. /**
  35251. * This helps creating camera with an orthographic mode.
  35252. * 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.
  35253. */
  35254. static readonly ORTHOGRAPHIC_CAMERA: number;
  35255. /**
  35256. * This is the default FOV mode for perspective cameras.
  35257. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  35258. */
  35259. static readonly FOVMODE_VERTICAL_FIXED: number;
  35260. /**
  35261. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  35262. */
  35263. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  35264. /**
  35265. * This specifies ther is no need for a camera rig.
  35266. * Basically only one eye is rendered corresponding to the camera.
  35267. */
  35268. static readonly RIG_MODE_NONE: number;
  35269. /**
  35270. * Simulates a camera Rig with one blue eye and one red eye.
  35271. * This can be use with 3d blue and red glasses.
  35272. */
  35273. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  35274. /**
  35275. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  35276. */
  35277. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  35278. /**
  35279. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  35280. */
  35281. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  35282. /**
  35283. * Defines that both eyes of the camera will be rendered over under each other.
  35284. */
  35285. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  35286. /**
  35287. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  35288. */
  35289. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  35290. /**
  35291. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  35292. */
  35293. static readonly RIG_MODE_VR: number;
  35294. /**
  35295. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  35296. */
  35297. static readonly RIG_MODE_WEBVR: number;
  35298. /**
  35299. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35300. */
  35301. static readonly RIG_MODE_CUSTOM: number;
  35302. /**
  35303. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35304. */
  35305. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35306. /**
  35307. * Define the input manager associated with the camera.
  35308. */
  35309. inputs: CameraInputsManager<Camera>;
  35310. /** @hidden */
  35311. _position: Vector3;
  35312. /**
  35313. * Define the current local position of the camera in the scene
  35314. */
  35315. get position(): Vector3;
  35316. set position(newPosition: Vector3);
  35317. protected _upVector: Vector3;
  35318. /**
  35319. * The vector the camera should consider as up.
  35320. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35321. */
  35322. set upVector(vec: Vector3);
  35323. get upVector(): Vector3;
  35324. /**
  35325. * Define the current limit on the left side for an orthographic camera
  35326. * In scene unit
  35327. */
  35328. orthoLeft: Nullable<number>;
  35329. /**
  35330. * Define the current limit on the right side for an orthographic camera
  35331. * In scene unit
  35332. */
  35333. orthoRight: Nullable<number>;
  35334. /**
  35335. * Define the current limit on the bottom side for an orthographic camera
  35336. * In scene unit
  35337. */
  35338. orthoBottom: Nullable<number>;
  35339. /**
  35340. * Define the current limit on the top side for an orthographic camera
  35341. * In scene unit
  35342. */
  35343. orthoTop: Nullable<number>;
  35344. /**
  35345. * Field Of View is set in Radians. (default is 0.8)
  35346. */
  35347. fov: number;
  35348. /**
  35349. * Define the minimum distance the camera can see from.
  35350. * This is important to note that the depth buffer are not infinite and the closer it starts
  35351. * the more your scene might encounter depth fighting issue.
  35352. */
  35353. minZ: number;
  35354. /**
  35355. * Define the maximum distance the camera can see to.
  35356. * This is important to note that the depth buffer are not infinite and the further it end
  35357. * the more your scene might encounter depth fighting issue.
  35358. */
  35359. maxZ: number;
  35360. /**
  35361. * Define the default inertia of the camera.
  35362. * This helps giving a smooth feeling to the camera movement.
  35363. */
  35364. inertia: number;
  35365. /**
  35366. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35367. */
  35368. mode: number;
  35369. /**
  35370. * Define whether the camera is intermediate.
  35371. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35372. */
  35373. isIntermediate: boolean;
  35374. /**
  35375. * Define the viewport of the camera.
  35376. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35377. */
  35378. viewport: Viewport;
  35379. /**
  35380. * Restricts the camera to viewing objects with the same layerMask.
  35381. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35382. */
  35383. layerMask: number;
  35384. /**
  35385. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35386. */
  35387. fovMode: number;
  35388. /**
  35389. * Rig mode of the camera.
  35390. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35391. * This is normally controlled byt the camera themselves as internal use.
  35392. */
  35393. cameraRigMode: number;
  35394. /**
  35395. * Defines the distance between both "eyes" in case of a RIG
  35396. */
  35397. interaxialDistance: number;
  35398. /**
  35399. * Defines if stereoscopic rendering is done side by side or over under.
  35400. */
  35401. isStereoscopicSideBySide: boolean;
  35402. /**
  35403. * 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
  35404. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35405. * else in the scene. (Eg. security camera)
  35406. *
  35407. * 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)
  35408. */
  35409. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35410. /**
  35411. * When set, the camera will render to this render target instead of the default canvas
  35412. *
  35413. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35414. */
  35415. outputRenderTarget: Nullable<RenderTargetTexture>;
  35416. /**
  35417. * Observable triggered when the camera view matrix has changed.
  35418. */
  35419. onViewMatrixChangedObservable: Observable<Camera>;
  35420. /**
  35421. * Observable triggered when the camera Projection matrix has changed.
  35422. */
  35423. onProjectionMatrixChangedObservable: Observable<Camera>;
  35424. /**
  35425. * Observable triggered when the inputs have been processed.
  35426. */
  35427. onAfterCheckInputsObservable: Observable<Camera>;
  35428. /**
  35429. * Observable triggered when reset has been called and applied to the camera.
  35430. */
  35431. onRestoreStateObservable: Observable<Camera>;
  35432. /**
  35433. * Is this camera a part of a rig system?
  35434. */
  35435. isRigCamera: boolean;
  35436. /**
  35437. * If isRigCamera set to true this will be set with the parent camera.
  35438. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35439. */
  35440. rigParent?: Camera;
  35441. /** @hidden */
  35442. _cameraRigParams: any;
  35443. /** @hidden */
  35444. _rigCameras: Camera[];
  35445. /** @hidden */
  35446. _rigPostProcess: Nullable<PostProcess>;
  35447. protected _webvrViewMatrix: Matrix;
  35448. /** @hidden */
  35449. _skipRendering: boolean;
  35450. /** @hidden */
  35451. _projectionMatrix: Matrix;
  35452. /** @hidden */
  35453. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35454. /** @hidden */
  35455. _activeMeshes: SmartArray<AbstractMesh>;
  35456. protected _globalPosition: Vector3;
  35457. /** @hidden */
  35458. _computedViewMatrix: Matrix;
  35459. private _doNotComputeProjectionMatrix;
  35460. private _transformMatrix;
  35461. private _frustumPlanes;
  35462. private _refreshFrustumPlanes;
  35463. private _storedFov;
  35464. private _stateStored;
  35465. /**
  35466. * Instantiates a new camera object.
  35467. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35468. * @see https://doc.babylonjs.com/features/cameras
  35469. * @param name Defines the name of the camera in the scene
  35470. * @param position Defines the position of the camera
  35471. * @param scene Defines the scene the camera belongs too
  35472. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35473. */
  35474. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35475. /**
  35476. * Store current camera state (fov, position, etc..)
  35477. * @returns the camera
  35478. */
  35479. storeState(): Camera;
  35480. /**
  35481. * Restores the camera state values if it has been stored. You must call storeState() first
  35482. */
  35483. protected _restoreStateValues(): boolean;
  35484. /**
  35485. * Restored camera state. You must call storeState() first.
  35486. * @returns true if restored and false otherwise
  35487. */
  35488. restoreState(): boolean;
  35489. /**
  35490. * Gets the class name of the camera.
  35491. * @returns the class name
  35492. */
  35493. getClassName(): string;
  35494. /** @hidden */
  35495. readonly _isCamera: boolean;
  35496. /**
  35497. * Gets a string representation of the camera useful for debug purpose.
  35498. * @param fullDetails Defines that a more verboe level of logging is required
  35499. * @returns the string representation
  35500. */
  35501. toString(fullDetails?: boolean): string;
  35502. /**
  35503. * Gets the current world space position of the camera.
  35504. */
  35505. get globalPosition(): Vector3;
  35506. /**
  35507. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35508. * @returns the active meshe list
  35509. */
  35510. getActiveMeshes(): SmartArray<AbstractMesh>;
  35511. /**
  35512. * Check whether a mesh is part of the current active mesh list of the camera
  35513. * @param mesh Defines the mesh to check
  35514. * @returns true if active, false otherwise
  35515. */
  35516. isActiveMesh(mesh: Mesh): boolean;
  35517. /**
  35518. * Is this camera ready to be used/rendered
  35519. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35520. * @return true if the camera is ready
  35521. */
  35522. isReady(completeCheck?: boolean): boolean;
  35523. /** @hidden */
  35524. _initCache(): void;
  35525. /** @hidden */
  35526. _updateCache(ignoreParentClass?: boolean): void;
  35527. /** @hidden */
  35528. _isSynchronized(): boolean;
  35529. /** @hidden */
  35530. _isSynchronizedViewMatrix(): boolean;
  35531. /** @hidden */
  35532. _isSynchronizedProjectionMatrix(): boolean;
  35533. /**
  35534. * Attach the input controls to a specific dom element to get the input from.
  35535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35536. */
  35537. attachControl(noPreventDefault?: boolean): void;
  35538. /**
  35539. * Detach the current controls from the specified dom element.
  35540. */
  35541. detachControl(): void;
  35542. /**
  35543. * Update the camera state according to the different inputs gathered during the frame.
  35544. */
  35545. update(): void;
  35546. /** @hidden */
  35547. _checkInputs(): void;
  35548. /** @hidden */
  35549. get rigCameras(): Camera[];
  35550. /**
  35551. * Gets the post process used by the rig cameras
  35552. */
  35553. get rigPostProcess(): Nullable<PostProcess>;
  35554. /**
  35555. * Internal, gets the first post proces.
  35556. * @returns the first post process to be run on this camera.
  35557. */
  35558. _getFirstPostProcess(): Nullable<PostProcess>;
  35559. private _cascadePostProcessesToRigCams;
  35560. /**
  35561. * Attach a post process to the camera.
  35562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35563. * @param postProcess The post process to attach to the camera
  35564. * @param insertAt The position of the post process in case several of them are in use in the scene
  35565. * @returns the position the post process has been inserted at
  35566. */
  35567. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35568. /**
  35569. * Detach a post process to the camera.
  35570. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35571. * @param postProcess The post process to detach from the camera
  35572. */
  35573. detachPostProcess(postProcess: PostProcess): void;
  35574. /**
  35575. * Gets the current world matrix of the camera
  35576. */
  35577. getWorldMatrix(): Matrix;
  35578. /** @hidden */
  35579. _getViewMatrix(): Matrix;
  35580. /**
  35581. * Gets the current view matrix of the camera.
  35582. * @param force forces the camera to recompute the matrix without looking at the cached state
  35583. * @returns the view matrix
  35584. */
  35585. getViewMatrix(force?: boolean): Matrix;
  35586. /**
  35587. * Freeze the projection matrix.
  35588. * It will prevent the cache check of the camera projection compute and can speed up perf
  35589. * if no parameter of the camera are meant to change
  35590. * @param projection Defines manually a projection if necessary
  35591. */
  35592. freezeProjectionMatrix(projection?: Matrix): void;
  35593. /**
  35594. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35595. */
  35596. unfreezeProjectionMatrix(): void;
  35597. /**
  35598. * Gets the current projection matrix of the camera.
  35599. * @param force forces the camera to recompute the matrix without looking at the cached state
  35600. * @returns the projection matrix
  35601. */
  35602. getProjectionMatrix(force?: boolean): Matrix;
  35603. /**
  35604. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35605. * @returns a Matrix
  35606. */
  35607. getTransformationMatrix(): Matrix;
  35608. private _updateFrustumPlanes;
  35609. /**
  35610. * Checks if a cullable object (mesh...) is in the camera frustum
  35611. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35612. * @param target The object to check
  35613. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35614. * @returns true if the object is in frustum otherwise false
  35615. */
  35616. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35617. /**
  35618. * Checks if a cullable object (mesh...) is in the camera frustum
  35619. * Unlike isInFrustum this cheks the full bounding box
  35620. * @param target The object to check
  35621. * @returns true if the object is in frustum otherwise false
  35622. */
  35623. isCompletelyInFrustum(target: ICullable): boolean;
  35624. /**
  35625. * Gets a ray in the forward direction from the camera.
  35626. * @param length Defines the length of the ray to create
  35627. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35628. * @param origin Defines the start point of the ray which defaults to the camera position
  35629. * @returns the forward ray
  35630. */
  35631. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35632. /**
  35633. * Gets a ray in the forward direction from the camera.
  35634. * @param refRay the ray to (re)use when setting the values
  35635. * @param length Defines the length of the ray to create
  35636. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35637. * @param origin Defines the start point of the ray which defaults to the camera position
  35638. * @returns the forward ray
  35639. */
  35640. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35641. /**
  35642. * Releases resources associated with this node.
  35643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35645. */
  35646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35647. /** @hidden */
  35648. _isLeftCamera: boolean;
  35649. /**
  35650. * Gets the left camera of a rig setup in case of Rigged Camera
  35651. */
  35652. get isLeftCamera(): boolean;
  35653. /** @hidden */
  35654. _isRightCamera: boolean;
  35655. /**
  35656. * Gets the right camera of a rig setup in case of Rigged Camera
  35657. */
  35658. get isRightCamera(): boolean;
  35659. /**
  35660. * Gets the left camera of a rig setup in case of Rigged Camera
  35661. */
  35662. get leftCamera(): Nullable<FreeCamera>;
  35663. /**
  35664. * Gets the right camera of a rig setup in case of Rigged Camera
  35665. */
  35666. get rightCamera(): Nullable<FreeCamera>;
  35667. /**
  35668. * Gets the left camera target of a rig setup in case of Rigged Camera
  35669. * @returns the target position
  35670. */
  35671. getLeftTarget(): Nullable<Vector3>;
  35672. /**
  35673. * Gets the right camera target of a rig setup in case of Rigged Camera
  35674. * @returns the target position
  35675. */
  35676. getRightTarget(): Nullable<Vector3>;
  35677. /**
  35678. * @hidden
  35679. */
  35680. setCameraRigMode(mode: number, rigParams: any): void;
  35681. /** @hidden */
  35682. static _setStereoscopicRigMode(camera: Camera): void;
  35683. /** @hidden */
  35684. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35685. /** @hidden */
  35686. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35687. /** @hidden */
  35688. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35689. /** @hidden */
  35690. _getVRProjectionMatrix(): Matrix;
  35691. protected _updateCameraRotationMatrix(): void;
  35692. protected _updateWebVRCameraRotationMatrix(): void;
  35693. /**
  35694. * This function MUST be overwritten by the different WebVR cameras available.
  35695. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35696. * @hidden
  35697. */
  35698. _getWebVRProjectionMatrix(): Matrix;
  35699. /**
  35700. * This function MUST be overwritten by the different WebVR cameras available.
  35701. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35702. * @hidden
  35703. */
  35704. _getWebVRViewMatrix(): Matrix;
  35705. /** @hidden */
  35706. setCameraRigParameter(name: string, value: any): void;
  35707. /**
  35708. * needs to be overridden by children so sub has required properties to be copied
  35709. * @hidden
  35710. */
  35711. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35712. /**
  35713. * May need to be overridden by children
  35714. * @hidden
  35715. */
  35716. _updateRigCameras(): void;
  35717. /** @hidden */
  35718. _setupInputs(): void;
  35719. /**
  35720. * Serialiaze the camera setup to a json represention
  35721. * @returns the JSON representation
  35722. */
  35723. serialize(): any;
  35724. /**
  35725. * Clones the current camera.
  35726. * @param name The cloned camera name
  35727. * @returns the cloned camera
  35728. */
  35729. clone(name: string): Camera;
  35730. /**
  35731. * Gets the direction of the camera relative to a given local axis.
  35732. * @param localAxis Defines the reference axis to provide a relative direction.
  35733. * @return the direction
  35734. */
  35735. getDirection(localAxis: Vector3): Vector3;
  35736. /**
  35737. * Returns the current camera absolute rotation
  35738. */
  35739. get absoluteRotation(): Quaternion;
  35740. /**
  35741. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35742. * @param localAxis Defines the reference axis to provide a relative direction.
  35743. * @param result Defines the vector to store the result in
  35744. */
  35745. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35746. /**
  35747. * Gets a camera constructor for a given camera type
  35748. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35749. * @param name The name of the camera the result will be able to instantiate
  35750. * @param scene The scene the result will construct the camera in
  35751. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35752. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35753. * @returns a factory method to construc the camera
  35754. */
  35755. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35756. /**
  35757. * Compute the world matrix of the camera.
  35758. * @returns the camera world matrix
  35759. */
  35760. computeWorldMatrix(): Matrix;
  35761. /**
  35762. * Parse a JSON and creates the camera from the parsed information
  35763. * @param parsedCamera The JSON to parse
  35764. * @param scene The scene to instantiate the camera in
  35765. * @returns the newly constructed camera
  35766. */
  35767. static Parse(parsedCamera: any, scene: Scene): Camera;
  35768. }
  35769. }
  35770. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35771. import { Nullable } from "babylonjs/types";
  35772. import { Scene } from "babylonjs/scene";
  35773. import { Vector4 } from "babylonjs/Maths/math.vector";
  35774. import { Mesh } from "babylonjs/Meshes/mesh";
  35775. /**
  35776. * Class containing static functions to help procedurally build meshes
  35777. */
  35778. export class DiscBuilder {
  35779. /**
  35780. * Creates a plane polygonal mesh. By default, this is a disc
  35781. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35782. * * 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
  35783. * * 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
  35784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35787. * @param name defines the name of the mesh
  35788. * @param options defines the options used to create the mesh
  35789. * @param scene defines the hosting scene
  35790. * @returns the plane polygonal mesh
  35791. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35792. */
  35793. static CreateDisc(name: string, options: {
  35794. radius?: number;
  35795. tessellation?: number;
  35796. arc?: number;
  35797. updatable?: boolean;
  35798. sideOrientation?: number;
  35799. frontUVs?: Vector4;
  35800. backUVs?: Vector4;
  35801. }, scene?: Nullable<Scene>): Mesh;
  35802. }
  35803. }
  35804. declare module "babylonjs/Particles/solidParticleSystem" {
  35805. import { Nullable } from "babylonjs/types";
  35806. import { Mesh } from "babylonjs/Meshes/mesh";
  35807. import { Scene, IDisposable } from "babylonjs/scene";
  35808. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35809. import { Material } from "babylonjs/Materials/material";
  35810. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35811. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35812. /**
  35813. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35814. *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.
  35815. * The SPS is also a particle system. It provides some methods to manage the particles.
  35816. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35817. *
  35818. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35819. */
  35820. export class SolidParticleSystem implements IDisposable {
  35821. /**
  35822. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35823. * Example : var p = SPS.particles[i];
  35824. */
  35825. particles: SolidParticle[];
  35826. /**
  35827. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35828. */
  35829. nbParticles: number;
  35830. /**
  35831. * If the particles must ever face the camera (default false). Useful for planar particles.
  35832. */
  35833. billboard: boolean;
  35834. /**
  35835. * Recompute normals when adding a shape
  35836. */
  35837. recomputeNormals: boolean;
  35838. /**
  35839. * This a counter ofr your own usage. It's not set by any SPS functions.
  35840. */
  35841. counter: number;
  35842. /**
  35843. * The SPS name. This name is also given to the underlying mesh.
  35844. */
  35845. name: string;
  35846. /**
  35847. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35848. */
  35849. mesh: Mesh;
  35850. /**
  35851. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35852. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35853. */
  35854. vars: any;
  35855. /**
  35856. * This array is populated when the SPS is set as 'pickable'.
  35857. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35858. * Each element of this array is an object `{idx: int, faceId: int}`.
  35859. * `idx` is the picked particle index in the `SPS.particles` array
  35860. * `faceId` is the picked face index counted within this particle.
  35861. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35862. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35863. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35864. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35865. */
  35866. pickedParticles: {
  35867. idx: number;
  35868. faceId: number;
  35869. }[];
  35870. /**
  35871. * This array is populated when the SPS is set as 'pickable'
  35872. * Each key of this array is a submesh index.
  35873. * Each element of this array is a second array defined like this :
  35874. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35875. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35876. * `idx` is the picked particle index in the `SPS.particles` array
  35877. * `faceId` is the picked face index counted within this particle.
  35878. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35879. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35880. */
  35881. pickedBySubMesh: {
  35882. idx: number;
  35883. faceId: number;
  35884. }[][];
  35885. /**
  35886. * This array is populated when `enableDepthSort` is set to true.
  35887. * Each element of this array is an instance of the class DepthSortedParticle.
  35888. */
  35889. depthSortedParticles: DepthSortedParticle[];
  35890. /**
  35891. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35892. * @hidden
  35893. */
  35894. _bSphereOnly: boolean;
  35895. /**
  35896. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35897. * @hidden
  35898. */
  35899. _bSphereRadiusFactor: number;
  35900. private _scene;
  35901. private _positions;
  35902. private _indices;
  35903. private _normals;
  35904. private _colors;
  35905. private _uvs;
  35906. private _indices32;
  35907. private _positions32;
  35908. private _normals32;
  35909. private _fixedNormal32;
  35910. private _colors32;
  35911. private _uvs32;
  35912. private _index;
  35913. private _updatable;
  35914. private _pickable;
  35915. private _isVisibilityBoxLocked;
  35916. private _alwaysVisible;
  35917. private _depthSort;
  35918. private _expandable;
  35919. private _shapeCounter;
  35920. private _copy;
  35921. private _color;
  35922. private _computeParticleColor;
  35923. private _computeParticleTexture;
  35924. private _computeParticleRotation;
  35925. private _computeParticleVertex;
  35926. private _computeBoundingBox;
  35927. private _depthSortParticles;
  35928. private _camera;
  35929. private _mustUnrotateFixedNormals;
  35930. private _particlesIntersect;
  35931. private _needs32Bits;
  35932. private _isNotBuilt;
  35933. private _lastParticleId;
  35934. private _idxOfId;
  35935. private _multimaterialEnabled;
  35936. private _useModelMaterial;
  35937. private _indicesByMaterial;
  35938. private _materialIndexes;
  35939. private _depthSortFunction;
  35940. private _materialSortFunction;
  35941. private _materials;
  35942. private _multimaterial;
  35943. private _materialIndexesById;
  35944. private _defaultMaterial;
  35945. private _autoUpdateSubMeshes;
  35946. private _tmpVertex;
  35947. /**
  35948. * Creates a SPS (Solid Particle System) object.
  35949. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35950. * @param scene (Scene) is the scene in which the SPS is added.
  35951. * @param options defines the options of the sps e.g.
  35952. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35953. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35954. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35955. * * 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.
  35956. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35957. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35958. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35959. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35960. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35961. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35962. */
  35963. constructor(name: string, scene: Scene, options?: {
  35964. updatable?: boolean;
  35965. isPickable?: boolean;
  35966. enableDepthSort?: boolean;
  35967. particleIntersection?: boolean;
  35968. boundingSphereOnly?: boolean;
  35969. bSphereRadiusFactor?: number;
  35970. expandable?: boolean;
  35971. useModelMaterial?: boolean;
  35972. enableMultiMaterial?: boolean;
  35973. });
  35974. /**
  35975. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35976. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35977. * @returns the created mesh
  35978. */
  35979. buildMesh(): Mesh;
  35980. /**
  35981. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35982. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35983. * Thus the particles generated from `digest()` have their property `position` set yet.
  35984. * @param mesh ( Mesh ) is the mesh to be digested
  35985. * @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
  35986. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35987. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35988. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35989. * @returns the current SPS
  35990. */
  35991. digest(mesh: Mesh, options?: {
  35992. facetNb?: number;
  35993. number?: number;
  35994. delta?: number;
  35995. storage?: [];
  35996. }): SolidParticleSystem;
  35997. /**
  35998. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35999. * @hidden
  36000. */
  36001. private _unrotateFixedNormals;
  36002. /**
  36003. * Resets the temporary working copy particle
  36004. * @hidden
  36005. */
  36006. private _resetCopy;
  36007. /**
  36008. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36009. * @param p the current index in the positions array to be updated
  36010. * @param ind the current index in the indices array
  36011. * @param shape a Vector3 array, the shape geometry
  36012. * @param positions the positions array to be updated
  36013. * @param meshInd the shape indices array
  36014. * @param indices the indices array to be updated
  36015. * @param meshUV the shape uv array
  36016. * @param uvs the uv array to be updated
  36017. * @param meshCol the shape color array
  36018. * @param colors the color array to be updated
  36019. * @param meshNor the shape normals array
  36020. * @param normals the normals array to be updated
  36021. * @param idx the particle index
  36022. * @param idxInShape the particle index in its shape
  36023. * @param options the addShape() method passed options
  36024. * @model the particle model
  36025. * @hidden
  36026. */
  36027. private _meshBuilder;
  36028. /**
  36029. * Returns a shape Vector3 array from positions float array
  36030. * @param positions float array
  36031. * @returns a vector3 array
  36032. * @hidden
  36033. */
  36034. private _posToShape;
  36035. /**
  36036. * Returns a shapeUV array from a float uvs (array deep copy)
  36037. * @param uvs as a float array
  36038. * @returns a shapeUV array
  36039. * @hidden
  36040. */
  36041. private _uvsToShapeUV;
  36042. /**
  36043. * Adds a new particle object in the particles array
  36044. * @param idx particle index in particles array
  36045. * @param id particle id
  36046. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36047. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36048. * @param model particle ModelShape object
  36049. * @param shapeId model shape identifier
  36050. * @param idxInShape index of the particle in the current model
  36051. * @param bInfo model bounding info object
  36052. * @param storage target storage array, if any
  36053. * @hidden
  36054. */
  36055. private _addParticle;
  36056. /**
  36057. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36058. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36059. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36060. * @param nb (positive integer) the number of particles to be created from this model
  36061. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36062. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36063. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36064. * @returns the number of shapes in the system
  36065. */
  36066. addShape(mesh: Mesh, nb: number, options?: {
  36067. positionFunction?: any;
  36068. vertexFunction?: any;
  36069. storage?: [];
  36070. }): number;
  36071. /**
  36072. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36073. * @hidden
  36074. */
  36075. private _rebuildParticle;
  36076. /**
  36077. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36078. * @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.
  36079. * @returns the SPS.
  36080. */
  36081. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36082. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36083. * Returns an array with the removed particles.
  36084. * 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.
  36085. * The SPS can't be empty so at least one particle needs to remain in place.
  36086. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36087. * @param start index of the first particle to remove
  36088. * @param end index of the last particle to remove (included)
  36089. * @returns an array populated with the removed particles
  36090. */
  36091. removeParticles(start: number, end: number): SolidParticle[];
  36092. /**
  36093. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36094. * @param solidParticleArray an array populated with Solid Particles objects
  36095. * @returns the SPS
  36096. */
  36097. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36098. /**
  36099. * Creates a new particle and modifies the SPS mesh geometry :
  36100. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36101. * - calls _addParticle() to populate the particle array
  36102. * factorized code from addShape() and insertParticlesFromArray()
  36103. * @param idx particle index in the particles array
  36104. * @param i particle index in its shape
  36105. * @param modelShape particle ModelShape object
  36106. * @param shape shape vertex array
  36107. * @param meshInd shape indices array
  36108. * @param meshUV shape uv array
  36109. * @param meshCol shape color array
  36110. * @param meshNor shape normals array
  36111. * @param bbInfo shape bounding info
  36112. * @param storage target particle storage
  36113. * @options addShape() passed options
  36114. * @hidden
  36115. */
  36116. private _insertNewParticle;
  36117. /**
  36118. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36119. * This method calls `updateParticle()` for each particle of the SPS.
  36120. * For an animated SPS, it is usually called within the render loop.
  36121. * 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.
  36122. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36123. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36124. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36125. * @returns the SPS.
  36126. */
  36127. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36128. /**
  36129. * Disposes the SPS.
  36130. */
  36131. dispose(): void;
  36132. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36133. * idx is the particle index in the SPS
  36134. * faceId is the picked face index counted within this particle.
  36135. * Returns null if the pickInfo can't identify a picked particle.
  36136. * @param pickingInfo (PickingInfo object)
  36137. * @returns {idx: number, faceId: number} or null
  36138. */
  36139. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36140. idx: number;
  36141. faceId: number;
  36142. }>;
  36143. /**
  36144. * Returns a SolidParticle object from its identifier : particle.id
  36145. * @param id (integer) the particle Id
  36146. * @returns the searched particle or null if not found in the SPS.
  36147. */
  36148. getParticleById(id: number): Nullable<SolidParticle>;
  36149. /**
  36150. * Returns a new array populated with the particles having the passed shapeId.
  36151. * @param shapeId (integer) the shape identifier
  36152. * @returns a new solid particle array
  36153. */
  36154. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36155. /**
  36156. * Populates the passed array "ref" with the particles having the passed shapeId.
  36157. * @param shapeId the shape identifier
  36158. * @returns the SPS
  36159. * @param ref
  36160. */
  36161. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36162. /**
  36163. * Computes the required SubMeshes according the materials assigned to the particles.
  36164. * @returns the solid particle system.
  36165. * Does nothing if called before the SPS mesh is built.
  36166. */
  36167. computeSubMeshes(): SolidParticleSystem;
  36168. /**
  36169. * Sorts the solid particles by material when MultiMaterial is enabled.
  36170. * Updates the indices32 array.
  36171. * Updates the indicesByMaterial array.
  36172. * Updates the mesh indices array.
  36173. * @returns the SPS
  36174. * @hidden
  36175. */
  36176. private _sortParticlesByMaterial;
  36177. /**
  36178. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36179. * @hidden
  36180. */
  36181. private _setMaterialIndexesById;
  36182. /**
  36183. * Returns an array with unique values of Materials from the passed array
  36184. * @param array the material array to be checked and filtered
  36185. * @hidden
  36186. */
  36187. private _filterUniqueMaterialId;
  36188. /**
  36189. * Sets a new Standard Material as _defaultMaterial if not already set.
  36190. * @hidden
  36191. */
  36192. private _setDefaultMaterial;
  36193. /**
  36194. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36195. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36196. * @returns the SPS.
  36197. */
  36198. refreshVisibleSize(): SolidParticleSystem;
  36199. /**
  36200. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36201. * @param size the size (float) of the visibility box
  36202. * note : this doesn't lock the SPS mesh bounding box.
  36203. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36204. */
  36205. setVisibilityBox(size: number): void;
  36206. /**
  36207. * Gets whether the SPS as always visible or not
  36208. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36209. */
  36210. get isAlwaysVisible(): boolean;
  36211. /**
  36212. * Sets the SPS as always visible or not
  36213. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36214. */
  36215. set isAlwaysVisible(val: boolean);
  36216. /**
  36217. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36218. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36219. */
  36220. set isVisibilityBoxLocked(val: boolean);
  36221. /**
  36222. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36223. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36224. */
  36225. get isVisibilityBoxLocked(): boolean;
  36226. /**
  36227. * Tells to `setParticles()` to compute 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. set computeParticleRotation(val: boolean);
  36232. /**
  36233. * Tells to `setParticles()` to compute 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. set computeParticleColor(val: boolean);
  36238. set computeParticleTexture(val: boolean);
  36239. /**
  36240. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36241. * Default value : false. The SPS is faster when it's set to false.
  36242. * Note : the particle custom vertex positions aren't stored values.
  36243. */
  36244. set computeParticleVertex(val: boolean);
  36245. /**
  36246. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36247. */
  36248. set computeBoundingBox(val: boolean);
  36249. /**
  36250. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36251. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36252. * Default : `true`
  36253. */
  36254. set depthSortParticles(val: boolean);
  36255. /**
  36256. * Gets if `setParticles()` computes the particle rotations or not.
  36257. * Default value : true. The SPS is faster when it's set to false.
  36258. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36259. */
  36260. get computeParticleRotation(): boolean;
  36261. /**
  36262. * Gets if `setParticles()` computes the particle colors or not.
  36263. * Default value : true. The SPS is faster when it's set to false.
  36264. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36265. */
  36266. get computeParticleColor(): boolean;
  36267. /**
  36268. * Gets if `setParticles()` computes the particle textures or not.
  36269. * Default value : true. The SPS is faster when it's set to false.
  36270. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36271. */
  36272. get computeParticleTexture(): boolean;
  36273. /**
  36274. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36275. * Default value : false. The SPS is faster when it's set to false.
  36276. * Note : the particle custom vertex positions aren't stored values.
  36277. */
  36278. get computeParticleVertex(): boolean;
  36279. /**
  36280. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36281. */
  36282. get computeBoundingBox(): boolean;
  36283. /**
  36284. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36285. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36286. * Default : `true`
  36287. */
  36288. get depthSortParticles(): boolean;
  36289. /**
  36290. * Gets if the SPS is created as expandable at construction time.
  36291. * Default : `false`
  36292. */
  36293. get expandable(): boolean;
  36294. /**
  36295. * Gets if the SPS supports the Multi Materials
  36296. */
  36297. get multimaterialEnabled(): boolean;
  36298. /**
  36299. * Gets if the SPS uses the model materials for its own multimaterial.
  36300. */
  36301. get useModelMaterial(): boolean;
  36302. /**
  36303. * The SPS used material array.
  36304. */
  36305. get materials(): Material[];
  36306. /**
  36307. * Sets the SPS MultiMaterial from the passed materials.
  36308. * Note : the passed array is internally copied and not used then by reference.
  36309. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36310. */
  36311. setMultiMaterial(materials: Material[]): void;
  36312. /**
  36313. * The SPS computed multimaterial object
  36314. */
  36315. get multimaterial(): MultiMaterial;
  36316. set multimaterial(mm: MultiMaterial);
  36317. /**
  36318. * If the subMeshes must be updated on the next call to setParticles()
  36319. */
  36320. get autoUpdateSubMeshes(): boolean;
  36321. set autoUpdateSubMeshes(val: boolean);
  36322. /**
  36323. * This function does nothing. It may be overwritten to set all the particle first values.
  36324. * The SPS doesn't call this function, you may have to call it by your own.
  36325. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36326. */
  36327. initParticles(): void;
  36328. /**
  36329. * This function does nothing. It may be overwritten to recycle a particle.
  36330. * The SPS doesn't call this function, you may have to call it by your own.
  36331. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36332. * @param particle The particle to recycle
  36333. * @returns the recycled particle
  36334. */
  36335. recycleParticle(particle: SolidParticle): SolidParticle;
  36336. /**
  36337. * Updates a particle : this function should be overwritten by the user.
  36338. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36339. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36340. * @example : just set a particle position or velocity and recycle conditions
  36341. * @param particle The particle to update
  36342. * @returns the updated particle
  36343. */
  36344. updateParticle(particle: SolidParticle): SolidParticle;
  36345. /**
  36346. * Updates a vertex of a particle : it can be overwritten by the user.
  36347. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36348. * @param particle the current particle
  36349. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36350. * @param pt the index of the current vertex in the particle shape
  36351. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36352. * @example : just set a vertex particle position or color
  36353. * @returns the sps
  36354. */
  36355. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36356. /**
  36357. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36358. * This does nothing and may be overwritten by the user.
  36359. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36360. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36361. * @param update the boolean update value actually passed to setParticles()
  36362. */
  36363. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36364. /**
  36365. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36366. * This will be passed three parameters.
  36367. * This does nothing and may be overwritten by the user.
  36368. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36369. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36370. * @param update the boolean update value actually passed to setParticles()
  36371. */
  36372. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36373. }
  36374. }
  36375. declare module "babylonjs/Particles/solidParticle" {
  36376. import { Nullable } from "babylonjs/types";
  36377. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36378. import { Color4 } from "babylonjs/Maths/math.color";
  36379. import { Mesh } from "babylonjs/Meshes/mesh";
  36380. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36381. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36382. import { Plane } from "babylonjs/Maths/math.plane";
  36383. import { Material } from "babylonjs/Materials/material";
  36384. /**
  36385. * Represents one particle of a solid particle system.
  36386. */
  36387. export class SolidParticle {
  36388. /**
  36389. * particle global index
  36390. */
  36391. idx: number;
  36392. /**
  36393. * particle identifier
  36394. */
  36395. id: number;
  36396. /**
  36397. * The color of the particle
  36398. */
  36399. color: Nullable<Color4>;
  36400. /**
  36401. * The world space position of the particle.
  36402. */
  36403. position: Vector3;
  36404. /**
  36405. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36406. */
  36407. rotation: Vector3;
  36408. /**
  36409. * The world space rotation quaternion of the particle.
  36410. */
  36411. rotationQuaternion: Nullable<Quaternion>;
  36412. /**
  36413. * The scaling of the particle.
  36414. */
  36415. scaling: Vector3;
  36416. /**
  36417. * The uvs of the particle.
  36418. */
  36419. uvs: Vector4;
  36420. /**
  36421. * The current speed of the particle.
  36422. */
  36423. velocity: Vector3;
  36424. /**
  36425. * The pivot point in the particle local space.
  36426. */
  36427. pivot: Vector3;
  36428. /**
  36429. * Must the particle be translated from its pivot point in its local space ?
  36430. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36431. * Default : false
  36432. */
  36433. translateFromPivot: boolean;
  36434. /**
  36435. * Is the particle active or not ?
  36436. */
  36437. alive: boolean;
  36438. /**
  36439. * Is the particle visible or not ?
  36440. */
  36441. isVisible: boolean;
  36442. /**
  36443. * Index of this particle in the global "positions" array (Internal use)
  36444. * @hidden
  36445. */
  36446. _pos: number;
  36447. /**
  36448. * @hidden Index of this particle in the global "indices" array (Internal use)
  36449. */
  36450. _ind: number;
  36451. /**
  36452. * @hidden ModelShape of this particle (Internal use)
  36453. */
  36454. _model: ModelShape;
  36455. /**
  36456. * ModelShape id of this particle
  36457. */
  36458. shapeId: number;
  36459. /**
  36460. * Index of the particle in its shape id
  36461. */
  36462. idxInShape: number;
  36463. /**
  36464. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36465. */
  36466. _modelBoundingInfo: BoundingInfo;
  36467. /**
  36468. * @hidden Particle BoundingInfo object (Internal use)
  36469. */
  36470. _boundingInfo: BoundingInfo;
  36471. /**
  36472. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36473. */
  36474. _sps: SolidParticleSystem;
  36475. /**
  36476. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36477. */
  36478. _stillInvisible: boolean;
  36479. /**
  36480. * @hidden Last computed particle rotation matrix
  36481. */
  36482. _rotationMatrix: number[];
  36483. /**
  36484. * Parent particle Id, if any.
  36485. * Default null.
  36486. */
  36487. parentId: Nullable<number>;
  36488. /**
  36489. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36490. */
  36491. materialIndex: Nullable<number>;
  36492. /**
  36493. * Custom object or properties.
  36494. */
  36495. props: Nullable<any>;
  36496. /**
  36497. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36498. * The possible values are :
  36499. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36500. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36501. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36502. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36503. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36504. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36505. * */
  36506. cullingStrategy: number;
  36507. /**
  36508. * @hidden Internal global position in the SPS.
  36509. */
  36510. _globalPosition: Vector3;
  36511. /**
  36512. * Creates a Solid Particle object.
  36513. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36514. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36515. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36516. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36517. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36518. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36519. * @param shapeId (integer) is the model shape identifier in the SPS.
  36520. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36521. * @param sps defines the sps it is associated to
  36522. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36523. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36524. */
  36525. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36526. /**
  36527. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36528. * @param target the particle target
  36529. * @returns the current particle
  36530. */
  36531. copyToRef(target: SolidParticle): SolidParticle;
  36532. /**
  36533. * Legacy support, changed scale to scaling
  36534. */
  36535. get scale(): Vector3;
  36536. /**
  36537. * Legacy support, changed scale to scaling
  36538. */
  36539. set scale(scale: Vector3);
  36540. /**
  36541. * Legacy support, changed quaternion to rotationQuaternion
  36542. */
  36543. get quaternion(): Nullable<Quaternion>;
  36544. /**
  36545. * Legacy support, changed quaternion to rotationQuaternion
  36546. */
  36547. set quaternion(q: Nullable<Quaternion>);
  36548. /**
  36549. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36550. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36551. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36552. * @returns true if it intersects
  36553. */
  36554. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36555. /**
  36556. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36557. * A particle is in the frustum if its bounding box intersects the frustum
  36558. * @param frustumPlanes defines the frustum to test
  36559. * @returns true if the particle is in the frustum planes
  36560. */
  36561. isInFrustum(frustumPlanes: Plane[]): boolean;
  36562. /**
  36563. * get the rotation matrix of the particle
  36564. * @hidden
  36565. */
  36566. getRotationMatrix(m: Matrix): void;
  36567. }
  36568. /**
  36569. * Represents the shape of the model used by one particle of a solid particle system.
  36570. * SPS internal tool, don't use it manually.
  36571. */
  36572. export class ModelShape {
  36573. /**
  36574. * The shape id
  36575. * @hidden
  36576. */
  36577. shapeID: number;
  36578. /**
  36579. * flat array of model positions (internal use)
  36580. * @hidden
  36581. */
  36582. _shape: Vector3[];
  36583. /**
  36584. * flat array of model UVs (internal use)
  36585. * @hidden
  36586. */
  36587. _shapeUV: number[];
  36588. /**
  36589. * color array of the model
  36590. * @hidden
  36591. */
  36592. _shapeColors: number[];
  36593. /**
  36594. * indices array of the model
  36595. * @hidden
  36596. */
  36597. _indices: number[];
  36598. /**
  36599. * normals array of the model
  36600. * @hidden
  36601. */
  36602. _normals: number[];
  36603. /**
  36604. * length of the shape in the model indices array (internal use)
  36605. * @hidden
  36606. */
  36607. _indicesLength: number;
  36608. /**
  36609. * Custom position function (internal use)
  36610. * @hidden
  36611. */
  36612. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36613. /**
  36614. * Custom vertex function (internal use)
  36615. * @hidden
  36616. */
  36617. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36618. /**
  36619. * Model material (internal use)
  36620. * @hidden
  36621. */
  36622. _material: Nullable<Material>;
  36623. /**
  36624. * 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.
  36625. * SPS internal tool, don't use it manually.
  36626. * @hidden
  36627. */
  36628. 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>);
  36629. }
  36630. /**
  36631. * Represents a Depth Sorted Particle in the solid particle system.
  36632. * @hidden
  36633. */
  36634. export class DepthSortedParticle {
  36635. /**
  36636. * Particle index
  36637. */
  36638. idx: number;
  36639. /**
  36640. * Index of the particle in the "indices" array
  36641. */
  36642. ind: number;
  36643. /**
  36644. * Length of the particle shape in the "indices" array
  36645. */
  36646. indicesLength: number;
  36647. /**
  36648. * Squared distance from the particle to the camera
  36649. */
  36650. sqDistance: number;
  36651. /**
  36652. * Material index when used with MultiMaterials
  36653. */
  36654. materialIndex: number;
  36655. /**
  36656. * Creates a new sorted particle
  36657. * @param materialIndex
  36658. */
  36659. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36660. }
  36661. /**
  36662. * Represents a solid particle vertex
  36663. */
  36664. export class SolidParticleVertex {
  36665. /**
  36666. * Vertex position
  36667. */
  36668. position: Vector3;
  36669. /**
  36670. * Vertex color
  36671. */
  36672. color: Color4;
  36673. /**
  36674. * Vertex UV
  36675. */
  36676. uv: Vector2;
  36677. /**
  36678. * Creates a new solid particle vertex
  36679. */
  36680. constructor();
  36681. /** Vertex x coordinate */
  36682. get x(): number;
  36683. set x(val: number);
  36684. /** Vertex y coordinate */
  36685. get y(): number;
  36686. set y(val: number);
  36687. /** Vertex z coordinate */
  36688. get z(): number;
  36689. set z(val: number);
  36690. }
  36691. }
  36692. declare module "babylonjs/Collisions/meshCollisionData" {
  36693. import { Collider } from "babylonjs/Collisions/collider";
  36694. import { Vector3 } from "babylonjs/Maths/math.vector";
  36695. import { Nullable } from "babylonjs/types";
  36696. import { Observer } from "babylonjs/Misc/observable";
  36697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36698. /**
  36699. * @hidden
  36700. */
  36701. export class _MeshCollisionData {
  36702. _checkCollisions: boolean;
  36703. _collisionMask: number;
  36704. _collisionGroup: number;
  36705. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36706. _collider: Nullable<Collider>;
  36707. _oldPositionForCollisions: Vector3;
  36708. _diffPositionForCollisions: Vector3;
  36709. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36710. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36711. _collisionResponse: boolean;
  36712. }
  36713. }
  36714. declare module "babylonjs/Meshes/abstractMesh" {
  36715. import { Observable } from "babylonjs/Misc/observable";
  36716. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36717. import { Camera } from "babylonjs/Cameras/camera";
  36718. import { Scene, IDisposable } from "babylonjs/scene";
  36719. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36720. import { Node } from "babylonjs/node";
  36721. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36722. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36724. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36725. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36726. import { Material } from "babylonjs/Materials/material";
  36727. import { Light } from "babylonjs/Lights/light";
  36728. import { Skeleton } from "babylonjs/Bones/skeleton";
  36729. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36730. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36731. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36732. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36733. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36734. import { Plane } from "babylonjs/Maths/math.plane";
  36735. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36736. import { Ray } from "babylonjs/Culling/ray";
  36737. import { Collider } from "babylonjs/Collisions/collider";
  36738. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36739. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36740. /** @hidden */
  36741. class _FacetDataStorage {
  36742. facetPositions: Vector3[];
  36743. facetNormals: Vector3[];
  36744. facetPartitioning: number[][];
  36745. facetNb: number;
  36746. partitioningSubdivisions: number;
  36747. partitioningBBoxRatio: number;
  36748. facetDataEnabled: boolean;
  36749. facetParameters: any;
  36750. bbSize: Vector3;
  36751. subDiv: {
  36752. max: number;
  36753. X: number;
  36754. Y: number;
  36755. Z: number;
  36756. };
  36757. facetDepthSort: boolean;
  36758. facetDepthSortEnabled: boolean;
  36759. depthSortedIndices: IndicesArray;
  36760. depthSortedFacets: {
  36761. ind: number;
  36762. sqDistance: number;
  36763. }[];
  36764. facetDepthSortFunction: (f1: {
  36765. ind: number;
  36766. sqDistance: number;
  36767. }, f2: {
  36768. ind: number;
  36769. sqDistance: number;
  36770. }) => number;
  36771. facetDepthSortFrom: Vector3;
  36772. facetDepthSortOrigin: Vector3;
  36773. invertedMatrix: Matrix;
  36774. }
  36775. /**
  36776. * @hidden
  36777. **/
  36778. class _InternalAbstractMeshDataInfo {
  36779. _hasVertexAlpha: boolean;
  36780. _useVertexColors: boolean;
  36781. _numBoneInfluencers: number;
  36782. _applyFog: boolean;
  36783. _receiveShadows: boolean;
  36784. _facetData: _FacetDataStorage;
  36785. _visibility: number;
  36786. _skeleton: Nullable<Skeleton>;
  36787. _layerMask: number;
  36788. _computeBonesUsingShaders: boolean;
  36789. _isActive: boolean;
  36790. _onlyForInstances: boolean;
  36791. _isActiveIntermediate: boolean;
  36792. _onlyForInstancesIntermediate: boolean;
  36793. _actAsRegularMesh: boolean;
  36794. _currentLOD: Nullable<AbstractMesh>;
  36795. }
  36796. /**
  36797. * Class used to store all common mesh properties
  36798. */
  36799. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36800. /** No occlusion */
  36801. static OCCLUSION_TYPE_NONE: number;
  36802. /** Occlusion set to optimisitic */
  36803. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36804. /** Occlusion set to strict */
  36805. static OCCLUSION_TYPE_STRICT: number;
  36806. /** Use an accurante occlusion algorithm */
  36807. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36808. /** Use a conservative occlusion algorithm */
  36809. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36810. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36811. * Test order :
  36812. * Is the bounding sphere outside the frustum ?
  36813. * If not, are the bounding box vertices outside the frustum ?
  36814. * It not, then the cullable object is in the frustum.
  36815. */
  36816. static readonly CULLINGSTRATEGY_STANDARD: number;
  36817. /** Culling strategy : Bounding Sphere Only.
  36818. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36819. * It's also less accurate than the standard because some not visible objects can still be selected.
  36820. * Test : is the bounding sphere outside the frustum ?
  36821. * If not, then the cullable object is in the frustum.
  36822. */
  36823. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36824. /** Culling strategy : Optimistic Inclusion.
  36825. * This in an inclusion test first, then the standard exclusion test.
  36826. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36827. * 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.
  36828. * Anyway, it's as accurate as the standard strategy.
  36829. * Test :
  36830. * Is the cullable object bounding sphere center in the frustum ?
  36831. * If not, apply the default culling strategy.
  36832. */
  36833. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36834. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36835. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36836. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36837. * 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.
  36838. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36839. * Test :
  36840. * Is the cullable object bounding sphere center in the frustum ?
  36841. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36842. */
  36843. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36844. /**
  36845. * No billboard
  36846. */
  36847. static get BILLBOARDMODE_NONE(): number;
  36848. /** Billboard on X axis */
  36849. static get BILLBOARDMODE_X(): number;
  36850. /** Billboard on Y axis */
  36851. static get BILLBOARDMODE_Y(): number;
  36852. /** Billboard on Z axis */
  36853. static get BILLBOARDMODE_Z(): number;
  36854. /** Billboard on all axes */
  36855. static get BILLBOARDMODE_ALL(): number;
  36856. /** Billboard on using position instead of orientation */
  36857. static get BILLBOARDMODE_USE_POSITION(): number;
  36858. /** @hidden */
  36859. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36860. /**
  36861. * The culling strategy to use to check whether the mesh must be rendered or not.
  36862. * This value can be changed at any time and will be used on the next render mesh selection.
  36863. * The possible values are :
  36864. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36865. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36866. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36867. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36868. * Please read each static variable documentation to get details about the culling process.
  36869. * */
  36870. cullingStrategy: number;
  36871. /**
  36872. * Gets the number of facets in the mesh
  36873. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36874. */
  36875. get facetNb(): number;
  36876. /**
  36877. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36878. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36879. */
  36880. get partitioningSubdivisions(): number;
  36881. set partitioningSubdivisions(nb: number);
  36882. /**
  36883. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36884. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36885. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36886. */
  36887. get partitioningBBoxRatio(): number;
  36888. set partitioningBBoxRatio(ratio: number);
  36889. /**
  36890. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36891. * Works only for updatable meshes.
  36892. * Doesn't work with multi-materials
  36893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36894. */
  36895. get mustDepthSortFacets(): boolean;
  36896. set mustDepthSortFacets(sort: boolean);
  36897. /**
  36898. * The location (Vector3) where the facet depth sort must be computed from.
  36899. * By default, the active camera position.
  36900. * Used only when facet depth sort is enabled
  36901. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36902. */
  36903. get facetDepthSortFrom(): Vector3;
  36904. set facetDepthSortFrom(location: Vector3);
  36905. /**
  36906. * gets a boolean indicating if facetData is enabled
  36907. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36908. */
  36909. get isFacetDataEnabled(): boolean;
  36910. /** @hidden */
  36911. _updateNonUniformScalingState(value: boolean): boolean;
  36912. /**
  36913. * An event triggered when this mesh collides with another one
  36914. */
  36915. onCollideObservable: Observable<AbstractMesh>;
  36916. /** Set a function to call when this mesh collides with another one */
  36917. set onCollide(callback: () => void);
  36918. /**
  36919. * An event triggered when the collision's position changes
  36920. */
  36921. onCollisionPositionChangeObservable: Observable<Vector3>;
  36922. /** Set a function to call when the collision's position changes */
  36923. set onCollisionPositionChange(callback: () => void);
  36924. /**
  36925. * An event triggered when material is changed
  36926. */
  36927. onMaterialChangedObservable: Observable<AbstractMesh>;
  36928. /**
  36929. * Gets or sets the orientation for POV movement & rotation
  36930. */
  36931. definedFacingForward: boolean;
  36932. /** @hidden */
  36933. _occlusionQuery: Nullable<WebGLQuery>;
  36934. /** @hidden */
  36935. _renderingGroup: Nullable<RenderingGroup>;
  36936. /**
  36937. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36938. */
  36939. get visibility(): number;
  36940. /**
  36941. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36942. */
  36943. set visibility(value: number);
  36944. /** Gets or sets the alpha index used to sort transparent meshes
  36945. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36946. */
  36947. alphaIndex: number;
  36948. /**
  36949. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36950. */
  36951. isVisible: boolean;
  36952. /**
  36953. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36954. */
  36955. isPickable: boolean;
  36956. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36957. showSubMeshesBoundingBox: boolean;
  36958. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36959. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36960. */
  36961. isBlocker: boolean;
  36962. /**
  36963. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36964. */
  36965. enablePointerMoveEvents: boolean;
  36966. private _renderingGroupId;
  36967. /**
  36968. * Specifies the rendering group id for this mesh (0 by default)
  36969. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36970. */
  36971. get renderingGroupId(): number;
  36972. set renderingGroupId(value: number);
  36973. private _material;
  36974. /** Gets or sets current material */
  36975. get material(): Nullable<Material>;
  36976. set material(value: Nullable<Material>);
  36977. /**
  36978. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36979. * @see https://doc.babylonjs.com/babylon101/shadows
  36980. */
  36981. get receiveShadows(): boolean;
  36982. set receiveShadows(value: boolean);
  36983. /** Defines color to use when rendering outline */
  36984. outlineColor: Color3;
  36985. /** Define width to use when rendering outline */
  36986. outlineWidth: number;
  36987. /** Defines color to use when rendering overlay */
  36988. overlayColor: Color3;
  36989. /** Defines alpha to use when rendering overlay */
  36990. overlayAlpha: number;
  36991. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36992. get hasVertexAlpha(): boolean;
  36993. set hasVertexAlpha(value: boolean);
  36994. /** 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) */
  36995. get useVertexColors(): boolean;
  36996. set useVertexColors(value: boolean);
  36997. /**
  36998. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36999. */
  37000. get computeBonesUsingShaders(): boolean;
  37001. set computeBonesUsingShaders(value: boolean);
  37002. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  37003. get numBoneInfluencers(): number;
  37004. set numBoneInfluencers(value: number);
  37005. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  37006. get applyFog(): boolean;
  37007. set applyFog(value: boolean);
  37008. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37009. useOctreeForRenderingSelection: boolean;
  37010. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37011. useOctreeForPicking: boolean;
  37012. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37013. useOctreeForCollisions: boolean;
  37014. /**
  37015. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37016. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37017. */
  37018. get layerMask(): number;
  37019. set layerMask(value: number);
  37020. /**
  37021. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37022. */
  37023. alwaysSelectAsActiveMesh: boolean;
  37024. /**
  37025. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37026. */
  37027. doNotSyncBoundingInfo: boolean;
  37028. /**
  37029. * Gets or sets the current action manager
  37030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37031. */
  37032. actionManager: Nullable<AbstractActionManager>;
  37033. private _meshCollisionData;
  37034. /**
  37035. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37036. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37037. */
  37038. ellipsoid: Vector3;
  37039. /**
  37040. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37041. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37042. */
  37043. ellipsoidOffset: Vector3;
  37044. /**
  37045. * Gets or sets a collision mask used to mask collisions (default is -1).
  37046. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37047. */
  37048. get collisionMask(): number;
  37049. set collisionMask(mask: number);
  37050. /**
  37051. * Gets or sets a collision response flag (default is true).
  37052. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37053. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37054. * to respond to the collision.
  37055. */
  37056. get collisionResponse(): boolean;
  37057. set collisionResponse(response: boolean);
  37058. /**
  37059. * Gets or sets the current collision group mask (-1 by default).
  37060. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37061. */
  37062. get collisionGroup(): number;
  37063. set collisionGroup(mask: number);
  37064. /**
  37065. * Gets or sets current surrounding meshes (null by default).
  37066. *
  37067. * By default collision detection is tested against every mesh in the scene.
  37068. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37069. * meshes will be tested for the collision.
  37070. *
  37071. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37072. */
  37073. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37074. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37075. /**
  37076. * Defines edge width used when edgesRenderer is enabled
  37077. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37078. */
  37079. edgesWidth: number;
  37080. /**
  37081. * Defines edge color used when edgesRenderer is enabled
  37082. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37083. */
  37084. edgesColor: Color4;
  37085. /** @hidden */
  37086. _edgesRenderer: Nullable<IEdgesRenderer>;
  37087. /** @hidden */
  37088. _masterMesh: Nullable<AbstractMesh>;
  37089. /** @hidden */
  37090. _boundingInfo: Nullable<BoundingInfo>;
  37091. /** @hidden */
  37092. _renderId: number;
  37093. /**
  37094. * Gets or sets the list of subMeshes
  37095. * @see https://doc.babylonjs.com/how_to/multi_materials
  37096. */
  37097. subMeshes: SubMesh[];
  37098. /** @hidden */
  37099. _intersectionsInProgress: AbstractMesh[];
  37100. /** @hidden */
  37101. _unIndexed: boolean;
  37102. /** @hidden */
  37103. _lightSources: Light[];
  37104. /** Gets the list of lights affecting that mesh */
  37105. get lightSources(): Light[];
  37106. /** @hidden */
  37107. get _positions(): Nullable<Vector3[]>;
  37108. /** @hidden */
  37109. _waitingData: {
  37110. lods: Nullable<any>;
  37111. actions: Nullable<any>;
  37112. freezeWorldMatrix: Nullable<boolean>;
  37113. };
  37114. /** @hidden */
  37115. _bonesTransformMatrices: Nullable<Float32Array>;
  37116. /** @hidden */
  37117. _transformMatrixTexture: Nullable<RawTexture>;
  37118. /**
  37119. * Gets or sets a skeleton to apply skining transformations
  37120. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37121. */
  37122. set skeleton(value: Nullable<Skeleton>);
  37123. get skeleton(): Nullable<Skeleton>;
  37124. /**
  37125. * An event triggered when the mesh is rebuilt.
  37126. */
  37127. onRebuildObservable: Observable<AbstractMesh>;
  37128. /**
  37129. * Creates a new AbstractMesh
  37130. * @param name defines the name of the mesh
  37131. * @param scene defines the hosting scene
  37132. */
  37133. constructor(name: string, scene?: Nullable<Scene>);
  37134. /**
  37135. * Returns the string "AbstractMesh"
  37136. * @returns "AbstractMesh"
  37137. */
  37138. getClassName(): string;
  37139. /**
  37140. * Gets a string representation of the current mesh
  37141. * @param fullDetails defines a boolean indicating if full details must be included
  37142. * @returns a string representation of the current mesh
  37143. */
  37144. toString(fullDetails?: boolean): string;
  37145. /**
  37146. * @hidden
  37147. */
  37148. protected _getEffectiveParent(): Nullable<Node>;
  37149. /** @hidden */
  37150. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37151. /** @hidden */
  37152. _rebuild(): void;
  37153. /** @hidden */
  37154. _resyncLightSources(): void;
  37155. /** @hidden */
  37156. _resyncLightSource(light: Light): void;
  37157. /** @hidden */
  37158. _unBindEffect(): void;
  37159. /** @hidden */
  37160. _removeLightSource(light: Light, dispose: boolean): void;
  37161. private _markSubMeshesAsDirty;
  37162. /** @hidden */
  37163. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37164. /** @hidden */
  37165. _markSubMeshesAsAttributesDirty(): void;
  37166. /** @hidden */
  37167. _markSubMeshesAsMiscDirty(): void;
  37168. /**
  37169. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37170. */
  37171. get scaling(): Vector3;
  37172. set scaling(newScaling: Vector3);
  37173. /**
  37174. * Returns true if the mesh is blocked. Implemented by child classes
  37175. */
  37176. get isBlocked(): boolean;
  37177. /**
  37178. * Returns the mesh itself by default. Implemented by child classes
  37179. * @param camera defines the camera to use to pick the right LOD level
  37180. * @returns the currentAbstractMesh
  37181. */
  37182. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37183. /**
  37184. * Returns 0 by default. Implemented by child classes
  37185. * @returns an integer
  37186. */
  37187. getTotalVertices(): number;
  37188. /**
  37189. * Returns a positive integer : the total number of indices in this mesh geometry.
  37190. * @returns the numner of indices or zero if the mesh has no geometry.
  37191. */
  37192. getTotalIndices(): number;
  37193. /**
  37194. * Returns null by default. Implemented by child classes
  37195. * @returns null
  37196. */
  37197. getIndices(): Nullable<IndicesArray>;
  37198. /**
  37199. * Returns the array of the requested vertex data kind. Implemented by child classes
  37200. * @param kind defines the vertex data kind to use
  37201. * @returns null
  37202. */
  37203. getVerticesData(kind: string): Nullable<FloatArray>;
  37204. /**
  37205. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37206. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37207. * Note that a new underlying VertexBuffer object is created each call.
  37208. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37209. * @param kind defines vertex data kind:
  37210. * * VertexBuffer.PositionKind
  37211. * * VertexBuffer.UVKind
  37212. * * VertexBuffer.UV2Kind
  37213. * * VertexBuffer.UV3Kind
  37214. * * VertexBuffer.UV4Kind
  37215. * * VertexBuffer.UV5Kind
  37216. * * VertexBuffer.UV6Kind
  37217. * * VertexBuffer.ColorKind
  37218. * * VertexBuffer.MatricesIndicesKind
  37219. * * VertexBuffer.MatricesIndicesExtraKind
  37220. * * VertexBuffer.MatricesWeightsKind
  37221. * * VertexBuffer.MatricesWeightsExtraKind
  37222. * @param data defines the data source
  37223. * @param updatable defines if the data must be flagged as updatable (or static)
  37224. * @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
  37225. * @returns the current mesh
  37226. */
  37227. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37228. /**
  37229. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37230. * If the mesh has no geometry, it is simply returned as it is.
  37231. * @param kind defines vertex data kind:
  37232. * * VertexBuffer.PositionKind
  37233. * * VertexBuffer.UVKind
  37234. * * VertexBuffer.UV2Kind
  37235. * * VertexBuffer.UV3Kind
  37236. * * VertexBuffer.UV4Kind
  37237. * * VertexBuffer.UV5Kind
  37238. * * VertexBuffer.UV6Kind
  37239. * * VertexBuffer.ColorKind
  37240. * * VertexBuffer.MatricesIndicesKind
  37241. * * VertexBuffer.MatricesIndicesExtraKind
  37242. * * VertexBuffer.MatricesWeightsKind
  37243. * * VertexBuffer.MatricesWeightsExtraKind
  37244. * @param data defines the data source
  37245. * @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
  37246. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37247. * @returns the current mesh
  37248. */
  37249. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37250. /**
  37251. * Sets the mesh indices,
  37252. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37253. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37254. * @param totalVertices Defines the total number of vertices
  37255. * @returns the current mesh
  37256. */
  37257. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37258. /**
  37259. * Gets a boolean indicating if specific vertex data is present
  37260. * @param kind defines the vertex data kind to use
  37261. * @returns true is data kind is present
  37262. */
  37263. isVerticesDataPresent(kind: string): boolean;
  37264. /**
  37265. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37266. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37267. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37268. * @returns a BoundingInfo
  37269. */
  37270. getBoundingInfo(): BoundingInfo;
  37271. /**
  37272. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37273. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37274. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37275. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37276. * @returns the current mesh
  37277. */
  37278. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37279. /**
  37280. * Overwrite the current bounding info
  37281. * @param boundingInfo defines the new bounding info
  37282. * @returns the current mesh
  37283. */
  37284. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37285. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37286. get useBones(): boolean;
  37287. /** @hidden */
  37288. _preActivate(): void;
  37289. /** @hidden */
  37290. _preActivateForIntermediateRendering(renderId: number): void;
  37291. /** @hidden */
  37292. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37293. /** @hidden */
  37294. _postActivate(): void;
  37295. /** @hidden */
  37296. _freeze(): void;
  37297. /** @hidden */
  37298. _unFreeze(): void;
  37299. /**
  37300. * Gets the current world matrix
  37301. * @returns a Matrix
  37302. */
  37303. getWorldMatrix(): Matrix;
  37304. /** @hidden */
  37305. _getWorldMatrixDeterminant(): number;
  37306. /**
  37307. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37308. */
  37309. get isAnInstance(): boolean;
  37310. /**
  37311. * Gets a boolean indicating if this mesh has instances
  37312. */
  37313. get hasInstances(): boolean;
  37314. /**
  37315. * Gets a boolean indicating if this mesh has thin instances
  37316. */
  37317. get hasThinInstances(): boolean;
  37318. /**
  37319. * Perform relative position change from the point of view of behind the front of the mesh.
  37320. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37321. * Supports definition of mesh facing forward or backward
  37322. * @param amountRight defines the distance on the right axis
  37323. * @param amountUp defines the distance on the up axis
  37324. * @param amountForward defines the distance on the forward axis
  37325. * @returns the current mesh
  37326. */
  37327. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37328. /**
  37329. * Calculate relative position change from the point of view of behind the front of the mesh.
  37330. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37331. * Supports definition of mesh facing forward or backward
  37332. * @param amountRight defines the distance on the right axis
  37333. * @param amountUp defines the distance on the up axis
  37334. * @param amountForward defines the distance on the forward axis
  37335. * @returns the new displacement vector
  37336. */
  37337. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37338. /**
  37339. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37340. * Supports definition of mesh facing forward or backward
  37341. * @param flipBack defines the flip
  37342. * @param twirlClockwise defines the twirl
  37343. * @param tiltRight defines the tilt
  37344. * @returns the current mesh
  37345. */
  37346. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37347. /**
  37348. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37349. * Supports definition of mesh facing forward or backward.
  37350. * @param flipBack defines the flip
  37351. * @param twirlClockwise defines the twirl
  37352. * @param tiltRight defines the tilt
  37353. * @returns the new rotation vector
  37354. */
  37355. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37356. /**
  37357. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37358. * This means the mesh underlying bounding box and sphere are recomputed.
  37359. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37360. * @returns the current mesh
  37361. */
  37362. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37363. /** @hidden */
  37364. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37365. /** @hidden */
  37366. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37367. /** @hidden */
  37368. _updateBoundingInfo(): AbstractMesh;
  37369. /** @hidden */
  37370. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37371. /** @hidden */
  37372. protected _afterComputeWorldMatrix(): void;
  37373. /** @hidden */
  37374. get _effectiveMesh(): AbstractMesh;
  37375. /**
  37376. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37377. * A mesh is in the frustum if its bounding box intersects the frustum
  37378. * @param frustumPlanes defines the frustum to test
  37379. * @returns true if the mesh is in the frustum planes
  37380. */
  37381. isInFrustum(frustumPlanes: Plane[]): boolean;
  37382. /**
  37383. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37384. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37385. * @param frustumPlanes defines the frustum to test
  37386. * @returns true if the mesh is completely in the frustum planes
  37387. */
  37388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37389. /**
  37390. * True if the mesh intersects another mesh or a SolidParticle object
  37391. * @param mesh defines a target mesh or SolidParticle to test
  37392. * @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)
  37393. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37394. * @returns true if there is an intersection
  37395. */
  37396. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37397. /**
  37398. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37399. * @param point defines the point to test
  37400. * @returns true if there is an intersection
  37401. */
  37402. intersectsPoint(point: Vector3): boolean;
  37403. /**
  37404. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37405. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37406. */
  37407. get checkCollisions(): boolean;
  37408. set checkCollisions(collisionEnabled: boolean);
  37409. /**
  37410. * Gets Collider object used to compute collisions (not physics)
  37411. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37412. */
  37413. get collider(): Nullable<Collider>;
  37414. /**
  37415. * Move the mesh using collision engine
  37416. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37417. * @param displacement defines the requested displacement vector
  37418. * @returns the current mesh
  37419. */
  37420. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37421. private _onCollisionPositionChange;
  37422. /** @hidden */
  37423. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37424. /** @hidden */
  37425. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37426. /** @hidden */
  37427. _checkCollision(collider: Collider): AbstractMesh;
  37428. /** @hidden */
  37429. _generatePointsArray(): boolean;
  37430. /**
  37431. * Checks if the passed Ray intersects with the mesh
  37432. * @param ray defines the ray to use
  37433. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37434. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37435. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37436. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37437. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37438. * @returns the picking info
  37439. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37440. */
  37441. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37442. /**
  37443. * Clones the current mesh
  37444. * @param name defines the mesh name
  37445. * @param newParent defines the new mesh parent
  37446. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37447. * @returns the new mesh
  37448. */
  37449. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37450. /**
  37451. * Disposes all the submeshes of the current meshnp
  37452. * @returns the current mesh
  37453. */
  37454. releaseSubMeshes(): AbstractMesh;
  37455. /**
  37456. * Releases resources associated with this abstract mesh.
  37457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37459. */
  37460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37461. /**
  37462. * Adds the passed mesh as a child to the current mesh
  37463. * @param mesh defines the child mesh
  37464. * @returns the current mesh
  37465. */
  37466. addChild(mesh: AbstractMesh): AbstractMesh;
  37467. /**
  37468. * Removes the passed mesh from the current mesh children list
  37469. * @param mesh defines the child mesh
  37470. * @returns the current mesh
  37471. */
  37472. removeChild(mesh: AbstractMesh): AbstractMesh;
  37473. /** @hidden */
  37474. private _initFacetData;
  37475. /**
  37476. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37477. * This method can be called within the render loop.
  37478. * 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
  37479. * @returns the current mesh
  37480. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37481. */
  37482. updateFacetData(): AbstractMesh;
  37483. /**
  37484. * Returns the facetLocalNormals array.
  37485. * The normals are expressed in the mesh local spac
  37486. * @returns an array of Vector3
  37487. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37488. */
  37489. getFacetLocalNormals(): Vector3[];
  37490. /**
  37491. * Returns the facetLocalPositions array.
  37492. * The facet positions are expressed in the mesh local space
  37493. * @returns an array of Vector3
  37494. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37495. */
  37496. getFacetLocalPositions(): Vector3[];
  37497. /**
  37498. * Returns the facetLocalPartioning array
  37499. * @returns an array of array of numbers
  37500. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37501. */
  37502. getFacetLocalPartitioning(): number[][];
  37503. /**
  37504. * Returns the i-th facet position in the world system.
  37505. * This method allocates a new Vector3 per call
  37506. * @param i defines the facet index
  37507. * @returns a new Vector3
  37508. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37509. */
  37510. getFacetPosition(i: number): Vector3;
  37511. /**
  37512. * Sets the reference Vector3 with the i-th facet position in the world system
  37513. * @param i defines the facet index
  37514. * @param ref defines the target vector
  37515. * @returns the current mesh
  37516. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37517. */
  37518. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37519. /**
  37520. * Returns the i-th facet normal in the world system.
  37521. * This method allocates a new Vector3 per call
  37522. * @param i defines the facet index
  37523. * @returns a new Vector3
  37524. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37525. */
  37526. getFacetNormal(i: number): Vector3;
  37527. /**
  37528. * Sets the reference Vector3 with the i-th facet normal in the world system
  37529. * @param i defines the facet index
  37530. * @param ref defines the target vector
  37531. * @returns the current mesh
  37532. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37533. */
  37534. getFacetNormalToRef(i: number, ref: Vector3): this;
  37535. /**
  37536. * 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)
  37537. * @param x defines x coordinate
  37538. * @param y defines y coordinate
  37539. * @param z defines z coordinate
  37540. * @returns the array of facet indexes
  37541. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37542. */
  37543. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37544. /**
  37545. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37546. * @param projected sets as the (x,y,z) world projection on the facet
  37547. * @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
  37548. * @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
  37549. * @param x defines x coordinate
  37550. * @param y defines y coordinate
  37551. * @param z defines z coordinate
  37552. * @returns the face index if found (or null instead)
  37553. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37554. */
  37555. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37556. /**
  37557. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37558. * @param projected sets as the (x,y,z) local projection on the facet
  37559. * @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
  37560. * @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
  37561. * @param x defines x coordinate
  37562. * @param y defines y coordinate
  37563. * @param z defines z coordinate
  37564. * @returns the face index if found (or null instead)
  37565. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37566. */
  37567. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37568. /**
  37569. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37570. * @returns the parameters
  37571. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37572. */
  37573. getFacetDataParameters(): any;
  37574. /**
  37575. * Disables the feature FacetData and frees the related memory
  37576. * @returns the current mesh
  37577. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37578. */
  37579. disableFacetData(): AbstractMesh;
  37580. /**
  37581. * Updates the AbstractMesh indices array
  37582. * @param indices defines the data source
  37583. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37584. * @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)
  37585. * @returns the current mesh
  37586. */
  37587. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37588. /**
  37589. * Creates new normals data for the mesh
  37590. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37591. * @returns the current mesh
  37592. */
  37593. createNormals(updatable: boolean): AbstractMesh;
  37594. /**
  37595. * Align the mesh with a normal
  37596. * @param normal defines the normal to use
  37597. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37598. * @returns the current mesh
  37599. */
  37600. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37601. /** @hidden */
  37602. _checkOcclusionQuery(): boolean;
  37603. /**
  37604. * Disables the mesh edge rendering mode
  37605. * @returns the currentAbstractMesh
  37606. */
  37607. disableEdgesRendering(): AbstractMesh;
  37608. /**
  37609. * Enables the edge rendering mode on the mesh.
  37610. * This mode makes the mesh edges visible
  37611. * @param epsilon defines the maximal distance between two angles to detect a face
  37612. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37613. * @returns the currentAbstractMesh
  37614. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37615. */
  37616. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37617. /**
  37618. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37619. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37620. */
  37621. getConnectedParticleSystems(): IParticleSystem[];
  37622. }
  37623. }
  37624. declare module "babylonjs/Actions/actionEvent" {
  37625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37626. import { Nullable } from "babylonjs/types";
  37627. import { Sprite } from "babylonjs/Sprites/sprite";
  37628. import { Scene } from "babylonjs/scene";
  37629. import { Vector2 } from "babylonjs/Maths/math.vector";
  37630. /**
  37631. * Interface used to define ActionEvent
  37632. */
  37633. export interface IActionEvent {
  37634. /** The mesh or sprite that triggered the action */
  37635. source: any;
  37636. /** The X mouse cursor position at the time of the event */
  37637. pointerX: number;
  37638. /** The Y mouse cursor position at the time of the event */
  37639. pointerY: number;
  37640. /** The mesh that is currently pointed at (can be null) */
  37641. meshUnderPointer: Nullable<AbstractMesh>;
  37642. /** the original (browser) event that triggered the ActionEvent */
  37643. sourceEvent?: any;
  37644. /** additional data for the event */
  37645. additionalData?: any;
  37646. }
  37647. /**
  37648. * ActionEvent is the event being sent when an action is triggered.
  37649. */
  37650. export class ActionEvent implements IActionEvent {
  37651. /** The mesh or sprite that triggered the action */
  37652. source: any;
  37653. /** The X mouse cursor position at the time of the event */
  37654. pointerX: number;
  37655. /** The Y mouse cursor position at the time of the event */
  37656. pointerY: number;
  37657. /** The mesh that is currently pointed at (can be null) */
  37658. meshUnderPointer: Nullable<AbstractMesh>;
  37659. /** the original (browser) event that triggered the ActionEvent */
  37660. sourceEvent?: any;
  37661. /** additional data for the event */
  37662. additionalData?: any;
  37663. /**
  37664. * Creates a new ActionEvent
  37665. * @param source The mesh or sprite that triggered the action
  37666. * @param pointerX The X mouse cursor position at the time of the event
  37667. * @param pointerY The Y mouse cursor position at the time of the event
  37668. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37669. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37670. * @param additionalData additional data for the event
  37671. */
  37672. constructor(
  37673. /** The mesh or sprite that triggered the action */
  37674. source: any,
  37675. /** The X mouse cursor position at the time of the event */
  37676. pointerX: number,
  37677. /** The Y mouse cursor position at the time of the event */
  37678. pointerY: number,
  37679. /** The mesh that is currently pointed at (can be null) */
  37680. meshUnderPointer: Nullable<AbstractMesh>,
  37681. /** the original (browser) event that triggered the ActionEvent */
  37682. sourceEvent?: any,
  37683. /** additional data for the event */
  37684. additionalData?: any);
  37685. /**
  37686. * Helper function to auto-create an ActionEvent from a source mesh.
  37687. * @param source The source mesh that triggered the event
  37688. * @param evt The original (browser) event
  37689. * @param additionalData additional data for the event
  37690. * @returns the new ActionEvent
  37691. */
  37692. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37693. /**
  37694. * Helper function to auto-create an ActionEvent from a source sprite
  37695. * @param source The source sprite that triggered the event
  37696. * @param scene Scene associated with the sprite
  37697. * @param evt The original (browser) event
  37698. * @param additionalData additional data for the event
  37699. * @returns the new ActionEvent
  37700. */
  37701. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37702. /**
  37703. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37704. * @param scene the scene where the event occurred
  37705. * @param evt The original (browser) event
  37706. * @returns the new ActionEvent
  37707. */
  37708. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37709. /**
  37710. * Helper function to auto-create an ActionEvent from a primitive
  37711. * @param prim defines the target primitive
  37712. * @param pointerPos defines the pointer position
  37713. * @param evt The original (browser) event
  37714. * @param additionalData additional data for the event
  37715. * @returns the new ActionEvent
  37716. */
  37717. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37718. }
  37719. }
  37720. declare module "babylonjs/Actions/abstractActionManager" {
  37721. import { IDisposable } from "babylonjs/scene";
  37722. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37723. import { IAction } from "babylonjs/Actions/action";
  37724. import { Nullable } from "babylonjs/types";
  37725. /**
  37726. * Abstract class used to decouple action Manager from scene and meshes.
  37727. * Do not instantiate.
  37728. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37729. */
  37730. export abstract class AbstractActionManager implements IDisposable {
  37731. /** Gets the list of active triggers */
  37732. static Triggers: {
  37733. [key: string]: number;
  37734. };
  37735. /** Gets the cursor to use when hovering items */
  37736. hoverCursor: string;
  37737. /** Gets the list of actions */
  37738. actions: IAction[];
  37739. /**
  37740. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37741. */
  37742. isRecursive: boolean;
  37743. /**
  37744. * Releases all associated resources
  37745. */
  37746. abstract dispose(): void;
  37747. /**
  37748. * Does this action manager has pointer triggers
  37749. */
  37750. abstract get hasPointerTriggers(): boolean;
  37751. /**
  37752. * Does this action manager has pick triggers
  37753. */
  37754. abstract get hasPickTriggers(): boolean;
  37755. /**
  37756. * Process a specific trigger
  37757. * @param trigger defines the trigger to process
  37758. * @param evt defines the event details to be processed
  37759. */
  37760. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37761. /**
  37762. * Does this action manager handles actions of any of the given triggers
  37763. * @param triggers defines the triggers to be tested
  37764. * @return a boolean indicating whether one (or more) of the triggers is handled
  37765. */
  37766. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37767. /**
  37768. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37769. * speed.
  37770. * @param triggerA defines the trigger to be tested
  37771. * @param triggerB defines the trigger to be tested
  37772. * @return a boolean indicating whether one (or more) of the triggers is handled
  37773. */
  37774. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37775. /**
  37776. * Does this action manager handles actions of a given trigger
  37777. * @param trigger defines the trigger to be tested
  37778. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37779. * @return whether the trigger is handled
  37780. */
  37781. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37782. /**
  37783. * Serialize this manager to a JSON object
  37784. * @param name defines the property name to store this manager
  37785. * @returns a JSON representation of this manager
  37786. */
  37787. abstract serialize(name: string): any;
  37788. /**
  37789. * Registers an action to this action manager
  37790. * @param action defines the action to be registered
  37791. * @return the action amended (prepared) after registration
  37792. */
  37793. abstract registerAction(action: IAction): Nullable<IAction>;
  37794. /**
  37795. * Unregisters an action to this action manager
  37796. * @param action defines the action to be unregistered
  37797. * @return a boolean indicating whether the action has been unregistered
  37798. */
  37799. abstract unregisterAction(action: IAction): Boolean;
  37800. /**
  37801. * Does exist one action manager with at least one trigger
  37802. **/
  37803. static get HasTriggers(): boolean;
  37804. /**
  37805. * Does exist one action manager with at least one pick trigger
  37806. **/
  37807. static get HasPickTriggers(): boolean;
  37808. /**
  37809. * Does exist one action manager that handles actions of a given trigger
  37810. * @param trigger defines the trigger to be tested
  37811. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37812. **/
  37813. static HasSpecificTrigger(trigger: number): boolean;
  37814. }
  37815. }
  37816. declare module "babylonjs/node" {
  37817. import { Scene } from "babylonjs/scene";
  37818. import { Nullable } from "babylonjs/types";
  37819. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37820. import { Engine } from "babylonjs/Engines/engine";
  37821. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37822. import { Observable } from "babylonjs/Misc/observable";
  37823. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37824. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37825. import { Animatable } from "babylonjs/Animations/animatable";
  37826. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37827. import { Animation } from "babylonjs/Animations/animation";
  37828. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37830. /**
  37831. * Defines how a node can be built from a string name.
  37832. */
  37833. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37834. /**
  37835. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37836. */
  37837. export class Node implements IBehaviorAware<Node> {
  37838. /** @hidden */
  37839. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37840. private static _NodeConstructors;
  37841. /**
  37842. * Add a new node constructor
  37843. * @param type defines the type name of the node to construct
  37844. * @param constructorFunc defines the constructor function
  37845. */
  37846. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37847. /**
  37848. * Returns a node constructor based on type name
  37849. * @param type defines the type name
  37850. * @param name defines the new node name
  37851. * @param scene defines the hosting scene
  37852. * @param options defines optional options to transmit to constructors
  37853. * @returns the new constructor or null
  37854. */
  37855. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37856. /**
  37857. * Gets or sets the name of the node
  37858. */
  37859. name: string;
  37860. /**
  37861. * Gets or sets the id of the node
  37862. */
  37863. id: string;
  37864. /**
  37865. * Gets or sets the unique id of the node
  37866. */
  37867. uniqueId: number;
  37868. /**
  37869. * Gets or sets a string used to store user defined state for the node
  37870. */
  37871. state: string;
  37872. /**
  37873. * Gets or sets an object used to store user defined information for the node
  37874. */
  37875. metadata: any;
  37876. /**
  37877. * For internal use only. Please do not use.
  37878. */
  37879. reservedDataStore: any;
  37880. /**
  37881. * List of inspectable custom properties (used by the Inspector)
  37882. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37883. */
  37884. inspectableCustomProperties: IInspectable[];
  37885. private _doNotSerialize;
  37886. /**
  37887. * Gets or sets a boolean used to define if the node must be serialized
  37888. */
  37889. get doNotSerialize(): boolean;
  37890. set doNotSerialize(value: boolean);
  37891. /** @hidden */
  37892. _isDisposed: boolean;
  37893. /**
  37894. * Gets a list of Animations associated with the node
  37895. */
  37896. animations: import("babylonjs/Animations/animation").Animation[];
  37897. protected _ranges: {
  37898. [name: string]: Nullable<AnimationRange>;
  37899. };
  37900. /**
  37901. * Callback raised when the node is ready to be used
  37902. */
  37903. onReady: Nullable<(node: Node) => void>;
  37904. private _isEnabled;
  37905. private _isParentEnabled;
  37906. private _isReady;
  37907. /** @hidden */
  37908. _currentRenderId: number;
  37909. private _parentUpdateId;
  37910. /** @hidden */
  37911. _childUpdateId: number;
  37912. /** @hidden */
  37913. _waitingParentId: Nullable<string>;
  37914. /** @hidden */
  37915. _scene: Scene;
  37916. /** @hidden */
  37917. _cache: any;
  37918. private _parentNode;
  37919. private _children;
  37920. /** @hidden */
  37921. _worldMatrix: Matrix;
  37922. /** @hidden */
  37923. _worldMatrixDeterminant: number;
  37924. /** @hidden */
  37925. _worldMatrixDeterminantIsDirty: boolean;
  37926. /** @hidden */
  37927. private _sceneRootNodesIndex;
  37928. /**
  37929. * Gets a boolean indicating if the node has been disposed
  37930. * @returns true if the node was disposed
  37931. */
  37932. isDisposed(): boolean;
  37933. /**
  37934. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37935. * @see https://doc.babylonjs.com/how_to/parenting
  37936. */
  37937. set parent(parent: Nullable<Node>);
  37938. get parent(): Nullable<Node>;
  37939. /** @hidden */
  37940. _addToSceneRootNodes(): void;
  37941. /** @hidden */
  37942. _removeFromSceneRootNodes(): void;
  37943. private _animationPropertiesOverride;
  37944. /**
  37945. * Gets or sets the animation properties override
  37946. */
  37947. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37948. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37949. /**
  37950. * Gets a string identifying the name of the class
  37951. * @returns "Node" string
  37952. */
  37953. getClassName(): string;
  37954. /** @hidden */
  37955. readonly _isNode: boolean;
  37956. /**
  37957. * An event triggered when the mesh is disposed
  37958. */
  37959. onDisposeObservable: Observable<Node>;
  37960. private _onDisposeObserver;
  37961. /**
  37962. * Sets a callback that will be raised when the node will be disposed
  37963. */
  37964. set onDispose(callback: () => void);
  37965. /**
  37966. * Creates a new Node
  37967. * @param name the name and id to be given to this node
  37968. * @param scene the scene this node will be added to
  37969. */
  37970. constructor(name: string, scene?: Nullable<Scene>);
  37971. /**
  37972. * Gets the scene of the node
  37973. * @returns a scene
  37974. */
  37975. getScene(): Scene;
  37976. /**
  37977. * Gets the engine of the node
  37978. * @returns a Engine
  37979. */
  37980. getEngine(): Engine;
  37981. private _behaviors;
  37982. /**
  37983. * Attach a behavior to the node
  37984. * @see https://doc.babylonjs.com/features/behaviour
  37985. * @param behavior defines the behavior to attach
  37986. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37987. * @returns the current Node
  37988. */
  37989. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37990. /**
  37991. * Remove an attached behavior
  37992. * @see https://doc.babylonjs.com/features/behaviour
  37993. * @param behavior defines the behavior to attach
  37994. * @returns the current Node
  37995. */
  37996. removeBehavior(behavior: Behavior<Node>): Node;
  37997. /**
  37998. * Gets the list of attached behaviors
  37999. * @see https://doc.babylonjs.com/features/behaviour
  38000. */
  38001. get behaviors(): Behavior<Node>[];
  38002. /**
  38003. * Gets an attached behavior by name
  38004. * @param name defines the name of the behavior to look for
  38005. * @see https://doc.babylonjs.com/features/behaviour
  38006. * @returns null if behavior was not found else the requested behavior
  38007. */
  38008. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38009. /**
  38010. * Returns the latest update of the World matrix
  38011. * @returns a Matrix
  38012. */
  38013. getWorldMatrix(): Matrix;
  38014. /** @hidden */
  38015. _getWorldMatrixDeterminant(): number;
  38016. /**
  38017. * Returns directly the latest state of the mesh World matrix.
  38018. * A Matrix is returned.
  38019. */
  38020. get worldMatrixFromCache(): Matrix;
  38021. /** @hidden */
  38022. _initCache(): void;
  38023. /** @hidden */
  38024. updateCache(force?: boolean): void;
  38025. /** @hidden */
  38026. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38027. /** @hidden */
  38028. _updateCache(ignoreParentClass?: boolean): void;
  38029. /** @hidden */
  38030. _isSynchronized(): boolean;
  38031. /** @hidden */
  38032. _markSyncedWithParent(): void;
  38033. /** @hidden */
  38034. isSynchronizedWithParent(): boolean;
  38035. /** @hidden */
  38036. isSynchronized(): boolean;
  38037. /**
  38038. * Is this node ready to be used/rendered
  38039. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38040. * @return true if the node is ready
  38041. */
  38042. isReady(completeCheck?: boolean): boolean;
  38043. /**
  38044. * Is this node enabled?
  38045. * 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
  38046. * @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
  38047. * @return whether this node (and its parent) is enabled
  38048. */
  38049. isEnabled(checkAncestors?: boolean): boolean;
  38050. /** @hidden */
  38051. protected _syncParentEnabledState(): void;
  38052. /**
  38053. * Set the enabled state of this node
  38054. * @param value defines the new enabled state
  38055. */
  38056. setEnabled(value: boolean): void;
  38057. /**
  38058. * Is this node a descendant of the given node?
  38059. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38060. * @param ancestor defines the parent node to inspect
  38061. * @returns a boolean indicating if this node is a descendant of the given node
  38062. */
  38063. isDescendantOf(ancestor: Node): boolean;
  38064. /** @hidden */
  38065. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38066. /**
  38067. * Will return all nodes that have this node as ascendant
  38068. * @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
  38069. * @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
  38070. * @return all children nodes of all types
  38071. */
  38072. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38073. /**
  38074. * Get all child-meshes of this node
  38075. * @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)
  38076. * @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
  38077. * @returns an array of AbstractMesh
  38078. */
  38079. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38080. /**
  38081. * Get all direct children of this node
  38082. * @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
  38083. * @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)
  38084. * @returns an array of Node
  38085. */
  38086. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38087. /** @hidden */
  38088. _setReady(state: boolean): void;
  38089. /**
  38090. * Get an animation by name
  38091. * @param name defines the name of the animation to look for
  38092. * @returns null if not found else the requested animation
  38093. */
  38094. getAnimationByName(name: string): Nullable<Animation>;
  38095. /**
  38096. * Creates an animation range for this node
  38097. * @param name defines the name of the range
  38098. * @param from defines the starting key
  38099. * @param to defines the end key
  38100. */
  38101. createAnimationRange(name: string, from: number, to: number): void;
  38102. /**
  38103. * Delete a specific animation range
  38104. * @param name defines the name of the range to delete
  38105. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38106. */
  38107. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38108. /**
  38109. * Get an animation range by name
  38110. * @param name defines the name of the animation range to look for
  38111. * @returns null if not found else the requested animation range
  38112. */
  38113. getAnimationRange(name: string): Nullable<AnimationRange>;
  38114. /**
  38115. * Gets the list of all animation ranges defined on this node
  38116. * @returns an array
  38117. */
  38118. getAnimationRanges(): Nullable<AnimationRange>[];
  38119. /**
  38120. * Will start the animation sequence
  38121. * @param name defines the range frames for animation sequence
  38122. * @param loop defines if the animation should loop (false by default)
  38123. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38124. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38125. * @returns the object created for this animation. If range does not exist, it will return null
  38126. */
  38127. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38128. /**
  38129. * Serialize animation ranges into a JSON compatible object
  38130. * @returns serialization object
  38131. */
  38132. serializeAnimationRanges(): any;
  38133. /**
  38134. * Computes the world matrix of the node
  38135. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38136. * @returns the world matrix
  38137. */
  38138. computeWorldMatrix(force?: boolean): Matrix;
  38139. /**
  38140. * Releases resources associated with this node.
  38141. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38142. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38143. */
  38144. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38145. /**
  38146. * Parse animation range data from a serialization object and store them into a given node
  38147. * @param node defines where to store the animation ranges
  38148. * @param parsedNode defines the serialization object to read data from
  38149. * @param scene defines the hosting scene
  38150. */
  38151. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38152. /**
  38153. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38154. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38155. * @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
  38156. * @returns the new bounding vectors
  38157. */
  38158. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38159. min: Vector3;
  38160. max: Vector3;
  38161. };
  38162. }
  38163. }
  38164. declare module "babylonjs/Animations/animation" {
  38165. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38166. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38167. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38168. import { Nullable } from "babylonjs/types";
  38169. import { Scene } from "babylonjs/scene";
  38170. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38171. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38172. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38173. import { Node } from "babylonjs/node";
  38174. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38175. import { Size } from "babylonjs/Maths/math.size";
  38176. import { Animatable } from "babylonjs/Animations/animatable";
  38177. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38178. /**
  38179. * @hidden
  38180. */
  38181. export class _IAnimationState {
  38182. key: number;
  38183. repeatCount: number;
  38184. workValue?: any;
  38185. loopMode?: number;
  38186. offsetValue?: any;
  38187. highLimitValue?: any;
  38188. }
  38189. /**
  38190. * Class used to store any kind of animation
  38191. */
  38192. export class Animation {
  38193. /**Name of the animation */
  38194. name: string;
  38195. /**Property to animate */
  38196. targetProperty: string;
  38197. /**The frames per second of the animation */
  38198. framePerSecond: number;
  38199. /**The data type of the animation */
  38200. dataType: number;
  38201. /**The loop mode of the animation */
  38202. loopMode?: number | undefined;
  38203. /**Specifies if blending should be enabled */
  38204. enableBlending?: boolean | undefined;
  38205. /**
  38206. * Use matrix interpolation instead of using direct key value when animating matrices
  38207. */
  38208. static AllowMatricesInterpolation: boolean;
  38209. /**
  38210. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38211. */
  38212. static AllowMatrixDecomposeForInterpolation: boolean;
  38213. /** Define the Url to load snippets */
  38214. static SnippetUrl: string;
  38215. /** Snippet ID if the animation was created from the snippet server */
  38216. snippetId: string;
  38217. /**
  38218. * Stores the key frames of the animation
  38219. */
  38220. private _keys;
  38221. /**
  38222. * Stores the easing function of the animation
  38223. */
  38224. private _easingFunction;
  38225. /**
  38226. * @hidden Internal use only
  38227. */
  38228. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38229. /**
  38230. * The set of event that will be linked to this animation
  38231. */
  38232. private _events;
  38233. /**
  38234. * Stores an array of target property paths
  38235. */
  38236. targetPropertyPath: string[];
  38237. /**
  38238. * Stores the blending speed of the animation
  38239. */
  38240. blendingSpeed: number;
  38241. /**
  38242. * Stores the animation ranges for the animation
  38243. */
  38244. private _ranges;
  38245. /**
  38246. * @hidden Internal use
  38247. */
  38248. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38249. /**
  38250. * Sets up an animation
  38251. * @param property The property to animate
  38252. * @param animationType The animation type to apply
  38253. * @param framePerSecond The frames per second of the animation
  38254. * @param easingFunction The easing function used in the animation
  38255. * @returns The created animation
  38256. */
  38257. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38258. /**
  38259. * Create and start an animation on a node
  38260. * @param name defines the name of the global animation that will be run on all nodes
  38261. * @param node defines the root node where the animation will take place
  38262. * @param targetProperty defines property to animate
  38263. * @param framePerSecond defines the number of frame per second yo use
  38264. * @param totalFrame defines the number of frames in total
  38265. * @param from defines the initial value
  38266. * @param to defines the final value
  38267. * @param loopMode defines which loop mode you want to use (off by default)
  38268. * @param easingFunction defines the easing function to use (linear by default)
  38269. * @param onAnimationEnd defines the callback to call when animation end
  38270. * @returns the animatable created for this animation
  38271. */
  38272. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38273. /**
  38274. * Create and start an animation on a node and its descendants
  38275. * @param name defines the name of the global animation that will be run on all nodes
  38276. * @param node defines the root node where the animation will take place
  38277. * @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
  38278. * @param targetProperty defines property to animate
  38279. * @param framePerSecond defines the number of frame per second to use
  38280. * @param totalFrame defines the number of frames in total
  38281. * @param from defines the initial value
  38282. * @param to defines the final value
  38283. * @param loopMode defines which loop mode you want to use (off by default)
  38284. * @param easingFunction defines the easing function to use (linear by default)
  38285. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38286. * @returns the list of animatables created for all nodes
  38287. * @example https://www.babylonjs-playground.com/#MH0VLI
  38288. */
  38289. 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[]>;
  38290. /**
  38291. * Creates a new animation, merges it with the existing animations and starts it
  38292. * @param name Name of the animation
  38293. * @param node Node which contains the scene that begins the animations
  38294. * @param targetProperty Specifies which property to animate
  38295. * @param framePerSecond The frames per second of the animation
  38296. * @param totalFrame The total number of frames
  38297. * @param from The frame at the beginning of the animation
  38298. * @param to The frame at the end of the animation
  38299. * @param loopMode Specifies the loop mode of the animation
  38300. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38301. * @param onAnimationEnd Callback to run once the animation is complete
  38302. * @returns Nullable animation
  38303. */
  38304. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38305. /**
  38306. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38307. * @param sourceAnimation defines the Animation containing keyframes to convert
  38308. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38309. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38310. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38311. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38312. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38313. */
  38314. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38315. /**
  38316. * Transition property of an host to the target Value
  38317. * @param property The property to transition
  38318. * @param targetValue The target Value of the property
  38319. * @param host The object where the property to animate belongs
  38320. * @param scene Scene used to run the animation
  38321. * @param frameRate Framerate (in frame/s) to use
  38322. * @param transition The transition type we want to use
  38323. * @param duration The duration of the animation, in milliseconds
  38324. * @param onAnimationEnd Callback trigger at the end of the animation
  38325. * @returns Nullable animation
  38326. */
  38327. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38328. /**
  38329. * Return the array of runtime animations currently using this animation
  38330. */
  38331. get runtimeAnimations(): RuntimeAnimation[];
  38332. /**
  38333. * Specifies if any of the runtime animations are currently running
  38334. */
  38335. get hasRunningRuntimeAnimations(): boolean;
  38336. /**
  38337. * Initializes the animation
  38338. * @param name Name of the animation
  38339. * @param targetProperty Property to animate
  38340. * @param framePerSecond The frames per second of the animation
  38341. * @param dataType The data type of the animation
  38342. * @param loopMode The loop mode of the animation
  38343. * @param enableBlending Specifies if blending should be enabled
  38344. */
  38345. constructor(
  38346. /**Name of the animation */
  38347. name: string,
  38348. /**Property to animate */
  38349. targetProperty: string,
  38350. /**The frames per second of the animation */
  38351. framePerSecond: number,
  38352. /**The data type of the animation */
  38353. dataType: number,
  38354. /**The loop mode of the animation */
  38355. loopMode?: number | undefined,
  38356. /**Specifies if blending should be enabled */
  38357. enableBlending?: boolean | undefined);
  38358. /**
  38359. * Converts the animation to a string
  38360. * @param fullDetails support for multiple levels of logging within scene loading
  38361. * @returns String form of the animation
  38362. */
  38363. toString(fullDetails?: boolean): string;
  38364. /**
  38365. * Add an event to this animation
  38366. * @param event Event to add
  38367. */
  38368. addEvent(event: AnimationEvent): void;
  38369. /**
  38370. * Remove all events found at the given frame
  38371. * @param frame The frame to remove events from
  38372. */
  38373. removeEvents(frame: number): void;
  38374. /**
  38375. * Retrieves all the events from the animation
  38376. * @returns Events from the animation
  38377. */
  38378. getEvents(): AnimationEvent[];
  38379. /**
  38380. * Creates an animation range
  38381. * @param name Name of the animation range
  38382. * @param from Starting frame of the animation range
  38383. * @param to Ending frame of the animation
  38384. */
  38385. createRange(name: string, from: number, to: number): void;
  38386. /**
  38387. * Deletes an animation range by name
  38388. * @param name Name of the animation range to delete
  38389. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38390. */
  38391. deleteRange(name: string, deleteFrames?: boolean): void;
  38392. /**
  38393. * Gets the animation range by name, or null if not defined
  38394. * @param name Name of the animation range
  38395. * @returns Nullable animation range
  38396. */
  38397. getRange(name: string): Nullable<AnimationRange>;
  38398. /**
  38399. * Gets the key frames from the animation
  38400. * @returns The key frames of the animation
  38401. */
  38402. getKeys(): Array<IAnimationKey>;
  38403. /**
  38404. * Gets the highest frame rate of the animation
  38405. * @returns Highest frame rate of the animation
  38406. */
  38407. getHighestFrame(): number;
  38408. /**
  38409. * Gets the easing function of the animation
  38410. * @returns Easing function of the animation
  38411. */
  38412. getEasingFunction(): IEasingFunction;
  38413. /**
  38414. * Sets the easing function of the animation
  38415. * @param easingFunction A custom mathematical formula for animation
  38416. */
  38417. setEasingFunction(easingFunction: EasingFunction): void;
  38418. /**
  38419. * Interpolates a scalar linearly
  38420. * @param startValue Start value of the animation curve
  38421. * @param endValue End value of the animation curve
  38422. * @param gradient Scalar amount to interpolate
  38423. * @returns Interpolated scalar value
  38424. */
  38425. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38426. /**
  38427. * Interpolates a scalar cubically
  38428. * @param startValue Start value of the animation curve
  38429. * @param outTangent End tangent of the animation
  38430. * @param endValue End value of the animation curve
  38431. * @param inTangent Start tangent of the animation curve
  38432. * @param gradient Scalar amount to interpolate
  38433. * @returns Interpolated scalar value
  38434. */
  38435. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38436. /**
  38437. * Interpolates a quaternion using a spherical linear interpolation
  38438. * @param startValue Start value of the animation curve
  38439. * @param endValue End value of the animation curve
  38440. * @param gradient Scalar amount to interpolate
  38441. * @returns Interpolated quaternion value
  38442. */
  38443. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38444. /**
  38445. * Interpolates a quaternion cubically
  38446. * @param startValue Start value of the animation curve
  38447. * @param outTangent End tangent of the animation curve
  38448. * @param endValue End value of the animation curve
  38449. * @param inTangent Start tangent of the animation curve
  38450. * @param gradient Scalar amount to interpolate
  38451. * @returns Interpolated quaternion value
  38452. */
  38453. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38454. /**
  38455. * Interpolates a Vector3 linearl
  38456. * @param startValue Start value of the animation curve
  38457. * @param endValue End value of the animation curve
  38458. * @param gradient Scalar amount to interpolate
  38459. * @returns Interpolated scalar value
  38460. */
  38461. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38462. /**
  38463. * Interpolates a Vector3 cubically
  38464. * @param startValue Start value of the animation curve
  38465. * @param outTangent End tangent of the animation
  38466. * @param endValue End value of the animation curve
  38467. * @param inTangent Start tangent of the animation curve
  38468. * @param gradient Scalar amount to interpolate
  38469. * @returns InterpolatedVector3 value
  38470. */
  38471. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38472. /**
  38473. * Interpolates a Vector2 linearly
  38474. * @param startValue Start value of the animation curve
  38475. * @param endValue End value of the animation curve
  38476. * @param gradient Scalar amount to interpolate
  38477. * @returns Interpolated Vector2 value
  38478. */
  38479. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38480. /**
  38481. * Interpolates a Vector2 cubically
  38482. * @param startValue Start value of the animation curve
  38483. * @param outTangent End tangent of the animation
  38484. * @param endValue End value of the animation curve
  38485. * @param inTangent Start tangent of the animation curve
  38486. * @param gradient Scalar amount to interpolate
  38487. * @returns Interpolated Vector2 value
  38488. */
  38489. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38490. /**
  38491. * Interpolates a size linearly
  38492. * @param startValue Start value of the animation curve
  38493. * @param endValue End value of the animation curve
  38494. * @param gradient Scalar amount to interpolate
  38495. * @returns Interpolated Size value
  38496. */
  38497. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38498. /**
  38499. * Interpolates a Color3 linearly
  38500. * @param startValue Start value of the animation curve
  38501. * @param endValue End value of the animation curve
  38502. * @param gradient Scalar amount to interpolate
  38503. * @returns Interpolated Color3 value
  38504. */
  38505. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38506. /**
  38507. * Interpolates a Color4 linearly
  38508. * @param startValue Start value of the animation curve
  38509. * @param endValue End value of the animation curve
  38510. * @param gradient Scalar amount to interpolate
  38511. * @returns Interpolated Color3 value
  38512. */
  38513. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38514. /**
  38515. * @hidden Internal use only
  38516. */
  38517. _getKeyValue(value: any): any;
  38518. /**
  38519. * @hidden Internal use only
  38520. */
  38521. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38522. /**
  38523. * Defines the function to use to interpolate matrices
  38524. * @param startValue defines the start matrix
  38525. * @param endValue defines the end matrix
  38526. * @param gradient defines the gradient between both matrices
  38527. * @param result defines an optional target matrix where to store the interpolation
  38528. * @returns the interpolated matrix
  38529. */
  38530. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38531. /**
  38532. * Makes a copy of the animation
  38533. * @returns Cloned animation
  38534. */
  38535. clone(): Animation;
  38536. /**
  38537. * Sets the key frames of the animation
  38538. * @param values The animation key frames to set
  38539. */
  38540. setKeys(values: Array<IAnimationKey>): void;
  38541. /**
  38542. * Serializes the animation to an object
  38543. * @returns Serialized object
  38544. */
  38545. serialize(): any;
  38546. /**
  38547. * Float animation type
  38548. */
  38549. static readonly ANIMATIONTYPE_FLOAT: number;
  38550. /**
  38551. * Vector3 animation type
  38552. */
  38553. static readonly ANIMATIONTYPE_VECTOR3: number;
  38554. /**
  38555. * Quaternion animation type
  38556. */
  38557. static readonly ANIMATIONTYPE_QUATERNION: number;
  38558. /**
  38559. * Matrix animation type
  38560. */
  38561. static readonly ANIMATIONTYPE_MATRIX: number;
  38562. /**
  38563. * Color3 animation type
  38564. */
  38565. static readonly ANIMATIONTYPE_COLOR3: number;
  38566. /**
  38567. * Color3 animation type
  38568. */
  38569. static readonly ANIMATIONTYPE_COLOR4: number;
  38570. /**
  38571. * Vector2 animation type
  38572. */
  38573. static readonly ANIMATIONTYPE_VECTOR2: number;
  38574. /**
  38575. * Size animation type
  38576. */
  38577. static readonly ANIMATIONTYPE_SIZE: number;
  38578. /**
  38579. * Relative Loop Mode
  38580. */
  38581. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38582. /**
  38583. * Cycle Loop Mode
  38584. */
  38585. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38586. /**
  38587. * Constant Loop Mode
  38588. */
  38589. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38590. /** @hidden */
  38591. static _UniversalLerp(left: any, right: any, amount: number): any;
  38592. /**
  38593. * Parses an animation object and creates an animation
  38594. * @param parsedAnimation Parsed animation object
  38595. * @returns Animation object
  38596. */
  38597. static Parse(parsedAnimation: any): Animation;
  38598. /**
  38599. * Appends the serialized animations from the source animations
  38600. * @param source Source containing the animations
  38601. * @param destination Target to store the animations
  38602. */
  38603. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38604. /**
  38605. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38606. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38607. * @param url defines the url to load from
  38608. * @returns a promise that will resolve to the new animation or an array of animations
  38609. */
  38610. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38611. /**
  38612. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38613. * @param snippetId defines the snippet to load
  38614. * @returns a promise that will resolve to the new animation or a new array of animations
  38615. */
  38616. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38617. }
  38618. }
  38619. declare module "babylonjs/Animations/animatable.interface" {
  38620. import { Nullable } from "babylonjs/types";
  38621. import { Animation } from "babylonjs/Animations/animation";
  38622. /**
  38623. * Interface containing an array of animations
  38624. */
  38625. export interface IAnimatable {
  38626. /**
  38627. * Array of animations
  38628. */
  38629. animations: Nullable<Array<Animation>>;
  38630. }
  38631. }
  38632. declare module "babylonjs/Misc/decorators" {
  38633. import { Nullable } from "babylonjs/types";
  38634. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38635. import { Scene } from "babylonjs/scene";
  38636. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38637. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38638. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38640. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38641. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38642. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38643. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38644. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38645. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38646. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38647. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38648. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38649. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38650. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38651. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38652. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38653. /**
  38654. * Decorator used to define property that can be serialized as reference to a camera
  38655. * @param sourceName defines the name of the property to decorate
  38656. */
  38657. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38658. /**
  38659. * Class used to help serialization objects
  38660. */
  38661. export class SerializationHelper {
  38662. /** @hidden */
  38663. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38664. /** @hidden */
  38665. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38666. /** @hidden */
  38667. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38668. /** @hidden */
  38669. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38670. /**
  38671. * Appends the serialized animations from the source animations
  38672. * @param source Source containing the animations
  38673. * @param destination Target to store the animations
  38674. */
  38675. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38676. /**
  38677. * Static function used to serialized a specific entity
  38678. * @param entity defines the entity to serialize
  38679. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38680. * @returns a JSON compatible object representing the serialization of the entity
  38681. */
  38682. static Serialize<T>(entity: T, serializationObject?: any): any;
  38683. /**
  38684. * Creates a new entity from a serialization data object
  38685. * @param creationFunction defines a function used to instanciated the new entity
  38686. * @param source defines the source serialization data
  38687. * @param scene defines the hosting scene
  38688. * @param rootUrl defines the root url for resources
  38689. * @returns a new entity
  38690. */
  38691. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38692. /**
  38693. * Clones an object
  38694. * @param creationFunction defines the function used to instanciate the new object
  38695. * @param source defines the source object
  38696. * @returns the cloned object
  38697. */
  38698. static Clone<T>(creationFunction: () => T, source: T): T;
  38699. /**
  38700. * Instanciates a new object based on a source one (some data will be shared between both object)
  38701. * @param creationFunction defines the function used to instanciate the new object
  38702. * @param source defines the source object
  38703. * @returns the new object
  38704. */
  38705. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38706. }
  38707. }
  38708. declare module "babylonjs/Materials/Textures/baseTexture" {
  38709. import { Observable } from "babylonjs/Misc/observable";
  38710. import { Nullable } from "babylonjs/types";
  38711. import { Scene } from "babylonjs/scene";
  38712. import { Matrix } from "babylonjs/Maths/math.vector";
  38713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38714. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38715. import { ISize } from "babylonjs/Maths/math.size";
  38716. import "babylonjs/Misc/fileTools";
  38717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38718. /**
  38719. * Base class of all the textures in babylon.
  38720. * It groups all the common properties the materials, post process, lights... might need
  38721. * in order to make a correct use of the texture.
  38722. */
  38723. export class BaseTexture implements IAnimatable {
  38724. /**
  38725. * Default anisotropic filtering level for the application.
  38726. * It is set to 4 as a good tradeoff between perf and quality.
  38727. */
  38728. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38729. /**
  38730. * Gets or sets the unique id of the texture
  38731. */
  38732. uniqueId: number;
  38733. /**
  38734. * Define the name of the texture.
  38735. */
  38736. name: string;
  38737. /**
  38738. * Gets or sets an object used to store user defined information.
  38739. */
  38740. metadata: any;
  38741. /**
  38742. * For internal use only. Please do not use.
  38743. */
  38744. reservedDataStore: any;
  38745. private _hasAlpha;
  38746. /**
  38747. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38748. */
  38749. set hasAlpha(value: boolean);
  38750. get hasAlpha(): boolean;
  38751. /**
  38752. * Defines if the alpha value should be determined via the rgb values.
  38753. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38754. */
  38755. getAlphaFromRGB: boolean;
  38756. /**
  38757. * Intensity or strength of the texture.
  38758. * It is commonly used by materials to fine tune the intensity of the texture
  38759. */
  38760. level: number;
  38761. /**
  38762. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38763. * This is part of the texture as textures usually maps to one uv set.
  38764. */
  38765. coordinatesIndex: number;
  38766. protected _coordinatesMode: number;
  38767. /**
  38768. * How a texture is mapped.
  38769. *
  38770. * | Value | Type | Description |
  38771. * | ----- | ----------------------------------- | ----------- |
  38772. * | 0 | EXPLICIT_MODE | |
  38773. * | 1 | SPHERICAL_MODE | |
  38774. * | 2 | PLANAR_MODE | |
  38775. * | 3 | CUBIC_MODE | |
  38776. * | 4 | PROJECTION_MODE | |
  38777. * | 5 | SKYBOX_MODE | |
  38778. * | 6 | INVCUBIC_MODE | |
  38779. * | 7 | EQUIRECTANGULAR_MODE | |
  38780. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38781. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38782. */
  38783. set coordinatesMode(value: number);
  38784. get coordinatesMode(): number;
  38785. private _wrapU;
  38786. /**
  38787. * | Value | Type | Description |
  38788. * | ----- | ------------------ | ----------- |
  38789. * | 0 | CLAMP_ADDRESSMODE | |
  38790. * | 1 | WRAP_ADDRESSMODE | |
  38791. * | 2 | MIRROR_ADDRESSMODE | |
  38792. */
  38793. get wrapU(): number;
  38794. set wrapU(value: number);
  38795. private _wrapV;
  38796. /**
  38797. * | Value | Type | Description |
  38798. * | ----- | ------------------ | ----------- |
  38799. * | 0 | CLAMP_ADDRESSMODE | |
  38800. * | 1 | WRAP_ADDRESSMODE | |
  38801. * | 2 | MIRROR_ADDRESSMODE | |
  38802. */
  38803. get wrapV(): number;
  38804. set wrapV(value: number);
  38805. /**
  38806. * | Value | Type | Description |
  38807. * | ----- | ------------------ | ----------- |
  38808. * | 0 | CLAMP_ADDRESSMODE | |
  38809. * | 1 | WRAP_ADDRESSMODE | |
  38810. * | 2 | MIRROR_ADDRESSMODE | |
  38811. */
  38812. wrapR: number;
  38813. /**
  38814. * With compliant hardware and browser (supporting anisotropic filtering)
  38815. * this defines the level of anisotropic filtering in the texture.
  38816. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38817. */
  38818. anisotropicFilteringLevel: number;
  38819. /**
  38820. * Define if the texture is a cube texture or if false a 2d texture.
  38821. */
  38822. get isCube(): boolean;
  38823. set isCube(value: boolean);
  38824. /**
  38825. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38826. */
  38827. get is3D(): boolean;
  38828. set is3D(value: boolean);
  38829. /**
  38830. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38831. */
  38832. get is2DArray(): boolean;
  38833. set is2DArray(value: boolean);
  38834. private _gammaSpace;
  38835. /**
  38836. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38837. * HDR texture are usually stored in linear space.
  38838. * This only impacts the PBR and Background materials
  38839. */
  38840. get gammaSpace(): boolean;
  38841. set gammaSpace(gamma: boolean);
  38842. /**
  38843. * Gets or sets whether or not the texture contains RGBD data.
  38844. */
  38845. get isRGBD(): boolean;
  38846. set isRGBD(value: boolean);
  38847. /**
  38848. * Is Z inverted in the texture (useful in a cube texture).
  38849. */
  38850. invertZ: boolean;
  38851. /**
  38852. * Are mip maps generated for this texture or not.
  38853. */
  38854. get noMipmap(): boolean;
  38855. /**
  38856. * @hidden
  38857. */
  38858. lodLevelInAlpha: boolean;
  38859. /**
  38860. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38861. */
  38862. get lodGenerationOffset(): number;
  38863. set lodGenerationOffset(value: number);
  38864. /**
  38865. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38866. */
  38867. get lodGenerationScale(): number;
  38868. set lodGenerationScale(value: number);
  38869. /**
  38870. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38871. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38872. * average roughness values.
  38873. */
  38874. get linearSpecularLOD(): boolean;
  38875. set linearSpecularLOD(value: boolean);
  38876. /**
  38877. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38878. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38879. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38880. */
  38881. get irradianceTexture(): Nullable<BaseTexture>;
  38882. set irradianceTexture(value: Nullable<BaseTexture>);
  38883. /**
  38884. * Define if the texture is a render target.
  38885. */
  38886. isRenderTarget: boolean;
  38887. /**
  38888. * Define the unique id of the texture in the scene.
  38889. */
  38890. get uid(): string;
  38891. /** @hidden */
  38892. _prefiltered: boolean;
  38893. /**
  38894. * Return a string representation of the texture.
  38895. * @returns the texture as a string
  38896. */
  38897. toString(): string;
  38898. /**
  38899. * Get the class name of the texture.
  38900. * @returns "BaseTexture"
  38901. */
  38902. getClassName(): string;
  38903. /**
  38904. * Define the list of animation attached to the texture.
  38905. */
  38906. animations: import("babylonjs/Animations/animation").Animation[];
  38907. /**
  38908. * An event triggered when the texture is disposed.
  38909. */
  38910. onDisposeObservable: Observable<BaseTexture>;
  38911. private _onDisposeObserver;
  38912. /**
  38913. * Callback triggered when the texture has been disposed.
  38914. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38915. */
  38916. set onDispose(callback: () => void);
  38917. /**
  38918. * Define the current state of the loading sequence when in delayed load mode.
  38919. */
  38920. delayLoadState: number;
  38921. protected _scene: Nullable<Scene>;
  38922. protected _engine: Nullable<ThinEngine>;
  38923. /** @hidden */
  38924. _texture: Nullable<InternalTexture>;
  38925. private _uid;
  38926. /**
  38927. * Define if the texture is preventinga material to render or not.
  38928. * If not and the texture is not ready, the engine will use a default black texture instead.
  38929. */
  38930. get isBlocking(): boolean;
  38931. /**
  38932. * Instantiates a new BaseTexture.
  38933. * Base class of all the textures in babylon.
  38934. * It groups all the common properties the materials, post process, lights... might need
  38935. * in order to make a correct use of the texture.
  38936. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38937. */
  38938. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38939. /**
  38940. * Get the scene the texture belongs to.
  38941. * @returns the scene or null if undefined
  38942. */
  38943. getScene(): Nullable<Scene>;
  38944. /** @hidden */
  38945. protected _getEngine(): Nullable<ThinEngine>;
  38946. /**
  38947. * Checks if the texture has the same transform matrix than another texture
  38948. * @param texture texture to check against
  38949. * @returns true if the transforms are the same, else false
  38950. */
  38951. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38952. /**
  38953. * Get the texture transform matrix used to offset tile the texture for istance.
  38954. * @returns the transformation matrix
  38955. */
  38956. getTextureMatrix(): Matrix;
  38957. /**
  38958. * Get the texture reflection matrix used to rotate/transform the reflection.
  38959. * @returns the reflection matrix
  38960. */
  38961. getReflectionTextureMatrix(): Matrix;
  38962. /**
  38963. * Get the underlying lower level texture from Babylon.
  38964. * @returns the insternal texture
  38965. */
  38966. getInternalTexture(): Nullable<InternalTexture>;
  38967. /**
  38968. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38969. * @returns true if ready or not blocking
  38970. */
  38971. isReadyOrNotBlocking(): boolean;
  38972. /**
  38973. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38974. * @returns true if fully ready
  38975. */
  38976. isReady(): boolean;
  38977. private _cachedSize;
  38978. /**
  38979. * Get the size of the texture.
  38980. * @returns the texture size.
  38981. */
  38982. getSize(): ISize;
  38983. /**
  38984. * Get the base size of the texture.
  38985. * It can be different from the size if the texture has been resized for POT for instance
  38986. * @returns the base size
  38987. */
  38988. getBaseSize(): ISize;
  38989. /**
  38990. * Update the sampling mode of the texture.
  38991. * Default is Trilinear mode.
  38992. *
  38993. * | Value | Type | Description |
  38994. * | ----- | ------------------ | ----------- |
  38995. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38996. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38997. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38998. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38999. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  39000. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  39001. * | 7 | NEAREST_LINEAR | |
  39002. * | 8 | NEAREST_NEAREST | |
  39003. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  39004. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  39005. * | 11 | LINEAR_LINEAR | |
  39006. * | 12 | LINEAR_NEAREST | |
  39007. *
  39008. * > _mag_: magnification filter (close to the viewer)
  39009. * > _min_: minification filter (far from the viewer)
  39010. * > _mip_: filter used between mip map levels
  39011. *@param samplingMode Define the new sampling mode of the texture
  39012. */
  39013. updateSamplingMode(samplingMode: number): void;
  39014. /**
  39015. * Scales the texture if is `canRescale()`
  39016. * @param ratio the resize factor we want to use to rescale
  39017. */
  39018. scale(ratio: number): void;
  39019. /**
  39020. * Get if the texture can rescale.
  39021. */
  39022. get canRescale(): boolean;
  39023. /** @hidden */
  39024. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  39025. /** @hidden */
  39026. _rebuild(): void;
  39027. /**
  39028. * Triggers the load sequence in delayed load mode.
  39029. */
  39030. delayLoad(): void;
  39031. /**
  39032. * Clones the texture.
  39033. * @returns the cloned texture
  39034. */
  39035. clone(): Nullable<BaseTexture>;
  39036. /**
  39037. * Get the texture underlying type (INT, FLOAT...)
  39038. */
  39039. get textureType(): number;
  39040. /**
  39041. * Get the texture underlying format (RGB, RGBA...)
  39042. */
  39043. get textureFormat(): number;
  39044. /**
  39045. * Indicates that textures need to be re-calculated for all materials
  39046. */
  39047. protected _markAllSubMeshesAsTexturesDirty(): void;
  39048. /**
  39049. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  39050. * This will returns an RGBA array buffer containing either in values (0-255) or
  39051. * float values (0-1) depending of the underlying buffer type.
  39052. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  39053. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  39054. * @param buffer defines a user defined buffer to fill with data (can be null)
  39055. * @returns The Array buffer containing the pixels data.
  39056. */
  39057. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  39058. /**
  39059. * Release and destroy the underlying lower level texture aka internalTexture.
  39060. */
  39061. releaseInternalTexture(): void;
  39062. /** @hidden */
  39063. get _lodTextureHigh(): Nullable<BaseTexture>;
  39064. /** @hidden */
  39065. get _lodTextureMid(): Nullable<BaseTexture>;
  39066. /** @hidden */
  39067. get _lodTextureLow(): Nullable<BaseTexture>;
  39068. /**
  39069. * Dispose the texture and release its associated resources.
  39070. */
  39071. dispose(): void;
  39072. /**
  39073. * Serialize the texture into a JSON representation that can be parsed later on.
  39074. * @returns the JSON representation of the texture
  39075. */
  39076. serialize(): any;
  39077. /**
  39078. * Helper function to be called back once a list of texture contains only ready textures.
  39079. * @param textures Define the list of textures to wait for
  39080. * @param callback Define the callback triggered once the entire list will be ready
  39081. */
  39082. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  39083. private static _isScene;
  39084. }
  39085. }
  39086. declare module "babylonjs/Materials/effect" {
  39087. import { Observable } from "babylonjs/Misc/observable";
  39088. import { Nullable } from "babylonjs/types";
  39089. import { IDisposable } from "babylonjs/scene";
  39090. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39091. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39092. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39093. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39094. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39095. import { Engine } from "babylonjs/Engines/engine";
  39096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39099. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39100. /**
  39101. * Options to be used when creating an effect.
  39102. */
  39103. export interface IEffectCreationOptions {
  39104. /**
  39105. * Atrributes that will be used in the shader.
  39106. */
  39107. attributes: string[];
  39108. /**
  39109. * Uniform varible names that will be set in the shader.
  39110. */
  39111. uniformsNames: string[];
  39112. /**
  39113. * Uniform buffer variable names that will be set in the shader.
  39114. */
  39115. uniformBuffersNames: string[];
  39116. /**
  39117. * Sampler texture variable names that will be set in the shader.
  39118. */
  39119. samplers: string[];
  39120. /**
  39121. * Define statements that will be set in the shader.
  39122. */
  39123. defines: any;
  39124. /**
  39125. * Possible fallbacks for this effect to improve performance when needed.
  39126. */
  39127. fallbacks: Nullable<IEffectFallbacks>;
  39128. /**
  39129. * Callback that will be called when the shader is compiled.
  39130. */
  39131. onCompiled: Nullable<(effect: Effect) => void>;
  39132. /**
  39133. * Callback that will be called if an error occurs during shader compilation.
  39134. */
  39135. onError: Nullable<(effect: Effect, errors: string) => void>;
  39136. /**
  39137. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39138. */
  39139. indexParameters?: any;
  39140. /**
  39141. * Max number of lights that can be used in the shader.
  39142. */
  39143. maxSimultaneousLights?: number;
  39144. /**
  39145. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39146. */
  39147. transformFeedbackVaryings?: Nullable<string[]>;
  39148. /**
  39149. * 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
  39150. */
  39151. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39152. /**
  39153. * Is this effect rendering to several color attachments ?
  39154. */
  39155. multiTarget?: boolean;
  39156. }
  39157. /**
  39158. * Effect containing vertex and fragment shader that can be executed on an object.
  39159. */
  39160. export class Effect implements IDisposable {
  39161. /**
  39162. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39163. */
  39164. static ShadersRepository: string;
  39165. /**
  39166. * Enable logging of the shader code when a compilation error occurs
  39167. */
  39168. static LogShaderCodeOnCompilationError: boolean;
  39169. /**
  39170. * Name of the effect.
  39171. */
  39172. name: any;
  39173. /**
  39174. * String container all the define statements that should be set on the shader.
  39175. */
  39176. defines: string;
  39177. /**
  39178. * Callback that will be called when the shader is compiled.
  39179. */
  39180. onCompiled: Nullable<(effect: Effect) => void>;
  39181. /**
  39182. * Callback that will be called if an error occurs during shader compilation.
  39183. */
  39184. onError: Nullable<(effect: Effect, errors: string) => void>;
  39185. /**
  39186. * Callback that will be called when effect is bound.
  39187. */
  39188. onBind: Nullable<(effect: Effect) => void>;
  39189. /**
  39190. * Unique ID of the effect.
  39191. */
  39192. uniqueId: number;
  39193. /**
  39194. * Observable that will be called when the shader is compiled.
  39195. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39196. */
  39197. onCompileObservable: Observable<Effect>;
  39198. /**
  39199. * Observable that will be called if an error occurs during shader compilation.
  39200. */
  39201. onErrorObservable: Observable<Effect>;
  39202. /** @hidden */
  39203. _onBindObservable: Nullable<Observable<Effect>>;
  39204. /**
  39205. * @hidden
  39206. * Specifies if the effect was previously ready
  39207. */
  39208. _wasPreviouslyReady: boolean;
  39209. /**
  39210. * Observable that will be called when effect is bound.
  39211. */
  39212. get onBindObservable(): Observable<Effect>;
  39213. /** @hidden */
  39214. _bonesComputationForcedToCPU: boolean;
  39215. /** @hidden */
  39216. _multiTarget: boolean;
  39217. private static _uniqueIdSeed;
  39218. private _engine;
  39219. private _uniformBuffersNames;
  39220. private _uniformBuffersNamesList;
  39221. private _uniformsNames;
  39222. private _samplerList;
  39223. private _samplers;
  39224. private _isReady;
  39225. private _compilationError;
  39226. private _allFallbacksProcessed;
  39227. private _attributesNames;
  39228. private _attributes;
  39229. private _attributeLocationByName;
  39230. private _uniforms;
  39231. /**
  39232. * Key for the effect.
  39233. * @hidden
  39234. */
  39235. _key: string;
  39236. private _indexParameters;
  39237. private _fallbacks;
  39238. private _vertexSourceCode;
  39239. private _fragmentSourceCode;
  39240. private _vertexSourceCodeOverride;
  39241. private _fragmentSourceCodeOverride;
  39242. private _transformFeedbackVaryings;
  39243. private _rawVertexSourceCode;
  39244. private _rawFragmentSourceCode;
  39245. /**
  39246. * Compiled shader to webGL program.
  39247. * @hidden
  39248. */
  39249. _pipelineContext: Nullable<IPipelineContext>;
  39250. private _valueCache;
  39251. private static _baseCache;
  39252. /**
  39253. * Instantiates an effect.
  39254. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39255. * @param baseName Name of the effect.
  39256. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39257. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39258. * @param samplers List of sampler variables that will be passed to the shader.
  39259. * @param engine Engine to be used to render the effect
  39260. * @param defines Define statements to be added to the shader.
  39261. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39262. * @param onCompiled Callback that will be called when the shader is compiled.
  39263. * @param onError Callback that will be called if an error occurs during shader compilation.
  39264. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39265. */
  39266. 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);
  39267. private _useFinalCode;
  39268. /**
  39269. * Unique key for this effect
  39270. */
  39271. get key(): string;
  39272. /**
  39273. * If the effect has been compiled and prepared.
  39274. * @returns if the effect is compiled and prepared.
  39275. */
  39276. isReady(): boolean;
  39277. private _isReadyInternal;
  39278. /**
  39279. * The engine the effect was initialized with.
  39280. * @returns the engine.
  39281. */
  39282. getEngine(): Engine;
  39283. /**
  39284. * The pipeline context for this effect
  39285. * @returns the associated pipeline context
  39286. */
  39287. getPipelineContext(): Nullable<IPipelineContext>;
  39288. /**
  39289. * The set of names of attribute variables for the shader.
  39290. * @returns An array of attribute names.
  39291. */
  39292. getAttributesNames(): string[];
  39293. /**
  39294. * Returns the attribute at the given index.
  39295. * @param index The index of the attribute.
  39296. * @returns The location of the attribute.
  39297. */
  39298. getAttributeLocation(index: number): number;
  39299. /**
  39300. * Returns the attribute based on the name of the variable.
  39301. * @param name of the attribute to look up.
  39302. * @returns the attribute location.
  39303. */
  39304. getAttributeLocationByName(name: string): number;
  39305. /**
  39306. * The number of attributes.
  39307. * @returns the numnber of attributes.
  39308. */
  39309. getAttributesCount(): number;
  39310. /**
  39311. * Gets the index of a uniform variable.
  39312. * @param uniformName of the uniform to look up.
  39313. * @returns the index.
  39314. */
  39315. getUniformIndex(uniformName: string): number;
  39316. /**
  39317. * Returns the attribute based on the name of the variable.
  39318. * @param uniformName of the uniform to look up.
  39319. * @returns the location of the uniform.
  39320. */
  39321. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39322. /**
  39323. * Returns an array of sampler variable names
  39324. * @returns The array of sampler variable names.
  39325. */
  39326. getSamplers(): string[];
  39327. /**
  39328. * Returns an array of uniform variable names
  39329. * @returns The array of uniform variable names.
  39330. */
  39331. getUniformNames(): string[];
  39332. /**
  39333. * Returns an array of uniform buffer variable names
  39334. * @returns The array of uniform buffer variable names.
  39335. */
  39336. getUniformBuffersNames(): string[];
  39337. /**
  39338. * Returns the index parameters used to create the effect
  39339. * @returns The index parameters object
  39340. */
  39341. getIndexParameters(): any;
  39342. /**
  39343. * The error from the last compilation.
  39344. * @returns the error string.
  39345. */
  39346. getCompilationError(): string;
  39347. /**
  39348. * Gets a boolean indicating that all fallbacks were used during compilation
  39349. * @returns true if all fallbacks were used
  39350. */
  39351. allFallbacksProcessed(): boolean;
  39352. /**
  39353. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39354. * @param func The callback to be used.
  39355. */
  39356. executeWhenCompiled(func: (effect: Effect) => void): void;
  39357. private _checkIsReady;
  39358. private _loadShader;
  39359. /**
  39360. * Gets the vertex shader source code of this effect
  39361. */
  39362. get vertexSourceCode(): string;
  39363. /**
  39364. * Gets the fragment shader source code of this effect
  39365. */
  39366. get fragmentSourceCode(): string;
  39367. /**
  39368. * Gets the vertex shader source code before it has been processed by the preprocessor
  39369. */
  39370. get rawVertexSourceCode(): string;
  39371. /**
  39372. * Gets the fragment shader source code before it has been processed by the preprocessor
  39373. */
  39374. get rawFragmentSourceCode(): string;
  39375. /**
  39376. * Recompiles the webGL program
  39377. * @param vertexSourceCode The source code for the vertex shader.
  39378. * @param fragmentSourceCode The source code for the fragment shader.
  39379. * @param onCompiled Callback called when completed.
  39380. * @param onError Callback called on error.
  39381. * @hidden
  39382. */
  39383. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39384. /**
  39385. * Prepares the effect
  39386. * @hidden
  39387. */
  39388. _prepareEffect(): void;
  39389. private _getShaderCodeAndErrorLine;
  39390. private _processCompilationErrors;
  39391. /**
  39392. * Checks if the effect is supported. (Must be called after compilation)
  39393. */
  39394. get isSupported(): boolean;
  39395. /**
  39396. * Binds a texture to the engine to be used as output of the shader.
  39397. * @param channel Name of the output variable.
  39398. * @param texture Texture to bind.
  39399. * @hidden
  39400. */
  39401. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39402. /**
  39403. * Sets a texture on the engine to be used in the shader.
  39404. * @param channel Name of the sampler variable.
  39405. * @param texture Texture to set.
  39406. */
  39407. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39408. /**
  39409. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39410. * @param channel Name of the sampler variable.
  39411. * @param texture Texture to set.
  39412. */
  39413. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39414. /**
  39415. * Sets an array of textures on the engine to be used in the shader.
  39416. * @param channel Name of the variable.
  39417. * @param textures Textures to set.
  39418. */
  39419. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39420. /**
  39421. * 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)
  39422. * @param channel Name of the sampler variable.
  39423. * @param postProcess Post process to get the input texture from.
  39424. */
  39425. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39426. /**
  39427. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39428. * 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)
  39429. * @param channel Name of the sampler variable.
  39430. * @param postProcess Post process to get the output texture from.
  39431. */
  39432. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39433. /** @hidden */
  39434. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39435. /** @hidden */
  39436. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39437. /** @hidden */
  39438. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39439. /** @hidden */
  39440. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39441. /**
  39442. * Binds a buffer to a uniform.
  39443. * @param buffer Buffer to bind.
  39444. * @param name Name of the uniform variable to bind to.
  39445. */
  39446. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39447. /**
  39448. * Binds block to a uniform.
  39449. * @param blockName Name of the block to bind.
  39450. * @param index Index to bind.
  39451. */
  39452. bindUniformBlock(blockName: string, index: number): void;
  39453. /**
  39454. * Sets an interger value on a uniform variable.
  39455. * @param uniformName Name of the variable.
  39456. * @param value Value to be set.
  39457. * @returns this effect.
  39458. */
  39459. setInt(uniformName: string, value: number): Effect;
  39460. /**
  39461. * Sets an int array on a uniform variable.
  39462. * @param uniformName Name of the variable.
  39463. * @param array array to be set.
  39464. * @returns this effect.
  39465. */
  39466. setIntArray(uniformName: string, array: Int32Array): Effect;
  39467. /**
  39468. * 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)
  39469. * @param uniformName Name of the variable.
  39470. * @param array array to be set.
  39471. * @returns this effect.
  39472. */
  39473. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39474. /**
  39475. * 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)
  39476. * @param uniformName Name of the variable.
  39477. * @param array array to be set.
  39478. * @returns this effect.
  39479. */
  39480. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39481. /**
  39482. * 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)
  39483. * @param uniformName Name of the variable.
  39484. * @param array array to be set.
  39485. * @returns this effect.
  39486. */
  39487. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39488. /**
  39489. * Sets an float array on a uniform variable.
  39490. * @param uniformName Name of the variable.
  39491. * @param array array to be set.
  39492. * @returns this effect.
  39493. */
  39494. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39495. /**
  39496. * 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)
  39497. * @param uniformName Name of the variable.
  39498. * @param array array to be set.
  39499. * @returns this effect.
  39500. */
  39501. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39502. /**
  39503. * 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)
  39504. * @param uniformName Name of the variable.
  39505. * @param array array to be set.
  39506. * @returns this effect.
  39507. */
  39508. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39509. /**
  39510. * 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)
  39511. * @param uniformName Name of the variable.
  39512. * @param array array to be set.
  39513. * @returns this effect.
  39514. */
  39515. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39516. /**
  39517. * Sets an array on a uniform variable.
  39518. * @param uniformName Name of the variable.
  39519. * @param array array to be set.
  39520. * @returns this effect.
  39521. */
  39522. setArray(uniformName: string, array: number[]): Effect;
  39523. /**
  39524. * 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)
  39525. * @param uniformName Name of the variable.
  39526. * @param array array to be set.
  39527. * @returns this effect.
  39528. */
  39529. setArray2(uniformName: string, array: number[]): Effect;
  39530. /**
  39531. * 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)
  39532. * @param uniformName Name of the variable.
  39533. * @param array array to be set.
  39534. * @returns this effect.
  39535. */
  39536. setArray3(uniformName: string, array: number[]): Effect;
  39537. /**
  39538. * 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)
  39539. * @param uniformName Name of the variable.
  39540. * @param array array to be set.
  39541. * @returns this effect.
  39542. */
  39543. setArray4(uniformName: string, array: number[]): Effect;
  39544. /**
  39545. * Sets matrices on a uniform variable.
  39546. * @param uniformName Name of the variable.
  39547. * @param matrices matrices to be set.
  39548. * @returns this effect.
  39549. */
  39550. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39551. /**
  39552. * Sets matrix on a uniform variable.
  39553. * @param uniformName Name of the variable.
  39554. * @param matrix matrix to be set.
  39555. * @returns this effect.
  39556. */
  39557. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39558. /**
  39559. * 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)
  39560. * @param uniformName Name of the variable.
  39561. * @param matrix matrix to be set.
  39562. * @returns this effect.
  39563. */
  39564. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39565. /**
  39566. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39567. * @param uniformName Name of the variable.
  39568. * @param matrix matrix to be set.
  39569. * @returns this effect.
  39570. */
  39571. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39572. /**
  39573. * Sets a float on a uniform variable.
  39574. * @param uniformName Name of the variable.
  39575. * @param value value to be set.
  39576. * @returns this effect.
  39577. */
  39578. setFloat(uniformName: string, value: number): Effect;
  39579. /**
  39580. * Sets a boolean on a uniform variable.
  39581. * @param uniformName Name of the variable.
  39582. * @param bool value to be set.
  39583. * @returns this effect.
  39584. */
  39585. setBool(uniformName: string, bool: boolean): Effect;
  39586. /**
  39587. * Sets a Vector2 on a uniform variable.
  39588. * @param uniformName Name of the variable.
  39589. * @param vector2 vector2 to be set.
  39590. * @returns this effect.
  39591. */
  39592. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39593. /**
  39594. * Sets a float2 on a uniform variable.
  39595. * @param uniformName Name of the variable.
  39596. * @param x First float in float2.
  39597. * @param y Second float in float2.
  39598. * @returns this effect.
  39599. */
  39600. setFloat2(uniformName: string, x: number, y: number): Effect;
  39601. /**
  39602. * Sets a Vector3 on a uniform variable.
  39603. * @param uniformName Name of the variable.
  39604. * @param vector3 Value to be set.
  39605. * @returns this effect.
  39606. */
  39607. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39608. /**
  39609. * Sets a float3 on a uniform variable.
  39610. * @param uniformName Name of the variable.
  39611. * @param x First float in float3.
  39612. * @param y Second float in float3.
  39613. * @param z Third float in float3.
  39614. * @returns this effect.
  39615. */
  39616. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39617. /**
  39618. * Sets a Vector4 on a uniform variable.
  39619. * @param uniformName Name of the variable.
  39620. * @param vector4 Value to be set.
  39621. * @returns this effect.
  39622. */
  39623. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39624. /**
  39625. * Sets a float4 on a uniform variable.
  39626. * @param uniformName Name of the variable.
  39627. * @param x First float in float4.
  39628. * @param y Second float in float4.
  39629. * @param z Third float in float4.
  39630. * @param w Fourth float in float4.
  39631. * @returns this effect.
  39632. */
  39633. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39634. /**
  39635. * Sets a Color3 on a uniform variable.
  39636. * @param uniformName Name of the variable.
  39637. * @param color3 Value to be set.
  39638. * @returns this effect.
  39639. */
  39640. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39641. /**
  39642. * Sets a Color4 on a uniform variable.
  39643. * @param uniformName Name of the variable.
  39644. * @param color3 Value to be set.
  39645. * @param alpha Alpha value to be set.
  39646. * @returns this effect.
  39647. */
  39648. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39649. /**
  39650. * Sets a Color4 on a uniform variable
  39651. * @param uniformName defines the name of the variable
  39652. * @param color4 defines the value to be set
  39653. * @returns this effect.
  39654. */
  39655. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39656. /** Release all associated resources */
  39657. dispose(): void;
  39658. /**
  39659. * This function will add a new shader to the shader store
  39660. * @param name the name of the shader
  39661. * @param pixelShader optional pixel shader content
  39662. * @param vertexShader optional vertex shader content
  39663. */
  39664. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39665. /**
  39666. * Store of each shader (The can be looked up using effect.key)
  39667. */
  39668. static ShadersStore: {
  39669. [key: string]: string;
  39670. };
  39671. /**
  39672. * Store of each included file for a shader (The can be looked up using effect.key)
  39673. */
  39674. static IncludesShadersStore: {
  39675. [key: string]: string;
  39676. };
  39677. /**
  39678. * Resets the cache of effects.
  39679. */
  39680. static ResetCache(): void;
  39681. }
  39682. }
  39683. declare module "babylonjs/Engines/engineCapabilities" {
  39684. /**
  39685. * Interface used to describe the capabilities of the engine relatively to the current browser
  39686. */
  39687. export interface EngineCapabilities {
  39688. /** Maximum textures units per fragment shader */
  39689. maxTexturesImageUnits: number;
  39690. /** Maximum texture units per vertex shader */
  39691. maxVertexTextureImageUnits: number;
  39692. /** Maximum textures units in the entire pipeline */
  39693. maxCombinedTexturesImageUnits: number;
  39694. /** Maximum texture size */
  39695. maxTextureSize: number;
  39696. /** Maximum texture samples */
  39697. maxSamples?: number;
  39698. /** Maximum cube texture size */
  39699. maxCubemapTextureSize: number;
  39700. /** Maximum render texture size */
  39701. maxRenderTextureSize: number;
  39702. /** Maximum number of vertex attributes */
  39703. maxVertexAttribs: number;
  39704. /** Maximum number of varyings */
  39705. maxVaryingVectors: number;
  39706. /** Maximum number of uniforms per vertex shader */
  39707. maxVertexUniformVectors: number;
  39708. /** Maximum number of uniforms per fragment shader */
  39709. maxFragmentUniformVectors: number;
  39710. /** Defines if standard derivates (dx/dy) are supported */
  39711. standardDerivatives: boolean;
  39712. /** Defines if s3tc texture compression is supported */
  39713. s3tc?: WEBGL_compressed_texture_s3tc;
  39714. /** Defines if pvrtc texture compression is supported */
  39715. pvrtc: any;
  39716. /** Defines if etc1 texture compression is supported */
  39717. etc1: any;
  39718. /** Defines if etc2 texture compression is supported */
  39719. etc2: any;
  39720. /** Defines if astc texture compression is supported */
  39721. astc: any;
  39722. /** Defines if bptc texture compression is supported */
  39723. bptc: any;
  39724. /** Defines if float textures are supported */
  39725. textureFloat: boolean;
  39726. /** Defines if vertex array objects are supported */
  39727. vertexArrayObject: boolean;
  39728. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39729. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39730. /** Gets the maximum level of anisotropy supported */
  39731. maxAnisotropy: number;
  39732. /** Defines if instancing is supported */
  39733. instancedArrays: boolean;
  39734. /** Defines if 32 bits indices are supported */
  39735. uintIndices: boolean;
  39736. /** Defines if high precision shaders are supported */
  39737. highPrecisionShaderSupported: boolean;
  39738. /** Defines if depth reading in the fragment shader is supported */
  39739. fragmentDepthSupported: boolean;
  39740. /** Defines if float texture linear filtering is supported*/
  39741. textureFloatLinearFiltering: boolean;
  39742. /** Defines if rendering to float textures is supported */
  39743. textureFloatRender: boolean;
  39744. /** Defines if half float textures are supported*/
  39745. textureHalfFloat: boolean;
  39746. /** Defines if half float texture linear filtering is supported*/
  39747. textureHalfFloatLinearFiltering: boolean;
  39748. /** Defines if rendering to half float textures is supported */
  39749. textureHalfFloatRender: boolean;
  39750. /** Defines if textureLOD shader command is supported */
  39751. textureLOD: boolean;
  39752. /** Defines if draw buffers extension is supported */
  39753. drawBuffersExtension: boolean;
  39754. /** Defines if depth textures are supported */
  39755. depthTextureExtension: boolean;
  39756. /** Defines if float color buffer are supported */
  39757. colorBufferFloat: boolean;
  39758. /** Gets disjoint timer query extension (null if not supported) */
  39759. timerQuery?: EXT_disjoint_timer_query;
  39760. /** Defines if timestamp can be used with timer query */
  39761. canUseTimestampForTimerQuery: boolean;
  39762. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39763. multiview?: any;
  39764. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39765. oculusMultiview?: any;
  39766. /** Function used to let the system compiles shaders in background */
  39767. parallelShaderCompile?: {
  39768. COMPLETION_STATUS_KHR: number;
  39769. };
  39770. /** Max number of texture samples for MSAA */
  39771. maxMSAASamples: number;
  39772. /** Defines if the blend min max extension is supported */
  39773. blendMinMax: boolean;
  39774. }
  39775. }
  39776. declare module "babylonjs/States/depthCullingState" {
  39777. import { Nullable } from "babylonjs/types";
  39778. /**
  39779. * @hidden
  39780. **/
  39781. export class DepthCullingState {
  39782. private _isDepthTestDirty;
  39783. private _isDepthMaskDirty;
  39784. private _isDepthFuncDirty;
  39785. private _isCullFaceDirty;
  39786. private _isCullDirty;
  39787. private _isZOffsetDirty;
  39788. private _isFrontFaceDirty;
  39789. private _depthTest;
  39790. private _depthMask;
  39791. private _depthFunc;
  39792. private _cull;
  39793. private _cullFace;
  39794. private _zOffset;
  39795. private _frontFace;
  39796. /**
  39797. * Initializes the state.
  39798. */
  39799. constructor();
  39800. get isDirty(): boolean;
  39801. get zOffset(): number;
  39802. set zOffset(value: number);
  39803. get cullFace(): Nullable<number>;
  39804. set cullFace(value: Nullable<number>);
  39805. get cull(): Nullable<boolean>;
  39806. set cull(value: Nullable<boolean>);
  39807. get depthFunc(): Nullable<number>;
  39808. set depthFunc(value: Nullable<number>);
  39809. get depthMask(): boolean;
  39810. set depthMask(value: boolean);
  39811. get depthTest(): boolean;
  39812. set depthTest(value: boolean);
  39813. get frontFace(): Nullable<number>;
  39814. set frontFace(value: Nullable<number>);
  39815. reset(): void;
  39816. apply(gl: WebGLRenderingContext): void;
  39817. }
  39818. }
  39819. declare module "babylonjs/States/stencilState" {
  39820. /**
  39821. * @hidden
  39822. **/
  39823. export class StencilState {
  39824. /** 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 */
  39825. static readonly ALWAYS: number;
  39826. /** Passed to stencilOperation to specify that stencil value must be kept */
  39827. static readonly KEEP: number;
  39828. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39829. static readonly REPLACE: number;
  39830. private _isStencilTestDirty;
  39831. private _isStencilMaskDirty;
  39832. private _isStencilFuncDirty;
  39833. private _isStencilOpDirty;
  39834. private _stencilTest;
  39835. private _stencilMask;
  39836. private _stencilFunc;
  39837. private _stencilFuncRef;
  39838. private _stencilFuncMask;
  39839. private _stencilOpStencilFail;
  39840. private _stencilOpDepthFail;
  39841. private _stencilOpStencilDepthPass;
  39842. get isDirty(): boolean;
  39843. get stencilFunc(): number;
  39844. set stencilFunc(value: number);
  39845. get stencilFuncRef(): number;
  39846. set stencilFuncRef(value: number);
  39847. get stencilFuncMask(): number;
  39848. set stencilFuncMask(value: number);
  39849. get stencilOpStencilFail(): number;
  39850. set stencilOpStencilFail(value: number);
  39851. get stencilOpDepthFail(): number;
  39852. set stencilOpDepthFail(value: number);
  39853. get stencilOpStencilDepthPass(): number;
  39854. set stencilOpStencilDepthPass(value: number);
  39855. get stencilMask(): number;
  39856. set stencilMask(value: number);
  39857. get stencilTest(): boolean;
  39858. set stencilTest(value: boolean);
  39859. constructor();
  39860. reset(): void;
  39861. apply(gl: WebGLRenderingContext): void;
  39862. }
  39863. }
  39864. declare module "babylonjs/States/alphaCullingState" {
  39865. /**
  39866. * @hidden
  39867. **/
  39868. export class AlphaState {
  39869. private _isAlphaBlendDirty;
  39870. private _isBlendFunctionParametersDirty;
  39871. private _isBlendEquationParametersDirty;
  39872. private _isBlendConstantsDirty;
  39873. private _alphaBlend;
  39874. private _blendFunctionParameters;
  39875. private _blendEquationParameters;
  39876. private _blendConstants;
  39877. /**
  39878. * Initializes the state.
  39879. */
  39880. constructor();
  39881. get isDirty(): boolean;
  39882. get alphaBlend(): boolean;
  39883. set alphaBlend(value: boolean);
  39884. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39885. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39886. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39887. reset(): void;
  39888. apply(gl: WebGLRenderingContext): void;
  39889. }
  39890. }
  39891. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  39892. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39893. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39894. /** @hidden */
  39895. export class WebGLShaderProcessor implements IShaderProcessor {
  39896. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  39897. }
  39898. }
  39899. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39900. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39901. /** @hidden */
  39902. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39903. attributeProcessor(attribute: string): string;
  39904. varyingProcessor(varying: string, isFragment: boolean): string;
  39905. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39906. }
  39907. }
  39908. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39909. /**
  39910. * Interface for attribute information associated with buffer instanciation
  39911. */
  39912. export interface InstancingAttributeInfo {
  39913. /**
  39914. * Name of the GLSL attribute
  39915. * if attribute index is not specified, this is used to retrieve the index from the effect
  39916. */
  39917. attributeName: string;
  39918. /**
  39919. * Index/offset of the attribute in the vertex shader
  39920. * if not specified, this will be computes from the name.
  39921. */
  39922. index?: number;
  39923. /**
  39924. * size of the attribute, 1, 2, 3 or 4
  39925. */
  39926. attributeSize: number;
  39927. /**
  39928. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39929. */
  39930. offset: number;
  39931. /**
  39932. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39933. * default to 1
  39934. */
  39935. divisor?: number;
  39936. /**
  39937. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39938. * default is FLOAT
  39939. */
  39940. attributeType?: number;
  39941. /**
  39942. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39943. */
  39944. normalized?: boolean;
  39945. }
  39946. }
  39947. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39949. import { Nullable } from "babylonjs/types";
  39950. module "babylonjs/Engines/thinEngine" {
  39951. interface ThinEngine {
  39952. /**
  39953. * Update a video texture
  39954. * @param texture defines the texture to update
  39955. * @param video defines the video element to use
  39956. * @param invertY defines if data must be stored with Y axis inverted
  39957. */
  39958. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39959. }
  39960. }
  39961. }
  39962. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39964. import { Nullable } from "babylonjs/types";
  39965. module "babylonjs/Engines/thinEngine" {
  39966. interface ThinEngine {
  39967. /**
  39968. * Creates a dynamic texture
  39969. * @param width defines the width of the texture
  39970. * @param height defines the height of the texture
  39971. * @param generateMipMaps defines if the engine should generate the mip levels
  39972. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39973. * @returns the dynamic texture inside an InternalTexture
  39974. */
  39975. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39976. /**
  39977. * Update the content of a dynamic texture
  39978. * @param texture defines the texture to update
  39979. * @param canvas defines the canvas containing the source
  39980. * @param invertY defines if data must be stored with Y axis inverted
  39981. * @param premulAlpha defines if alpha is stored as premultiplied
  39982. * @param format defines the format of the data
  39983. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39984. */
  39985. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39986. }
  39987. }
  39988. }
  39989. declare module "babylonjs/Materials/Textures/videoTexture" {
  39990. import { Observable } from "babylonjs/Misc/observable";
  39991. import { Nullable } from "babylonjs/types";
  39992. import { Scene } from "babylonjs/scene";
  39993. import { Texture } from "babylonjs/Materials/Textures/texture";
  39994. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39995. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39996. /**
  39997. * Settings for finer control over video usage
  39998. */
  39999. export interface VideoTextureSettings {
  40000. /**
  40001. * Applies `autoplay` to video, if specified
  40002. */
  40003. autoPlay?: boolean;
  40004. /**
  40005. * Applies `muted` to video, if specified
  40006. */
  40007. muted?: boolean;
  40008. /**
  40009. * Applies `loop` to video, if specified
  40010. */
  40011. loop?: boolean;
  40012. /**
  40013. * Automatically updates internal texture from video at every frame in the render loop
  40014. */
  40015. autoUpdateTexture: boolean;
  40016. /**
  40017. * Image src displayed during the video loading or until the user interacts with the video.
  40018. */
  40019. poster?: string;
  40020. }
  40021. /**
  40022. * If you want to display a video in your scene, this is the special texture for that.
  40023. * This special texture works similar to other textures, with the exception of a few parameters.
  40024. * @see https://doc.babylonjs.com/how_to/video_texture
  40025. */
  40026. export class VideoTexture extends Texture {
  40027. /**
  40028. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40029. */
  40030. readonly autoUpdateTexture: boolean;
  40031. /**
  40032. * The video instance used by the texture internally
  40033. */
  40034. readonly video: HTMLVideoElement;
  40035. private _onUserActionRequestedObservable;
  40036. /**
  40037. * Event triggerd when a dom action is required by the user to play the video.
  40038. * This happens due to recent changes in browser policies preventing video to auto start.
  40039. */
  40040. get onUserActionRequestedObservable(): Observable<Texture>;
  40041. private _generateMipMaps;
  40042. private _stillImageCaptured;
  40043. private _displayingPosterTexture;
  40044. private _settings;
  40045. private _createInternalTextureOnEvent;
  40046. private _frameId;
  40047. private _currentSrc;
  40048. /**
  40049. * Creates a video texture.
  40050. * If you want to display a video in your scene, this is the special texture for that.
  40051. * This special texture works similar to other textures, with the exception of a few parameters.
  40052. * @see https://doc.babylonjs.com/how_to/video_texture
  40053. * @param name optional name, will detect from video source, if not defined
  40054. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40055. * @param scene is obviously the current scene.
  40056. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40057. * @param invertY is false by default but can be used to invert video on Y axis
  40058. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40059. * @param settings allows finer control over video usage
  40060. */
  40061. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40062. private _getName;
  40063. private _getVideo;
  40064. private _createInternalTexture;
  40065. private reset;
  40066. /**
  40067. * @hidden Internal method to initiate `update`.
  40068. */
  40069. _rebuild(): void;
  40070. /**
  40071. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40072. */
  40073. update(): void;
  40074. /**
  40075. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40076. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40077. */
  40078. updateTexture(isVisible: boolean): void;
  40079. protected _updateInternalTexture: () => void;
  40080. /**
  40081. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40082. * @param url New url.
  40083. */
  40084. updateURL(url: string): void;
  40085. /**
  40086. * Clones the texture.
  40087. * @returns the cloned texture
  40088. */
  40089. clone(): VideoTexture;
  40090. /**
  40091. * Dispose the texture and release its associated resources.
  40092. */
  40093. dispose(): void;
  40094. /**
  40095. * Creates a video texture straight from a stream.
  40096. * @param scene Define the scene the texture should be created in
  40097. * @param stream Define the stream the texture should be created from
  40098. * @returns The created video texture as a promise
  40099. */
  40100. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40101. /**
  40102. * Creates a video texture straight from your WebCam video feed.
  40103. * @param scene Define the scene the texture should be created in
  40104. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40105. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40106. * @returns The created video texture as a promise
  40107. */
  40108. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40109. minWidth: number;
  40110. maxWidth: number;
  40111. minHeight: number;
  40112. maxHeight: number;
  40113. deviceId: string;
  40114. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40115. /**
  40116. * Creates a video texture straight from your WebCam video feed.
  40117. * @param scene Define the scene the texture should be created in
  40118. * @param onReady Define a callback to triggered once the texture will be ready
  40119. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40120. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40121. */
  40122. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40123. minWidth: number;
  40124. maxWidth: number;
  40125. minHeight: number;
  40126. maxHeight: number;
  40127. deviceId: string;
  40128. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40129. }
  40130. }
  40131. declare module "babylonjs/Engines/thinEngine" {
  40132. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40133. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40134. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40135. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40136. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40137. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40138. import { Observable } from "babylonjs/Misc/observable";
  40139. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40140. import { StencilState } from "babylonjs/States/stencilState";
  40141. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40142. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40143. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40144. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40145. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40146. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40147. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40148. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40149. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40150. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40151. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40152. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40153. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40154. import { WebRequest } from "babylonjs/Misc/webRequest";
  40155. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40156. /**
  40157. * Defines the interface used by objects working like Scene
  40158. * @hidden
  40159. */
  40160. export interface ISceneLike {
  40161. _addPendingData(data: any): void;
  40162. _removePendingData(data: any): void;
  40163. offlineProvider: IOfflineProvider;
  40164. }
  40165. /**
  40166. * Information about the current host
  40167. */
  40168. export interface HostInformation {
  40169. /**
  40170. * Defines if the current host is a mobile
  40171. */
  40172. isMobile: boolean;
  40173. }
  40174. /** Interface defining initialization parameters for Engine class */
  40175. export interface EngineOptions extends WebGLContextAttributes {
  40176. /**
  40177. * Defines if the engine should no exceed a specified device ratio
  40178. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40179. */
  40180. limitDeviceRatio?: number;
  40181. /**
  40182. * Defines if webvr should be enabled automatically
  40183. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40184. */
  40185. autoEnableWebVR?: boolean;
  40186. /**
  40187. * Defines if webgl2 should be turned off even if supported
  40188. * @see https://doc.babylonjs.com/features/webgl2
  40189. */
  40190. disableWebGL2Support?: boolean;
  40191. /**
  40192. * Defines if webaudio should be initialized as well
  40193. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40194. */
  40195. audioEngine?: boolean;
  40196. /**
  40197. * Defines if animations should run using a deterministic lock step
  40198. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40199. */
  40200. deterministicLockstep?: boolean;
  40201. /** Defines the maximum steps to use with deterministic lock step mode */
  40202. lockstepMaxSteps?: number;
  40203. /** Defines the seconds between each deterministic lock step */
  40204. timeStep?: number;
  40205. /**
  40206. * Defines that engine should ignore context lost events
  40207. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40208. */
  40209. doNotHandleContextLost?: boolean;
  40210. /**
  40211. * Defines that engine should ignore modifying touch action attribute and style
  40212. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40213. */
  40214. doNotHandleTouchAction?: boolean;
  40215. /**
  40216. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40217. */
  40218. useHighPrecisionFloats?: boolean;
  40219. /**
  40220. * Make the canvas XR Compatible for XR sessions
  40221. */
  40222. xrCompatible?: boolean;
  40223. /**
  40224. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40225. */
  40226. useHighPrecisionMatrix?: boolean;
  40227. /**
  40228. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40229. */
  40230. failIfMajorPerformanceCaveat?: boolean;
  40231. }
  40232. /**
  40233. * The base engine class (root of all engines)
  40234. */
  40235. export class ThinEngine {
  40236. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40237. static ExceptionList: ({
  40238. key: string;
  40239. capture: string;
  40240. captureConstraint: number;
  40241. targets: string[];
  40242. } | {
  40243. key: string;
  40244. capture: null;
  40245. captureConstraint: null;
  40246. targets: string[];
  40247. })[];
  40248. /** @hidden */
  40249. static _TextureLoaders: IInternalTextureLoader[];
  40250. /**
  40251. * Returns the current npm package of the sdk
  40252. */
  40253. static get NpmPackage(): string;
  40254. /**
  40255. * Returns the current version of the framework
  40256. */
  40257. static get Version(): string;
  40258. /**
  40259. * Returns a string describing the current engine
  40260. */
  40261. get description(): string;
  40262. /**
  40263. * Gets or sets the epsilon value used by collision engine
  40264. */
  40265. static CollisionsEpsilon: number;
  40266. /**
  40267. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40268. */
  40269. static get ShadersRepository(): string;
  40270. static set ShadersRepository(value: string);
  40271. /** @hidden */
  40272. _shaderProcessor: IShaderProcessor;
  40273. /**
  40274. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40275. */
  40276. forcePOTTextures: boolean;
  40277. /**
  40278. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40279. */
  40280. isFullscreen: boolean;
  40281. /**
  40282. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40283. */
  40284. cullBackFaces: boolean;
  40285. /**
  40286. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40287. */
  40288. renderEvenInBackground: boolean;
  40289. /**
  40290. * Gets or sets a boolean indicating that cache can be kept between frames
  40291. */
  40292. preventCacheWipeBetweenFrames: boolean;
  40293. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40294. validateShaderPrograms: boolean;
  40295. /**
  40296. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40297. * This can provide greater z depth for distant objects.
  40298. */
  40299. useReverseDepthBuffer: boolean;
  40300. /**
  40301. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40302. */
  40303. disableUniformBuffers: boolean;
  40304. /** @hidden */
  40305. _uniformBuffers: UniformBuffer[];
  40306. /**
  40307. * Gets a boolean indicating that the engine supports uniform buffers
  40308. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40309. */
  40310. get supportsUniformBuffers(): boolean;
  40311. /** @hidden */
  40312. _gl: WebGLRenderingContext;
  40313. /** @hidden */
  40314. _webGLVersion: number;
  40315. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40316. protected _windowIsBackground: boolean;
  40317. protected _creationOptions: EngineOptions;
  40318. protected _highPrecisionShadersAllowed: boolean;
  40319. /** @hidden */
  40320. get _shouldUseHighPrecisionShader(): boolean;
  40321. /**
  40322. * Gets a boolean indicating that only power of 2 textures are supported
  40323. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40324. */
  40325. get needPOTTextures(): boolean;
  40326. /** @hidden */
  40327. _badOS: boolean;
  40328. /** @hidden */
  40329. _badDesktopOS: boolean;
  40330. private _hardwareScalingLevel;
  40331. /** @hidden */
  40332. _caps: EngineCapabilities;
  40333. private _isStencilEnable;
  40334. private _glVersion;
  40335. private _glRenderer;
  40336. private _glVendor;
  40337. /** @hidden */
  40338. _videoTextureSupported: boolean;
  40339. protected _renderingQueueLaunched: boolean;
  40340. protected _activeRenderLoops: (() => void)[];
  40341. /**
  40342. * Observable signaled when a context lost event is raised
  40343. */
  40344. onContextLostObservable: Observable<ThinEngine>;
  40345. /**
  40346. * Observable signaled when a context restored event is raised
  40347. */
  40348. onContextRestoredObservable: Observable<ThinEngine>;
  40349. private _onContextLost;
  40350. private _onContextRestored;
  40351. protected _contextWasLost: boolean;
  40352. /** @hidden */
  40353. _doNotHandleContextLost: boolean;
  40354. /**
  40355. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40357. */
  40358. get doNotHandleContextLost(): boolean;
  40359. set doNotHandleContextLost(value: boolean);
  40360. /**
  40361. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40362. */
  40363. disableVertexArrayObjects: boolean;
  40364. /** @hidden */
  40365. protected _colorWrite: boolean;
  40366. /** @hidden */
  40367. protected _colorWriteChanged: boolean;
  40368. /** @hidden */
  40369. protected _depthCullingState: DepthCullingState;
  40370. /** @hidden */
  40371. protected _stencilState: StencilState;
  40372. /** @hidden */
  40373. _alphaState: AlphaState;
  40374. /** @hidden */
  40375. _alphaMode: number;
  40376. /** @hidden */
  40377. _alphaEquation: number;
  40378. /** @hidden */
  40379. _internalTexturesCache: InternalTexture[];
  40380. /** @hidden */
  40381. protected _activeChannel: number;
  40382. private _currentTextureChannel;
  40383. /** @hidden */
  40384. protected _boundTexturesCache: {
  40385. [key: string]: Nullable<InternalTexture>;
  40386. };
  40387. /** @hidden */
  40388. protected _currentEffect: Nullable<Effect>;
  40389. /** @hidden */
  40390. protected _currentProgram: Nullable<WebGLProgram>;
  40391. private _compiledEffects;
  40392. private _vertexAttribArraysEnabled;
  40393. /** @hidden */
  40394. protected _cachedViewport: Nullable<IViewportLike>;
  40395. private _cachedVertexArrayObject;
  40396. /** @hidden */
  40397. protected _cachedVertexBuffers: any;
  40398. /** @hidden */
  40399. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40400. /** @hidden */
  40401. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40402. /** @hidden */
  40403. _currentRenderTarget: Nullable<InternalTexture>;
  40404. private _uintIndicesCurrentlySet;
  40405. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40406. /** @hidden */
  40407. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40408. /** @hidden */
  40409. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40410. private _currentBufferPointers;
  40411. private _currentInstanceLocations;
  40412. private _currentInstanceBuffers;
  40413. private _textureUnits;
  40414. /** @hidden */
  40415. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40416. /** @hidden */
  40417. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40418. /** @hidden */
  40419. _boundRenderFunction: any;
  40420. private _vaoRecordInProgress;
  40421. private _mustWipeVertexAttributes;
  40422. private _emptyTexture;
  40423. private _emptyCubeTexture;
  40424. private _emptyTexture3D;
  40425. private _emptyTexture2DArray;
  40426. /** @hidden */
  40427. _frameHandler: number;
  40428. private _nextFreeTextureSlots;
  40429. private _maxSimultaneousTextures;
  40430. private _activeRequests;
  40431. /** @hidden */
  40432. _transformTextureUrl: Nullable<(url: string) => string>;
  40433. /**
  40434. * Gets information about the current host
  40435. */
  40436. hostInformation: HostInformation;
  40437. protected get _supportsHardwareTextureRescaling(): boolean;
  40438. private _framebufferDimensionsObject;
  40439. /**
  40440. * sets the object from which width and height will be taken from when getting render width and height
  40441. * Will fallback to the gl object
  40442. * @param dimensions the framebuffer width and height that will be used.
  40443. */
  40444. set framebufferDimensionsObject(dimensions: Nullable<{
  40445. framebufferWidth: number;
  40446. framebufferHeight: number;
  40447. }>);
  40448. /**
  40449. * Gets the current viewport
  40450. */
  40451. get currentViewport(): Nullable<IViewportLike>;
  40452. /**
  40453. * Gets the default empty texture
  40454. */
  40455. get emptyTexture(): InternalTexture;
  40456. /**
  40457. * Gets the default empty 3D texture
  40458. */
  40459. get emptyTexture3D(): InternalTexture;
  40460. /**
  40461. * Gets the default empty 2D array texture
  40462. */
  40463. get emptyTexture2DArray(): InternalTexture;
  40464. /**
  40465. * Gets the default empty cube texture
  40466. */
  40467. get emptyCubeTexture(): InternalTexture;
  40468. /**
  40469. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40470. */
  40471. readonly premultipliedAlpha: boolean;
  40472. /**
  40473. * Observable event triggered before each texture is initialized
  40474. */
  40475. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40476. /**
  40477. * Creates a new engine
  40478. * @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
  40479. * @param antialias defines enable antialiasing (default: false)
  40480. * @param options defines further options to be sent to the getContext() function
  40481. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40482. */
  40483. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40484. private _rebuildInternalTextures;
  40485. private _rebuildEffects;
  40486. /**
  40487. * Gets a boolean indicating if all created effects are ready
  40488. * @returns true if all effects are ready
  40489. */
  40490. areAllEffectsReady(): boolean;
  40491. protected _rebuildBuffers(): void;
  40492. protected _initGLContext(): void;
  40493. /**
  40494. * Gets version of the current webGL context
  40495. */
  40496. get webGLVersion(): number;
  40497. /**
  40498. * Gets a string identifying the name of the class
  40499. * @returns "Engine" string
  40500. */
  40501. getClassName(): string;
  40502. /**
  40503. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40504. */
  40505. get isStencilEnable(): boolean;
  40506. /** @hidden */
  40507. _prepareWorkingCanvas(): void;
  40508. /**
  40509. * Reset the texture cache to empty state
  40510. */
  40511. resetTextureCache(): void;
  40512. /**
  40513. * Gets an object containing information about the current webGL context
  40514. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40515. */
  40516. getGlInfo(): {
  40517. vendor: string;
  40518. renderer: string;
  40519. version: string;
  40520. };
  40521. /**
  40522. * Defines the hardware scaling level.
  40523. * By default the hardware scaling level is computed from the window device ratio.
  40524. * 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.
  40525. * @param level defines the level to use
  40526. */
  40527. setHardwareScalingLevel(level: number): void;
  40528. /**
  40529. * Gets the current hardware scaling level.
  40530. * By default the hardware scaling level is computed from the window device ratio.
  40531. * 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.
  40532. * @returns a number indicating the current hardware scaling level
  40533. */
  40534. getHardwareScalingLevel(): number;
  40535. /**
  40536. * Gets the list of loaded textures
  40537. * @returns an array containing all loaded textures
  40538. */
  40539. getLoadedTexturesCache(): InternalTexture[];
  40540. /**
  40541. * Gets the object containing all engine capabilities
  40542. * @returns the EngineCapabilities object
  40543. */
  40544. getCaps(): EngineCapabilities;
  40545. /**
  40546. * stop executing a render loop function and remove it from the execution array
  40547. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40548. */
  40549. stopRenderLoop(renderFunction?: () => void): void;
  40550. /** @hidden */
  40551. _renderLoop(): void;
  40552. /**
  40553. * Gets the HTML canvas attached with the current webGL context
  40554. * @returns a HTML canvas
  40555. */
  40556. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40557. /**
  40558. * Gets host window
  40559. * @returns the host window object
  40560. */
  40561. getHostWindow(): Nullable<Window>;
  40562. /**
  40563. * Gets the current render width
  40564. * @param useScreen defines if screen size must be used (or the current render target if any)
  40565. * @returns a number defining the current render width
  40566. */
  40567. getRenderWidth(useScreen?: boolean): number;
  40568. /**
  40569. * Gets the current render height
  40570. * @param useScreen defines if screen size must be used (or the current render target if any)
  40571. * @returns a number defining the current render height
  40572. */
  40573. getRenderHeight(useScreen?: boolean): number;
  40574. /**
  40575. * Can be used to override the current requestAnimationFrame requester.
  40576. * @hidden
  40577. */
  40578. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40579. /**
  40580. * Register and execute a render loop. The engine can have more than one render function
  40581. * @param renderFunction defines the function to continuously execute
  40582. */
  40583. runRenderLoop(renderFunction: () => void): void;
  40584. /**
  40585. * Clear the current render buffer or the current render target (if any is set up)
  40586. * @param color defines the color to use
  40587. * @param backBuffer defines if the back buffer must be cleared
  40588. * @param depth defines if the depth buffer must be cleared
  40589. * @param stencil defines if the stencil buffer must be cleared
  40590. */
  40591. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40592. private _viewportCached;
  40593. /** @hidden */
  40594. _viewport(x: number, y: number, width: number, height: number): void;
  40595. /**
  40596. * Set the WebGL's viewport
  40597. * @param viewport defines the viewport element to be used
  40598. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40599. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40600. */
  40601. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40602. /**
  40603. * Begin a new frame
  40604. */
  40605. beginFrame(): void;
  40606. /**
  40607. * Enf the current frame
  40608. */
  40609. endFrame(): void;
  40610. /**
  40611. * Resize the view according to the canvas' size
  40612. */
  40613. resize(): void;
  40614. /**
  40615. * Force a specific size of the canvas
  40616. * @param width defines the new canvas' width
  40617. * @param height defines the new canvas' height
  40618. * @returns true if the size was changed
  40619. */
  40620. setSize(width: number, height: number): boolean;
  40621. /**
  40622. * Binds the frame buffer to the specified texture.
  40623. * @param texture The texture to render to or null for the default canvas
  40624. * @param faceIndex The face of the texture to render to in case of cube texture
  40625. * @param requiredWidth The width of the target to render to
  40626. * @param requiredHeight The height of the target to render to
  40627. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40628. * @param lodLevel defines the lod level to bind to the frame buffer
  40629. * @param layer defines the 2d array index to bind to frame buffer to
  40630. */
  40631. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40632. /** @hidden */
  40633. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40634. /**
  40635. * Unbind the current render target texture from the webGL context
  40636. * @param texture defines the render target texture to unbind
  40637. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40638. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40639. */
  40640. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40641. /**
  40642. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40643. */
  40644. flushFramebuffer(): void;
  40645. /**
  40646. * Unbind the current render target and bind the default framebuffer
  40647. */
  40648. restoreDefaultFramebuffer(): void;
  40649. /** @hidden */
  40650. protected _resetVertexBufferBinding(): void;
  40651. /**
  40652. * Creates a vertex buffer
  40653. * @param data the data for the vertex buffer
  40654. * @returns the new WebGL static buffer
  40655. */
  40656. createVertexBuffer(data: DataArray): DataBuffer;
  40657. private _createVertexBuffer;
  40658. /**
  40659. * Creates a dynamic vertex buffer
  40660. * @param data the data for the dynamic vertex buffer
  40661. * @returns the new WebGL dynamic buffer
  40662. */
  40663. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40664. protected _resetIndexBufferBinding(): void;
  40665. /**
  40666. * Creates a new index buffer
  40667. * @param indices defines the content of the index buffer
  40668. * @param updatable defines if the index buffer must be updatable
  40669. * @returns a new webGL buffer
  40670. */
  40671. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40672. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40673. /**
  40674. * Bind a webGL buffer to the webGL context
  40675. * @param buffer defines the buffer to bind
  40676. */
  40677. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40678. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40679. private bindBuffer;
  40680. /**
  40681. * update the bound buffer with the given data
  40682. * @param data defines the data to update
  40683. */
  40684. updateArrayBuffer(data: Float32Array): void;
  40685. private _vertexAttribPointer;
  40686. /** @hidden */
  40687. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40688. private _bindVertexBuffersAttributes;
  40689. /**
  40690. * Records a vertex array object
  40691. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40692. * @param vertexBuffers defines the list of vertex buffers to store
  40693. * @param indexBuffer defines the index buffer to store
  40694. * @param effect defines the effect to store
  40695. * @returns the new vertex array object
  40696. */
  40697. recordVertexArrayObject(vertexBuffers: {
  40698. [key: string]: VertexBuffer;
  40699. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40700. /**
  40701. * Bind a specific vertex array object
  40702. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40703. * @param vertexArrayObject defines the vertex array object to bind
  40704. * @param indexBuffer defines the index buffer to bind
  40705. */
  40706. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40707. /**
  40708. * Bind webGl buffers directly to the webGL context
  40709. * @param vertexBuffer defines the vertex buffer to bind
  40710. * @param indexBuffer defines the index buffer to bind
  40711. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40712. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40713. * @param effect defines the effect associated with the vertex buffer
  40714. */
  40715. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40716. private _unbindVertexArrayObject;
  40717. /**
  40718. * Bind a list of vertex buffers to the webGL context
  40719. * @param vertexBuffers defines the list of vertex buffers to bind
  40720. * @param indexBuffer defines the index buffer to bind
  40721. * @param effect defines the effect associated with the vertex buffers
  40722. */
  40723. bindBuffers(vertexBuffers: {
  40724. [key: string]: Nullable<VertexBuffer>;
  40725. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40726. /**
  40727. * Unbind all instance attributes
  40728. */
  40729. unbindInstanceAttributes(): void;
  40730. /**
  40731. * Release and free the memory of a vertex array object
  40732. * @param vao defines the vertex array object to delete
  40733. */
  40734. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40735. /** @hidden */
  40736. _releaseBuffer(buffer: DataBuffer): boolean;
  40737. protected _deleteBuffer(buffer: DataBuffer): void;
  40738. /**
  40739. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40740. * @param instancesBuffer defines the webGL buffer to update and bind
  40741. * @param data defines the data to store in the buffer
  40742. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40743. */
  40744. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40745. /**
  40746. * Bind the content of a webGL buffer used with instantiation
  40747. * @param instancesBuffer defines the webGL buffer to bind
  40748. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40749. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40750. */
  40751. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40752. /**
  40753. * Disable the instance attribute corresponding to the name in parameter
  40754. * @param name defines the name of the attribute to disable
  40755. */
  40756. disableInstanceAttributeByName(name: string): void;
  40757. /**
  40758. * Disable the instance attribute corresponding to the location in parameter
  40759. * @param attributeLocation defines the attribute location of the attribute to disable
  40760. */
  40761. disableInstanceAttribute(attributeLocation: number): void;
  40762. /**
  40763. * Disable the attribute corresponding to the location in parameter
  40764. * @param attributeLocation defines the attribute location of the attribute to disable
  40765. */
  40766. disableAttributeByIndex(attributeLocation: number): void;
  40767. /**
  40768. * Send a draw order
  40769. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40770. * @param indexStart defines the starting index
  40771. * @param indexCount defines the number of index to draw
  40772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40773. */
  40774. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40775. /**
  40776. * Draw a list of points
  40777. * @param verticesStart defines the index of first vertex to draw
  40778. * @param verticesCount defines the count of vertices to draw
  40779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40780. */
  40781. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40782. /**
  40783. * Draw a list of unindexed primitives
  40784. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40785. * @param verticesStart defines the index of first vertex to draw
  40786. * @param verticesCount defines the count of vertices to draw
  40787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40788. */
  40789. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40790. /**
  40791. * Draw a list of indexed primitives
  40792. * @param fillMode defines the primitive to use
  40793. * @param indexStart defines the starting index
  40794. * @param indexCount defines the number of index to draw
  40795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40796. */
  40797. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40798. /**
  40799. * Draw a list of unindexed primitives
  40800. * @param fillMode defines the primitive to use
  40801. * @param verticesStart defines the index of first vertex to draw
  40802. * @param verticesCount defines the count of vertices to draw
  40803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40804. */
  40805. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40806. private _drawMode;
  40807. /** @hidden */
  40808. protected _reportDrawCall(): void;
  40809. /** @hidden */
  40810. _releaseEffect(effect: Effect): void;
  40811. /** @hidden */
  40812. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40813. /**
  40814. * Create a new effect (used to store vertex/fragment shaders)
  40815. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40816. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40817. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40818. * @param samplers defines an array of string used to represent textures
  40819. * @param defines defines the string containing the defines to use to compile the shaders
  40820. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40821. * @param onCompiled defines a function to call when the effect creation is successful
  40822. * @param onError defines a function to call when the effect creation has failed
  40823. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40824. * @returns the new Effect
  40825. */
  40826. 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;
  40827. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40828. private _compileShader;
  40829. private _compileRawShader;
  40830. /** @hidden */
  40831. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40832. /**
  40833. * Directly creates a webGL program
  40834. * @param pipelineContext defines the pipeline context to attach to
  40835. * @param vertexCode defines the vertex shader code to use
  40836. * @param fragmentCode defines the fragment shader code to use
  40837. * @param context defines the webGL context to use (if not set, the current one will be used)
  40838. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40839. * @returns the new webGL program
  40840. */
  40841. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40842. /**
  40843. * Creates a webGL program
  40844. * @param pipelineContext defines the pipeline context to attach to
  40845. * @param vertexCode defines the vertex shader code to use
  40846. * @param fragmentCode defines the fragment shader code to use
  40847. * @param defines defines the string containing the defines to use to compile the shaders
  40848. * @param context defines the webGL context to use (if not set, the current one will be used)
  40849. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40850. * @returns the new webGL program
  40851. */
  40852. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40853. /**
  40854. * Creates a new pipeline context
  40855. * @returns the new pipeline
  40856. */
  40857. createPipelineContext(): IPipelineContext;
  40858. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40859. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40860. /** @hidden */
  40861. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40862. /** @hidden */
  40863. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40864. /** @hidden */
  40865. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40866. /**
  40867. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40868. * @param pipelineContext defines the pipeline context to use
  40869. * @param uniformsNames defines the list of uniform names
  40870. * @returns an array of webGL uniform locations
  40871. */
  40872. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40873. /**
  40874. * Gets the lsit of active attributes for a given webGL program
  40875. * @param pipelineContext defines the pipeline context to use
  40876. * @param attributesNames defines the list of attribute names to get
  40877. * @returns an array of indices indicating the offset of each attribute
  40878. */
  40879. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40880. /**
  40881. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40882. * @param effect defines the effect to activate
  40883. */
  40884. enableEffect(effect: Nullable<Effect>): void;
  40885. /**
  40886. * Set the value of an uniform to a number (int)
  40887. * @param uniform defines the webGL uniform location where to store the value
  40888. * @param value defines the int number to store
  40889. * @returns true if the value was set
  40890. */
  40891. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40892. /**
  40893. * Set the value of an uniform to an array of int32
  40894. * @param uniform defines the webGL uniform location where to store the value
  40895. * @param array defines the array of int32 to store
  40896. * @returns true if the value was set
  40897. */
  40898. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40899. /**
  40900. * Set the value of an uniform to an array of int32 (stored as vec2)
  40901. * @param uniform defines the webGL uniform location where to store the value
  40902. * @param array defines the array of int32 to store
  40903. * @returns true if the value was set
  40904. */
  40905. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40906. /**
  40907. * Set the value of an uniform to an array of int32 (stored as vec3)
  40908. * @param uniform defines the webGL uniform location where to store the value
  40909. * @param array defines the array of int32 to store
  40910. * @returns true if the value was set
  40911. */
  40912. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40913. /**
  40914. * Set the value of an uniform to an array of int32 (stored as vec4)
  40915. * @param uniform defines the webGL uniform location where to store the value
  40916. * @param array defines the array of int32 to store
  40917. * @returns true if the value was set
  40918. */
  40919. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40920. /**
  40921. * Set the value of an uniform to an array of number
  40922. * @param uniform defines the webGL uniform location where to store the value
  40923. * @param array defines the array of number to store
  40924. * @returns true if the value was set
  40925. */
  40926. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40927. /**
  40928. * Set the value of an uniform to an array of number (stored as vec2)
  40929. * @param uniform defines the webGL uniform location where to store the value
  40930. * @param array defines the array of number to store
  40931. * @returns true if the value was set
  40932. */
  40933. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40934. /**
  40935. * Set the value of an uniform to an array of number (stored as vec3)
  40936. * @param uniform defines the webGL uniform location where to store the value
  40937. * @param array defines the array of number to store
  40938. * @returns true if the value was set
  40939. */
  40940. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40941. /**
  40942. * Set the value of an uniform to an array of number (stored as vec4)
  40943. * @param uniform defines the webGL uniform location where to store the value
  40944. * @param array defines the array of number to store
  40945. * @returns true if the value was set
  40946. */
  40947. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40948. /**
  40949. * Set the value of an uniform to an array of float32 (stored as matrices)
  40950. * @param uniform defines the webGL uniform location where to store the value
  40951. * @param matrices defines the array of float32 to store
  40952. * @returns true if the value was set
  40953. */
  40954. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40955. /**
  40956. * Set the value of an uniform to a matrix (3x3)
  40957. * @param uniform defines the webGL uniform location where to store the value
  40958. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40959. * @returns true if the value was set
  40960. */
  40961. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40962. /**
  40963. * Set the value of an uniform to a matrix (2x2)
  40964. * @param uniform defines the webGL uniform location where to store the value
  40965. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40966. * @returns true if the value was set
  40967. */
  40968. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40969. /**
  40970. * Set the value of an uniform to a number (float)
  40971. * @param uniform defines the webGL uniform location where to store the value
  40972. * @param value defines the float number to store
  40973. * @returns true if the value was transfered
  40974. */
  40975. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40976. /**
  40977. * Set the value of an uniform to a vec2
  40978. * @param uniform defines the webGL uniform location where to store the value
  40979. * @param x defines the 1st component of the value
  40980. * @param y defines the 2nd component of the value
  40981. * @returns true if the value was set
  40982. */
  40983. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40984. /**
  40985. * Set the value of an uniform to a vec3
  40986. * @param uniform defines the webGL uniform location where to store the value
  40987. * @param x defines the 1st component of the value
  40988. * @param y defines the 2nd component of the value
  40989. * @param z defines the 3rd component of the value
  40990. * @returns true if the value was set
  40991. */
  40992. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40993. /**
  40994. * Set the value of an uniform to a vec4
  40995. * @param uniform defines the webGL uniform location where to store the value
  40996. * @param x defines the 1st component of the value
  40997. * @param y defines the 2nd component of the value
  40998. * @param z defines the 3rd component of the value
  40999. * @param w defines the 4th component of the value
  41000. * @returns true if the value was set
  41001. */
  41002. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41003. /**
  41004. * Apply all cached states (depth, culling, stencil and alpha)
  41005. */
  41006. applyStates(): void;
  41007. /**
  41008. * Enable or disable color writing
  41009. * @param enable defines the state to set
  41010. */
  41011. setColorWrite(enable: boolean): void;
  41012. /**
  41013. * Gets a boolean indicating if color writing is enabled
  41014. * @returns the current color writing state
  41015. */
  41016. getColorWrite(): boolean;
  41017. /**
  41018. * Gets the depth culling state manager
  41019. */
  41020. get depthCullingState(): DepthCullingState;
  41021. /**
  41022. * Gets the alpha state manager
  41023. */
  41024. get alphaState(): AlphaState;
  41025. /**
  41026. * Gets the stencil state manager
  41027. */
  41028. get stencilState(): StencilState;
  41029. /**
  41030. * Clears the list of texture accessible through engine.
  41031. * This can help preventing texture load conflict due to name collision.
  41032. */
  41033. clearInternalTexturesCache(): void;
  41034. /**
  41035. * Force the entire cache to be cleared
  41036. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41037. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41038. */
  41039. wipeCaches(bruteForce?: boolean): void;
  41040. /** @hidden */
  41041. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41042. min: number;
  41043. mag: number;
  41044. };
  41045. /** @hidden */
  41046. _createTexture(): WebGLTexture;
  41047. /**
  41048. * Usually called from Texture.ts.
  41049. * Passed information to create a WebGLTexture
  41050. * @param url defines a value which contains one of the following:
  41051. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41052. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41053. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41054. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41055. * @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)
  41056. * @param scene needed for loading to the correct scene
  41057. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41058. * @param onLoad optional callback to be called upon successful completion
  41059. * @param onError optional callback to be called upon failure
  41060. * @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
  41061. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41062. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41063. * @param forcedExtension defines the extension to use to pick the right loader
  41064. * @param mimeType defines an optional mime type
  41065. * @param loaderOptions options to be passed to the loader
  41066. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41067. */
  41068. 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;
  41069. /**
  41070. * Loads an image as an HTMLImageElement.
  41071. * @param input url string, ArrayBuffer, or Blob to load
  41072. * @param onLoad callback called when the image successfully loads
  41073. * @param onError callback called when the image fails to load
  41074. * @param offlineProvider offline provider for caching
  41075. * @param mimeType optional mime type
  41076. * @returns the HTMLImageElement of the loaded image
  41077. * @hidden
  41078. */
  41079. 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>;
  41080. /**
  41081. * @hidden
  41082. */
  41083. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41084. private _unpackFlipYCached;
  41085. /**
  41086. * In case you are sharing the context with other applications, it might
  41087. * be interested to not cache the unpack flip y state to ensure a consistent
  41088. * value would be set.
  41089. */
  41090. enableUnpackFlipYCached: boolean;
  41091. /** @hidden */
  41092. _unpackFlipY(value: boolean): void;
  41093. /** @hidden */
  41094. _getUnpackAlignement(): number;
  41095. private _getTextureTarget;
  41096. /**
  41097. * Update the sampling mode of a given texture
  41098. * @param samplingMode defines the required sampling mode
  41099. * @param texture defines the texture to update
  41100. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41101. */
  41102. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41103. /**
  41104. * Update the sampling mode of a given texture
  41105. * @param texture defines the texture to update
  41106. * @param wrapU defines the texture wrap mode of the u coordinates
  41107. * @param wrapV defines the texture wrap mode of the v coordinates
  41108. * @param wrapR defines the texture wrap mode of the r coordinates
  41109. */
  41110. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41111. /** @hidden */
  41112. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41113. width: number;
  41114. height: number;
  41115. layers?: number;
  41116. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41117. /** @hidden */
  41118. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41119. /** @hidden */
  41120. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41121. /**
  41122. * Update a portion of an internal texture
  41123. * @param texture defines the texture to update
  41124. * @param imageData defines the data to store into the texture
  41125. * @param xOffset defines the x coordinates of the update rectangle
  41126. * @param yOffset defines the y coordinates of the update rectangle
  41127. * @param width defines the width of the update rectangle
  41128. * @param height defines the height of the update rectangle
  41129. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41130. * @param lod defines the lod level to update (0 by default)
  41131. */
  41132. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41133. /** @hidden */
  41134. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41135. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41136. private _prepareWebGLTexture;
  41137. /** @hidden */
  41138. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41139. private _getDepthStencilBuffer;
  41140. /** @hidden */
  41141. _releaseFramebufferObjects(texture: InternalTexture): void;
  41142. /** @hidden */
  41143. _releaseTexture(texture: InternalTexture): void;
  41144. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41145. protected _setProgram(program: WebGLProgram): void;
  41146. protected _boundUniforms: {
  41147. [key: number]: WebGLUniformLocation;
  41148. };
  41149. /**
  41150. * Binds an effect to the webGL context
  41151. * @param effect defines the effect to bind
  41152. */
  41153. bindSamplers(effect: Effect): void;
  41154. private _activateCurrentTexture;
  41155. /** @hidden */
  41156. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41157. /** @hidden */
  41158. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41159. /**
  41160. * Unbind all textures from the webGL context
  41161. */
  41162. unbindAllTextures(): void;
  41163. /**
  41164. * Sets a texture to the according uniform.
  41165. * @param channel The texture channel
  41166. * @param uniform The uniform to set
  41167. * @param texture The texture to apply
  41168. */
  41169. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  41170. private _bindSamplerUniformToChannel;
  41171. private _getTextureWrapMode;
  41172. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41173. /**
  41174. * Sets an array of texture to the webGL context
  41175. * @param channel defines the channel where the texture array must be set
  41176. * @param uniform defines the associated uniform location
  41177. * @param textures defines the array of textures to bind
  41178. */
  41179. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  41180. /** @hidden */
  41181. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41182. private _setTextureParameterFloat;
  41183. private _setTextureParameterInteger;
  41184. /**
  41185. * Unbind all vertex attributes from the webGL context
  41186. */
  41187. unbindAllAttributes(): void;
  41188. /**
  41189. * 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
  41190. */
  41191. releaseEffects(): void;
  41192. /**
  41193. * Dispose and release all associated resources
  41194. */
  41195. dispose(): void;
  41196. /**
  41197. * Attach a new callback raised when context lost event is fired
  41198. * @param callback defines the callback to call
  41199. */
  41200. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41201. /**
  41202. * Attach a new callback raised when context restored event is fired
  41203. * @param callback defines the callback to call
  41204. */
  41205. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41206. /**
  41207. * Get the current error code of the webGL context
  41208. * @returns the error code
  41209. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41210. */
  41211. getError(): number;
  41212. private _canRenderToFloatFramebuffer;
  41213. private _canRenderToHalfFloatFramebuffer;
  41214. private _canRenderToFramebuffer;
  41215. /** @hidden */
  41216. _getWebGLTextureType(type: number): number;
  41217. /** @hidden */
  41218. _getInternalFormat(format: number): number;
  41219. /** @hidden */
  41220. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41221. /** @hidden */
  41222. _getRGBAMultiSampleBufferFormat(type: number): number;
  41223. /** @hidden */
  41224. _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;
  41225. /**
  41226. * Loads a file from a url
  41227. * @param url url to load
  41228. * @param onSuccess callback called when the file successfully loads
  41229. * @param onProgress callback called while file is loading (if the server supports this mode)
  41230. * @param offlineProvider defines the offline provider for caching
  41231. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41232. * @param onError callback called when the file fails to load
  41233. * @returns a file request object
  41234. * @hidden
  41235. */
  41236. 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;
  41237. /**
  41238. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41239. * @param x defines the x coordinate of the rectangle where pixels must be read
  41240. * @param y defines the y coordinate of the rectangle where pixels must be read
  41241. * @param width defines the width of the rectangle where pixels must be read
  41242. * @param height defines the height of the rectangle where pixels must be read
  41243. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41244. * @returns a Uint8Array containing RGBA colors
  41245. */
  41246. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41247. private static _IsSupported;
  41248. private static _HasMajorPerformanceCaveat;
  41249. /**
  41250. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41251. */
  41252. static get IsSupported(): boolean;
  41253. /**
  41254. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41255. * @returns true if the engine can be created
  41256. * @ignorenaming
  41257. */
  41258. static isSupported(): boolean;
  41259. /**
  41260. * 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)
  41261. */
  41262. static get HasMajorPerformanceCaveat(): boolean;
  41263. /**
  41264. * Find the next highest power of two.
  41265. * @param x Number to start search from.
  41266. * @return Next highest power of two.
  41267. */
  41268. static CeilingPOT(x: number): number;
  41269. /**
  41270. * Find the next lowest power of two.
  41271. * @param x Number to start search from.
  41272. * @return Next lowest power of two.
  41273. */
  41274. static FloorPOT(x: number): number;
  41275. /**
  41276. * Find the nearest power of two.
  41277. * @param x Number to start search from.
  41278. * @return Next nearest power of two.
  41279. */
  41280. static NearestPOT(x: number): number;
  41281. /**
  41282. * Get the closest exponent of two
  41283. * @param value defines the value to approximate
  41284. * @param max defines the maximum value to return
  41285. * @param mode defines how to define the closest value
  41286. * @returns closest exponent of two of the given value
  41287. */
  41288. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41289. /**
  41290. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41291. * @param func - the function to be called
  41292. * @param requester - the object that will request the next frame. Falls back to window.
  41293. * @returns frame number
  41294. */
  41295. static QueueNewFrame(func: () => void, requester?: any): number;
  41296. /**
  41297. * Gets host document
  41298. * @returns the host document object
  41299. */
  41300. getHostDocument(): Nullable<Document>;
  41301. }
  41302. }
  41303. declare module "babylonjs/Materials/Textures/internalTexture" {
  41304. import { Observable } from "babylonjs/Misc/observable";
  41305. import { Nullable, int } from "babylonjs/types";
  41306. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41308. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41309. /**
  41310. * Defines the source of the internal texture
  41311. */
  41312. export enum InternalTextureSource {
  41313. /**
  41314. * The source of the texture data is unknown
  41315. */
  41316. Unknown = 0,
  41317. /**
  41318. * Texture data comes from an URL
  41319. */
  41320. Url = 1,
  41321. /**
  41322. * Texture data is only used for temporary storage
  41323. */
  41324. Temp = 2,
  41325. /**
  41326. * Texture data comes from raw data (ArrayBuffer)
  41327. */
  41328. Raw = 3,
  41329. /**
  41330. * Texture content is dynamic (video or dynamic texture)
  41331. */
  41332. Dynamic = 4,
  41333. /**
  41334. * Texture content is generated by rendering to it
  41335. */
  41336. RenderTarget = 5,
  41337. /**
  41338. * Texture content is part of a multi render target process
  41339. */
  41340. MultiRenderTarget = 6,
  41341. /**
  41342. * Texture data comes from a cube data file
  41343. */
  41344. Cube = 7,
  41345. /**
  41346. * Texture data comes from a raw cube data
  41347. */
  41348. CubeRaw = 8,
  41349. /**
  41350. * Texture data come from a prefiltered cube data file
  41351. */
  41352. CubePrefiltered = 9,
  41353. /**
  41354. * Texture content is raw 3D data
  41355. */
  41356. Raw3D = 10,
  41357. /**
  41358. * Texture content is raw 2D array data
  41359. */
  41360. Raw2DArray = 11,
  41361. /**
  41362. * Texture content is a depth texture
  41363. */
  41364. Depth = 12,
  41365. /**
  41366. * Texture data comes from a raw cube data encoded with RGBD
  41367. */
  41368. CubeRawRGBD = 13
  41369. }
  41370. /**
  41371. * Class used to store data associated with WebGL texture data for the engine
  41372. * This class should not be used directly
  41373. */
  41374. export class InternalTexture {
  41375. /** @hidden */
  41376. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41377. /**
  41378. * Defines if the texture is ready
  41379. */
  41380. isReady: boolean;
  41381. /**
  41382. * Defines if the texture is a cube texture
  41383. */
  41384. isCube: boolean;
  41385. /**
  41386. * Defines if the texture contains 3D data
  41387. */
  41388. is3D: boolean;
  41389. /**
  41390. * Defines if the texture contains 2D array data
  41391. */
  41392. is2DArray: boolean;
  41393. /**
  41394. * Defines if the texture contains multiview data
  41395. */
  41396. isMultiview: boolean;
  41397. /**
  41398. * Gets the URL used to load this texture
  41399. */
  41400. url: string;
  41401. /**
  41402. * Gets the sampling mode of the texture
  41403. */
  41404. samplingMode: number;
  41405. /**
  41406. * Gets a boolean indicating if the texture needs mipmaps generation
  41407. */
  41408. generateMipMaps: boolean;
  41409. /**
  41410. * Gets the number of samples used by the texture (WebGL2+ only)
  41411. */
  41412. samples: number;
  41413. /**
  41414. * Gets the type of the texture (int, float...)
  41415. */
  41416. type: number;
  41417. /**
  41418. * Gets the format of the texture (RGB, RGBA...)
  41419. */
  41420. format: number;
  41421. /**
  41422. * Observable called when the texture is loaded
  41423. */
  41424. onLoadedObservable: Observable<InternalTexture>;
  41425. /**
  41426. * Gets the width of the texture
  41427. */
  41428. width: number;
  41429. /**
  41430. * Gets the height of the texture
  41431. */
  41432. height: number;
  41433. /**
  41434. * Gets the depth of the texture
  41435. */
  41436. depth: number;
  41437. /**
  41438. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41439. */
  41440. baseWidth: number;
  41441. /**
  41442. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41443. */
  41444. baseHeight: number;
  41445. /**
  41446. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41447. */
  41448. baseDepth: number;
  41449. /**
  41450. * Gets a boolean indicating if the texture is inverted on Y axis
  41451. */
  41452. invertY: boolean;
  41453. /** @hidden */
  41454. _invertVScale: boolean;
  41455. /** @hidden */
  41456. _associatedChannel: number;
  41457. /** @hidden */
  41458. _source: InternalTextureSource;
  41459. /** @hidden */
  41460. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41461. /** @hidden */
  41462. _bufferView: Nullable<ArrayBufferView>;
  41463. /** @hidden */
  41464. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41465. /** @hidden */
  41466. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41467. /** @hidden */
  41468. _size: number;
  41469. /** @hidden */
  41470. _extension: string;
  41471. /** @hidden */
  41472. _files: Nullable<string[]>;
  41473. /** @hidden */
  41474. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41475. /** @hidden */
  41476. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41477. /** @hidden */
  41478. _framebuffer: Nullable<WebGLFramebuffer>;
  41479. /** @hidden */
  41480. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41481. /** @hidden */
  41482. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41483. /** @hidden */
  41484. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41485. /** @hidden */
  41486. _attachments: Nullable<number[]>;
  41487. /** @hidden */
  41488. _textureArray: Nullable<InternalTexture[]>;
  41489. /** @hidden */
  41490. _cachedCoordinatesMode: Nullable<number>;
  41491. /** @hidden */
  41492. _cachedWrapU: Nullable<number>;
  41493. /** @hidden */
  41494. _cachedWrapV: Nullable<number>;
  41495. /** @hidden */
  41496. _cachedWrapR: Nullable<number>;
  41497. /** @hidden */
  41498. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41499. /** @hidden */
  41500. _isDisabled: boolean;
  41501. /** @hidden */
  41502. _compression: Nullable<string>;
  41503. /** @hidden */
  41504. _generateStencilBuffer: boolean;
  41505. /** @hidden */
  41506. _generateDepthBuffer: boolean;
  41507. /** @hidden */
  41508. _comparisonFunction: number;
  41509. /** @hidden */
  41510. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41511. /** @hidden */
  41512. _lodGenerationScale: number;
  41513. /** @hidden */
  41514. _lodGenerationOffset: number;
  41515. /** @hidden */
  41516. _depthStencilTexture: Nullable<InternalTexture>;
  41517. /** @hidden */
  41518. _colorTextureArray: Nullable<WebGLTexture>;
  41519. /** @hidden */
  41520. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41521. /** @hidden */
  41522. _lodTextureHigh: Nullable<BaseTexture>;
  41523. /** @hidden */
  41524. _lodTextureMid: Nullable<BaseTexture>;
  41525. /** @hidden */
  41526. _lodTextureLow: Nullable<BaseTexture>;
  41527. /** @hidden */
  41528. _isRGBD: boolean;
  41529. /** @hidden */
  41530. _linearSpecularLOD: boolean;
  41531. /** @hidden */
  41532. _irradianceTexture: Nullable<BaseTexture>;
  41533. /** @hidden */
  41534. _webGLTexture: Nullable<WebGLTexture>;
  41535. /** @hidden */
  41536. _references: number;
  41537. /** @hidden */
  41538. _gammaSpace: Nullable<boolean>;
  41539. private _engine;
  41540. /**
  41541. * Gets the Engine the texture belongs to.
  41542. * @returns The babylon engine
  41543. */
  41544. getEngine(): ThinEngine;
  41545. /**
  41546. * Gets the data source type of the texture
  41547. */
  41548. get source(): InternalTextureSource;
  41549. /**
  41550. * Creates a new InternalTexture
  41551. * @param engine defines the engine to use
  41552. * @param source defines the type of data that will be used
  41553. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41554. */
  41555. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41556. /**
  41557. * Increments the number of references (ie. the number of Texture that point to it)
  41558. */
  41559. incrementReferences(): void;
  41560. /**
  41561. * Change the size of the texture (not the size of the content)
  41562. * @param width defines the new width
  41563. * @param height defines the new height
  41564. * @param depth defines the new depth (1 by default)
  41565. */
  41566. updateSize(width: int, height: int, depth?: int): void;
  41567. /** @hidden */
  41568. _rebuild(): void;
  41569. /** @hidden */
  41570. _swapAndDie(target: InternalTexture): void;
  41571. /**
  41572. * Dispose the current allocated resources
  41573. */
  41574. dispose(): void;
  41575. }
  41576. }
  41577. declare module "babylonjs/Loading/loadingScreen" {
  41578. /**
  41579. * Interface used to present a loading screen while loading a scene
  41580. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41581. */
  41582. export interface ILoadingScreen {
  41583. /**
  41584. * Function called to display the loading screen
  41585. */
  41586. displayLoadingUI: () => void;
  41587. /**
  41588. * Function called to hide the loading screen
  41589. */
  41590. hideLoadingUI: () => void;
  41591. /**
  41592. * Gets or sets the color to use for the background
  41593. */
  41594. loadingUIBackgroundColor: string;
  41595. /**
  41596. * Gets or sets the text to display while loading
  41597. */
  41598. loadingUIText: string;
  41599. }
  41600. /**
  41601. * Class used for the default loading screen
  41602. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41603. */
  41604. export class DefaultLoadingScreen implements ILoadingScreen {
  41605. private _renderingCanvas;
  41606. private _loadingText;
  41607. private _loadingDivBackgroundColor;
  41608. private _loadingDiv;
  41609. private _loadingTextDiv;
  41610. /** Gets or sets the logo url to use for the default loading screen */
  41611. static DefaultLogoUrl: string;
  41612. /** Gets or sets the spinner url to use for the default loading screen */
  41613. static DefaultSpinnerUrl: string;
  41614. /**
  41615. * Creates a new default loading screen
  41616. * @param _renderingCanvas defines the canvas used to render the scene
  41617. * @param _loadingText defines the default text to display
  41618. * @param _loadingDivBackgroundColor defines the default background color
  41619. */
  41620. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41621. /**
  41622. * Function called to display the loading screen
  41623. */
  41624. displayLoadingUI(): void;
  41625. /**
  41626. * Function called to hide the loading screen
  41627. */
  41628. hideLoadingUI(): void;
  41629. /**
  41630. * Gets or sets the text to display while loading
  41631. */
  41632. set loadingUIText(text: string);
  41633. get loadingUIText(): string;
  41634. /**
  41635. * Gets or sets the color to use for the background
  41636. */
  41637. get loadingUIBackgroundColor(): string;
  41638. set loadingUIBackgroundColor(color: string);
  41639. private _resizeLoadingUI;
  41640. }
  41641. }
  41642. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41643. /**
  41644. * Interface for any object that can request an animation frame
  41645. */
  41646. export interface ICustomAnimationFrameRequester {
  41647. /**
  41648. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41649. */
  41650. renderFunction?: Function;
  41651. /**
  41652. * Called to request the next frame to render to
  41653. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41654. */
  41655. requestAnimationFrame: Function;
  41656. /**
  41657. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41658. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41659. */
  41660. requestID?: number;
  41661. }
  41662. }
  41663. declare module "babylonjs/Misc/performanceMonitor" {
  41664. /**
  41665. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41666. */
  41667. export class PerformanceMonitor {
  41668. private _enabled;
  41669. private _rollingFrameTime;
  41670. private _lastFrameTimeMs;
  41671. /**
  41672. * constructor
  41673. * @param frameSampleSize The number of samples required to saturate the sliding window
  41674. */
  41675. constructor(frameSampleSize?: number);
  41676. /**
  41677. * Samples current frame
  41678. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41679. */
  41680. sampleFrame(timeMs?: number): void;
  41681. /**
  41682. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41683. */
  41684. get averageFrameTime(): number;
  41685. /**
  41686. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41687. */
  41688. get averageFrameTimeVariance(): number;
  41689. /**
  41690. * Returns the frame time of the most recent frame
  41691. */
  41692. get instantaneousFrameTime(): number;
  41693. /**
  41694. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41695. */
  41696. get averageFPS(): number;
  41697. /**
  41698. * Returns the average framerate in frames per second using the most recent frame time
  41699. */
  41700. get instantaneousFPS(): number;
  41701. /**
  41702. * Returns true if enough samples have been taken to completely fill the sliding window
  41703. */
  41704. get isSaturated(): boolean;
  41705. /**
  41706. * Enables contributions to the sliding window sample set
  41707. */
  41708. enable(): void;
  41709. /**
  41710. * Disables contributions to the sliding window sample set
  41711. * Samples will not be interpolated over the disabled period
  41712. */
  41713. disable(): void;
  41714. /**
  41715. * Returns true if sampling is enabled
  41716. */
  41717. get isEnabled(): boolean;
  41718. /**
  41719. * Resets performance monitor
  41720. */
  41721. reset(): void;
  41722. }
  41723. /**
  41724. * RollingAverage
  41725. *
  41726. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41727. */
  41728. export class RollingAverage {
  41729. /**
  41730. * Current average
  41731. */
  41732. average: number;
  41733. /**
  41734. * Current variance
  41735. */
  41736. variance: number;
  41737. protected _samples: Array<number>;
  41738. protected _sampleCount: number;
  41739. protected _pos: number;
  41740. protected _m2: number;
  41741. /**
  41742. * constructor
  41743. * @param length The number of samples required to saturate the sliding window
  41744. */
  41745. constructor(length: number);
  41746. /**
  41747. * Adds a sample to the sample set
  41748. * @param v The sample value
  41749. */
  41750. add(v: number): void;
  41751. /**
  41752. * Returns previously added values or null if outside of history or outside the sliding window domain
  41753. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41754. * @return Value previously recorded with add() or null if outside of range
  41755. */
  41756. history(i: number): number;
  41757. /**
  41758. * Returns true if enough samples have been taken to completely fill the sliding window
  41759. * @return true if sample-set saturated
  41760. */
  41761. isSaturated(): boolean;
  41762. /**
  41763. * Resets the rolling average (equivalent to 0 samples taken so far)
  41764. */
  41765. reset(): void;
  41766. /**
  41767. * Wraps a value around the sample range boundaries
  41768. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41769. * @return Wrapped position in sample range
  41770. */
  41771. protected _wrapPosition(i: number): number;
  41772. }
  41773. }
  41774. declare module "babylonjs/Misc/perfCounter" {
  41775. /**
  41776. * This class is used to track a performance counter which is number based.
  41777. * The user has access to many properties which give statistics of different nature.
  41778. *
  41779. * The implementer can track two kinds of Performance Counter: time and count.
  41780. * 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.
  41781. * 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.
  41782. */
  41783. export class PerfCounter {
  41784. /**
  41785. * Gets or sets a global boolean to turn on and off all the counters
  41786. */
  41787. static Enabled: boolean;
  41788. /**
  41789. * Returns the smallest value ever
  41790. */
  41791. get min(): number;
  41792. /**
  41793. * Returns the biggest value ever
  41794. */
  41795. get max(): number;
  41796. /**
  41797. * Returns the average value since the performance counter is running
  41798. */
  41799. get average(): number;
  41800. /**
  41801. * Returns the average value of the last second the counter was monitored
  41802. */
  41803. get lastSecAverage(): number;
  41804. /**
  41805. * Returns the current value
  41806. */
  41807. get current(): number;
  41808. /**
  41809. * Gets the accumulated total
  41810. */
  41811. get total(): number;
  41812. /**
  41813. * Gets the total value count
  41814. */
  41815. get count(): number;
  41816. /**
  41817. * Creates a new counter
  41818. */
  41819. constructor();
  41820. /**
  41821. * Call this method to start monitoring a new frame.
  41822. * 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.
  41823. */
  41824. fetchNewFrame(): void;
  41825. /**
  41826. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41827. * @param newCount the count value to add to the monitored count
  41828. * @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.
  41829. */
  41830. addCount(newCount: number, fetchResult: boolean): void;
  41831. /**
  41832. * Start monitoring this performance counter
  41833. */
  41834. beginMonitoring(): void;
  41835. /**
  41836. * Compute the time lapsed since the previous beginMonitoring() call.
  41837. * @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
  41838. */
  41839. endMonitoring(newFrame?: boolean): void;
  41840. private _fetchResult;
  41841. private _startMonitoringTime;
  41842. private _min;
  41843. private _max;
  41844. private _average;
  41845. private _current;
  41846. private _totalValueCount;
  41847. private _totalAccumulated;
  41848. private _lastSecAverage;
  41849. private _lastSecAccumulated;
  41850. private _lastSecTime;
  41851. private _lastSecValueCount;
  41852. }
  41853. }
  41854. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41855. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41856. import { Nullable } from "babylonjs/types";
  41857. module "babylonjs/Engines/thinEngine" {
  41858. interface ThinEngine {
  41859. /** @hidden */
  41860. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41861. }
  41862. }
  41863. }
  41864. declare module "babylonjs/Audio/analyser" {
  41865. import { Scene } from "babylonjs/scene";
  41866. /**
  41867. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41869. */
  41870. export class Analyser {
  41871. /**
  41872. * Gets or sets the smoothing
  41873. * @ignorenaming
  41874. */
  41875. SMOOTHING: number;
  41876. /**
  41877. * Gets or sets the FFT table size
  41878. * @ignorenaming
  41879. */
  41880. FFT_SIZE: number;
  41881. /**
  41882. * Gets or sets the bar graph amplitude
  41883. * @ignorenaming
  41884. */
  41885. BARGRAPHAMPLITUDE: number;
  41886. /**
  41887. * Gets or sets the position of the debug canvas
  41888. * @ignorenaming
  41889. */
  41890. DEBUGCANVASPOS: {
  41891. x: number;
  41892. y: number;
  41893. };
  41894. /**
  41895. * Gets or sets the debug canvas size
  41896. * @ignorenaming
  41897. */
  41898. DEBUGCANVASSIZE: {
  41899. width: number;
  41900. height: number;
  41901. };
  41902. private _byteFreqs;
  41903. private _byteTime;
  41904. private _floatFreqs;
  41905. private _webAudioAnalyser;
  41906. private _debugCanvas;
  41907. private _debugCanvasContext;
  41908. private _scene;
  41909. private _registerFunc;
  41910. private _audioEngine;
  41911. /**
  41912. * Creates a new analyser
  41913. * @param scene defines hosting scene
  41914. */
  41915. constructor(scene: Scene);
  41916. /**
  41917. * Get the number of data values you will have to play with for the visualization
  41918. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41919. * @returns a number
  41920. */
  41921. getFrequencyBinCount(): number;
  41922. /**
  41923. * Gets the current frequency data as a byte array
  41924. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41925. * @returns a Uint8Array
  41926. */
  41927. getByteFrequencyData(): Uint8Array;
  41928. /**
  41929. * Gets the current waveform as a byte array
  41930. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41931. * @returns a Uint8Array
  41932. */
  41933. getByteTimeDomainData(): Uint8Array;
  41934. /**
  41935. * Gets the current frequency data as a float array
  41936. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41937. * @returns a Float32Array
  41938. */
  41939. getFloatFrequencyData(): Float32Array;
  41940. /**
  41941. * Renders the debug canvas
  41942. */
  41943. drawDebugCanvas(): void;
  41944. /**
  41945. * Stops rendering the debug canvas and removes it
  41946. */
  41947. stopDebugCanvas(): void;
  41948. /**
  41949. * Connects two audio nodes
  41950. * @param inputAudioNode defines first node to connect
  41951. * @param outputAudioNode defines second node to connect
  41952. */
  41953. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41954. /**
  41955. * Releases all associated resources
  41956. */
  41957. dispose(): void;
  41958. }
  41959. }
  41960. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  41961. import { Observable } from "babylonjs/Misc/observable";
  41962. import { IDisposable } from "babylonjs/scene";
  41963. import { Nullable } from "babylonjs/types";
  41964. import { Analyser } from "babylonjs/Audio/analyser";
  41965. /**
  41966. * This represents an audio engine and it is responsible
  41967. * to play, synchronize and analyse sounds throughout the application.
  41968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41969. */
  41970. export interface IAudioEngine extends IDisposable {
  41971. /**
  41972. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41973. */
  41974. readonly canUseWebAudio: boolean;
  41975. /**
  41976. * Gets the current AudioContext if available.
  41977. */
  41978. readonly audioContext: Nullable<AudioContext>;
  41979. /**
  41980. * The master gain node defines the global audio volume of your audio engine.
  41981. */
  41982. readonly masterGain: GainNode;
  41983. /**
  41984. * Gets whether or not mp3 are supported by your browser.
  41985. */
  41986. readonly isMP3supported: boolean;
  41987. /**
  41988. * Gets whether or not ogg are supported by your browser.
  41989. */
  41990. readonly isOGGsupported: boolean;
  41991. /**
  41992. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41993. * @ignoreNaming
  41994. */
  41995. WarnedWebAudioUnsupported: boolean;
  41996. /**
  41997. * Defines if the audio engine relies on a custom unlocked button.
  41998. * In this case, the embedded button will not be displayed.
  41999. */
  42000. useCustomUnlockedButton: boolean;
  42001. /**
  42002. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42003. */
  42004. readonly unlocked: boolean;
  42005. /**
  42006. * Event raised when audio has been unlocked on the browser.
  42007. */
  42008. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42009. /**
  42010. * Event raised when audio has been locked on the browser.
  42011. */
  42012. onAudioLockedObservable: Observable<IAudioEngine>;
  42013. /**
  42014. * Flags the audio engine in Locked state.
  42015. * This happens due to new browser policies preventing audio to autoplay.
  42016. */
  42017. lock(): void;
  42018. /**
  42019. * Unlocks the audio engine once a user action has been done on the dom.
  42020. * This is helpful to resume play once browser policies have been satisfied.
  42021. */
  42022. unlock(): void;
  42023. /**
  42024. * Gets the global volume sets on the master gain.
  42025. * @returns the global volume if set or -1 otherwise
  42026. */
  42027. getGlobalVolume(): number;
  42028. /**
  42029. * Sets the global volume of your experience (sets on the master gain).
  42030. * @param newVolume Defines the new global volume of the application
  42031. */
  42032. setGlobalVolume(newVolume: number): void;
  42033. /**
  42034. * Connect the audio engine to an audio analyser allowing some amazing
  42035. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42036. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42037. * @param analyser The analyser to connect to the engine
  42038. */
  42039. connectToAnalyser(analyser: Analyser): void;
  42040. }
  42041. }
  42042. declare module "babylonjs/Engines/engine" {
  42043. import { Observable } from "babylonjs/Misc/observable";
  42044. import { Nullable } from "babylonjs/types";
  42045. import { Scene } from "babylonjs/scene";
  42046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42047. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42048. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42049. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42050. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42051. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42052. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42053. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42054. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42055. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42056. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42057. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42058. import "babylonjs/Engines/Extensions/engine.alpha";
  42059. import "babylonjs/Engines/Extensions/engine.readTexture";
  42060. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42061. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42062. import { Material } from "babylonjs/Materials/material";
  42063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42064. /**
  42065. * Defines the interface used by display changed events
  42066. */
  42067. export interface IDisplayChangedEventArgs {
  42068. /** Gets the vrDisplay object (if any) */
  42069. vrDisplay: Nullable<any>;
  42070. /** Gets a boolean indicating if webVR is supported */
  42071. vrSupported: boolean;
  42072. }
  42073. /**
  42074. * Defines the interface used by objects containing a viewport (like a camera)
  42075. */
  42076. interface IViewportOwnerLike {
  42077. /**
  42078. * Gets or sets the viewport
  42079. */
  42080. viewport: IViewportLike;
  42081. }
  42082. /**
  42083. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42084. */
  42085. export class Engine extends ThinEngine {
  42086. /** Defines that alpha blending is disabled */
  42087. static readonly ALPHA_DISABLE: number;
  42088. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42089. static readonly ALPHA_ADD: number;
  42090. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42091. static readonly ALPHA_COMBINE: number;
  42092. /** Defines that alpha blending to DEST - SRC * DEST */
  42093. static readonly ALPHA_SUBTRACT: number;
  42094. /** Defines that alpha blending to SRC * DEST */
  42095. static readonly ALPHA_MULTIPLY: number;
  42096. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42097. static readonly ALPHA_MAXIMIZED: number;
  42098. /** Defines that alpha blending to SRC + DEST */
  42099. static readonly ALPHA_ONEONE: number;
  42100. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42101. static readonly ALPHA_PREMULTIPLIED: number;
  42102. /**
  42103. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42104. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42105. */
  42106. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42107. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42108. static readonly ALPHA_INTERPOLATE: number;
  42109. /**
  42110. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42111. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42112. */
  42113. static readonly ALPHA_SCREENMODE: number;
  42114. /** Defines that the ressource is not delayed*/
  42115. static readonly DELAYLOADSTATE_NONE: number;
  42116. /** Defines that the ressource was successfully delay loaded */
  42117. static readonly DELAYLOADSTATE_LOADED: number;
  42118. /** Defines that the ressource is currently delay loading */
  42119. static readonly DELAYLOADSTATE_LOADING: number;
  42120. /** Defines that the ressource is delayed and has not started loading */
  42121. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42122. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42123. static readonly NEVER: number;
  42124. /** 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 */
  42125. static readonly ALWAYS: number;
  42126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42127. static readonly LESS: number;
  42128. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42129. static readonly EQUAL: number;
  42130. /** 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 */
  42131. static readonly LEQUAL: number;
  42132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42133. static readonly GREATER: number;
  42134. /** 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 */
  42135. static readonly GEQUAL: number;
  42136. /** 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 */
  42137. static readonly NOTEQUAL: number;
  42138. /** Passed to stencilOperation to specify that stencil value must be kept */
  42139. static readonly KEEP: number;
  42140. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42141. static readonly REPLACE: number;
  42142. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42143. static readonly INCR: number;
  42144. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42145. static readonly DECR: number;
  42146. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42147. static readonly INVERT: number;
  42148. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42149. static readonly INCR_WRAP: number;
  42150. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42151. static readonly DECR_WRAP: number;
  42152. /** Texture is not repeating outside of 0..1 UVs */
  42153. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42154. /** Texture is repeating outside of 0..1 UVs */
  42155. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42156. /** Texture is repeating and mirrored */
  42157. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42158. /** ALPHA */
  42159. static readonly TEXTUREFORMAT_ALPHA: number;
  42160. /** LUMINANCE */
  42161. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42162. /** LUMINANCE_ALPHA */
  42163. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42164. /** RGB */
  42165. static readonly TEXTUREFORMAT_RGB: number;
  42166. /** RGBA */
  42167. static readonly TEXTUREFORMAT_RGBA: number;
  42168. /** RED */
  42169. static readonly TEXTUREFORMAT_RED: number;
  42170. /** RED (2nd reference) */
  42171. static readonly TEXTUREFORMAT_R: number;
  42172. /** RG */
  42173. static readonly TEXTUREFORMAT_RG: number;
  42174. /** RED_INTEGER */
  42175. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42176. /** RED_INTEGER (2nd reference) */
  42177. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42178. /** RG_INTEGER */
  42179. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42180. /** RGB_INTEGER */
  42181. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42182. /** RGBA_INTEGER */
  42183. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42184. /** UNSIGNED_BYTE */
  42185. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42186. /** UNSIGNED_BYTE (2nd reference) */
  42187. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42188. /** FLOAT */
  42189. static readonly TEXTURETYPE_FLOAT: number;
  42190. /** HALF_FLOAT */
  42191. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42192. /** BYTE */
  42193. static readonly TEXTURETYPE_BYTE: number;
  42194. /** SHORT */
  42195. static readonly TEXTURETYPE_SHORT: number;
  42196. /** UNSIGNED_SHORT */
  42197. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42198. /** INT */
  42199. static readonly TEXTURETYPE_INT: number;
  42200. /** UNSIGNED_INT */
  42201. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42202. /** UNSIGNED_SHORT_4_4_4_4 */
  42203. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42204. /** UNSIGNED_SHORT_5_5_5_1 */
  42205. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42206. /** UNSIGNED_SHORT_5_6_5 */
  42207. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42208. /** UNSIGNED_INT_2_10_10_10_REV */
  42209. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42210. /** UNSIGNED_INT_24_8 */
  42211. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42212. /** UNSIGNED_INT_10F_11F_11F_REV */
  42213. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42214. /** UNSIGNED_INT_5_9_9_9_REV */
  42215. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42216. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42217. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42218. /** nearest is mag = nearest and min = nearest and mip = linear */
  42219. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42220. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42221. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42222. /** Trilinear is mag = linear and min = linear and mip = linear */
  42223. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42224. /** nearest is mag = nearest and min = nearest and mip = linear */
  42225. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42226. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42227. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42228. /** Trilinear is mag = linear and min = linear and mip = linear */
  42229. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42230. /** mag = nearest and min = nearest and mip = nearest */
  42231. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42232. /** mag = nearest and min = linear and mip = nearest */
  42233. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42234. /** mag = nearest and min = linear and mip = linear */
  42235. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42236. /** mag = nearest and min = linear and mip = none */
  42237. static readonly TEXTURE_NEAREST_LINEAR: number;
  42238. /** mag = nearest and min = nearest and mip = none */
  42239. static readonly TEXTURE_NEAREST_NEAREST: number;
  42240. /** mag = linear and min = nearest and mip = nearest */
  42241. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42242. /** mag = linear and min = nearest and mip = linear */
  42243. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42244. /** mag = linear and min = linear and mip = none */
  42245. static readonly TEXTURE_LINEAR_LINEAR: number;
  42246. /** mag = linear and min = nearest and mip = none */
  42247. static readonly TEXTURE_LINEAR_NEAREST: number;
  42248. /** Explicit coordinates mode */
  42249. static readonly TEXTURE_EXPLICIT_MODE: number;
  42250. /** Spherical coordinates mode */
  42251. static readonly TEXTURE_SPHERICAL_MODE: number;
  42252. /** Planar coordinates mode */
  42253. static readonly TEXTURE_PLANAR_MODE: number;
  42254. /** Cubic coordinates mode */
  42255. static readonly TEXTURE_CUBIC_MODE: number;
  42256. /** Projection coordinates mode */
  42257. static readonly TEXTURE_PROJECTION_MODE: number;
  42258. /** Skybox coordinates mode */
  42259. static readonly TEXTURE_SKYBOX_MODE: number;
  42260. /** Inverse Cubic coordinates mode */
  42261. static readonly TEXTURE_INVCUBIC_MODE: number;
  42262. /** Equirectangular coordinates mode */
  42263. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42264. /** Equirectangular Fixed coordinates mode */
  42265. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42266. /** Equirectangular Fixed Mirrored coordinates mode */
  42267. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42268. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42269. static readonly SCALEMODE_FLOOR: number;
  42270. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42271. static readonly SCALEMODE_NEAREST: number;
  42272. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42273. static readonly SCALEMODE_CEILING: number;
  42274. /**
  42275. * Returns the current npm package of the sdk
  42276. */
  42277. static get NpmPackage(): string;
  42278. /**
  42279. * Returns the current version of the framework
  42280. */
  42281. static get Version(): string;
  42282. /** Gets the list of created engines */
  42283. static get Instances(): Engine[];
  42284. /**
  42285. * Gets the latest created engine
  42286. */
  42287. static get LastCreatedEngine(): Nullable<Engine>;
  42288. /**
  42289. * Gets the latest created scene
  42290. */
  42291. static get LastCreatedScene(): Nullable<Scene>;
  42292. /**
  42293. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42294. * @param flag defines which part of the materials must be marked as dirty
  42295. * @param predicate defines a predicate used to filter which materials should be affected
  42296. */
  42297. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42298. /**
  42299. * Method called to create the default loading screen.
  42300. * This can be overriden in your own app.
  42301. * @param canvas The rendering canvas element
  42302. * @returns The loading screen
  42303. */
  42304. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42305. /**
  42306. * Method called to create the default rescale post process on each engine.
  42307. */
  42308. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42309. /**
  42310. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42311. **/
  42312. enableOfflineSupport: boolean;
  42313. /**
  42314. * 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)
  42315. **/
  42316. disableManifestCheck: boolean;
  42317. /**
  42318. * Gets the list of created scenes
  42319. */
  42320. scenes: Scene[];
  42321. /**
  42322. * Event raised when a new scene is created
  42323. */
  42324. onNewSceneAddedObservable: Observable<Scene>;
  42325. /**
  42326. * Gets the list of created postprocesses
  42327. */
  42328. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42329. /**
  42330. * Gets a boolean indicating if the pointer is currently locked
  42331. */
  42332. isPointerLock: boolean;
  42333. /**
  42334. * Observable event triggered each time the rendering canvas is resized
  42335. */
  42336. onResizeObservable: Observable<Engine>;
  42337. /**
  42338. * Observable event triggered each time the canvas loses focus
  42339. */
  42340. onCanvasBlurObservable: Observable<Engine>;
  42341. /**
  42342. * Observable event triggered each time the canvas gains focus
  42343. */
  42344. onCanvasFocusObservable: Observable<Engine>;
  42345. /**
  42346. * Observable event triggered each time the canvas receives pointerout event
  42347. */
  42348. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42349. /**
  42350. * Observable raised when the engine begins a new frame
  42351. */
  42352. onBeginFrameObservable: Observable<Engine>;
  42353. /**
  42354. * If set, will be used to request the next animation frame for the render loop
  42355. */
  42356. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42357. /**
  42358. * Observable raised when the engine ends the current frame
  42359. */
  42360. onEndFrameObservable: Observable<Engine>;
  42361. /**
  42362. * Observable raised when the engine is about to compile a shader
  42363. */
  42364. onBeforeShaderCompilationObservable: Observable<Engine>;
  42365. /**
  42366. * Observable raised when the engine has jsut compiled a shader
  42367. */
  42368. onAfterShaderCompilationObservable: Observable<Engine>;
  42369. /**
  42370. * Gets the audio engine
  42371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42372. * @ignorenaming
  42373. */
  42374. static audioEngine: IAudioEngine;
  42375. /**
  42376. * Default AudioEngine factory responsible of creating the Audio Engine.
  42377. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42378. */
  42379. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42380. /**
  42381. * Default offline support factory responsible of creating a tool used to store data locally.
  42382. * By default, this will create a Database object if the workload has been embedded.
  42383. */
  42384. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42385. private _loadingScreen;
  42386. private _pointerLockRequested;
  42387. private _rescalePostProcess;
  42388. private _deterministicLockstep;
  42389. private _lockstepMaxSteps;
  42390. private _timeStep;
  42391. protected get _supportsHardwareTextureRescaling(): boolean;
  42392. private _fps;
  42393. private _deltaTime;
  42394. /** @hidden */
  42395. _drawCalls: PerfCounter;
  42396. /** 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 */
  42397. canvasTabIndex: number;
  42398. /**
  42399. * Turn this value on if you want to pause FPS computation when in background
  42400. */
  42401. disablePerformanceMonitorInBackground: boolean;
  42402. private _performanceMonitor;
  42403. /**
  42404. * Gets the performance monitor attached to this engine
  42405. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42406. */
  42407. get performanceMonitor(): PerformanceMonitor;
  42408. private _onFocus;
  42409. private _onBlur;
  42410. private _onCanvasPointerOut;
  42411. private _onCanvasBlur;
  42412. private _onCanvasFocus;
  42413. private _onFullscreenChange;
  42414. private _onPointerLockChange;
  42415. /**
  42416. * Gets the HTML element used to attach event listeners
  42417. * @returns a HTML element
  42418. */
  42419. getInputElement(): Nullable<HTMLElement>;
  42420. /**
  42421. * Creates a new engine
  42422. * @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
  42423. * @param antialias defines enable antialiasing (default: false)
  42424. * @param options defines further options to be sent to the getContext() function
  42425. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42426. */
  42427. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42428. /**
  42429. * Gets current aspect ratio
  42430. * @param viewportOwner defines the camera to use to get the aspect ratio
  42431. * @param useScreen defines if screen size must be used (or the current render target if any)
  42432. * @returns a number defining the aspect ratio
  42433. */
  42434. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42435. /**
  42436. * Gets current screen aspect ratio
  42437. * @returns a number defining the aspect ratio
  42438. */
  42439. getScreenAspectRatio(): number;
  42440. /**
  42441. * Gets the client rect of the HTML canvas attached with the current webGL context
  42442. * @returns a client rectanglee
  42443. */
  42444. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42445. /**
  42446. * Gets the client rect of the HTML element used for events
  42447. * @returns a client rectanglee
  42448. */
  42449. getInputElementClientRect(): Nullable<ClientRect>;
  42450. /**
  42451. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42452. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42453. * @returns true if engine is in deterministic lock step mode
  42454. */
  42455. isDeterministicLockStep(): boolean;
  42456. /**
  42457. * Gets the max steps when engine is running in deterministic lock step
  42458. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42459. * @returns the max steps
  42460. */
  42461. getLockstepMaxSteps(): number;
  42462. /**
  42463. * Returns the time in ms between steps when using deterministic lock step.
  42464. * @returns time step in (ms)
  42465. */
  42466. getTimeStep(): number;
  42467. /**
  42468. * Force the mipmap generation for the given render target texture
  42469. * @param texture defines the render target texture to use
  42470. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42471. */
  42472. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42473. /** States */
  42474. /**
  42475. * Set various states to the webGL context
  42476. * @param culling defines backface culling state
  42477. * @param zOffset defines the value to apply to zOffset (0 by default)
  42478. * @param force defines if states must be applied even if cache is up to date
  42479. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42480. */
  42481. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42482. /**
  42483. * Set the z offset to apply to current rendering
  42484. * @param value defines the offset to apply
  42485. */
  42486. setZOffset(value: number): void;
  42487. /**
  42488. * Gets the current value of the zOffset
  42489. * @returns the current zOffset state
  42490. */
  42491. getZOffset(): number;
  42492. /**
  42493. * Enable or disable depth buffering
  42494. * @param enable defines the state to set
  42495. */
  42496. setDepthBuffer(enable: boolean): void;
  42497. /**
  42498. * Gets a boolean indicating if depth writing is enabled
  42499. * @returns the current depth writing state
  42500. */
  42501. getDepthWrite(): boolean;
  42502. /**
  42503. * Enable or disable depth writing
  42504. * @param enable defines the state to set
  42505. */
  42506. setDepthWrite(enable: boolean): void;
  42507. /**
  42508. * Gets a boolean indicating if stencil buffer is enabled
  42509. * @returns the current stencil buffer state
  42510. */
  42511. getStencilBuffer(): boolean;
  42512. /**
  42513. * Enable or disable the stencil buffer
  42514. * @param enable defines if the stencil buffer must be enabled or disabled
  42515. */
  42516. setStencilBuffer(enable: boolean): void;
  42517. /**
  42518. * Gets the current stencil mask
  42519. * @returns a number defining the new stencil mask to use
  42520. */
  42521. getStencilMask(): number;
  42522. /**
  42523. * Sets the current stencil mask
  42524. * @param mask defines the new stencil mask to use
  42525. */
  42526. setStencilMask(mask: number): void;
  42527. /**
  42528. * Gets the current stencil function
  42529. * @returns a number defining the stencil function to use
  42530. */
  42531. getStencilFunction(): number;
  42532. /**
  42533. * Gets the current stencil reference value
  42534. * @returns a number defining the stencil reference value to use
  42535. */
  42536. getStencilFunctionReference(): number;
  42537. /**
  42538. * Gets the current stencil mask
  42539. * @returns a number defining the stencil mask to use
  42540. */
  42541. getStencilFunctionMask(): number;
  42542. /**
  42543. * Sets the current stencil function
  42544. * @param stencilFunc defines the new stencil function to use
  42545. */
  42546. setStencilFunction(stencilFunc: number): void;
  42547. /**
  42548. * Sets the current stencil reference
  42549. * @param reference defines the new stencil reference to use
  42550. */
  42551. setStencilFunctionReference(reference: number): void;
  42552. /**
  42553. * Sets the current stencil mask
  42554. * @param mask defines the new stencil mask to use
  42555. */
  42556. setStencilFunctionMask(mask: number): void;
  42557. /**
  42558. * Gets the current stencil operation when stencil fails
  42559. * @returns a number defining stencil operation to use when stencil fails
  42560. */
  42561. getStencilOperationFail(): number;
  42562. /**
  42563. * Gets the current stencil operation when depth fails
  42564. * @returns a number defining stencil operation to use when depth fails
  42565. */
  42566. getStencilOperationDepthFail(): number;
  42567. /**
  42568. * Gets the current stencil operation when stencil passes
  42569. * @returns a number defining stencil operation to use when stencil passes
  42570. */
  42571. getStencilOperationPass(): number;
  42572. /**
  42573. * Sets the stencil operation to use when stencil fails
  42574. * @param operation defines the stencil operation to use when stencil fails
  42575. */
  42576. setStencilOperationFail(operation: number): void;
  42577. /**
  42578. * Sets the stencil operation to use when depth fails
  42579. * @param operation defines the stencil operation to use when depth fails
  42580. */
  42581. setStencilOperationDepthFail(operation: number): void;
  42582. /**
  42583. * Sets the stencil operation to use when stencil passes
  42584. * @param operation defines the stencil operation to use when stencil passes
  42585. */
  42586. setStencilOperationPass(operation: number): void;
  42587. /**
  42588. * Sets a boolean indicating if the dithering state is enabled or disabled
  42589. * @param value defines the dithering state
  42590. */
  42591. setDitheringState(value: boolean): void;
  42592. /**
  42593. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42594. * @param value defines the rasterizer state
  42595. */
  42596. setRasterizerState(value: boolean): void;
  42597. /**
  42598. * Gets the current depth function
  42599. * @returns a number defining the depth function
  42600. */
  42601. getDepthFunction(): Nullable<number>;
  42602. /**
  42603. * Sets the current depth function
  42604. * @param depthFunc defines the function to use
  42605. */
  42606. setDepthFunction(depthFunc: number): void;
  42607. /**
  42608. * Sets the current depth function to GREATER
  42609. */
  42610. setDepthFunctionToGreater(): void;
  42611. /**
  42612. * Sets the current depth function to GEQUAL
  42613. */
  42614. setDepthFunctionToGreaterOrEqual(): void;
  42615. /**
  42616. * Sets the current depth function to LESS
  42617. */
  42618. setDepthFunctionToLess(): void;
  42619. /**
  42620. * Sets the current depth function to LEQUAL
  42621. */
  42622. setDepthFunctionToLessOrEqual(): void;
  42623. private _cachedStencilBuffer;
  42624. private _cachedStencilFunction;
  42625. private _cachedStencilMask;
  42626. private _cachedStencilOperationPass;
  42627. private _cachedStencilOperationFail;
  42628. private _cachedStencilOperationDepthFail;
  42629. private _cachedStencilReference;
  42630. /**
  42631. * Caches the the state of the stencil buffer
  42632. */
  42633. cacheStencilState(): void;
  42634. /**
  42635. * Restores the state of the stencil buffer
  42636. */
  42637. restoreStencilState(): void;
  42638. /**
  42639. * Directly set the WebGL Viewport
  42640. * @param x defines the x coordinate of the viewport (in screen space)
  42641. * @param y defines the y coordinate of the viewport (in screen space)
  42642. * @param width defines the width of the viewport (in screen space)
  42643. * @param height defines the height of the viewport (in screen space)
  42644. * @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
  42645. */
  42646. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42647. /**
  42648. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42649. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42650. * @param y defines the y-coordinate of the corner of the clear rectangle
  42651. * @param width defines the width of the clear rectangle
  42652. * @param height defines the height of the clear rectangle
  42653. * @param clearColor defines the clear color
  42654. */
  42655. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42656. /**
  42657. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42658. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42659. * @param y defines the y-coordinate of the corner of the clear rectangle
  42660. * @param width defines the width of the clear rectangle
  42661. * @param height defines the height of the clear rectangle
  42662. */
  42663. enableScissor(x: number, y: number, width: number, height: number): void;
  42664. /**
  42665. * Disable previously set scissor test rectangle
  42666. */
  42667. disableScissor(): void;
  42668. protected _reportDrawCall(): void;
  42669. /**
  42670. * Initializes a webVR display and starts listening to display change events
  42671. * The onVRDisplayChangedObservable will be notified upon these changes
  42672. * @returns The onVRDisplayChangedObservable
  42673. */
  42674. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42675. /** @hidden */
  42676. _prepareVRComponent(): void;
  42677. /** @hidden */
  42678. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42679. /** @hidden */
  42680. _submitVRFrame(): void;
  42681. /**
  42682. * Call this function to leave webVR mode
  42683. * Will do nothing if webVR is not supported or if there is no webVR device
  42684. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42685. */
  42686. disableVR(): void;
  42687. /**
  42688. * Gets a boolean indicating that the system is in VR mode and is presenting
  42689. * @returns true if VR mode is engaged
  42690. */
  42691. isVRPresenting(): boolean;
  42692. /** @hidden */
  42693. _requestVRFrame(): void;
  42694. /** @hidden */
  42695. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42696. /**
  42697. * Gets the source code of the vertex shader associated with a specific webGL program
  42698. * @param program defines the program to use
  42699. * @returns a string containing the source code of the vertex shader associated with the program
  42700. */
  42701. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42702. /**
  42703. * Gets the source code of the fragment shader associated with a specific webGL program
  42704. * @param program defines the program to use
  42705. * @returns a string containing the source code of the fragment shader associated with the program
  42706. */
  42707. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42708. /**
  42709. * Sets a depth stencil texture from a render target to the according uniform.
  42710. * @param channel The texture channel
  42711. * @param uniform The uniform to set
  42712. * @param texture The render target texture containing the depth stencil texture to apply
  42713. */
  42714. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42715. /**
  42716. * Sets a texture to the webGL context from a postprocess
  42717. * @param channel defines the channel to use
  42718. * @param postProcess defines the source postprocess
  42719. */
  42720. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42721. /**
  42722. * Binds the output of the passed in post process to the texture channel specified
  42723. * @param channel The channel the texture should be bound to
  42724. * @param postProcess The post process which's output should be bound
  42725. */
  42726. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42727. protected _rebuildBuffers(): void;
  42728. /** @hidden */
  42729. _renderFrame(): void;
  42730. _renderLoop(): void;
  42731. /** @hidden */
  42732. _renderViews(): boolean;
  42733. /**
  42734. * Toggle full screen mode
  42735. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42736. */
  42737. switchFullscreen(requestPointerLock: boolean): void;
  42738. /**
  42739. * Enters full screen mode
  42740. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42741. */
  42742. enterFullscreen(requestPointerLock: boolean): void;
  42743. /**
  42744. * Exits full screen mode
  42745. */
  42746. exitFullscreen(): void;
  42747. /**
  42748. * Enters Pointerlock mode
  42749. */
  42750. enterPointerlock(): void;
  42751. /**
  42752. * Exits Pointerlock mode
  42753. */
  42754. exitPointerlock(): void;
  42755. /**
  42756. * Begin a new frame
  42757. */
  42758. beginFrame(): void;
  42759. /**
  42760. * Enf the current frame
  42761. */
  42762. endFrame(): void;
  42763. resize(): void;
  42764. /**
  42765. * Force a specific size of the canvas
  42766. * @param width defines the new canvas' width
  42767. * @param height defines the new canvas' height
  42768. * @returns true if the size was changed
  42769. */
  42770. setSize(width: number, height: number): boolean;
  42771. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42772. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42773. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42774. _releaseTexture(texture: InternalTexture): void;
  42775. /**
  42776. * @hidden
  42777. * Rescales a texture
  42778. * @param source input texutre
  42779. * @param destination destination texture
  42780. * @param scene scene to use to render the resize
  42781. * @param internalFormat format to use when resizing
  42782. * @param onComplete callback to be called when resize has completed
  42783. */
  42784. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42785. /**
  42786. * Gets the current framerate
  42787. * @returns a number representing the framerate
  42788. */
  42789. getFps(): number;
  42790. /**
  42791. * Gets the time spent between current and previous frame
  42792. * @returns a number representing the delta time in ms
  42793. */
  42794. getDeltaTime(): number;
  42795. private _measureFps;
  42796. /** @hidden */
  42797. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42798. /**
  42799. * Updates the sample count of a render target texture
  42800. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42801. * @param texture defines the texture to update
  42802. * @param samples defines the sample count to set
  42803. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42804. */
  42805. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42806. /**
  42807. * Updates a depth texture Comparison Mode and Function.
  42808. * If the comparison Function is equal to 0, the mode will be set to none.
  42809. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42810. * @param texture The texture to set the comparison function for
  42811. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42812. */
  42813. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42814. /**
  42815. * Creates a webGL buffer to use with instanciation
  42816. * @param capacity defines the size of the buffer
  42817. * @returns the webGL buffer
  42818. */
  42819. createInstancesBuffer(capacity: number): DataBuffer;
  42820. /**
  42821. * Delete a webGL buffer used with instanciation
  42822. * @param buffer defines the webGL buffer to delete
  42823. */
  42824. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42825. private _clientWaitAsync;
  42826. /** @hidden */
  42827. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42828. dispose(): void;
  42829. private _disableTouchAction;
  42830. /**
  42831. * Display the loading screen
  42832. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42833. */
  42834. displayLoadingUI(): void;
  42835. /**
  42836. * Hide the loading screen
  42837. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42838. */
  42839. hideLoadingUI(): void;
  42840. /**
  42841. * Gets the current loading screen object
  42842. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42843. */
  42844. get loadingScreen(): ILoadingScreen;
  42845. /**
  42846. * Sets the current loading screen object
  42847. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42848. */
  42849. set loadingScreen(loadingScreen: ILoadingScreen);
  42850. /**
  42851. * Sets the current loading screen text
  42852. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42853. */
  42854. set loadingUIText(text: string);
  42855. /**
  42856. * Sets the current loading screen background color
  42857. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42858. */
  42859. set loadingUIBackgroundColor(color: string);
  42860. /** Pointerlock and fullscreen */
  42861. /**
  42862. * Ask the browser to promote the current element to pointerlock mode
  42863. * @param element defines the DOM element to promote
  42864. */
  42865. static _RequestPointerlock(element: HTMLElement): void;
  42866. /**
  42867. * Asks the browser to exit pointerlock mode
  42868. */
  42869. static _ExitPointerlock(): void;
  42870. /**
  42871. * Ask the browser to promote the current element to fullscreen rendering mode
  42872. * @param element defines the DOM element to promote
  42873. */
  42874. static _RequestFullscreen(element: HTMLElement): void;
  42875. /**
  42876. * Asks the browser to exit fullscreen mode
  42877. */
  42878. static _ExitFullscreen(): void;
  42879. }
  42880. }
  42881. declare module "babylonjs/Engines/engineStore" {
  42882. import { Nullable } from "babylonjs/types";
  42883. import { Engine } from "babylonjs/Engines/engine";
  42884. import { Scene } from "babylonjs/scene";
  42885. /**
  42886. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42887. * during the life time of the application.
  42888. */
  42889. export class EngineStore {
  42890. /** Gets the list of created engines */
  42891. static Instances: import("babylonjs/Engines/engine").Engine[];
  42892. /** @hidden */
  42893. static _LastCreatedScene: Nullable<Scene>;
  42894. /**
  42895. * Gets the latest created engine
  42896. */
  42897. static get LastCreatedEngine(): Nullable<Engine>;
  42898. /**
  42899. * Gets the latest created scene
  42900. */
  42901. static get LastCreatedScene(): Nullable<Scene>;
  42902. /**
  42903. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42904. * @ignorenaming
  42905. */
  42906. static UseFallbackTexture: boolean;
  42907. /**
  42908. * Texture content used if a texture cannot loaded
  42909. * @ignorenaming
  42910. */
  42911. static FallbackTexture: string;
  42912. }
  42913. }
  42914. declare module "babylonjs/Misc/promise" {
  42915. /**
  42916. * Helper class that provides a small promise polyfill
  42917. */
  42918. export class PromisePolyfill {
  42919. /**
  42920. * Static function used to check if the polyfill is required
  42921. * If this is the case then the function will inject the polyfill to window.Promise
  42922. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42923. */
  42924. static Apply(force?: boolean): void;
  42925. }
  42926. }
  42927. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42928. /**
  42929. * Interface for screenshot methods with describe argument called `size` as object with options
  42930. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42931. */
  42932. export interface IScreenshotSize {
  42933. /**
  42934. * number in pixels for canvas height
  42935. */
  42936. height?: number;
  42937. /**
  42938. * multiplier allowing render at a higher or lower resolution
  42939. * If value is defined then height and width will be ignored and taken from camera
  42940. */
  42941. precision?: number;
  42942. /**
  42943. * number in pixels for canvas width
  42944. */
  42945. width?: number;
  42946. }
  42947. }
  42948. declare module "babylonjs/Misc/tools" {
  42949. import { Nullable, float } from "babylonjs/types";
  42950. import { DomManagement } from "babylonjs/Misc/domManagement";
  42951. import { WebRequest } from "babylonjs/Misc/webRequest";
  42952. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42953. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42954. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42955. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42956. import { Camera } from "babylonjs/Cameras/camera";
  42957. import { Engine } from "babylonjs/Engines/engine";
  42958. interface IColor4Like {
  42959. r: float;
  42960. g: float;
  42961. b: float;
  42962. a: float;
  42963. }
  42964. /**
  42965. * Class containing a set of static utilities functions
  42966. */
  42967. export class Tools {
  42968. /**
  42969. * Gets or sets the base URL to use to load assets
  42970. */
  42971. static get BaseUrl(): string;
  42972. static set BaseUrl(value: string);
  42973. /**
  42974. * Enable/Disable Custom HTTP Request Headers globally.
  42975. * default = false
  42976. * @see CustomRequestHeaders
  42977. */
  42978. static UseCustomRequestHeaders: boolean;
  42979. /**
  42980. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42981. * i.e. when loading files, where the server/service expects an Authorization header
  42982. */
  42983. static CustomRequestHeaders: {
  42984. [key: string]: string;
  42985. };
  42986. /**
  42987. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42988. */
  42989. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42990. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42991. /**
  42992. * Default behaviour for cors in the application.
  42993. * It can be a string if the expected behavior is identical in the entire app.
  42994. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42995. */
  42996. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42997. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42998. /**
  42999. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43000. * @ignorenaming
  43001. */
  43002. static get UseFallbackTexture(): boolean;
  43003. static set UseFallbackTexture(value: boolean);
  43004. /**
  43005. * Use this object to register external classes like custom textures or material
  43006. * to allow the laoders to instantiate them
  43007. */
  43008. static get RegisteredExternalClasses(): {
  43009. [key: string]: Object;
  43010. };
  43011. static set RegisteredExternalClasses(classes: {
  43012. [key: string]: Object;
  43013. });
  43014. /**
  43015. * Texture content used if a texture cannot loaded
  43016. * @ignorenaming
  43017. */
  43018. static get fallbackTexture(): string;
  43019. static set fallbackTexture(value: string);
  43020. /**
  43021. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43022. * @param u defines the coordinate on X axis
  43023. * @param v defines the coordinate on Y axis
  43024. * @param width defines the width of the source data
  43025. * @param height defines the height of the source data
  43026. * @param pixels defines the source byte array
  43027. * @param color defines the output color
  43028. */
  43029. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43030. /**
  43031. * Interpolates between a and b via alpha
  43032. * @param a The lower value (returned when alpha = 0)
  43033. * @param b The upper value (returned when alpha = 1)
  43034. * @param alpha The interpolation-factor
  43035. * @return The mixed value
  43036. */
  43037. static Mix(a: number, b: number, alpha: number): number;
  43038. /**
  43039. * Tries to instantiate a new object from a given class name
  43040. * @param className defines the class name to instantiate
  43041. * @returns the new object or null if the system was not able to do the instantiation
  43042. */
  43043. static Instantiate(className: string): any;
  43044. /**
  43045. * Provides a slice function that will work even on IE
  43046. * @param data defines the array to slice
  43047. * @param start defines the start of the data (optional)
  43048. * @param end defines the end of the data (optional)
  43049. * @returns the new sliced array
  43050. */
  43051. static Slice<T>(data: T, start?: number, end?: number): T;
  43052. /**
  43053. * Provides a slice function that will work even on IE
  43054. * The difference between this and Slice is that this will force-convert to array
  43055. * @param data defines the array to slice
  43056. * @param start defines the start of the data (optional)
  43057. * @param end defines the end of the data (optional)
  43058. * @returns the new sliced array
  43059. */
  43060. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43061. /**
  43062. * Polyfill for setImmediate
  43063. * @param action defines the action to execute after the current execution block
  43064. */
  43065. static SetImmediate(action: () => void): void;
  43066. /**
  43067. * Function indicating if a number is an exponent of 2
  43068. * @param value defines the value to test
  43069. * @returns true if the value is an exponent of 2
  43070. */
  43071. static IsExponentOfTwo(value: number): boolean;
  43072. private static _tmpFloatArray;
  43073. /**
  43074. * Returns the nearest 32-bit single precision float representation of a Number
  43075. * @param value A Number. If the parameter is of a different type, it will get converted
  43076. * to a number or to NaN if it cannot be converted
  43077. * @returns number
  43078. */
  43079. static FloatRound(value: number): number;
  43080. /**
  43081. * Extracts the filename from a path
  43082. * @param path defines the path to use
  43083. * @returns the filename
  43084. */
  43085. static GetFilename(path: string): string;
  43086. /**
  43087. * Extracts the "folder" part of a path (everything before the filename).
  43088. * @param uri The URI to extract the info from
  43089. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43090. * @returns The "folder" part of the path
  43091. */
  43092. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43093. /**
  43094. * Extracts text content from a DOM element hierarchy
  43095. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43096. */
  43097. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43098. /**
  43099. * Convert an angle in radians to degrees
  43100. * @param angle defines the angle to convert
  43101. * @returns the angle in degrees
  43102. */
  43103. static ToDegrees(angle: number): number;
  43104. /**
  43105. * Convert an angle in degrees to radians
  43106. * @param angle defines the angle to convert
  43107. * @returns the angle in radians
  43108. */
  43109. static ToRadians(angle: number): number;
  43110. /**
  43111. * Returns an array if obj is not an array
  43112. * @param obj defines the object to evaluate as an array
  43113. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43114. * @returns either obj directly if obj is an array or a new array containing obj
  43115. */
  43116. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43117. /**
  43118. * Gets the pointer prefix to use
  43119. * @param engine defines the engine we are finding the prefix for
  43120. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43121. */
  43122. static GetPointerPrefix(engine: Engine): string;
  43123. /**
  43124. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43125. * @param url define the url we are trying
  43126. * @param element define the dom element where to configure the cors policy
  43127. */
  43128. static SetCorsBehavior(url: string | string[], element: {
  43129. crossOrigin: string | null;
  43130. }): void;
  43131. /**
  43132. * Removes unwanted characters from an url
  43133. * @param url defines the url to clean
  43134. * @returns the cleaned url
  43135. */
  43136. static CleanUrl(url: string): string;
  43137. /**
  43138. * Gets or sets a function used to pre-process url before using them to load assets
  43139. */
  43140. static get PreprocessUrl(): (url: string) => string;
  43141. static set PreprocessUrl(processor: (url: string) => string);
  43142. /**
  43143. * Loads an image as an HTMLImageElement.
  43144. * @param input url string, ArrayBuffer, or Blob to load
  43145. * @param onLoad callback called when the image successfully loads
  43146. * @param onError callback called when the image fails to load
  43147. * @param offlineProvider offline provider for caching
  43148. * @param mimeType optional mime type
  43149. * @returns the HTMLImageElement of the loaded image
  43150. */
  43151. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43152. /**
  43153. * Loads a file from a url
  43154. * @param url url string, ArrayBuffer, or Blob to load
  43155. * @param onSuccess callback called when the file successfully loads
  43156. * @param onProgress callback called while file is loading (if the server supports this mode)
  43157. * @param offlineProvider defines the offline provider for caching
  43158. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43159. * @param onError callback called when the file fails to load
  43160. * @returns a file request object
  43161. */
  43162. 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;
  43163. /**
  43164. * Loads a file from a url
  43165. * @param url the file url to load
  43166. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43167. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43168. */
  43169. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43170. /**
  43171. * Load a script (identified by an url). When the url returns, the
  43172. * content of this file is added into a new script element, attached to the DOM (body element)
  43173. * @param scriptUrl defines the url of the script to laod
  43174. * @param onSuccess defines the callback called when the script is loaded
  43175. * @param onError defines the callback to call if an error occurs
  43176. * @param scriptId defines the id of the script element
  43177. */
  43178. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43179. /**
  43180. * Load an asynchronous script (identified by an url). When the url returns, the
  43181. * content of this file is added into a new script element, attached to the DOM (body element)
  43182. * @param scriptUrl defines the url of the script to laod
  43183. * @param scriptId defines the id of the script element
  43184. * @returns a promise request object
  43185. */
  43186. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43187. /**
  43188. * Loads a file from a blob
  43189. * @param fileToLoad defines the blob to use
  43190. * @param callback defines the callback to call when data is loaded
  43191. * @param progressCallback defines the callback to call during loading process
  43192. * @returns a file request object
  43193. */
  43194. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43195. /**
  43196. * Reads a file from a File object
  43197. * @param file defines the file to load
  43198. * @param onSuccess defines the callback to call when data is loaded
  43199. * @param onProgress defines the callback to call during loading process
  43200. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43201. * @param onError defines the callback to call when an error occurs
  43202. * @returns a file request object
  43203. */
  43204. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43205. /**
  43206. * Creates a data url from a given string content
  43207. * @param content defines the content to convert
  43208. * @returns the new data url link
  43209. */
  43210. static FileAsURL(content: string): string;
  43211. /**
  43212. * Format the given number to a specific decimal format
  43213. * @param value defines the number to format
  43214. * @param decimals defines the number of decimals to use
  43215. * @returns the formatted string
  43216. */
  43217. static Format(value: number, decimals?: number): string;
  43218. /**
  43219. * Tries to copy an object by duplicating every property
  43220. * @param source defines the source object
  43221. * @param destination defines the target object
  43222. * @param doNotCopyList defines a list of properties to avoid
  43223. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43224. */
  43225. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43226. /**
  43227. * Gets a boolean indicating if the given object has no own property
  43228. * @param obj defines the object to test
  43229. * @returns true if object has no own property
  43230. */
  43231. static IsEmpty(obj: any): boolean;
  43232. /**
  43233. * Function used to register events at window level
  43234. * @param windowElement defines the Window object to use
  43235. * @param events defines the events to register
  43236. */
  43237. static RegisterTopRootEvents(windowElement: Window, events: {
  43238. name: string;
  43239. handler: Nullable<(e: FocusEvent) => any>;
  43240. }[]): void;
  43241. /**
  43242. * Function used to unregister events from window level
  43243. * @param windowElement defines the Window object to use
  43244. * @param events defines the events to unregister
  43245. */
  43246. static UnregisterTopRootEvents(windowElement: Window, events: {
  43247. name: string;
  43248. handler: Nullable<(e: FocusEvent) => any>;
  43249. }[]): void;
  43250. /**
  43251. * @ignore
  43252. */
  43253. static _ScreenshotCanvas: HTMLCanvasElement;
  43254. /**
  43255. * Dumps the current bound framebuffer
  43256. * @param width defines the rendering width
  43257. * @param height defines the rendering height
  43258. * @param engine defines the hosting engine
  43259. * @param successCallback defines the callback triggered once the data are available
  43260. * @param mimeType defines the mime type of the result
  43261. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43262. */
  43263. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43264. /**
  43265. * Converts the canvas data to blob.
  43266. * This acts as a polyfill for browsers not supporting the to blob function.
  43267. * @param canvas Defines the canvas to extract the data from
  43268. * @param successCallback Defines the callback triggered once the data are available
  43269. * @param mimeType Defines the mime type of the result
  43270. */
  43271. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43272. /**
  43273. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43274. * @param successCallback defines the callback triggered once the data are available
  43275. * @param mimeType defines the mime type of the result
  43276. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43277. */
  43278. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43279. /**
  43280. * Downloads a blob in the browser
  43281. * @param blob defines the blob to download
  43282. * @param fileName defines the name of the downloaded file
  43283. */
  43284. static Download(blob: Blob, fileName: string): void;
  43285. /**
  43286. * Will return the right value of the noPreventDefault variable
  43287. * Needed to keep backwards compatibility to the old API.
  43288. *
  43289. * @param args arguments passed to the attachControl function
  43290. * @returns the correct value for noPreventDefault
  43291. */
  43292. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43293. /**
  43294. * Captures a screenshot of the current rendering
  43295. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43296. * @param engine defines the rendering engine
  43297. * @param camera defines the source camera
  43298. * @param size This parameter can be set to a single number or to an object with the
  43299. * following (optional) properties: precision, width, height. If a single number is passed,
  43300. * it will be used for both width and height. If an object is passed, the screenshot size
  43301. * will be derived from the parameters. The precision property is a multiplier allowing
  43302. * rendering at a higher or lower resolution
  43303. * @param successCallback defines the callback receives a single parameter which contains the
  43304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43305. * src parameter of an <img> to display it
  43306. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43307. * Check your browser for supported MIME types
  43308. */
  43309. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43310. /**
  43311. * Captures a screenshot of the current rendering
  43312. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43313. * @param engine defines the rendering engine
  43314. * @param camera defines the source camera
  43315. * @param size This parameter can be set to a single number or to an object with the
  43316. * following (optional) properties: precision, width, height. If a single number is passed,
  43317. * it will be used for both width and height. If an object is passed, the screenshot size
  43318. * will be derived from the parameters. The precision property is a multiplier allowing
  43319. * rendering at a higher or lower resolution
  43320. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43321. * Check your browser for supported MIME types
  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 CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43326. /**
  43327. * Generates an image screenshot from the specified camera.
  43328. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43329. * @param engine The engine to use for rendering
  43330. * @param camera The camera to use for rendering
  43331. * @param size This parameter can be set to a single number or to an object with the
  43332. * following (optional) properties: precision, width, height. If a single number is passed,
  43333. * it will be used for both width and height. If an object is passed, the screenshot size
  43334. * will be derived from the parameters. The precision property is a multiplier allowing
  43335. * rendering at a higher or lower resolution
  43336. * @param successCallback The callback receives a single parameter which contains the
  43337. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43338. * src parameter of an <img> to display it
  43339. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43340. * Check your browser for supported MIME types
  43341. * @param samples Texture samples (default: 1)
  43342. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43343. * @param fileName A name for for the downloaded file.
  43344. */
  43345. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43346. /**
  43347. * Generates an image screenshot from the specified camera.
  43348. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43349. * @param engine The engine to use for rendering
  43350. * @param camera The camera to use for rendering
  43351. * @param size This parameter can be set to a single number or to an object with the
  43352. * following (optional) properties: precision, width, height. If a single number is passed,
  43353. * it will be used for both width and height. If an object is passed, the screenshot size
  43354. * will be derived from the parameters. The precision property is a multiplier allowing
  43355. * rendering at a higher or lower resolution
  43356. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43357. * Check your browser for supported MIME types
  43358. * @param samples Texture samples (default: 1)
  43359. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43360. * @param fileName A name for for the downloaded file.
  43361. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43362. * to the src parameter of an <img> to display it
  43363. */
  43364. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43365. /**
  43366. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43367. * Be aware Math.random() could cause collisions, but:
  43368. * "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"
  43369. * @returns a pseudo random id
  43370. */
  43371. static RandomId(): string;
  43372. /**
  43373. * Test if the given uri is a base64 string
  43374. * @param uri The uri to test
  43375. * @return True if the uri is a base64 string or false otherwise
  43376. */
  43377. static IsBase64(uri: string): boolean;
  43378. /**
  43379. * Decode the given base64 uri.
  43380. * @param uri The uri to decode
  43381. * @return The decoded base64 data.
  43382. */
  43383. static DecodeBase64(uri: string): ArrayBuffer;
  43384. /**
  43385. * Gets the absolute url.
  43386. * @param url the input url
  43387. * @return the absolute url
  43388. */
  43389. static GetAbsoluteUrl(url: string): string;
  43390. /**
  43391. * No log
  43392. */
  43393. static readonly NoneLogLevel: number;
  43394. /**
  43395. * Only message logs
  43396. */
  43397. static readonly MessageLogLevel: number;
  43398. /**
  43399. * Only warning logs
  43400. */
  43401. static readonly WarningLogLevel: number;
  43402. /**
  43403. * Only error logs
  43404. */
  43405. static readonly ErrorLogLevel: number;
  43406. /**
  43407. * All logs
  43408. */
  43409. static readonly AllLogLevel: number;
  43410. /**
  43411. * Gets a value indicating the number of loading errors
  43412. * @ignorenaming
  43413. */
  43414. static get errorsCount(): number;
  43415. /**
  43416. * Callback called when a new log is added
  43417. */
  43418. static OnNewCacheEntry: (entry: string) => void;
  43419. /**
  43420. * Log a message to the console
  43421. * @param message defines the message to log
  43422. */
  43423. static Log(message: string): void;
  43424. /**
  43425. * Write a warning message to the console
  43426. * @param message defines the message to log
  43427. */
  43428. static Warn(message: string): void;
  43429. /**
  43430. * Write an error message to the console
  43431. * @param message defines the message to log
  43432. */
  43433. static Error(message: string): void;
  43434. /**
  43435. * Gets current log cache (list of logs)
  43436. */
  43437. static get LogCache(): string;
  43438. /**
  43439. * Clears the log cache
  43440. */
  43441. static ClearLogCache(): void;
  43442. /**
  43443. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43444. */
  43445. static set LogLevels(level: number);
  43446. /**
  43447. * Checks if the window object exists
  43448. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43449. */
  43450. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43451. /**
  43452. * No performance log
  43453. */
  43454. static readonly PerformanceNoneLogLevel: number;
  43455. /**
  43456. * Use user marks to log performance
  43457. */
  43458. static readonly PerformanceUserMarkLogLevel: number;
  43459. /**
  43460. * Log performance to the console
  43461. */
  43462. static readonly PerformanceConsoleLogLevel: number;
  43463. private static _performance;
  43464. /**
  43465. * Sets the current performance log level
  43466. */
  43467. static set PerformanceLogLevel(level: number);
  43468. private static _StartPerformanceCounterDisabled;
  43469. private static _EndPerformanceCounterDisabled;
  43470. private static _StartUserMark;
  43471. private static _EndUserMark;
  43472. private static _StartPerformanceConsole;
  43473. private static _EndPerformanceConsole;
  43474. /**
  43475. * Starts a performance counter
  43476. */
  43477. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43478. /**
  43479. * Ends a specific performance coutner
  43480. */
  43481. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43482. /**
  43483. * Gets either window.performance.now() if supported or Date.now() else
  43484. */
  43485. static get Now(): number;
  43486. /**
  43487. * This method will return the name of the class used to create the instance of the given object.
  43488. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43489. * @param object the object to get the class name from
  43490. * @param isType defines if the object is actually a type
  43491. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43492. */
  43493. static GetClassName(object: any, isType?: boolean): string;
  43494. /**
  43495. * Gets the first element of an array satisfying a given predicate
  43496. * @param array defines the array to browse
  43497. * @param predicate defines the predicate to use
  43498. * @returns null if not found or the element
  43499. */
  43500. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43501. /**
  43502. * This method will return the name of the full name of the class, including its owning module (if any).
  43503. * 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).
  43504. * @param object the object to get the class name from
  43505. * @param isType defines if the object is actually a type
  43506. * @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.
  43507. * @ignorenaming
  43508. */
  43509. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43510. /**
  43511. * Returns a promise that resolves after the given amount of time.
  43512. * @param delay Number of milliseconds to delay
  43513. * @returns Promise that resolves after the given amount of time
  43514. */
  43515. static DelayAsync(delay: number): Promise<void>;
  43516. /**
  43517. * Utility function to detect if the current user agent is Safari
  43518. * @returns whether or not the current user agent is safari
  43519. */
  43520. static IsSafari(): boolean;
  43521. }
  43522. /**
  43523. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43524. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43525. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43526. * @param name The name of the class, case should be preserved
  43527. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43528. */
  43529. export function className(name: string, module?: string): (target: Object) => void;
  43530. /**
  43531. * An implementation of a loop for asynchronous functions.
  43532. */
  43533. export class AsyncLoop {
  43534. /**
  43535. * Defines the number of iterations for the loop
  43536. */
  43537. iterations: number;
  43538. /**
  43539. * Defines the current index of the loop.
  43540. */
  43541. index: number;
  43542. private _done;
  43543. private _fn;
  43544. private _successCallback;
  43545. /**
  43546. * Constructor.
  43547. * @param iterations the number of iterations.
  43548. * @param func the function to run each iteration
  43549. * @param successCallback the callback that will be called upon succesful execution
  43550. * @param offset starting offset.
  43551. */
  43552. constructor(
  43553. /**
  43554. * Defines the number of iterations for the loop
  43555. */
  43556. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43557. /**
  43558. * Execute the next iteration. Must be called after the last iteration was finished.
  43559. */
  43560. executeNext(): void;
  43561. /**
  43562. * Break the loop and run the success callback.
  43563. */
  43564. breakLoop(): void;
  43565. /**
  43566. * Create and run an async loop.
  43567. * @param iterations the number of iterations.
  43568. * @param fn the function to run each iteration
  43569. * @param successCallback the callback that will be called upon succesful execution
  43570. * @param offset starting offset.
  43571. * @returns the created async loop object
  43572. */
  43573. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43574. /**
  43575. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43576. * @param iterations total number of iterations
  43577. * @param syncedIterations number of synchronous iterations in each async iteration.
  43578. * @param fn the function to call each iteration.
  43579. * @param callback a success call back that will be called when iterating stops.
  43580. * @param breakFunction a break condition (optional)
  43581. * @param timeout timeout settings for the setTimeout function. default - 0.
  43582. * @returns the created async loop object
  43583. */
  43584. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43585. }
  43586. }
  43587. declare module "babylonjs/Misc/stringDictionary" {
  43588. import { Nullable } from "babylonjs/types";
  43589. /**
  43590. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43591. * The underlying implementation relies on an associative array to ensure the best performances.
  43592. * The value can be anything including 'null' but except 'undefined'
  43593. */
  43594. export class StringDictionary<T> {
  43595. /**
  43596. * This will clear this dictionary and copy the content from the 'source' one.
  43597. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43598. * @param source the dictionary to take the content from and copy to this dictionary
  43599. */
  43600. copyFrom(source: StringDictionary<T>): void;
  43601. /**
  43602. * Get a value based from its key
  43603. * @param key the given key to get the matching value from
  43604. * @return the value if found, otherwise undefined is returned
  43605. */
  43606. get(key: string): T | undefined;
  43607. /**
  43608. * Get a value from its key or add it if it doesn't exist.
  43609. * This method will ensure you that a given key/data will be present in the dictionary.
  43610. * @param key the given key to get the matching value from
  43611. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43612. * The factory will only be invoked if there's no data for the given key.
  43613. * @return the value corresponding to the key.
  43614. */
  43615. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43616. /**
  43617. * Get a value from its key if present in the dictionary otherwise add it
  43618. * @param key the key to get the value from
  43619. * @param val if there's no such key/value pair in the dictionary add it with this value
  43620. * @return the value corresponding to the key
  43621. */
  43622. getOrAdd(key: string, val: T): T;
  43623. /**
  43624. * Check if there's a given key in the dictionary
  43625. * @param key the key to check for
  43626. * @return true if the key is present, false otherwise
  43627. */
  43628. contains(key: string): boolean;
  43629. /**
  43630. * Add a new key and its corresponding value
  43631. * @param key the key to add
  43632. * @param value the value corresponding to the key
  43633. * @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
  43634. */
  43635. add(key: string, value: T): boolean;
  43636. /**
  43637. * Update a specific value associated to a key
  43638. * @param key defines the key to use
  43639. * @param value defines the value to store
  43640. * @returns true if the value was updated (or false if the key was not found)
  43641. */
  43642. set(key: string, value: T): boolean;
  43643. /**
  43644. * Get the element of the given key and remove it from the dictionary
  43645. * @param key defines the key to search
  43646. * @returns the value associated with the key or null if not found
  43647. */
  43648. getAndRemove(key: string): Nullable<T>;
  43649. /**
  43650. * Remove a key/value from the dictionary.
  43651. * @param key the key to remove
  43652. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43653. */
  43654. remove(key: string): boolean;
  43655. /**
  43656. * Clear the whole content of the dictionary
  43657. */
  43658. clear(): void;
  43659. /**
  43660. * Gets the current count
  43661. */
  43662. get count(): number;
  43663. /**
  43664. * Execute a callback on each key/val of the dictionary.
  43665. * Note that you can remove any element in this dictionary in the callback implementation
  43666. * @param callback the callback to execute on a given key/value pair
  43667. */
  43668. forEach(callback: (key: string, val: T) => void): void;
  43669. /**
  43670. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43671. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43672. * Note that you can remove any element in this dictionary in the callback implementation
  43673. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43674. * @returns the first item
  43675. */
  43676. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43677. private _count;
  43678. private _data;
  43679. }
  43680. }
  43681. declare module "babylonjs/Collisions/collisionCoordinator" {
  43682. import { Nullable } from "babylonjs/types";
  43683. import { Scene } from "babylonjs/scene";
  43684. import { Vector3 } from "babylonjs/Maths/math.vector";
  43685. import { Collider } from "babylonjs/Collisions/collider";
  43686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43687. /** @hidden */
  43688. export interface ICollisionCoordinator {
  43689. createCollider(): Collider;
  43690. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43691. init(scene: Scene): void;
  43692. }
  43693. /** @hidden */
  43694. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43695. private _scene;
  43696. private _scaledPosition;
  43697. private _scaledVelocity;
  43698. private _finalPosition;
  43699. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43700. createCollider(): Collider;
  43701. init(scene: Scene): void;
  43702. private _collideWithWorld;
  43703. }
  43704. }
  43705. declare module "babylonjs/Inputs/scene.inputManager" {
  43706. import { Nullable } from "babylonjs/types";
  43707. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43708. import { Vector2 } from "babylonjs/Maths/math.vector";
  43709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43710. import { Scene } from "babylonjs/scene";
  43711. /**
  43712. * Class used to manage all inputs for the scene.
  43713. */
  43714. export class InputManager {
  43715. /** The distance in pixel that you have to move to prevent some events */
  43716. static DragMovementThreshold: number;
  43717. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43718. static LongPressDelay: number;
  43719. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43720. static DoubleClickDelay: number;
  43721. /** If you need to check double click without raising a single click at first click, enable this flag */
  43722. static ExclusiveDoubleClickMode: boolean;
  43723. /** 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. */
  43724. private _alreadyAttached;
  43725. private _alreadyAttachedTo;
  43726. private _wheelEventName;
  43727. private _onPointerMove;
  43728. private _onPointerDown;
  43729. private _onPointerUp;
  43730. private _initClickEvent;
  43731. private _initActionManager;
  43732. private _delayedSimpleClick;
  43733. private _delayedSimpleClickTimeout;
  43734. private _previousDelayedSimpleClickTimeout;
  43735. private _meshPickProceed;
  43736. private _previousButtonPressed;
  43737. private _currentPickResult;
  43738. private _previousPickResult;
  43739. private _totalPointersPressed;
  43740. private _doubleClickOccured;
  43741. private _pointerOverMesh;
  43742. private _pickedDownMesh;
  43743. private _pickedUpMesh;
  43744. private _pointerX;
  43745. private _pointerY;
  43746. private _unTranslatedPointerX;
  43747. private _unTranslatedPointerY;
  43748. private _startingPointerPosition;
  43749. private _previousStartingPointerPosition;
  43750. private _startingPointerTime;
  43751. private _previousStartingPointerTime;
  43752. private _pointerCaptures;
  43753. private _meshUnderPointerId;
  43754. private _onKeyDown;
  43755. private _onKeyUp;
  43756. private _keyboardIsAttached;
  43757. private _onCanvasFocusObserver;
  43758. private _onCanvasBlurObserver;
  43759. private _scene;
  43760. /**
  43761. * Creates a new InputManager
  43762. * @param scene defines the hosting scene
  43763. */
  43764. constructor(scene: Scene);
  43765. /**
  43766. * Gets the mesh that is currently under the pointer
  43767. */
  43768. get meshUnderPointer(): Nullable<AbstractMesh>;
  43769. /**
  43770. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43771. * @param pointerId the pointer id to use
  43772. * @returns The mesh under this pointer id or null if not found
  43773. */
  43774. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43775. /**
  43776. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43777. */
  43778. get unTranslatedPointer(): Vector2;
  43779. /**
  43780. * Gets or sets the current on-screen X position of the pointer
  43781. */
  43782. get pointerX(): number;
  43783. set pointerX(value: number);
  43784. /**
  43785. * Gets or sets the current on-screen Y position of the pointer
  43786. */
  43787. get pointerY(): number;
  43788. set pointerY(value: number);
  43789. private _updatePointerPosition;
  43790. private _processPointerMove;
  43791. private _setRayOnPointerInfo;
  43792. private _checkPrePointerObservable;
  43793. /**
  43794. * Use this method to simulate a pointer move on a mesh
  43795. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43796. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43797. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43798. */
  43799. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43800. /**
  43801. * Use this method to simulate a pointer down on a mesh
  43802. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43803. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43804. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43805. */
  43806. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43807. private _processPointerDown;
  43808. /** @hidden */
  43809. _isPointerSwiping(): boolean;
  43810. /**
  43811. * Use this method to simulate a pointer up on a mesh
  43812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43815. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43816. */
  43817. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43818. private _processPointerUp;
  43819. /**
  43820. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43821. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43822. * @returns true if the pointer was captured
  43823. */
  43824. isPointerCaptured(pointerId?: number): boolean;
  43825. /**
  43826. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43827. * @param attachUp defines if you want to attach events to pointerup
  43828. * @param attachDown defines if you want to attach events to pointerdown
  43829. * @param attachMove defines if you want to attach events to pointermove
  43830. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43831. */
  43832. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43833. /**
  43834. * Detaches all event handlers
  43835. */
  43836. detachControl(): void;
  43837. /**
  43838. * Force the value of meshUnderPointer
  43839. * @param mesh defines the mesh to use
  43840. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43841. */
  43842. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43843. /**
  43844. * Gets the mesh under the pointer
  43845. * @returns a Mesh or null if no mesh is under the pointer
  43846. */
  43847. getPointerOverMesh(): Nullable<AbstractMesh>;
  43848. }
  43849. }
  43850. declare module "babylonjs/Animations/animationGroup" {
  43851. import { Animatable } from "babylonjs/Animations/animatable";
  43852. import { Animation } from "babylonjs/Animations/animation";
  43853. import { Scene, IDisposable } from "babylonjs/scene";
  43854. import { Observable } from "babylonjs/Misc/observable";
  43855. import { Nullable } from "babylonjs/types";
  43856. import "babylonjs/Animations/animatable";
  43857. /**
  43858. * This class defines the direct association between an animation and a target
  43859. */
  43860. export class TargetedAnimation {
  43861. /**
  43862. * Animation to perform
  43863. */
  43864. animation: Animation;
  43865. /**
  43866. * Target to animate
  43867. */
  43868. target: any;
  43869. /**
  43870. * Returns the string "TargetedAnimation"
  43871. * @returns "TargetedAnimation"
  43872. */
  43873. getClassName(): string;
  43874. /**
  43875. * Serialize the object
  43876. * @returns the JSON object representing the current entity
  43877. */
  43878. serialize(): any;
  43879. }
  43880. /**
  43881. * Use this class to create coordinated animations on multiple targets
  43882. */
  43883. export class AnimationGroup implements IDisposable {
  43884. /** The name of the animation group */
  43885. name: string;
  43886. private _scene;
  43887. private _targetedAnimations;
  43888. private _animatables;
  43889. private _from;
  43890. private _to;
  43891. private _isStarted;
  43892. private _isPaused;
  43893. private _speedRatio;
  43894. private _loopAnimation;
  43895. private _isAdditive;
  43896. /**
  43897. * Gets or sets the unique id of the node
  43898. */
  43899. uniqueId: number;
  43900. /**
  43901. * This observable will notify when one animation have ended
  43902. */
  43903. onAnimationEndObservable: Observable<TargetedAnimation>;
  43904. /**
  43905. * Observer raised when one animation loops
  43906. */
  43907. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43908. /**
  43909. * Observer raised when all animations have looped
  43910. */
  43911. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43912. /**
  43913. * This observable will notify when all animations have ended.
  43914. */
  43915. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43916. /**
  43917. * This observable will notify when all animations have paused.
  43918. */
  43919. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43920. /**
  43921. * This observable will notify when all animations are playing.
  43922. */
  43923. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43924. /**
  43925. * Gets the first frame
  43926. */
  43927. get from(): number;
  43928. /**
  43929. * Gets the last frame
  43930. */
  43931. get to(): number;
  43932. /**
  43933. * Define if the animations are started
  43934. */
  43935. get isStarted(): boolean;
  43936. /**
  43937. * Gets a value indicating that the current group is playing
  43938. */
  43939. get isPlaying(): boolean;
  43940. /**
  43941. * Gets or sets the speed ratio to use for all animations
  43942. */
  43943. get speedRatio(): number;
  43944. /**
  43945. * Gets or sets the speed ratio to use for all animations
  43946. */
  43947. set speedRatio(value: number);
  43948. /**
  43949. * Gets or sets if all animations should loop or not
  43950. */
  43951. get loopAnimation(): boolean;
  43952. set loopAnimation(value: boolean);
  43953. /**
  43954. * Gets or sets if all animations should be evaluated additively
  43955. */
  43956. get isAdditive(): boolean;
  43957. set isAdditive(value: boolean);
  43958. /**
  43959. * Gets the targeted animations for this animation group
  43960. */
  43961. get targetedAnimations(): Array<TargetedAnimation>;
  43962. /**
  43963. * returning the list of animatables controlled by this animation group.
  43964. */
  43965. get animatables(): Array<Animatable>;
  43966. /**
  43967. * Gets the list of target animations
  43968. */
  43969. get children(): TargetedAnimation[];
  43970. /**
  43971. * Instantiates a new Animation Group.
  43972. * This helps managing several animations at once.
  43973. * @see https://doc.babylonjs.com/how_to/group
  43974. * @param name Defines the name of the group
  43975. * @param scene Defines the scene the group belongs to
  43976. */
  43977. constructor(
  43978. /** The name of the animation group */
  43979. name: string, scene?: Nullable<Scene>);
  43980. /**
  43981. * Add an animation (with its target) in the group
  43982. * @param animation defines the animation we want to add
  43983. * @param target defines the target of the animation
  43984. * @returns the TargetedAnimation object
  43985. */
  43986. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43987. /**
  43988. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43989. * It can add constant keys at begin or end
  43990. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43991. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43992. * @returns the animation group
  43993. */
  43994. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43995. private _animationLoopCount;
  43996. private _animationLoopFlags;
  43997. private _processLoop;
  43998. /**
  43999. * Start all animations on given targets
  44000. * @param loop defines if animations must loop
  44001. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44002. * @param from defines the from key (optional)
  44003. * @param to defines the to key (optional)
  44004. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44005. * @returns the current animation group
  44006. */
  44007. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44008. /**
  44009. * Pause all animations
  44010. * @returns the animation group
  44011. */
  44012. pause(): AnimationGroup;
  44013. /**
  44014. * Play all animations to initial state
  44015. * This function will start() the animations if they were not started or will restart() them if they were paused
  44016. * @param loop defines if animations must loop
  44017. * @returns the animation group
  44018. */
  44019. play(loop?: boolean): AnimationGroup;
  44020. /**
  44021. * Reset all animations to initial state
  44022. * @returns the animation group
  44023. */
  44024. reset(): AnimationGroup;
  44025. /**
  44026. * Restart animations from key 0
  44027. * @returns the animation group
  44028. */
  44029. restart(): AnimationGroup;
  44030. /**
  44031. * Stop all animations
  44032. * @returns the animation group
  44033. */
  44034. stop(): AnimationGroup;
  44035. /**
  44036. * Set animation weight for all animatables
  44037. * @param weight defines the weight to use
  44038. * @return the animationGroup
  44039. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44040. */
  44041. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44042. /**
  44043. * Synchronize and normalize all animatables with a source animatable
  44044. * @param root defines the root animatable to synchronize with
  44045. * @return the animationGroup
  44046. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44047. */
  44048. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44049. /**
  44050. * Goes to a specific frame in this animation group
  44051. * @param frame the frame number to go to
  44052. * @return the animationGroup
  44053. */
  44054. goToFrame(frame: number): AnimationGroup;
  44055. /**
  44056. * Dispose all associated resources
  44057. */
  44058. dispose(): void;
  44059. private _checkAnimationGroupEnded;
  44060. /**
  44061. * Clone the current animation group and returns a copy
  44062. * @param newName defines the name of the new group
  44063. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44064. * @returns the new aniamtion group
  44065. */
  44066. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44067. /**
  44068. * Serializes the animationGroup to an object
  44069. * @returns Serialized object
  44070. */
  44071. serialize(): any;
  44072. /**
  44073. * Returns a new AnimationGroup object parsed from the source provided.
  44074. * @param parsedAnimationGroup defines the source
  44075. * @param scene defines the scene that will receive the animationGroup
  44076. * @returns a new AnimationGroup
  44077. */
  44078. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44079. /**
  44080. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44081. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44082. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44083. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44084. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44085. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44086. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44087. */
  44088. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44089. /**
  44090. * Returns the string "AnimationGroup"
  44091. * @returns "AnimationGroup"
  44092. */
  44093. getClassName(): string;
  44094. /**
  44095. * Creates a detailled string about the object
  44096. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44097. * @returns a string representing the object
  44098. */
  44099. toString(fullDetails?: boolean): string;
  44100. }
  44101. }
  44102. declare module "babylonjs/scene" {
  44103. import { Nullable } from "babylonjs/types";
  44104. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44105. import { Observable } from "babylonjs/Misc/observable";
  44106. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44107. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44108. import { Geometry } from "babylonjs/Meshes/geometry";
  44109. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44110. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44112. import { Mesh } from "babylonjs/Meshes/mesh";
  44113. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44114. import { Bone } from "babylonjs/Bones/bone";
  44115. import { Skeleton } from "babylonjs/Bones/skeleton";
  44116. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44117. import { Camera } from "babylonjs/Cameras/camera";
  44118. import { AbstractScene } from "babylonjs/abstractScene";
  44119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44120. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44121. import { Material } from "babylonjs/Materials/material";
  44122. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44123. import { Effect } from "babylonjs/Materials/effect";
  44124. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44125. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44126. import { Light } from "babylonjs/Lights/light";
  44127. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44128. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44129. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44130. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44131. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44132. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44133. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44134. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44135. import { Engine } from "babylonjs/Engines/engine";
  44136. import { Node } from "babylonjs/node";
  44137. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44138. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44139. import { WebRequest } from "babylonjs/Misc/webRequest";
  44140. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44141. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44142. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44143. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44144. import { Plane } from "babylonjs/Maths/math.plane";
  44145. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44146. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44147. import { Ray } from "babylonjs/Culling/ray";
  44148. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44149. import { Animation } from "babylonjs/Animations/animation";
  44150. import { Animatable } from "babylonjs/Animations/animatable";
  44151. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44152. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44153. import { Collider } from "babylonjs/Collisions/collider";
  44154. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44155. /**
  44156. * Define an interface for all classes that will hold resources
  44157. */
  44158. export interface IDisposable {
  44159. /**
  44160. * Releases all held resources
  44161. */
  44162. dispose(): void;
  44163. }
  44164. /** Interface defining initialization parameters for Scene class */
  44165. export interface SceneOptions {
  44166. /**
  44167. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44168. * It will improve performance when the number of geometries becomes important.
  44169. */
  44170. useGeometryUniqueIdsMap?: boolean;
  44171. /**
  44172. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44173. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44174. */
  44175. useMaterialMeshMap?: boolean;
  44176. /**
  44177. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44178. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44179. */
  44180. useClonedMeshMap?: boolean;
  44181. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44182. virtual?: boolean;
  44183. }
  44184. /**
  44185. * Represents a scene to be rendered by the engine.
  44186. * @see https://doc.babylonjs.com/features/scene
  44187. */
  44188. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44189. /** The fog is deactivated */
  44190. static readonly FOGMODE_NONE: number;
  44191. /** The fog density is following an exponential function */
  44192. static readonly FOGMODE_EXP: number;
  44193. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44194. static readonly FOGMODE_EXP2: number;
  44195. /** The fog density is following a linear function. */
  44196. static readonly FOGMODE_LINEAR: number;
  44197. /**
  44198. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44199. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44200. */
  44201. static MinDeltaTime: number;
  44202. /**
  44203. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44204. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44205. */
  44206. static MaxDeltaTime: number;
  44207. /**
  44208. * Factory used to create the default material.
  44209. * @param name The name of the material to create
  44210. * @param scene The scene to create the material for
  44211. * @returns The default material
  44212. */
  44213. static DefaultMaterialFactory(scene: Scene): Material;
  44214. /**
  44215. * Factory used to create the a collision coordinator.
  44216. * @returns The collision coordinator
  44217. */
  44218. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44219. /** @hidden */
  44220. _inputManager: InputManager;
  44221. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44222. cameraToUseForPointers: Nullable<Camera>;
  44223. /** @hidden */
  44224. readonly _isScene: boolean;
  44225. /** @hidden */
  44226. _blockEntityCollection: boolean;
  44227. /**
  44228. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44229. */
  44230. autoClear: boolean;
  44231. /**
  44232. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44233. */
  44234. autoClearDepthAndStencil: boolean;
  44235. /**
  44236. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44237. */
  44238. clearColor: Color4;
  44239. /**
  44240. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44241. */
  44242. ambientColor: Color3;
  44243. /**
  44244. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44245. * It should only be one of the following (if not the default embedded one):
  44246. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44247. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44248. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44249. * The material properties need to be setup according to the type of texture in use.
  44250. */
  44251. environmentBRDFTexture: BaseTexture;
  44252. /**
  44253. * Texture used in all pbr material as the reflection texture.
  44254. * As in the majority of the scene they are the same (exception for multi room and so on),
  44255. * this is easier to reference from here than from all the materials.
  44256. */
  44257. get environmentTexture(): Nullable<BaseTexture>;
  44258. /**
  44259. * Texture used in all pbr material as the reflection texture.
  44260. * As in the majority of the scene they are the same (exception for multi room and so on),
  44261. * this is easier to set here than in all the materials.
  44262. */
  44263. set environmentTexture(value: Nullable<BaseTexture>);
  44264. /** @hidden */
  44265. protected _environmentIntensity: number;
  44266. /**
  44267. * Intensity of the environment in all pbr material.
  44268. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44269. * As in the majority of the scene they are the same (exception for multi room and so on),
  44270. * this is easier to reference from here than from all the materials.
  44271. */
  44272. get environmentIntensity(): number;
  44273. /**
  44274. * Intensity of the environment in all pbr material.
  44275. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44276. * As in the majority of the scene they are the same (exception for multi room and so on),
  44277. * this is easier to set here than in all the materials.
  44278. */
  44279. set environmentIntensity(value: number);
  44280. /** @hidden */
  44281. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44282. /**
  44283. * Default image processing configuration used either in the rendering
  44284. * Forward main pass or through the imageProcessingPostProcess if present.
  44285. * As in the majority of the scene they are the same (exception for multi camera),
  44286. * this is easier to reference from here than from all the materials and post process.
  44287. *
  44288. * No setter as we it is a shared configuration, you can set the values instead.
  44289. */
  44290. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44291. private _forceWireframe;
  44292. /**
  44293. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44294. */
  44295. set forceWireframe(value: boolean);
  44296. get forceWireframe(): boolean;
  44297. private _skipFrustumClipping;
  44298. /**
  44299. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44300. */
  44301. set skipFrustumClipping(value: boolean);
  44302. get skipFrustumClipping(): boolean;
  44303. private _forcePointsCloud;
  44304. /**
  44305. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44306. */
  44307. set forcePointsCloud(value: boolean);
  44308. get forcePointsCloud(): boolean;
  44309. /**
  44310. * Gets or sets the active clipplane 1
  44311. */
  44312. clipPlane: Nullable<Plane>;
  44313. /**
  44314. * Gets or sets the active clipplane 2
  44315. */
  44316. clipPlane2: Nullable<Plane>;
  44317. /**
  44318. * Gets or sets the active clipplane 3
  44319. */
  44320. clipPlane3: Nullable<Plane>;
  44321. /**
  44322. * Gets or sets the active clipplane 4
  44323. */
  44324. clipPlane4: Nullable<Plane>;
  44325. /**
  44326. * Gets or sets the active clipplane 5
  44327. */
  44328. clipPlane5: Nullable<Plane>;
  44329. /**
  44330. * Gets or sets the active clipplane 6
  44331. */
  44332. clipPlane6: Nullable<Plane>;
  44333. /**
  44334. * Gets or sets a boolean indicating if animations are enabled
  44335. */
  44336. animationsEnabled: boolean;
  44337. private _animationPropertiesOverride;
  44338. /**
  44339. * Gets or sets the animation properties override
  44340. */
  44341. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44342. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44343. /**
  44344. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44345. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44346. */
  44347. useConstantAnimationDeltaTime: boolean;
  44348. /**
  44349. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44350. * Please note that it requires to run a ray cast through the scene on every frame
  44351. */
  44352. constantlyUpdateMeshUnderPointer: boolean;
  44353. /**
  44354. * Defines the HTML cursor to use when hovering over interactive elements
  44355. */
  44356. hoverCursor: string;
  44357. /**
  44358. * Defines the HTML default cursor to use (empty by default)
  44359. */
  44360. defaultCursor: string;
  44361. /**
  44362. * Defines whether cursors are handled by the scene.
  44363. */
  44364. doNotHandleCursors: boolean;
  44365. /**
  44366. * This is used to call preventDefault() on pointer down
  44367. * in order to block unwanted artifacts like system double clicks
  44368. */
  44369. preventDefaultOnPointerDown: boolean;
  44370. /**
  44371. * This is used to call preventDefault() on pointer up
  44372. * in order to block unwanted artifacts like system double clicks
  44373. */
  44374. preventDefaultOnPointerUp: boolean;
  44375. /**
  44376. * Gets or sets user defined metadata
  44377. */
  44378. metadata: any;
  44379. /**
  44380. * For internal use only. Please do not use.
  44381. */
  44382. reservedDataStore: any;
  44383. /**
  44384. * Gets the name of the plugin used to load this scene (null by default)
  44385. */
  44386. loadingPluginName: string;
  44387. /**
  44388. * Use this array to add regular expressions used to disable offline support for specific urls
  44389. */
  44390. disableOfflineSupportExceptionRules: RegExp[];
  44391. /**
  44392. * An event triggered when the scene is disposed.
  44393. */
  44394. onDisposeObservable: Observable<Scene>;
  44395. private _onDisposeObserver;
  44396. /** Sets a function to be executed when this scene is disposed. */
  44397. set onDispose(callback: () => void);
  44398. /**
  44399. * An event triggered before rendering the scene (right after animations and physics)
  44400. */
  44401. onBeforeRenderObservable: Observable<Scene>;
  44402. private _onBeforeRenderObserver;
  44403. /** Sets a function to be executed before rendering this scene */
  44404. set beforeRender(callback: Nullable<() => void>);
  44405. /**
  44406. * An event triggered after rendering the scene
  44407. */
  44408. onAfterRenderObservable: Observable<Scene>;
  44409. /**
  44410. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44411. */
  44412. onAfterRenderCameraObservable: Observable<Camera>;
  44413. private _onAfterRenderObserver;
  44414. /** Sets a function to be executed after rendering this scene */
  44415. set afterRender(callback: Nullable<() => void>);
  44416. /**
  44417. * An event triggered before animating the scene
  44418. */
  44419. onBeforeAnimationsObservable: Observable<Scene>;
  44420. /**
  44421. * An event triggered after animations processing
  44422. */
  44423. onAfterAnimationsObservable: Observable<Scene>;
  44424. /**
  44425. * An event triggered before draw calls are ready to be sent
  44426. */
  44427. onBeforeDrawPhaseObservable: Observable<Scene>;
  44428. /**
  44429. * An event triggered after draw calls have been sent
  44430. */
  44431. onAfterDrawPhaseObservable: Observable<Scene>;
  44432. /**
  44433. * An event triggered when the scene is ready
  44434. */
  44435. onReadyObservable: Observable<Scene>;
  44436. /**
  44437. * An event triggered before rendering a camera
  44438. */
  44439. onBeforeCameraRenderObservable: Observable<Camera>;
  44440. private _onBeforeCameraRenderObserver;
  44441. /** Sets a function to be executed before rendering a camera*/
  44442. set beforeCameraRender(callback: () => void);
  44443. /**
  44444. * An event triggered after rendering a camera
  44445. */
  44446. onAfterCameraRenderObservable: Observable<Camera>;
  44447. private _onAfterCameraRenderObserver;
  44448. /** Sets a function to be executed after rendering a camera*/
  44449. set afterCameraRender(callback: () => void);
  44450. /**
  44451. * An event triggered when active meshes evaluation is about to start
  44452. */
  44453. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44454. /**
  44455. * An event triggered when active meshes evaluation is done
  44456. */
  44457. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44458. /**
  44459. * An event triggered when particles rendering is about to start
  44460. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44461. */
  44462. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44463. /**
  44464. * An event triggered when particles rendering is done
  44465. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44466. */
  44467. onAfterParticlesRenderingObservable: Observable<Scene>;
  44468. /**
  44469. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44470. */
  44471. onDataLoadedObservable: Observable<Scene>;
  44472. /**
  44473. * An event triggered when a camera is created
  44474. */
  44475. onNewCameraAddedObservable: Observable<Camera>;
  44476. /**
  44477. * An event triggered when a camera is removed
  44478. */
  44479. onCameraRemovedObservable: Observable<Camera>;
  44480. /**
  44481. * An event triggered when a light is created
  44482. */
  44483. onNewLightAddedObservable: Observable<Light>;
  44484. /**
  44485. * An event triggered when a light is removed
  44486. */
  44487. onLightRemovedObservable: Observable<Light>;
  44488. /**
  44489. * An event triggered when a geometry is created
  44490. */
  44491. onNewGeometryAddedObservable: Observable<Geometry>;
  44492. /**
  44493. * An event triggered when a geometry is removed
  44494. */
  44495. onGeometryRemovedObservable: Observable<Geometry>;
  44496. /**
  44497. * An event triggered when a transform node is created
  44498. */
  44499. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44500. /**
  44501. * An event triggered when a transform node is removed
  44502. */
  44503. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44504. /**
  44505. * An event triggered when a mesh is created
  44506. */
  44507. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44508. /**
  44509. * An event triggered when a mesh is removed
  44510. */
  44511. onMeshRemovedObservable: Observable<AbstractMesh>;
  44512. /**
  44513. * An event triggered when a skeleton is created
  44514. */
  44515. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44516. /**
  44517. * An event triggered when a skeleton is removed
  44518. */
  44519. onSkeletonRemovedObservable: Observable<Skeleton>;
  44520. /**
  44521. * An event triggered when a material is created
  44522. */
  44523. onNewMaterialAddedObservable: Observable<Material>;
  44524. /**
  44525. * An event triggered when a material is removed
  44526. */
  44527. onMaterialRemovedObservable: Observable<Material>;
  44528. /**
  44529. * An event triggered when a texture is created
  44530. */
  44531. onNewTextureAddedObservable: Observable<BaseTexture>;
  44532. /**
  44533. * An event triggered when a texture is removed
  44534. */
  44535. onTextureRemovedObservable: Observable<BaseTexture>;
  44536. /**
  44537. * An event triggered when render targets are about to be rendered
  44538. * Can happen multiple times per frame.
  44539. */
  44540. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44541. /**
  44542. * An event triggered when render targets were rendered.
  44543. * Can happen multiple times per frame.
  44544. */
  44545. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44546. /**
  44547. * An event triggered before calculating deterministic simulation step
  44548. */
  44549. onBeforeStepObservable: Observable<Scene>;
  44550. /**
  44551. * An event triggered after calculating deterministic simulation step
  44552. */
  44553. onAfterStepObservable: Observable<Scene>;
  44554. /**
  44555. * An event triggered when the activeCamera property is updated
  44556. */
  44557. onActiveCameraChanged: Observable<Scene>;
  44558. /**
  44559. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44560. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44561. * 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)
  44562. */
  44563. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44564. /**
  44565. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44566. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44567. * 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)
  44568. */
  44569. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44570. /**
  44571. * This Observable will when a mesh has been imported into the scene.
  44572. */
  44573. onMeshImportedObservable: Observable<AbstractMesh>;
  44574. /**
  44575. * This Observable will when an animation file has been imported into the scene.
  44576. */
  44577. onAnimationFileImportedObservable: Observable<Scene>;
  44578. /**
  44579. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44580. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44581. */
  44582. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44583. /** @hidden */
  44584. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44585. /**
  44586. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44587. */
  44588. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44589. /**
  44590. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44591. */
  44592. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44593. /**
  44594. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44595. */
  44596. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44597. /** Callback called when a pointer move is detected */
  44598. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44599. /** Callback called when a pointer down is detected */
  44600. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44601. /** Callback called when a pointer up is detected */
  44602. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44603. /** Callback called when a pointer pick is detected */
  44604. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44605. /**
  44606. * 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).
  44607. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44608. */
  44609. onPrePointerObservable: Observable<PointerInfoPre>;
  44610. /**
  44611. * Observable event triggered each time an input event is received from the rendering canvas
  44612. */
  44613. onPointerObservable: Observable<PointerInfo>;
  44614. /**
  44615. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44616. */
  44617. get unTranslatedPointer(): Vector2;
  44618. /**
  44619. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44620. */
  44621. static get DragMovementThreshold(): number;
  44622. static set DragMovementThreshold(value: number);
  44623. /**
  44624. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44625. */
  44626. static get LongPressDelay(): number;
  44627. static set LongPressDelay(value: number);
  44628. /**
  44629. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44630. */
  44631. static get DoubleClickDelay(): number;
  44632. static set DoubleClickDelay(value: number);
  44633. /** If you need to check double click without raising a single click at first click, enable this flag */
  44634. static get ExclusiveDoubleClickMode(): boolean;
  44635. static set ExclusiveDoubleClickMode(value: boolean);
  44636. /** @hidden */
  44637. _mirroredCameraPosition: Nullable<Vector3>;
  44638. /**
  44639. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44640. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44641. */
  44642. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44643. /**
  44644. * Observable event triggered each time an keyboard event is received from the hosting window
  44645. */
  44646. onKeyboardObservable: Observable<KeyboardInfo>;
  44647. private _useRightHandedSystem;
  44648. /**
  44649. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44650. */
  44651. set useRightHandedSystem(value: boolean);
  44652. get useRightHandedSystem(): boolean;
  44653. private _timeAccumulator;
  44654. private _currentStepId;
  44655. private _currentInternalStep;
  44656. /**
  44657. * Sets the step Id used by deterministic lock step
  44658. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44659. * @param newStepId defines the step Id
  44660. */
  44661. setStepId(newStepId: number): void;
  44662. /**
  44663. * Gets the step Id used by deterministic lock step
  44664. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44665. * @returns the step Id
  44666. */
  44667. getStepId(): number;
  44668. /**
  44669. * Gets the internal step used by deterministic lock step
  44670. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44671. * @returns the internal step
  44672. */
  44673. getInternalStep(): number;
  44674. private _fogEnabled;
  44675. /**
  44676. * Gets or sets a boolean indicating if fog is enabled on this scene
  44677. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44678. * (Default is true)
  44679. */
  44680. set fogEnabled(value: boolean);
  44681. get fogEnabled(): boolean;
  44682. private _fogMode;
  44683. /**
  44684. * Gets or sets the fog mode to use
  44685. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44686. * | mode | value |
  44687. * | --- | --- |
  44688. * | FOGMODE_NONE | 0 |
  44689. * | FOGMODE_EXP | 1 |
  44690. * | FOGMODE_EXP2 | 2 |
  44691. * | FOGMODE_LINEAR | 3 |
  44692. */
  44693. set fogMode(value: number);
  44694. get fogMode(): number;
  44695. /**
  44696. * Gets or sets the fog color to use
  44697. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44698. * (Default is Color3(0.2, 0.2, 0.3))
  44699. */
  44700. fogColor: Color3;
  44701. /**
  44702. * Gets or sets the fog density to use
  44703. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44704. * (Default is 0.1)
  44705. */
  44706. fogDensity: number;
  44707. /**
  44708. * Gets or sets the fog start distance to use
  44709. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44710. * (Default is 0)
  44711. */
  44712. fogStart: number;
  44713. /**
  44714. * Gets or sets the fog end distance to use
  44715. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44716. * (Default is 1000)
  44717. */
  44718. fogEnd: number;
  44719. /**
  44720. * Flag indicating that the frame buffer binding is handled by another component
  44721. */
  44722. prePass: boolean;
  44723. private _shadowsEnabled;
  44724. /**
  44725. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44726. */
  44727. set shadowsEnabled(value: boolean);
  44728. get shadowsEnabled(): boolean;
  44729. private _lightsEnabled;
  44730. /**
  44731. * Gets or sets a boolean indicating if lights are enabled on this scene
  44732. */
  44733. set lightsEnabled(value: boolean);
  44734. get lightsEnabled(): boolean;
  44735. /** All of the active cameras added to this scene. */
  44736. activeCameras: Camera[];
  44737. /** @hidden */
  44738. _activeCamera: Nullable<Camera>;
  44739. /** Gets or sets the current active camera */
  44740. get activeCamera(): Nullable<Camera>;
  44741. set activeCamera(value: Nullable<Camera>);
  44742. private _defaultMaterial;
  44743. /** The default material used on meshes when no material is affected */
  44744. get defaultMaterial(): Material;
  44745. /** The default material used on meshes when no material is affected */
  44746. set defaultMaterial(value: Material);
  44747. private _texturesEnabled;
  44748. /**
  44749. * Gets or sets a boolean indicating if textures are enabled on this scene
  44750. */
  44751. set texturesEnabled(value: boolean);
  44752. get texturesEnabled(): boolean;
  44753. /**
  44754. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44755. */
  44756. physicsEnabled: boolean;
  44757. /**
  44758. * Gets or sets a boolean indicating if particles are enabled on this scene
  44759. */
  44760. particlesEnabled: boolean;
  44761. /**
  44762. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44763. */
  44764. spritesEnabled: boolean;
  44765. private _skeletonsEnabled;
  44766. /**
  44767. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44768. */
  44769. set skeletonsEnabled(value: boolean);
  44770. get skeletonsEnabled(): boolean;
  44771. /**
  44772. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44773. */
  44774. lensFlaresEnabled: boolean;
  44775. /**
  44776. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44777. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44778. */
  44779. collisionsEnabled: boolean;
  44780. private _collisionCoordinator;
  44781. /** @hidden */
  44782. get collisionCoordinator(): ICollisionCoordinator;
  44783. /**
  44784. * Defines the gravity applied to this scene (used only for collisions)
  44785. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44786. */
  44787. gravity: Vector3;
  44788. /**
  44789. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44790. */
  44791. postProcessesEnabled: boolean;
  44792. /**
  44793. * Gets the current postprocess manager
  44794. */
  44795. postProcessManager: PostProcessManager;
  44796. /**
  44797. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44798. */
  44799. renderTargetsEnabled: boolean;
  44800. /**
  44801. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44802. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44803. */
  44804. dumpNextRenderTargets: boolean;
  44805. /**
  44806. * The list of user defined render targets added to the scene
  44807. */
  44808. customRenderTargets: RenderTargetTexture[];
  44809. /**
  44810. * Defines if texture loading must be delayed
  44811. * If true, textures will only be loaded when they need to be rendered
  44812. */
  44813. useDelayedTextureLoading: boolean;
  44814. /**
  44815. * Gets the list of meshes imported to the scene through SceneLoader
  44816. */
  44817. importedMeshesFiles: String[];
  44818. /**
  44819. * Gets or sets a boolean indicating if probes are enabled on this scene
  44820. */
  44821. probesEnabled: boolean;
  44822. /**
  44823. * Gets or sets the current offline provider to use to store scene data
  44824. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44825. */
  44826. offlineProvider: IOfflineProvider;
  44827. /**
  44828. * Gets or sets the action manager associated with the scene
  44829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44830. */
  44831. actionManager: AbstractActionManager;
  44832. private _meshesForIntersections;
  44833. /**
  44834. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44835. */
  44836. proceduralTexturesEnabled: boolean;
  44837. private _engine;
  44838. private _totalVertices;
  44839. /** @hidden */
  44840. _activeIndices: PerfCounter;
  44841. /** @hidden */
  44842. _activeParticles: PerfCounter;
  44843. /** @hidden */
  44844. _activeBones: PerfCounter;
  44845. private _animationRatio;
  44846. /** @hidden */
  44847. _animationTimeLast: number;
  44848. /** @hidden */
  44849. _animationTime: number;
  44850. /**
  44851. * Gets or sets a general scale for animation speed
  44852. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44853. */
  44854. animationTimeScale: number;
  44855. /** @hidden */
  44856. _cachedMaterial: Nullable<Material>;
  44857. /** @hidden */
  44858. _cachedEffect: Nullable<Effect>;
  44859. /** @hidden */
  44860. _cachedVisibility: Nullable<number>;
  44861. private _renderId;
  44862. private _frameId;
  44863. private _executeWhenReadyTimeoutId;
  44864. private _intermediateRendering;
  44865. private _viewUpdateFlag;
  44866. private _projectionUpdateFlag;
  44867. /** @hidden */
  44868. _toBeDisposed: Nullable<IDisposable>[];
  44869. private _activeRequests;
  44870. /** @hidden */
  44871. _pendingData: any[];
  44872. private _isDisposed;
  44873. /**
  44874. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44875. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44876. */
  44877. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44878. private _activeMeshes;
  44879. private _processedMaterials;
  44880. private _renderTargets;
  44881. /** @hidden */
  44882. _activeParticleSystems: SmartArray<IParticleSystem>;
  44883. private _activeSkeletons;
  44884. private _softwareSkinnedMeshes;
  44885. private _renderingManager;
  44886. /** @hidden */
  44887. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44888. private _transformMatrix;
  44889. private _sceneUbo;
  44890. /** @hidden */
  44891. _viewMatrix: Matrix;
  44892. private _projectionMatrix;
  44893. /** @hidden */
  44894. _forcedViewPosition: Nullable<Vector3>;
  44895. /** @hidden */
  44896. _frustumPlanes: Plane[];
  44897. /**
  44898. * Gets the list of frustum planes (built from the active camera)
  44899. */
  44900. get frustumPlanes(): Plane[];
  44901. /**
  44902. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44903. * This is useful if there are more lights that the maximum simulteanous authorized
  44904. */
  44905. requireLightSorting: boolean;
  44906. /** @hidden */
  44907. readonly useMaterialMeshMap: boolean;
  44908. /** @hidden */
  44909. readonly useClonedMeshMap: boolean;
  44910. private _externalData;
  44911. private _uid;
  44912. /**
  44913. * @hidden
  44914. * Backing store of defined scene components.
  44915. */
  44916. _components: ISceneComponent[];
  44917. /**
  44918. * @hidden
  44919. * Backing store of defined scene components.
  44920. */
  44921. _serializableComponents: ISceneSerializableComponent[];
  44922. /**
  44923. * List of components to register on the next registration step.
  44924. */
  44925. private _transientComponents;
  44926. /**
  44927. * Registers the transient components if needed.
  44928. */
  44929. private _registerTransientComponents;
  44930. /**
  44931. * @hidden
  44932. * Add a component to the scene.
  44933. * Note that the ccomponent could be registered on th next frame if this is called after
  44934. * the register component stage.
  44935. * @param component Defines the component to add to the scene
  44936. */
  44937. _addComponent(component: ISceneComponent): void;
  44938. /**
  44939. * @hidden
  44940. * Gets a component from the scene.
  44941. * @param name defines the name of the component to retrieve
  44942. * @returns the component or null if not present
  44943. */
  44944. _getComponent(name: string): Nullable<ISceneComponent>;
  44945. /**
  44946. * @hidden
  44947. * Defines the actions happening before camera updates.
  44948. */
  44949. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44950. /**
  44951. * @hidden
  44952. * Defines the actions happening before clear the canvas.
  44953. */
  44954. _beforeClearStage: Stage<SimpleStageAction>;
  44955. /**
  44956. * @hidden
  44957. * Defines the actions when collecting render targets for the frame.
  44958. */
  44959. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44960. /**
  44961. * @hidden
  44962. * Defines the actions happening for one camera in the frame.
  44963. */
  44964. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44965. /**
  44966. * @hidden
  44967. * Defines the actions happening during the per mesh ready checks.
  44968. */
  44969. _isReadyForMeshStage: Stage<MeshStageAction>;
  44970. /**
  44971. * @hidden
  44972. * Defines the actions happening before evaluate active mesh checks.
  44973. */
  44974. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44975. /**
  44976. * @hidden
  44977. * Defines the actions happening during the evaluate sub mesh checks.
  44978. */
  44979. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44980. /**
  44981. * @hidden
  44982. * Defines the actions happening during the active mesh stage.
  44983. */
  44984. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  44985. /**
  44986. * @hidden
  44987. * Defines the actions happening during the per camera render target step.
  44988. */
  44989. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44990. /**
  44991. * @hidden
  44992. * Defines the actions happening just before the active camera is drawing.
  44993. */
  44994. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44995. /**
  44996. * @hidden
  44997. * Defines the actions happening just before a render target is drawing.
  44998. */
  44999. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45000. /**
  45001. * @hidden
  45002. * Defines the actions happening just before a rendering group is drawing.
  45003. */
  45004. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45005. /**
  45006. * @hidden
  45007. * Defines the actions happening just before a mesh is drawing.
  45008. */
  45009. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45010. /**
  45011. * @hidden
  45012. * Defines the actions happening just after a mesh has been drawn.
  45013. */
  45014. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45015. /**
  45016. * @hidden
  45017. * Defines the actions happening just after a rendering group has been drawn.
  45018. */
  45019. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45020. /**
  45021. * @hidden
  45022. * Defines the actions happening just after the active camera has been drawn.
  45023. */
  45024. _afterCameraDrawStage: Stage<CameraStageAction>;
  45025. /**
  45026. * @hidden
  45027. * Defines the actions happening just after a render target has been drawn.
  45028. */
  45029. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45030. /**
  45031. * @hidden
  45032. * Defines the actions happening just after rendering all cameras and computing intersections.
  45033. */
  45034. _afterRenderStage: Stage<SimpleStageAction>;
  45035. /**
  45036. * @hidden
  45037. * Defines the actions happening when a pointer move event happens.
  45038. */
  45039. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45040. /**
  45041. * @hidden
  45042. * Defines the actions happening when a pointer down event happens.
  45043. */
  45044. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45045. /**
  45046. * @hidden
  45047. * Defines the actions happening when a pointer up event happens.
  45048. */
  45049. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45050. /**
  45051. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45052. */
  45053. private geometriesByUniqueId;
  45054. /**
  45055. * Creates a new Scene
  45056. * @param engine defines the engine to use to render this scene
  45057. * @param options defines the scene options
  45058. */
  45059. constructor(engine: Engine, options?: SceneOptions);
  45060. /**
  45061. * Gets a string identifying the name of the class
  45062. * @returns "Scene" string
  45063. */
  45064. getClassName(): string;
  45065. private _defaultMeshCandidates;
  45066. /**
  45067. * @hidden
  45068. */
  45069. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45070. private _defaultSubMeshCandidates;
  45071. /**
  45072. * @hidden
  45073. */
  45074. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45075. /**
  45076. * Sets the default candidate providers for the scene.
  45077. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45078. * and getCollidingSubMeshCandidates to their default function
  45079. */
  45080. setDefaultCandidateProviders(): void;
  45081. /**
  45082. * Gets the mesh that is currently under the pointer
  45083. */
  45084. get meshUnderPointer(): Nullable<AbstractMesh>;
  45085. /**
  45086. * Gets or sets the current on-screen X position of the pointer
  45087. */
  45088. get pointerX(): number;
  45089. set pointerX(value: number);
  45090. /**
  45091. * Gets or sets the current on-screen Y position of the pointer
  45092. */
  45093. get pointerY(): number;
  45094. set pointerY(value: number);
  45095. /**
  45096. * Gets the cached material (ie. the latest rendered one)
  45097. * @returns the cached material
  45098. */
  45099. getCachedMaterial(): Nullable<Material>;
  45100. /**
  45101. * Gets the cached effect (ie. the latest rendered one)
  45102. * @returns the cached effect
  45103. */
  45104. getCachedEffect(): Nullable<Effect>;
  45105. /**
  45106. * Gets the cached visibility state (ie. the latest rendered one)
  45107. * @returns the cached visibility state
  45108. */
  45109. getCachedVisibility(): Nullable<number>;
  45110. /**
  45111. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45112. * @param material defines the current material
  45113. * @param effect defines the current effect
  45114. * @param visibility defines the current visibility state
  45115. * @returns true if one parameter is not cached
  45116. */
  45117. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45118. /**
  45119. * Gets the engine associated with the scene
  45120. * @returns an Engine
  45121. */
  45122. getEngine(): Engine;
  45123. /**
  45124. * Gets the total number of vertices rendered per frame
  45125. * @returns the total number of vertices rendered per frame
  45126. */
  45127. getTotalVertices(): number;
  45128. /**
  45129. * Gets the performance counter for total vertices
  45130. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45131. */
  45132. get totalVerticesPerfCounter(): PerfCounter;
  45133. /**
  45134. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45135. * @returns the total number of active indices rendered per frame
  45136. */
  45137. getActiveIndices(): number;
  45138. /**
  45139. * Gets the performance counter for active indices
  45140. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45141. */
  45142. get totalActiveIndicesPerfCounter(): PerfCounter;
  45143. /**
  45144. * Gets the total number of active particles rendered per frame
  45145. * @returns the total number of active particles rendered per frame
  45146. */
  45147. getActiveParticles(): number;
  45148. /**
  45149. * Gets the performance counter for active particles
  45150. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45151. */
  45152. get activeParticlesPerfCounter(): PerfCounter;
  45153. /**
  45154. * Gets the total number of active bones rendered per frame
  45155. * @returns the total number of active bones rendered per frame
  45156. */
  45157. getActiveBones(): number;
  45158. /**
  45159. * Gets the performance counter for active bones
  45160. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45161. */
  45162. get activeBonesPerfCounter(): PerfCounter;
  45163. /**
  45164. * Gets the array of active meshes
  45165. * @returns an array of AbstractMesh
  45166. */
  45167. getActiveMeshes(): SmartArray<AbstractMesh>;
  45168. /**
  45169. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45170. * @returns a number
  45171. */
  45172. getAnimationRatio(): number;
  45173. /**
  45174. * Gets an unique Id for the current render phase
  45175. * @returns a number
  45176. */
  45177. getRenderId(): number;
  45178. /**
  45179. * Gets an unique Id for the current frame
  45180. * @returns a number
  45181. */
  45182. getFrameId(): number;
  45183. /** Call this function if you want to manually increment the render Id*/
  45184. incrementRenderId(): void;
  45185. private _createUbo;
  45186. /**
  45187. * Use this method to simulate a pointer move on a mesh
  45188. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45189. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45190. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45191. * @returns the current scene
  45192. */
  45193. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45194. /**
  45195. * Use this method to simulate a pointer down on a mesh
  45196. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45197. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45198. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45199. * @returns the current scene
  45200. */
  45201. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45202. /**
  45203. * Use this method to simulate a pointer up on a mesh
  45204. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45205. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45206. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45207. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45208. * @returns the current scene
  45209. */
  45210. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45211. /**
  45212. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45213. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45214. * @returns true if the pointer was captured
  45215. */
  45216. isPointerCaptured(pointerId?: number): boolean;
  45217. /**
  45218. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45219. * @param attachUp defines if you want to attach events to pointerup
  45220. * @param attachDown defines if you want to attach events to pointerdown
  45221. * @param attachMove defines if you want to attach events to pointermove
  45222. */
  45223. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45224. /** Detaches all event handlers*/
  45225. detachControl(): void;
  45226. /**
  45227. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45228. * Delay loaded resources are not taking in account
  45229. * @return true if all required resources are ready
  45230. */
  45231. isReady(): boolean;
  45232. /** Resets all cached information relative to material (including effect and visibility) */
  45233. resetCachedMaterial(): void;
  45234. /**
  45235. * Registers a function to be called before every frame render
  45236. * @param func defines the function to register
  45237. */
  45238. registerBeforeRender(func: () => void): void;
  45239. /**
  45240. * Unregisters a function called before every frame render
  45241. * @param func defines the function to unregister
  45242. */
  45243. unregisterBeforeRender(func: () => void): void;
  45244. /**
  45245. * Registers a function to be called after every frame render
  45246. * @param func defines the function to register
  45247. */
  45248. registerAfterRender(func: () => void): void;
  45249. /**
  45250. * Unregisters a function called after every frame render
  45251. * @param func defines the function to unregister
  45252. */
  45253. unregisterAfterRender(func: () => void): void;
  45254. private _executeOnceBeforeRender;
  45255. /**
  45256. * The provided function will run before render once and will be disposed afterwards.
  45257. * A timeout delay can be provided so that the function will be executed in N ms.
  45258. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45259. * @param func The function to be executed.
  45260. * @param timeout optional delay in ms
  45261. */
  45262. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45263. /** @hidden */
  45264. _addPendingData(data: any): void;
  45265. /** @hidden */
  45266. _removePendingData(data: any): void;
  45267. /**
  45268. * Returns the number of items waiting to be loaded
  45269. * @returns the number of items waiting to be loaded
  45270. */
  45271. getWaitingItemsCount(): number;
  45272. /**
  45273. * Returns a boolean indicating if the scene is still loading data
  45274. */
  45275. get isLoading(): boolean;
  45276. /**
  45277. * Registers a function to be executed when the scene is ready
  45278. * @param {Function} func - the function to be executed
  45279. */
  45280. executeWhenReady(func: () => void): void;
  45281. /**
  45282. * Returns a promise that resolves when the scene is ready
  45283. * @returns A promise that resolves when the scene is ready
  45284. */
  45285. whenReadyAsync(): Promise<void>;
  45286. /** @hidden */
  45287. _checkIsReady(): void;
  45288. /**
  45289. * Gets all animatable attached to the scene
  45290. */
  45291. get animatables(): Animatable[];
  45292. /**
  45293. * Resets the last animation time frame.
  45294. * Useful to override when animations start running when loading a scene for the first time.
  45295. */
  45296. resetLastAnimationTimeFrame(): void;
  45297. /**
  45298. * Gets the current view matrix
  45299. * @returns a Matrix
  45300. */
  45301. getViewMatrix(): Matrix;
  45302. /**
  45303. * Gets the current projection matrix
  45304. * @returns a Matrix
  45305. */
  45306. getProjectionMatrix(): Matrix;
  45307. /**
  45308. * Gets the current transform matrix
  45309. * @returns a Matrix made of View * Projection
  45310. */
  45311. getTransformMatrix(): Matrix;
  45312. /**
  45313. * Sets the current transform matrix
  45314. * @param viewL defines the View matrix to use
  45315. * @param projectionL defines the Projection matrix to use
  45316. * @param viewR defines the right View matrix to use (if provided)
  45317. * @param projectionR defines the right Projection matrix to use (if provided)
  45318. */
  45319. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45320. /**
  45321. * Gets the uniform buffer used to store scene data
  45322. * @returns a UniformBuffer
  45323. */
  45324. getSceneUniformBuffer(): UniformBuffer;
  45325. /**
  45326. * Gets an unique (relatively to the current scene) Id
  45327. * @returns an unique number for the scene
  45328. */
  45329. getUniqueId(): number;
  45330. /**
  45331. * Add a mesh to the list of scene's meshes
  45332. * @param newMesh defines the mesh to add
  45333. * @param recursive if all child meshes should also be added to the scene
  45334. */
  45335. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45336. /**
  45337. * Remove a mesh for the list of scene's meshes
  45338. * @param toRemove defines the mesh to remove
  45339. * @param recursive if all child meshes should also be removed from the scene
  45340. * @returns the index where the mesh was in the mesh list
  45341. */
  45342. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45343. /**
  45344. * Add a transform node to the list of scene's transform nodes
  45345. * @param newTransformNode defines the transform node to add
  45346. */
  45347. addTransformNode(newTransformNode: TransformNode): void;
  45348. /**
  45349. * Remove a transform node for the list of scene's transform nodes
  45350. * @param toRemove defines the transform node to remove
  45351. * @returns the index where the transform node was in the transform node list
  45352. */
  45353. removeTransformNode(toRemove: TransformNode): number;
  45354. /**
  45355. * Remove a skeleton for the list of scene's skeletons
  45356. * @param toRemove defines the skeleton to remove
  45357. * @returns the index where the skeleton was in the skeleton list
  45358. */
  45359. removeSkeleton(toRemove: Skeleton): number;
  45360. /**
  45361. * Remove a morph target for the list of scene's morph targets
  45362. * @param toRemove defines the morph target to remove
  45363. * @returns the index where the morph target was in the morph target list
  45364. */
  45365. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45366. /**
  45367. * Remove a light for the list of scene's lights
  45368. * @param toRemove defines the light to remove
  45369. * @returns the index where the light was in the light list
  45370. */
  45371. removeLight(toRemove: Light): number;
  45372. /**
  45373. * Remove a camera for the list of scene's cameras
  45374. * @param toRemove defines the camera to remove
  45375. * @returns the index where the camera was in the camera list
  45376. */
  45377. removeCamera(toRemove: Camera): number;
  45378. /**
  45379. * Remove a particle system for the list of scene's particle systems
  45380. * @param toRemove defines the particle system to remove
  45381. * @returns the index where the particle system was in the particle system list
  45382. */
  45383. removeParticleSystem(toRemove: IParticleSystem): number;
  45384. /**
  45385. * Remove a animation for the list of scene's animations
  45386. * @param toRemove defines the animation to remove
  45387. * @returns the index where the animation was in the animation list
  45388. */
  45389. removeAnimation(toRemove: Animation): number;
  45390. /**
  45391. * Will stop the animation of the given target
  45392. * @param target - the target
  45393. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45394. * @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)
  45395. */
  45396. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45397. /**
  45398. * Removes the given animation group from this scene.
  45399. * @param toRemove The animation group to remove
  45400. * @returns The index of the removed animation group
  45401. */
  45402. removeAnimationGroup(toRemove: AnimationGroup): number;
  45403. /**
  45404. * Removes the given multi-material from this scene.
  45405. * @param toRemove The multi-material to remove
  45406. * @returns The index of the removed multi-material
  45407. */
  45408. removeMultiMaterial(toRemove: MultiMaterial): number;
  45409. /**
  45410. * Removes the given material from this scene.
  45411. * @param toRemove The material to remove
  45412. * @returns The index of the removed material
  45413. */
  45414. removeMaterial(toRemove: Material): number;
  45415. /**
  45416. * Removes the given action manager from this scene.
  45417. * @param toRemove The action manager to remove
  45418. * @returns The index of the removed action manager
  45419. */
  45420. removeActionManager(toRemove: AbstractActionManager): number;
  45421. /**
  45422. * Removes the given texture from this scene.
  45423. * @param toRemove The texture to remove
  45424. * @returns The index of the removed texture
  45425. */
  45426. removeTexture(toRemove: BaseTexture): number;
  45427. /**
  45428. * Adds the given light to this scene
  45429. * @param newLight The light to add
  45430. */
  45431. addLight(newLight: Light): void;
  45432. /**
  45433. * Sorts the list list based on light priorities
  45434. */
  45435. sortLightsByPriority(): void;
  45436. /**
  45437. * Adds the given camera to this scene
  45438. * @param newCamera The camera to add
  45439. */
  45440. addCamera(newCamera: Camera): void;
  45441. /**
  45442. * Adds the given skeleton to this scene
  45443. * @param newSkeleton The skeleton to add
  45444. */
  45445. addSkeleton(newSkeleton: Skeleton): void;
  45446. /**
  45447. * Adds the given particle system to this scene
  45448. * @param newParticleSystem The particle system to add
  45449. */
  45450. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45451. /**
  45452. * Adds the given animation to this scene
  45453. * @param newAnimation The animation to add
  45454. */
  45455. addAnimation(newAnimation: Animation): void;
  45456. /**
  45457. * Adds the given animation group to this scene.
  45458. * @param newAnimationGroup The animation group to add
  45459. */
  45460. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45461. /**
  45462. * Adds the given multi-material to this scene
  45463. * @param newMultiMaterial The multi-material to add
  45464. */
  45465. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45466. /**
  45467. * Adds the given material to this scene
  45468. * @param newMaterial The material to add
  45469. */
  45470. addMaterial(newMaterial: Material): void;
  45471. /**
  45472. * Adds the given morph target to this scene
  45473. * @param newMorphTargetManager The morph target to add
  45474. */
  45475. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45476. /**
  45477. * Adds the given geometry to this scene
  45478. * @param newGeometry The geometry to add
  45479. */
  45480. addGeometry(newGeometry: Geometry): void;
  45481. /**
  45482. * Adds the given action manager to this scene
  45483. * @param newActionManager The action manager to add
  45484. */
  45485. addActionManager(newActionManager: AbstractActionManager): void;
  45486. /**
  45487. * Adds the given texture to this scene.
  45488. * @param newTexture The texture to add
  45489. */
  45490. addTexture(newTexture: BaseTexture): void;
  45491. /**
  45492. * Switch active camera
  45493. * @param newCamera defines the new active camera
  45494. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45495. */
  45496. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45497. /**
  45498. * sets the active camera of the scene using its ID
  45499. * @param id defines the camera's ID
  45500. * @return the new active camera or null if none found.
  45501. */
  45502. setActiveCameraByID(id: string): Nullable<Camera>;
  45503. /**
  45504. * sets the active camera of the scene using its name
  45505. * @param name defines the camera's name
  45506. * @returns the new active camera or null if none found.
  45507. */
  45508. setActiveCameraByName(name: string): Nullable<Camera>;
  45509. /**
  45510. * get an animation group using its name
  45511. * @param name defines the material's name
  45512. * @return the animation group or null if none found.
  45513. */
  45514. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45515. /**
  45516. * Get a material using its unique id
  45517. * @param uniqueId defines the material's unique id
  45518. * @return the material or null if none found.
  45519. */
  45520. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45521. /**
  45522. * get a material using its id
  45523. * @param id defines the material's ID
  45524. * @return the material or null if none found.
  45525. */
  45526. getMaterialByID(id: string): Nullable<Material>;
  45527. /**
  45528. * Gets a the last added material using a given id
  45529. * @param id defines the material's ID
  45530. * @return the last material with the given id or null if none found.
  45531. */
  45532. getLastMaterialByID(id: string): Nullable<Material>;
  45533. /**
  45534. * Gets a material using its name
  45535. * @param name defines the material's name
  45536. * @return the material or null if none found.
  45537. */
  45538. getMaterialByName(name: string): Nullable<Material>;
  45539. /**
  45540. * Get a texture using its unique id
  45541. * @param uniqueId defines the texture's unique id
  45542. * @return the texture or null if none found.
  45543. */
  45544. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45545. /**
  45546. * Gets a camera using its id
  45547. * @param id defines the id to look for
  45548. * @returns the camera or null if not found
  45549. */
  45550. getCameraByID(id: string): Nullable<Camera>;
  45551. /**
  45552. * Gets a camera using its unique id
  45553. * @param uniqueId defines the unique id to look for
  45554. * @returns the camera or null if not found
  45555. */
  45556. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45557. /**
  45558. * Gets a camera using its name
  45559. * @param name defines the camera's name
  45560. * @return the camera or null if none found.
  45561. */
  45562. getCameraByName(name: string): Nullable<Camera>;
  45563. /**
  45564. * Gets a bone using its id
  45565. * @param id defines the bone's id
  45566. * @return the bone or null if not found
  45567. */
  45568. getBoneByID(id: string): Nullable<Bone>;
  45569. /**
  45570. * Gets a bone using its id
  45571. * @param name defines the bone's name
  45572. * @return the bone or null if not found
  45573. */
  45574. getBoneByName(name: string): Nullable<Bone>;
  45575. /**
  45576. * Gets a light node using its name
  45577. * @param name defines the the light's name
  45578. * @return the light or null if none found.
  45579. */
  45580. getLightByName(name: string): Nullable<Light>;
  45581. /**
  45582. * Gets a light node using its id
  45583. * @param id defines the light's id
  45584. * @return the light or null if none found.
  45585. */
  45586. getLightByID(id: string): Nullable<Light>;
  45587. /**
  45588. * Gets a light node using its scene-generated unique ID
  45589. * @param uniqueId defines the light's unique id
  45590. * @return the light or null if none found.
  45591. */
  45592. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45593. /**
  45594. * Gets a particle system by id
  45595. * @param id defines the particle system id
  45596. * @return the corresponding system or null if none found
  45597. */
  45598. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45599. /**
  45600. * Gets a geometry using its ID
  45601. * @param id defines the geometry's id
  45602. * @return the geometry or null if none found.
  45603. */
  45604. getGeometryByID(id: string): Nullable<Geometry>;
  45605. private _getGeometryByUniqueID;
  45606. /**
  45607. * Add a new geometry to this scene
  45608. * @param geometry defines the geometry to be added to the scene.
  45609. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45610. * @return a boolean defining if the geometry was added or not
  45611. */
  45612. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45613. /**
  45614. * Removes an existing geometry
  45615. * @param geometry defines the geometry to be removed from the scene
  45616. * @return a boolean defining if the geometry was removed or not
  45617. */
  45618. removeGeometry(geometry: Geometry): boolean;
  45619. /**
  45620. * Gets the list of geometries attached to the scene
  45621. * @returns an array of Geometry
  45622. */
  45623. getGeometries(): Geometry[];
  45624. /**
  45625. * Gets the first added mesh found of a given ID
  45626. * @param id defines the id to search for
  45627. * @return the mesh found or null if not found at all
  45628. */
  45629. getMeshByID(id: string): Nullable<AbstractMesh>;
  45630. /**
  45631. * Gets a list of meshes using their id
  45632. * @param id defines the id to search for
  45633. * @returns a list of meshes
  45634. */
  45635. getMeshesByID(id: string): Array<AbstractMesh>;
  45636. /**
  45637. * Gets the first added transform node found of a given ID
  45638. * @param id defines the id to search for
  45639. * @return the found transform node or null if not found at all.
  45640. */
  45641. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45642. /**
  45643. * Gets a transform node with its auto-generated unique id
  45644. * @param uniqueId efines the unique id to search for
  45645. * @return the found transform node or null if not found at all.
  45646. */
  45647. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45648. /**
  45649. * Gets a list of transform nodes using their id
  45650. * @param id defines the id to search for
  45651. * @returns a list of transform nodes
  45652. */
  45653. getTransformNodesByID(id: string): Array<TransformNode>;
  45654. /**
  45655. * Gets a mesh with its auto-generated unique id
  45656. * @param uniqueId defines the unique id to search for
  45657. * @return the found mesh or null if not found at all.
  45658. */
  45659. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45660. /**
  45661. * Gets a the last added mesh using a given id
  45662. * @param id defines the id to search for
  45663. * @return the found mesh or null if not found at all.
  45664. */
  45665. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45666. /**
  45667. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45668. * @param id defines the id to search for
  45669. * @return the found node or null if not found at all
  45670. */
  45671. getLastEntryByID(id: string): Nullable<Node>;
  45672. /**
  45673. * Gets a node (Mesh, Camera, Light) using a given id
  45674. * @param id defines the id to search for
  45675. * @return the found node or null if not found at all
  45676. */
  45677. getNodeByID(id: string): Nullable<Node>;
  45678. /**
  45679. * Gets a node (Mesh, Camera, Light) using a given name
  45680. * @param name defines the name to search for
  45681. * @return the found node or null if not found at all.
  45682. */
  45683. getNodeByName(name: string): Nullable<Node>;
  45684. /**
  45685. * Gets a mesh using a given name
  45686. * @param name defines the name to search for
  45687. * @return the found mesh or null if not found at all.
  45688. */
  45689. getMeshByName(name: string): Nullable<AbstractMesh>;
  45690. /**
  45691. * Gets a transform node using a given name
  45692. * @param name defines the name to search for
  45693. * @return the found transform node or null if not found at all.
  45694. */
  45695. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45696. /**
  45697. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45698. * @param id defines the id to search for
  45699. * @return the found skeleton or null if not found at all.
  45700. */
  45701. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45702. /**
  45703. * Gets a skeleton using a given auto generated unique id
  45704. * @param uniqueId defines the unique id to search for
  45705. * @return the found skeleton or null if not found at all.
  45706. */
  45707. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45708. /**
  45709. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45710. * @param id defines the id to search for
  45711. * @return the found skeleton or null if not found at all.
  45712. */
  45713. getSkeletonById(id: string): Nullable<Skeleton>;
  45714. /**
  45715. * Gets a skeleton using a given name
  45716. * @param name defines the name to search for
  45717. * @return the found skeleton or null if not found at all.
  45718. */
  45719. getSkeletonByName(name: string): Nullable<Skeleton>;
  45720. /**
  45721. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45722. * @param id defines the id to search for
  45723. * @return the found morph target manager or null if not found at all.
  45724. */
  45725. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45726. /**
  45727. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45728. * @param id defines the id to search for
  45729. * @return the found morph target or null if not found at all.
  45730. */
  45731. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45732. /**
  45733. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45734. * @param name defines the name to search for
  45735. * @return the found morph target or null if not found at all.
  45736. */
  45737. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45738. /**
  45739. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45740. * @param name defines the name to search for
  45741. * @return the found post process or null if not found at all.
  45742. */
  45743. getPostProcessByName(name: string): Nullable<PostProcess>;
  45744. /**
  45745. * Gets a boolean indicating if the given mesh is active
  45746. * @param mesh defines the mesh to look for
  45747. * @returns true if the mesh is in the active list
  45748. */
  45749. isActiveMesh(mesh: AbstractMesh): boolean;
  45750. /**
  45751. * Return a unique id as a string which can serve as an identifier for the scene
  45752. */
  45753. get uid(): string;
  45754. /**
  45755. * Add an externaly attached data from its key.
  45756. * This method call will fail and return false, if such key already exists.
  45757. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45758. * @param key the unique key that identifies the data
  45759. * @param data the data object to associate to the key for this Engine instance
  45760. * @return true if no such key were already present and the data was added successfully, false otherwise
  45761. */
  45762. addExternalData<T>(key: string, data: T): boolean;
  45763. /**
  45764. * Get an externaly attached data from its key
  45765. * @param key the unique key that identifies the data
  45766. * @return the associated data, if present (can be null), or undefined if not present
  45767. */
  45768. getExternalData<T>(key: string): Nullable<T>;
  45769. /**
  45770. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45771. * @param key the unique key that identifies the data
  45772. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45773. * @return the associated data, can be null if the factory returned null.
  45774. */
  45775. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45776. /**
  45777. * Remove an externaly attached data from the Engine instance
  45778. * @param key the unique key that identifies the data
  45779. * @return true if the data was successfully removed, false if it doesn't exist
  45780. */
  45781. removeExternalData(key: string): boolean;
  45782. private _evaluateSubMesh;
  45783. /**
  45784. * Clear the processed materials smart array preventing retention point in material dispose.
  45785. */
  45786. freeProcessedMaterials(): void;
  45787. private _preventFreeActiveMeshesAndRenderingGroups;
  45788. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45789. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45790. * when disposing several meshes in a row or a hierarchy of meshes.
  45791. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45792. */
  45793. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45794. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45795. /**
  45796. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45797. */
  45798. freeActiveMeshes(): void;
  45799. /**
  45800. * Clear the info related to rendering groups preventing retention points during dispose.
  45801. */
  45802. freeRenderingGroups(): void;
  45803. /** @hidden */
  45804. _isInIntermediateRendering(): boolean;
  45805. /**
  45806. * Lambda returning the list of potentially active meshes.
  45807. */
  45808. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45809. /**
  45810. * Lambda returning the list of potentially active sub meshes.
  45811. */
  45812. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45813. /**
  45814. * Lambda returning the list of potentially intersecting sub meshes.
  45815. */
  45816. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45817. /**
  45818. * Lambda returning the list of potentially colliding sub meshes.
  45819. */
  45820. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45821. private _activeMeshesFrozen;
  45822. private _skipEvaluateActiveMeshesCompletely;
  45823. /**
  45824. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45825. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45826. * @param onSuccess optional success callback
  45827. * @param onError optional error callback
  45828. * @returns the current scene
  45829. */
  45830. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45831. /**
  45832. * Use this function to restart evaluating active meshes on every frame
  45833. * @returns the current scene
  45834. */
  45835. unfreezeActiveMeshes(): Scene;
  45836. private _evaluateActiveMeshes;
  45837. private _activeMesh;
  45838. /**
  45839. * Update the transform matrix to update from the current active camera
  45840. * @param force defines a boolean used to force the update even if cache is up to date
  45841. */
  45842. updateTransformMatrix(force?: boolean): void;
  45843. private _bindFrameBuffer;
  45844. /** @hidden */
  45845. _allowPostProcessClearColor: boolean;
  45846. /** @hidden */
  45847. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45848. private _processSubCameras;
  45849. private _checkIntersections;
  45850. /** @hidden */
  45851. _advancePhysicsEngineStep(step: number): void;
  45852. /**
  45853. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45854. */
  45855. getDeterministicFrameTime: () => number;
  45856. /** @hidden */
  45857. _animate(): void;
  45858. /** Execute all animations (for a frame) */
  45859. animate(): void;
  45860. /**
  45861. * Render the scene
  45862. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45863. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45864. */
  45865. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45866. /**
  45867. * Freeze all materials
  45868. * A frozen material will not be updatable but should be faster to render
  45869. */
  45870. freezeMaterials(): void;
  45871. /**
  45872. * Unfreeze all materials
  45873. * A frozen material will not be updatable but should be faster to render
  45874. */
  45875. unfreezeMaterials(): void;
  45876. /**
  45877. * Releases all held ressources
  45878. */
  45879. dispose(): void;
  45880. /**
  45881. * Gets if the scene is already disposed
  45882. */
  45883. get isDisposed(): boolean;
  45884. /**
  45885. * Call this function to reduce memory footprint of the scene.
  45886. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45887. */
  45888. clearCachedVertexData(): void;
  45889. /**
  45890. * This function will remove the local cached buffer data from texture.
  45891. * It will save memory but will prevent the texture from being rebuilt
  45892. */
  45893. cleanCachedTextureBuffer(): void;
  45894. /**
  45895. * Get the world extend vectors with an optional filter
  45896. *
  45897. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45898. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45899. */
  45900. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45901. min: Vector3;
  45902. max: Vector3;
  45903. };
  45904. /**
  45905. * Creates a ray that can be used to pick in the scene
  45906. * @param x defines the x coordinate of the origin (on-screen)
  45907. * @param y defines the y coordinate of the origin (on-screen)
  45908. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45909. * @param camera defines the camera to use for the picking
  45910. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45911. * @returns a Ray
  45912. */
  45913. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45914. /**
  45915. * Creates a ray that can be used to pick in the scene
  45916. * @param x defines the x coordinate of the origin (on-screen)
  45917. * @param y defines the y coordinate of the origin (on-screen)
  45918. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45919. * @param result defines the ray where to store the picking ray
  45920. * @param camera defines the camera to use for the picking
  45921. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45922. * @returns the current scene
  45923. */
  45924. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45925. /**
  45926. * Creates a ray that can be used to pick in the scene
  45927. * @param x defines the x coordinate of the origin (on-screen)
  45928. * @param y defines the y coordinate of the origin (on-screen)
  45929. * @param camera defines the camera to use for the picking
  45930. * @returns a Ray
  45931. */
  45932. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45933. /**
  45934. * Creates a ray that can be used to pick in the scene
  45935. * @param x defines the x coordinate of the origin (on-screen)
  45936. * @param y defines the y coordinate of the origin (on-screen)
  45937. * @param result defines the ray where to store the picking ray
  45938. * @param camera defines the camera to use for the picking
  45939. * @returns the current scene
  45940. */
  45941. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45942. /** Launch a ray to try to pick a mesh in the scene
  45943. * @param x position on screen
  45944. * @param y position on screen
  45945. * @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
  45946. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45947. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45948. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45949. * @returns a PickingInfo
  45950. */
  45951. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45952. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45953. * @param x position on screen
  45954. * @param y position on screen
  45955. * @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
  45956. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45957. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45958. * @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)
  45959. */
  45960. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45961. /** Use the given ray to pick a mesh in the scene
  45962. * @param ray The ray to use to pick meshes
  45963. * @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
  45964. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45965. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45966. * @returns a PickingInfo
  45967. */
  45968. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45969. /**
  45970. * Launch a ray to try to pick a mesh in the scene
  45971. * @param x X position on screen
  45972. * @param y Y position on screen
  45973. * @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
  45974. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45975. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45976. * @returns an array of PickingInfo
  45977. */
  45978. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45979. /**
  45980. * Launch a ray to try to pick a mesh in the scene
  45981. * @param ray Ray to use
  45982. * @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
  45983. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45984. * @returns an array of PickingInfo
  45985. */
  45986. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45987. /**
  45988. * Force the value of meshUnderPointer
  45989. * @param mesh defines the mesh to use
  45990. * @param pointerId optional pointer id when using more than one pointer
  45991. */
  45992. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45993. /**
  45994. * Gets the mesh under the pointer
  45995. * @returns a Mesh or null if no mesh is under the pointer
  45996. */
  45997. getPointerOverMesh(): Nullable<AbstractMesh>;
  45998. /** @hidden */
  45999. _rebuildGeometries(): void;
  46000. /** @hidden */
  46001. _rebuildTextures(): void;
  46002. private _getByTags;
  46003. /**
  46004. * Get a list of meshes by tags
  46005. * @param tagsQuery defines the tags query to use
  46006. * @param forEach defines a predicate used to filter results
  46007. * @returns an array of Mesh
  46008. */
  46009. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46010. /**
  46011. * Get a list of cameras by tags
  46012. * @param tagsQuery defines the tags query to use
  46013. * @param forEach defines a predicate used to filter results
  46014. * @returns an array of Camera
  46015. */
  46016. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46017. /**
  46018. * Get a list of lights by tags
  46019. * @param tagsQuery defines the tags query to use
  46020. * @param forEach defines a predicate used to filter results
  46021. * @returns an array of Light
  46022. */
  46023. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46024. /**
  46025. * Get a list of materials by tags
  46026. * @param tagsQuery defines the tags query to use
  46027. * @param forEach defines a predicate used to filter results
  46028. * @returns an array of Material
  46029. */
  46030. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46031. /**
  46032. * Get a list of transform nodes by tags
  46033. * @param tagsQuery defines the tags query to use
  46034. * @param forEach defines a predicate used to filter results
  46035. * @returns an array of TransformNode
  46036. */
  46037. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46038. /**
  46039. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46040. * This allowed control for front to back rendering or reversly depending of the special needs.
  46041. *
  46042. * @param renderingGroupId The rendering group id corresponding to its index
  46043. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46044. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46045. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46046. */
  46047. 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;
  46048. /**
  46049. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46050. *
  46051. * @param renderingGroupId The rendering group id corresponding to its index
  46052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46053. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46054. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46055. */
  46056. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46057. /**
  46058. * Gets the current auto clear configuration for one rendering group of the rendering
  46059. * manager.
  46060. * @param index the rendering group index to get the information for
  46061. * @returns The auto clear setup for the requested rendering group
  46062. */
  46063. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46064. private _blockMaterialDirtyMechanism;
  46065. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46066. get blockMaterialDirtyMechanism(): boolean;
  46067. set blockMaterialDirtyMechanism(value: boolean);
  46068. /**
  46069. * Will flag all materials as dirty to trigger new shader compilation
  46070. * @param flag defines the flag used to specify which material part must be marked as dirty
  46071. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46072. */
  46073. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46074. /** @hidden */
  46075. _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;
  46076. /** @hidden */
  46077. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46078. /** @hidden */
  46079. _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;
  46080. /** @hidden */
  46081. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46082. /** @hidden */
  46083. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46084. /** @hidden */
  46085. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46086. }
  46087. }
  46088. declare module "babylonjs/assetContainer" {
  46089. import { AbstractScene } from "babylonjs/abstractScene";
  46090. import { Scene } from "babylonjs/scene";
  46091. import { Mesh } from "babylonjs/Meshes/mesh";
  46092. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46093. import { Skeleton } from "babylonjs/Bones/skeleton";
  46094. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46095. import { Animatable } from "babylonjs/Animations/animatable";
  46096. import { Nullable } from "babylonjs/types";
  46097. import { Node } from "babylonjs/node";
  46098. /**
  46099. * Set of assets to keep when moving a scene into an asset container.
  46100. */
  46101. export class KeepAssets extends AbstractScene {
  46102. }
  46103. /**
  46104. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46105. */
  46106. export class InstantiatedEntries {
  46107. /**
  46108. * List of new root nodes (eg. nodes with no parent)
  46109. */
  46110. rootNodes: TransformNode[];
  46111. /**
  46112. * List of new skeletons
  46113. */
  46114. skeletons: Skeleton[];
  46115. /**
  46116. * List of new animation groups
  46117. */
  46118. animationGroups: AnimationGroup[];
  46119. }
  46120. /**
  46121. * Container with a set of assets that can be added or removed from a scene.
  46122. */
  46123. export class AssetContainer extends AbstractScene {
  46124. private _wasAddedToScene;
  46125. /**
  46126. * The scene the AssetContainer belongs to.
  46127. */
  46128. scene: Scene;
  46129. /**
  46130. * Instantiates an AssetContainer.
  46131. * @param scene The scene the AssetContainer belongs to.
  46132. */
  46133. constructor(scene: Scene);
  46134. /**
  46135. * Instantiate or clone all meshes and add the new ones to the scene.
  46136. * Skeletons and animation groups will all be cloned
  46137. * @param nameFunction defines an optional function used to get new names for clones
  46138. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46139. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46140. */
  46141. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46142. /**
  46143. * Adds all the assets from the container to the scene.
  46144. */
  46145. addAllToScene(): void;
  46146. /**
  46147. * Removes all the assets in the container from the scene
  46148. */
  46149. removeAllFromScene(): void;
  46150. /**
  46151. * Disposes all the assets in the container
  46152. */
  46153. dispose(): void;
  46154. private _moveAssets;
  46155. /**
  46156. * Removes all the assets contained in the scene and adds them to the container.
  46157. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46158. */
  46159. moveAllFromScene(keepAssets?: KeepAssets): void;
  46160. /**
  46161. * 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.
  46162. * @returns the root mesh
  46163. */
  46164. createRootMesh(): Mesh;
  46165. /**
  46166. * Merge animations (direct and animation groups) from this asset container into a scene
  46167. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46168. * @param animatables set of animatables to retarget to a node from the scene
  46169. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46170. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46171. */
  46172. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46173. }
  46174. }
  46175. declare module "babylonjs/abstractScene" {
  46176. import { Scene } from "babylonjs/scene";
  46177. import { Nullable } from "babylonjs/types";
  46178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46179. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46180. import { Geometry } from "babylonjs/Meshes/geometry";
  46181. import { Skeleton } from "babylonjs/Bones/skeleton";
  46182. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46183. import { AssetContainer } from "babylonjs/assetContainer";
  46184. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46185. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46187. import { Material } from "babylonjs/Materials/material";
  46188. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46189. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46190. import { Camera } from "babylonjs/Cameras/camera";
  46191. import { Light } from "babylonjs/Lights/light";
  46192. import { Node } from "babylonjs/node";
  46193. import { Animation } from "babylonjs/Animations/animation";
  46194. /**
  46195. * Defines how the parser contract is defined.
  46196. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46197. */
  46198. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46199. /**
  46200. * Defines how the individual parser contract is defined.
  46201. * These parser can parse an individual asset
  46202. */
  46203. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46204. /**
  46205. * Base class of the scene acting as a container for the different elements composing a scene.
  46206. * This class is dynamically extended by the different components of the scene increasing
  46207. * flexibility and reducing coupling
  46208. */
  46209. export abstract class AbstractScene {
  46210. /**
  46211. * Stores the list of available parsers in the application.
  46212. */
  46213. private static _BabylonFileParsers;
  46214. /**
  46215. * Stores the list of available individual parsers in the application.
  46216. */
  46217. private static _IndividualBabylonFileParsers;
  46218. /**
  46219. * Adds a parser in the list of available ones
  46220. * @param name Defines the name of the parser
  46221. * @param parser Defines the parser to add
  46222. */
  46223. static AddParser(name: string, parser: BabylonFileParser): void;
  46224. /**
  46225. * Gets a general parser from the list of avaialble ones
  46226. * @param name Defines the name of the parser
  46227. * @returns the requested parser or null
  46228. */
  46229. static GetParser(name: string): Nullable<BabylonFileParser>;
  46230. /**
  46231. * Adds n individual parser in the list of available ones
  46232. * @param name Defines the name of the parser
  46233. * @param parser Defines the parser to add
  46234. */
  46235. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46236. /**
  46237. * Gets an individual parser from the list of avaialble ones
  46238. * @param name Defines the name of the parser
  46239. * @returns the requested parser or null
  46240. */
  46241. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46242. /**
  46243. * Parser json data and populate both a scene and its associated container object
  46244. * @param jsonData Defines the data to parse
  46245. * @param scene Defines the scene to parse the data for
  46246. * @param container Defines the container attached to the parsing sequence
  46247. * @param rootUrl Defines the root url of the data
  46248. */
  46249. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46250. /**
  46251. * Gets the list of root nodes (ie. nodes with no parent)
  46252. */
  46253. rootNodes: Node[];
  46254. /** All of the cameras added to this scene
  46255. * @see https://doc.babylonjs.com/babylon101/cameras
  46256. */
  46257. cameras: Camera[];
  46258. /**
  46259. * All of the lights added to this scene
  46260. * @see https://doc.babylonjs.com/babylon101/lights
  46261. */
  46262. lights: Light[];
  46263. /**
  46264. * All of the (abstract) meshes added to this scene
  46265. */
  46266. meshes: AbstractMesh[];
  46267. /**
  46268. * The list of skeletons added to the scene
  46269. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46270. */
  46271. skeletons: Skeleton[];
  46272. /**
  46273. * All of the particle systems added to this scene
  46274. * @see https://doc.babylonjs.com/babylon101/particles
  46275. */
  46276. particleSystems: IParticleSystem[];
  46277. /**
  46278. * Gets a list of Animations associated with the scene
  46279. */
  46280. animations: Animation[];
  46281. /**
  46282. * All of the animation groups added to this scene
  46283. * @see https://doc.babylonjs.com/how_to/group
  46284. */
  46285. animationGroups: AnimationGroup[];
  46286. /**
  46287. * All of the multi-materials added to this scene
  46288. * @see https://doc.babylonjs.com/how_to/multi_materials
  46289. */
  46290. multiMaterials: MultiMaterial[];
  46291. /**
  46292. * All of the materials added to this scene
  46293. * In the context of a Scene, it is not supposed to be modified manually.
  46294. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46295. * Note also that the order of the Material within the array is not significant and might change.
  46296. * @see https://doc.babylonjs.com/babylon101/materials
  46297. */
  46298. materials: Material[];
  46299. /**
  46300. * The list of morph target managers added to the scene
  46301. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46302. */
  46303. morphTargetManagers: MorphTargetManager[];
  46304. /**
  46305. * The list of geometries used in the scene.
  46306. */
  46307. geometries: Geometry[];
  46308. /**
  46309. * All of the tranform nodes added to this scene
  46310. * In the context of a Scene, it is not supposed to be modified manually.
  46311. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46312. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46313. * @see https://doc.babylonjs.com/how_to/transformnode
  46314. */
  46315. transformNodes: TransformNode[];
  46316. /**
  46317. * ActionManagers available on the scene.
  46318. */
  46319. actionManagers: AbstractActionManager[];
  46320. /**
  46321. * Textures to keep.
  46322. */
  46323. textures: BaseTexture[];
  46324. /** @hidden */
  46325. protected _environmentTexture: Nullable<BaseTexture>;
  46326. /**
  46327. * Texture used in all pbr material as the reflection texture.
  46328. * As in the majority of the scene they are the same (exception for multi room and so on),
  46329. * this is easier to reference from here than from all the materials.
  46330. */
  46331. get environmentTexture(): Nullable<BaseTexture>;
  46332. set environmentTexture(value: Nullable<BaseTexture>);
  46333. /**
  46334. * The list of postprocesses added to the scene
  46335. */
  46336. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46337. /**
  46338. * @returns all meshes, lights, cameras, transformNodes and bones
  46339. */
  46340. getNodes(): Array<Node>;
  46341. }
  46342. }
  46343. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46344. /**
  46345. * Interface used to define options for Sound class
  46346. */
  46347. export interface ISoundOptions {
  46348. /**
  46349. * Does the sound autoplay once loaded.
  46350. */
  46351. autoplay?: boolean;
  46352. /**
  46353. * Does the sound loop after it finishes playing once.
  46354. */
  46355. loop?: boolean;
  46356. /**
  46357. * Sound's volume
  46358. */
  46359. volume?: number;
  46360. /**
  46361. * Is it a spatial sound?
  46362. */
  46363. spatialSound?: boolean;
  46364. /**
  46365. * Maximum distance to hear that sound
  46366. */
  46367. maxDistance?: number;
  46368. /**
  46369. * Uses user defined attenuation function
  46370. */
  46371. useCustomAttenuation?: boolean;
  46372. /**
  46373. * Define the roll off factor of spatial sounds.
  46374. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46375. */
  46376. rolloffFactor?: number;
  46377. /**
  46378. * Define the reference distance the sound should be heard perfectly.
  46379. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46380. */
  46381. refDistance?: number;
  46382. /**
  46383. * Define the distance attenuation model the sound will follow.
  46384. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46385. */
  46386. distanceModel?: string;
  46387. /**
  46388. * Defines the playback speed (1 by default)
  46389. */
  46390. playbackRate?: number;
  46391. /**
  46392. * Defines if the sound is from a streaming source
  46393. */
  46394. streaming?: boolean;
  46395. /**
  46396. * Defines an optional length (in seconds) inside the sound file
  46397. */
  46398. length?: number;
  46399. /**
  46400. * Defines an optional offset (in seconds) inside the sound file
  46401. */
  46402. offset?: number;
  46403. /**
  46404. * If true, URLs will not be required to state the audio file codec to use.
  46405. */
  46406. skipCodecCheck?: boolean;
  46407. }
  46408. }
  46409. declare module "babylonjs/Audio/sound" {
  46410. import { Observable } from "babylonjs/Misc/observable";
  46411. import { Vector3 } from "babylonjs/Maths/math.vector";
  46412. import { Nullable } from "babylonjs/types";
  46413. import { Scene } from "babylonjs/scene";
  46414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46415. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46416. /**
  46417. * Defines a sound that can be played in the application.
  46418. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46420. */
  46421. export class Sound {
  46422. /**
  46423. * The name of the sound in the scene.
  46424. */
  46425. name: string;
  46426. /**
  46427. * Does the sound autoplay once loaded.
  46428. */
  46429. autoplay: boolean;
  46430. /**
  46431. * Does the sound loop after it finishes playing once.
  46432. */
  46433. loop: boolean;
  46434. /**
  46435. * Does the sound use a custom attenuation curve to simulate the falloff
  46436. * happening when the source gets further away from the camera.
  46437. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46438. */
  46439. useCustomAttenuation: boolean;
  46440. /**
  46441. * The sound track id this sound belongs to.
  46442. */
  46443. soundTrackId: number;
  46444. /**
  46445. * Is this sound currently played.
  46446. */
  46447. isPlaying: boolean;
  46448. /**
  46449. * Is this sound currently paused.
  46450. */
  46451. isPaused: boolean;
  46452. /**
  46453. * Does this sound enables spatial sound.
  46454. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46455. */
  46456. spatialSound: boolean;
  46457. /**
  46458. * Define the reference distance the sound should be heard perfectly.
  46459. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46460. */
  46461. refDistance: number;
  46462. /**
  46463. * Define the roll off factor of spatial sounds.
  46464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46465. */
  46466. rolloffFactor: number;
  46467. /**
  46468. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46470. */
  46471. maxDistance: number;
  46472. /**
  46473. * Define the distance attenuation model the sound will follow.
  46474. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46475. */
  46476. distanceModel: string;
  46477. /**
  46478. * @hidden
  46479. * Back Compat
  46480. **/
  46481. onended: () => any;
  46482. /**
  46483. * Gets or sets an object used to store user defined information for the sound.
  46484. */
  46485. metadata: any;
  46486. /**
  46487. * Observable event when the current playing sound finishes.
  46488. */
  46489. onEndedObservable: Observable<Sound>;
  46490. /**
  46491. * Gets the current time for the sound.
  46492. */
  46493. get currentTime(): number;
  46494. private _panningModel;
  46495. private _playbackRate;
  46496. private _streaming;
  46497. private _startTime;
  46498. private _startOffset;
  46499. private _position;
  46500. /** @hidden */
  46501. _positionInEmitterSpace: boolean;
  46502. private _localDirection;
  46503. private _volume;
  46504. private _isReadyToPlay;
  46505. private _isDirectional;
  46506. private _readyToPlayCallback;
  46507. private _audioBuffer;
  46508. private _soundSource;
  46509. private _streamingSource;
  46510. private _soundPanner;
  46511. private _soundGain;
  46512. private _inputAudioNode;
  46513. private _outputAudioNode;
  46514. private _coneInnerAngle;
  46515. private _coneOuterAngle;
  46516. private _coneOuterGain;
  46517. private _scene;
  46518. private _connectedTransformNode;
  46519. private _customAttenuationFunction;
  46520. private _registerFunc;
  46521. private _isOutputConnected;
  46522. private _htmlAudioElement;
  46523. private _urlType;
  46524. private _length?;
  46525. private _offset?;
  46526. /** @hidden */
  46527. static _SceneComponentInitialization: (scene: Scene) => void;
  46528. /**
  46529. * Create a sound and attach it to a scene
  46530. * @param name Name of your sound
  46531. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46532. * @param scene defines the scene the sound belongs to
  46533. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46534. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46535. */
  46536. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46537. /**
  46538. * Release the sound and its associated resources
  46539. */
  46540. dispose(): void;
  46541. /**
  46542. * Gets if the sounds is ready to be played or not.
  46543. * @returns true if ready, otherwise false
  46544. */
  46545. isReady(): boolean;
  46546. private _soundLoaded;
  46547. /**
  46548. * Sets the data of the sound from an audiobuffer
  46549. * @param audioBuffer The audioBuffer containing the data
  46550. */
  46551. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46552. /**
  46553. * Updates the current sounds options such as maxdistance, loop...
  46554. * @param options A JSON object containing values named as the object properties
  46555. */
  46556. updateOptions(options: ISoundOptions): void;
  46557. private _createSpatialParameters;
  46558. private _updateSpatialParameters;
  46559. /**
  46560. * Switch the panning model to HRTF:
  46561. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46562. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46563. */
  46564. switchPanningModelToHRTF(): void;
  46565. /**
  46566. * Switch the panning model to Equal Power:
  46567. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46568. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46569. */
  46570. switchPanningModelToEqualPower(): void;
  46571. private _switchPanningModel;
  46572. /**
  46573. * Connect this sound to a sound track audio node like gain...
  46574. * @param soundTrackAudioNode the sound track audio node to connect to
  46575. */
  46576. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46577. /**
  46578. * Transform this sound into a directional source
  46579. * @param coneInnerAngle Size of the inner cone in degree
  46580. * @param coneOuterAngle Size of the outer cone in degree
  46581. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46582. */
  46583. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46584. /**
  46585. * Gets or sets the inner angle for the directional cone.
  46586. */
  46587. get directionalConeInnerAngle(): number;
  46588. /**
  46589. * Gets or sets the inner angle for the directional cone.
  46590. */
  46591. set directionalConeInnerAngle(value: number);
  46592. /**
  46593. * Gets or sets the outer angle for the directional cone.
  46594. */
  46595. get directionalConeOuterAngle(): number;
  46596. /**
  46597. * Gets or sets the outer angle for the directional cone.
  46598. */
  46599. set directionalConeOuterAngle(value: number);
  46600. /**
  46601. * Sets the position of the emitter if spatial sound is enabled
  46602. * @param newPosition Defines the new posisiton
  46603. */
  46604. setPosition(newPosition: Vector3): void;
  46605. /**
  46606. * Sets the local direction of the emitter if spatial sound is enabled
  46607. * @param newLocalDirection Defines the new local direction
  46608. */
  46609. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46610. private _updateDirection;
  46611. /** @hidden */
  46612. updateDistanceFromListener(): void;
  46613. /**
  46614. * Sets a new custom attenuation function for the sound.
  46615. * @param callback Defines the function used for the attenuation
  46616. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46617. */
  46618. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46619. /**
  46620. * Play the sound
  46621. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46622. * @param offset (optional) Start the sound at a specific time in seconds
  46623. * @param length (optional) Sound duration (in seconds)
  46624. */
  46625. play(time?: number, offset?: number, length?: number): void;
  46626. private _onended;
  46627. /**
  46628. * Stop the sound
  46629. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46630. */
  46631. stop(time?: number): void;
  46632. /**
  46633. * Put the sound in pause
  46634. */
  46635. pause(): void;
  46636. /**
  46637. * Sets a dedicated volume for this sounds
  46638. * @param newVolume Define the new volume of the sound
  46639. * @param time Define time for gradual change to new volume
  46640. */
  46641. setVolume(newVolume: number, time?: number): void;
  46642. /**
  46643. * Set the sound play back rate
  46644. * @param newPlaybackRate Define the playback rate the sound should be played at
  46645. */
  46646. setPlaybackRate(newPlaybackRate: number): void;
  46647. /**
  46648. * Gets the volume of the sound.
  46649. * @returns the volume of the sound
  46650. */
  46651. getVolume(): number;
  46652. /**
  46653. * Attach the sound to a dedicated mesh
  46654. * @param transformNode The transform node to connect the sound with
  46655. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46656. */
  46657. attachToMesh(transformNode: TransformNode): void;
  46658. /**
  46659. * Detach the sound from the previously attached mesh
  46660. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46661. */
  46662. detachFromMesh(): void;
  46663. private _onRegisterAfterWorldMatrixUpdate;
  46664. /**
  46665. * Clone the current sound in the scene.
  46666. * @returns the new sound clone
  46667. */
  46668. clone(): Nullable<Sound>;
  46669. /**
  46670. * Gets the current underlying audio buffer containing the data
  46671. * @returns the audio buffer
  46672. */
  46673. getAudioBuffer(): Nullable<AudioBuffer>;
  46674. /**
  46675. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46676. * @returns the source node
  46677. */
  46678. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46679. /**
  46680. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46681. * @returns the gain node
  46682. */
  46683. getSoundGain(): Nullable<GainNode>;
  46684. /**
  46685. * Serializes the Sound in a JSON representation
  46686. * @returns the JSON representation of the sound
  46687. */
  46688. serialize(): any;
  46689. /**
  46690. * Parse a JSON representation of a sound to innstantiate in a given scene
  46691. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46692. * @param scene Define the scene the new parsed sound should be created in
  46693. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46694. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46695. * @returns the newly parsed sound
  46696. */
  46697. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46698. }
  46699. }
  46700. declare module "babylonjs/Actions/directAudioActions" {
  46701. import { Action } from "babylonjs/Actions/action";
  46702. import { Condition } from "babylonjs/Actions/condition";
  46703. import { Sound } from "babylonjs/Audio/sound";
  46704. /**
  46705. * This defines an action helpful to play a defined sound on a triggered action.
  46706. */
  46707. export class PlaySoundAction extends Action {
  46708. private _sound;
  46709. /**
  46710. * Instantiate the action
  46711. * @param triggerOptions defines the trigger options
  46712. * @param sound defines the sound to play
  46713. * @param condition defines the trigger related conditions
  46714. */
  46715. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46716. /** @hidden */
  46717. _prepare(): void;
  46718. /**
  46719. * Execute the action and play the sound.
  46720. */
  46721. execute(): void;
  46722. /**
  46723. * Serializes the actions and its related information.
  46724. * @param parent defines the object to serialize in
  46725. * @returns the serialized object
  46726. */
  46727. serialize(parent: any): any;
  46728. }
  46729. /**
  46730. * This defines an action helpful to stop a defined sound on a triggered action.
  46731. */
  46732. export class StopSoundAction extends Action {
  46733. private _sound;
  46734. /**
  46735. * Instantiate the action
  46736. * @param triggerOptions defines the trigger options
  46737. * @param sound defines the sound to stop
  46738. * @param condition defines the trigger related conditions
  46739. */
  46740. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46741. /** @hidden */
  46742. _prepare(): void;
  46743. /**
  46744. * Execute the action and stop the sound.
  46745. */
  46746. execute(): void;
  46747. /**
  46748. * Serializes the actions and its related information.
  46749. * @param parent defines the object to serialize in
  46750. * @returns the serialized object
  46751. */
  46752. serialize(parent: any): any;
  46753. }
  46754. }
  46755. declare module "babylonjs/Actions/interpolateValueAction" {
  46756. import { Action } from "babylonjs/Actions/action";
  46757. import { Condition } from "babylonjs/Actions/condition";
  46758. import { Observable } from "babylonjs/Misc/observable";
  46759. /**
  46760. * This defines an action responsible to change the value of a property
  46761. * by interpolating between its current value and the newly set one once triggered.
  46762. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46763. */
  46764. export class InterpolateValueAction extends Action {
  46765. /**
  46766. * Defines the path of the property where the value should be interpolated
  46767. */
  46768. propertyPath: string;
  46769. /**
  46770. * Defines the target value at the end of the interpolation.
  46771. */
  46772. value: any;
  46773. /**
  46774. * Defines the time it will take for the property to interpolate to the value.
  46775. */
  46776. duration: number;
  46777. /**
  46778. * Defines if the other scene animations should be stopped when the action has been triggered
  46779. */
  46780. stopOtherAnimations?: boolean;
  46781. /**
  46782. * Defines a callback raised once the interpolation animation has been done.
  46783. */
  46784. onInterpolationDone?: () => void;
  46785. /**
  46786. * Observable triggered once the interpolation animation has been done.
  46787. */
  46788. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46789. private _target;
  46790. private _effectiveTarget;
  46791. private _property;
  46792. /**
  46793. * Instantiate the action
  46794. * @param triggerOptions defines the trigger options
  46795. * @param target defines the object containing the value to interpolate
  46796. * @param propertyPath defines the path to the property in the target object
  46797. * @param value defines the target value at the end of the interpolation
  46798. * @param duration deines the time it will take for the property to interpolate to the value.
  46799. * @param condition defines the trigger related conditions
  46800. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46801. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46802. */
  46803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46804. /** @hidden */
  46805. _prepare(): void;
  46806. /**
  46807. * Execute the action starts the value interpolation.
  46808. */
  46809. execute(): void;
  46810. /**
  46811. * Serializes the actions and its related information.
  46812. * @param parent defines the object to serialize in
  46813. * @returns the serialized object
  46814. */
  46815. serialize(parent: any): any;
  46816. }
  46817. }
  46818. declare module "babylonjs/Actions/index" {
  46819. export * from "babylonjs/Actions/abstractActionManager";
  46820. export * from "babylonjs/Actions/action";
  46821. export * from "babylonjs/Actions/actionEvent";
  46822. export * from "babylonjs/Actions/actionManager";
  46823. export * from "babylonjs/Actions/condition";
  46824. export * from "babylonjs/Actions/directActions";
  46825. export * from "babylonjs/Actions/directAudioActions";
  46826. export * from "babylonjs/Actions/interpolateValueAction";
  46827. }
  46828. declare module "babylonjs/Animations/index" {
  46829. export * from "babylonjs/Animations/animatable";
  46830. export * from "babylonjs/Animations/animation";
  46831. export * from "babylonjs/Animations/animationGroup";
  46832. export * from "babylonjs/Animations/animationPropertiesOverride";
  46833. export * from "babylonjs/Animations/easing";
  46834. export * from "babylonjs/Animations/runtimeAnimation";
  46835. export * from "babylonjs/Animations/animationEvent";
  46836. export * from "babylonjs/Animations/animationGroup";
  46837. export * from "babylonjs/Animations/animationKey";
  46838. export * from "babylonjs/Animations/animationRange";
  46839. export * from "babylonjs/Animations/animatable.interface";
  46840. }
  46841. declare module "babylonjs/Audio/audioEngine" {
  46842. import { Analyser } from "babylonjs/Audio/analyser";
  46843. import { Nullable } from "babylonjs/types";
  46844. import { Observable } from "babylonjs/Misc/observable";
  46845. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  46846. /**
  46847. * This represents the default audio engine used in babylon.
  46848. * It is responsible to play, synchronize and analyse sounds throughout the application.
  46849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46850. */
  46851. export class AudioEngine implements IAudioEngine {
  46852. private _audioContext;
  46853. private _audioContextInitialized;
  46854. private _muteButton;
  46855. private _hostElement;
  46856. /**
  46857. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  46858. */
  46859. canUseWebAudio: boolean;
  46860. /**
  46861. * The master gain node defines the global audio volume of your audio engine.
  46862. */
  46863. masterGain: GainNode;
  46864. /**
  46865. * Defines if Babylon should emit a warning if WebAudio is not supported.
  46866. * @ignoreNaming
  46867. */
  46868. WarnedWebAudioUnsupported: boolean;
  46869. /**
  46870. * Gets whether or not mp3 are supported by your browser.
  46871. */
  46872. isMP3supported: boolean;
  46873. /**
  46874. * Gets whether or not ogg are supported by your browser.
  46875. */
  46876. isOGGsupported: boolean;
  46877. /**
  46878. * Gets whether audio has been unlocked on the device.
  46879. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  46880. * a user interaction has happened.
  46881. */
  46882. unlocked: boolean;
  46883. /**
  46884. * Defines if the audio engine relies on a custom unlocked button.
  46885. * In this case, the embedded button will not be displayed.
  46886. */
  46887. useCustomUnlockedButton: boolean;
  46888. /**
  46889. * Event raised when audio has been unlocked on the browser.
  46890. */
  46891. onAudioUnlockedObservable: Observable<IAudioEngine>;
  46892. /**
  46893. * Event raised when audio has been locked on the browser.
  46894. */
  46895. onAudioLockedObservable: Observable<IAudioEngine>;
  46896. /**
  46897. * Gets the current AudioContext if available.
  46898. */
  46899. get audioContext(): Nullable<AudioContext>;
  46900. private _connectedAnalyser;
  46901. /**
  46902. * Instantiates a new audio engine.
  46903. *
  46904. * There should be only one per page as some browsers restrict the number
  46905. * of audio contexts you can create.
  46906. * @param hostElement defines the host element where to display the mute icon if necessary
  46907. */
  46908. constructor(hostElement?: Nullable<HTMLElement>);
  46909. /**
  46910. * Flags the audio engine in Locked state.
  46911. * This happens due to new browser policies preventing audio to autoplay.
  46912. */
  46913. lock(): void;
  46914. /**
  46915. * Unlocks the audio engine once a user action has been done on the dom.
  46916. * This is helpful to resume play once browser policies have been satisfied.
  46917. */
  46918. unlock(): void;
  46919. private _resumeAudioContext;
  46920. private _initializeAudioContext;
  46921. private _tryToRun;
  46922. private _triggerRunningState;
  46923. private _triggerSuspendedState;
  46924. private _displayMuteButton;
  46925. private _moveButtonToTopLeft;
  46926. private _onResize;
  46927. private _hideMuteButton;
  46928. /**
  46929. * Destroy and release the resources associated with the audio ccontext.
  46930. */
  46931. dispose(): void;
  46932. /**
  46933. * Gets the global volume sets on the master gain.
  46934. * @returns the global volume if set or -1 otherwise
  46935. */
  46936. getGlobalVolume(): number;
  46937. /**
  46938. * Sets the global volume of your experience (sets on the master gain).
  46939. * @param newVolume Defines the new global volume of the application
  46940. */
  46941. setGlobalVolume(newVolume: number): void;
  46942. /**
  46943. * Connect the audio engine to an audio analyser allowing some amazing
  46944. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46945. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46946. * @param analyser The analyser to connect to the engine
  46947. */
  46948. connectToAnalyser(analyser: Analyser): void;
  46949. }
  46950. }
  46951. declare module "babylonjs/Audio/soundTrack" {
  46952. import { Sound } from "babylonjs/Audio/sound";
  46953. import { Analyser } from "babylonjs/Audio/analyser";
  46954. import { Scene } from "babylonjs/scene";
  46955. /**
  46956. * Options allowed during the creation of a sound track.
  46957. */
  46958. export interface ISoundTrackOptions {
  46959. /**
  46960. * The volume the sound track should take during creation
  46961. */
  46962. volume?: number;
  46963. /**
  46964. * Define if the sound track is the main sound track of the scene
  46965. */
  46966. mainTrack?: boolean;
  46967. }
  46968. /**
  46969. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46970. * It will be also used in a future release to apply effects on a specific track.
  46971. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46972. */
  46973. export class SoundTrack {
  46974. /**
  46975. * The unique identifier of the sound track in the scene.
  46976. */
  46977. id: number;
  46978. /**
  46979. * The list of sounds included in the sound track.
  46980. */
  46981. soundCollection: Array<Sound>;
  46982. private _outputAudioNode;
  46983. private _scene;
  46984. private _connectedAnalyser;
  46985. private _options;
  46986. private _isInitialized;
  46987. /**
  46988. * Creates a new sound track.
  46989. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46990. * @param scene Define the scene the sound track belongs to
  46991. * @param options
  46992. */
  46993. constructor(scene: Scene, options?: ISoundTrackOptions);
  46994. private _initializeSoundTrackAudioGraph;
  46995. /**
  46996. * Release the sound track and its associated resources
  46997. */
  46998. dispose(): void;
  46999. /**
  47000. * Adds a sound to this sound track
  47001. * @param sound define the cound to add
  47002. * @ignoreNaming
  47003. */
  47004. addSound(sound: Sound): void;
  47005. /**
  47006. * Removes a sound to this sound track
  47007. * @param sound define the cound to remove
  47008. * @ignoreNaming
  47009. */
  47010. removeSound(sound: Sound): void;
  47011. /**
  47012. * Set a global volume for the full sound track.
  47013. * @param newVolume Define the new volume of the sound track
  47014. */
  47015. setVolume(newVolume: number): void;
  47016. /**
  47017. * Switch the panning model to HRTF:
  47018. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47019. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47020. */
  47021. switchPanningModelToHRTF(): void;
  47022. /**
  47023. * Switch the panning model to Equal Power:
  47024. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47025. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47026. */
  47027. switchPanningModelToEqualPower(): void;
  47028. /**
  47029. * Connect the sound track to an audio analyser allowing some amazing
  47030. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47031. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47032. * @param analyser The analyser to connect to the engine
  47033. */
  47034. connectToAnalyser(analyser: Analyser): void;
  47035. }
  47036. }
  47037. declare module "babylonjs/Audio/audioSceneComponent" {
  47038. import { Sound } from "babylonjs/Audio/sound";
  47039. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47040. import { Nullable } from "babylonjs/types";
  47041. import { Vector3 } from "babylonjs/Maths/math.vector";
  47042. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47043. import { Scene } from "babylonjs/scene";
  47044. import { AbstractScene } from "babylonjs/abstractScene";
  47045. import "babylonjs/Audio/audioEngine";
  47046. module "babylonjs/abstractScene" {
  47047. interface AbstractScene {
  47048. /**
  47049. * The list of sounds used in the scene.
  47050. */
  47051. sounds: Nullable<Array<Sound>>;
  47052. }
  47053. }
  47054. module "babylonjs/scene" {
  47055. interface Scene {
  47056. /**
  47057. * @hidden
  47058. * Backing field
  47059. */
  47060. _mainSoundTrack: SoundTrack;
  47061. /**
  47062. * The main sound track played by the scene.
  47063. * It cotains your primary collection of sounds.
  47064. */
  47065. mainSoundTrack: SoundTrack;
  47066. /**
  47067. * The list of sound tracks added to the scene
  47068. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47069. */
  47070. soundTracks: Nullable<Array<SoundTrack>>;
  47071. /**
  47072. * Gets a sound using a given name
  47073. * @param name defines the name to search for
  47074. * @return the found sound or null if not found at all.
  47075. */
  47076. getSoundByName(name: string): Nullable<Sound>;
  47077. /**
  47078. * Gets or sets if audio support is enabled
  47079. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47080. */
  47081. audioEnabled: boolean;
  47082. /**
  47083. * Gets or sets if audio will be output to headphones
  47084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47085. */
  47086. headphone: boolean;
  47087. /**
  47088. * Gets or sets custom audio listener position provider
  47089. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47090. */
  47091. audioListenerPositionProvider: Nullable<() => Vector3>;
  47092. /**
  47093. * Gets or sets a refresh rate when using 3D audio positioning
  47094. */
  47095. audioPositioningRefreshRate: number;
  47096. }
  47097. }
  47098. /**
  47099. * Defines the sound scene component responsible to manage any sounds
  47100. * in a given scene.
  47101. */
  47102. export class AudioSceneComponent implements ISceneSerializableComponent {
  47103. private static _CameraDirectionLH;
  47104. private static _CameraDirectionRH;
  47105. /**
  47106. * The component name helpfull to identify the component in the list of scene components.
  47107. */
  47108. readonly name: string;
  47109. /**
  47110. * The scene the component belongs to.
  47111. */
  47112. scene: Scene;
  47113. private _audioEnabled;
  47114. /**
  47115. * Gets whether audio is enabled or not.
  47116. * Please use related enable/disable method to switch state.
  47117. */
  47118. get audioEnabled(): boolean;
  47119. private _headphone;
  47120. /**
  47121. * Gets whether audio is outputing to headphone or not.
  47122. * Please use the according Switch methods to change output.
  47123. */
  47124. get headphone(): boolean;
  47125. /**
  47126. * Gets or sets a refresh rate when using 3D audio positioning
  47127. */
  47128. audioPositioningRefreshRate: number;
  47129. private _audioListenerPositionProvider;
  47130. /**
  47131. * Gets the current audio listener position provider
  47132. */
  47133. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47134. /**
  47135. * Sets a custom listener position for all sounds in the scene
  47136. * By default, this is the position of the first active camera
  47137. */
  47138. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47139. /**
  47140. * Creates a new instance of the component for the given scene
  47141. * @param scene Defines the scene to register the component in
  47142. */
  47143. constructor(scene: Scene);
  47144. /**
  47145. * Registers the component in a given scene
  47146. */
  47147. register(): void;
  47148. /**
  47149. * Rebuilds the elements related to this component in case of
  47150. * context lost for instance.
  47151. */
  47152. rebuild(): void;
  47153. /**
  47154. * Serializes the component data to the specified json object
  47155. * @param serializationObject The object to serialize to
  47156. */
  47157. serialize(serializationObject: any): void;
  47158. /**
  47159. * Adds all the elements from the container to the scene
  47160. * @param container the container holding the elements
  47161. */
  47162. addFromContainer(container: AbstractScene): void;
  47163. /**
  47164. * Removes all the elements in the container from the scene
  47165. * @param container contains the elements to remove
  47166. * @param dispose if the removed element should be disposed (default: false)
  47167. */
  47168. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47169. /**
  47170. * Disposes the component and the associated ressources.
  47171. */
  47172. dispose(): void;
  47173. /**
  47174. * Disables audio in the associated scene.
  47175. */
  47176. disableAudio(): void;
  47177. /**
  47178. * Enables audio in the associated scene.
  47179. */
  47180. enableAudio(): void;
  47181. /**
  47182. * Switch audio to headphone output.
  47183. */
  47184. switchAudioModeForHeadphones(): void;
  47185. /**
  47186. * Switch audio to normal speakers.
  47187. */
  47188. switchAudioModeForNormalSpeakers(): void;
  47189. private _cachedCameraDirection;
  47190. private _cachedCameraPosition;
  47191. private _lastCheck;
  47192. private _afterRender;
  47193. }
  47194. }
  47195. declare module "babylonjs/Audio/weightedsound" {
  47196. import { Sound } from "babylonjs/Audio/sound";
  47197. /**
  47198. * Wraps one or more Sound objects and selects one with random weight for playback.
  47199. */
  47200. export class WeightedSound {
  47201. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47202. loop: boolean;
  47203. private _coneInnerAngle;
  47204. private _coneOuterAngle;
  47205. private _volume;
  47206. /** A Sound is currently playing. */
  47207. isPlaying: boolean;
  47208. /** A Sound is currently paused. */
  47209. isPaused: boolean;
  47210. private _sounds;
  47211. private _weights;
  47212. private _currentIndex?;
  47213. /**
  47214. * Creates a new WeightedSound from the list of sounds given.
  47215. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47216. * @param sounds Array of Sounds that will be selected from.
  47217. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47218. */
  47219. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47220. /**
  47221. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47222. */
  47223. get directionalConeInnerAngle(): number;
  47224. /**
  47225. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47226. */
  47227. set directionalConeInnerAngle(value: number);
  47228. /**
  47229. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47230. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47231. */
  47232. get directionalConeOuterAngle(): number;
  47233. /**
  47234. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47235. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47236. */
  47237. set directionalConeOuterAngle(value: number);
  47238. /**
  47239. * Playback volume.
  47240. */
  47241. get volume(): number;
  47242. /**
  47243. * Playback volume.
  47244. */
  47245. set volume(value: number);
  47246. private _onended;
  47247. /**
  47248. * Suspend playback
  47249. */
  47250. pause(): void;
  47251. /**
  47252. * Stop playback
  47253. */
  47254. stop(): void;
  47255. /**
  47256. * Start playback.
  47257. * @param startOffset Position the clip head at a specific time in seconds.
  47258. */
  47259. play(startOffset?: number): void;
  47260. }
  47261. }
  47262. declare module "babylonjs/Audio/index" {
  47263. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47264. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47265. export * from "babylonjs/Audio/analyser";
  47266. export * from "babylonjs/Audio/audioEngine";
  47267. export * from "babylonjs/Audio/audioSceneComponent";
  47268. export * from "babylonjs/Audio/sound";
  47269. export * from "babylonjs/Audio/soundTrack";
  47270. export * from "babylonjs/Audio/weightedsound";
  47271. }
  47272. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47273. import { Behavior } from "babylonjs/Behaviors/behavior";
  47274. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47275. import { BackEase } from "babylonjs/Animations/easing";
  47276. /**
  47277. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47278. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47279. */
  47280. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47281. /**
  47282. * Gets the name of the behavior.
  47283. */
  47284. get name(): string;
  47285. /**
  47286. * The easing function used by animations
  47287. */
  47288. static EasingFunction: BackEase;
  47289. /**
  47290. * The easing mode used by animations
  47291. */
  47292. static EasingMode: number;
  47293. /**
  47294. * The duration of the animation, in milliseconds
  47295. */
  47296. transitionDuration: number;
  47297. /**
  47298. * Length of the distance animated by the transition when lower radius is reached
  47299. */
  47300. lowerRadiusTransitionRange: number;
  47301. /**
  47302. * Length of the distance animated by the transition when upper radius is reached
  47303. */
  47304. upperRadiusTransitionRange: number;
  47305. private _autoTransitionRange;
  47306. /**
  47307. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47308. */
  47309. get autoTransitionRange(): boolean;
  47310. /**
  47311. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47312. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47313. */
  47314. set autoTransitionRange(value: boolean);
  47315. private _attachedCamera;
  47316. private _onAfterCheckInputsObserver;
  47317. private _onMeshTargetChangedObserver;
  47318. /**
  47319. * Initializes the behavior.
  47320. */
  47321. init(): void;
  47322. /**
  47323. * Attaches the behavior to its arc rotate camera.
  47324. * @param camera Defines the camera to attach the behavior to
  47325. */
  47326. attach(camera: ArcRotateCamera): void;
  47327. /**
  47328. * Detaches the behavior from its current arc rotate camera.
  47329. */
  47330. detach(): void;
  47331. private _radiusIsAnimating;
  47332. private _radiusBounceTransition;
  47333. private _animatables;
  47334. private _cachedWheelPrecision;
  47335. /**
  47336. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47337. * @param radiusLimit The limit to check against.
  47338. * @return Bool to indicate if at limit.
  47339. */
  47340. private _isRadiusAtLimit;
  47341. /**
  47342. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47343. * @param radiusDelta The delta by which to animate to. Can be negative.
  47344. */
  47345. private _applyBoundRadiusAnimation;
  47346. /**
  47347. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47348. */
  47349. protected _clearAnimationLocks(): void;
  47350. /**
  47351. * Stops and removes all animations that have been applied to the camera
  47352. */
  47353. stopAllAnimations(): void;
  47354. }
  47355. }
  47356. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47357. import { Behavior } from "babylonjs/Behaviors/behavior";
  47358. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47359. import { ExponentialEase } from "babylonjs/Animations/easing";
  47360. import { Nullable } from "babylonjs/types";
  47361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47362. import { Vector3 } from "babylonjs/Maths/math.vector";
  47363. /**
  47364. * 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.
  47365. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47366. */
  47367. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47368. /**
  47369. * Gets the name of the behavior.
  47370. */
  47371. get name(): string;
  47372. private _mode;
  47373. private _radiusScale;
  47374. private _positionScale;
  47375. private _defaultElevation;
  47376. private _elevationReturnTime;
  47377. private _elevationReturnWaitTime;
  47378. private _zoomStopsAnimation;
  47379. private _framingTime;
  47380. /**
  47381. * The easing function used by animations
  47382. */
  47383. static EasingFunction: ExponentialEase;
  47384. /**
  47385. * The easing mode used by animations
  47386. */
  47387. static EasingMode: number;
  47388. /**
  47389. * Sets the current mode used by the behavior
  47390. */
  47391. set mode(mode: number);
  47392. /**
  47393. * Gets current mode used by the behavior.
  47394. */
  47395. get mode(): number;
  47396. /**
  47397. * Sets the scale applied to the radius (1 by default)
  47398. */
  47399. set radiusScale(radius: number);
  47400. /**
  47401. * Gets the scale applied to the radius
  47402. */
  47403. get radiusScale(): number;
  47404. /**
  47405. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47406. */
  47407. set positionScale(scale: number);
  47408. /**
  47409. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47410. */
  47411. get positionScale(): number;
  47412. /**
  47413. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47414. * behaviour is triggered, in radians.
  47415. */
  47416. set defaultElevation(elevation: number);
  47417. /**
  47418. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47419. * behaviour is triggered, in radians.
  47420. */
  47421. get defaultElevation(): number;
  47422. /**
  47423. * Sets the time (in milliseconds) taken to return to the default beta position.
  47424. * Negative value indicates camera should not return to default.
  47425. */
  47426. set elevationReturnTime(speed: number);
  47427. /**
  47428. * Gets the time (in milliseconds) taken to return to the default beta position.
  47429. * Negative value indicates camera should not return to default.
  47430. */
  47431. get elevationReturnTime(): number;
  47432. /**
  47433. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47434. */
  47435. set elevationReturnWaitTime(time: number);
  47436. /**
  47437. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47438. */
  47439. get elevationReturnWaitTime(): number;
  47440. /**
  47441. * Sets the flag that indicates if user zooming should stop animation.
  47442. */
  47443. set zoomStopsAnimation(flag: boolean);
  47444. /**
  47445. * Gets the flag that indicates if user zooming should stop animation.
  47446. */
  47447. get zoomStopsAnimation(): boolean;
  47448. /**
  47449. * Sets the transition time when framing the mesh, in milliseconds
  47450. */
  47451. set framingTime(time: number);
  47452. /**
  47453. * Gets the transition time when framing the mesh, in milliseconds
  47454. */
  47455. get framingTime(): number;
  47456. /**
  47457. * Define if the behavior should automatically change the configured
  47458. * camera limits and sensibilities.
  47459. */
  47460. autoCorrectCameraLimitsAndSensibility: boolean;
  47461. private _onPrePointerObservableObserver;
  47462. private _onAfterCheckInputsObserver;
  47463. private _onMeshTargetChangedObserver;
  47464. private _attachedCamera;
  47465. private _isPointerDown;
  47466. private _lastInteractionTime;
  47467. /**
  47468. * Initializes the behavior.
  47469. */
  47470. init(): void;
  47471. /**
  47472. * Attaches the behavior to its arc rotate camera.
  47473. * @param camera Defines the camera to attach the behavior to
  47474. */
  47475. attach(camera: ArcRotateCamera): void;
  47476. /**
  47477. * Detaches the behavior from its current arc rotate camera.
  47478. */
  47479. detach(): void;
  47480. private _animatables;
  47481. private _betaIsAnimating;
  47482. private _betaTransition;
  47483. private _radiusTransition;
  47484. private _vectorTransition;
  47485. /**
  47486. * Targets the given mesh and updates zoom level accordingly.
  47487. * @param mesh The mesh to target.
  47488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47490. */
  47491. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47492. /**
  47493. * Targets the given mesh with its children and updates zoom level accordingly.
  47494. * @param mesh The mesh to target.
  47495. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47496. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47497. */
  47498. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47499. /**
  47500. * Targets the given meshes with their children and updates zoom level accordingly.
  47501. * @param meshes The mesh to target.
  47502. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47503. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47504. */
  47505. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47506. /**
  47507. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47508. * @param minimumWorld Determines the smaller position of the bounding box extend
  47509. * @param maximumWorld Determines the bigger position of the bounding box extend
  47510. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47511. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47512. */
  47513. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47514. /**
  47515. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47516. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47517. * frustum width.
  47518. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47519. * to fully enclose the mesh in the viewing frustum.
  47520. */
  47521. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47522. /**
  47523. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47524. * is automatically returned to its default position (expected to be above ground plane).
  47525. */
  47526. private _maintainCameraAboveGround;
  47527. /**
  47528. * Returns the frustum slope based on the canvas ratio and camera FOV
  47529. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47530. */
  47531. private _getFrustumSlope;
  47532. /**
  47533. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47534. */
  47535. private _clearAnimationLocks;
  47536. /**
  47537. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47538. */
  47539. private _applyUserInteraction;
  47540. /**
  47541. * Stops and removes all animations that have been applied to the camera
  47542. */
  47543. stopAllAnimations(): void;
  47544. /**
  47545. * Gets a value indicating if the user is moving the camera
  47546. */
  47547. get isUserIsMoving(): boolean;
  47548. /**
  47549. * The camera can move all the way towards the mesh.
  47550. */
  47551. static IgnoreBoundsSizeMode: number;
  47552. /**
  47553. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47554. */
  47555. static FitFrustumSidesMode: number;
  47556. }
  47557. }
  47558. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47559. import { Nullable } from "babylonjs/types";
  47560. import { Camera } from "babylonjs/Cameras/camera";
  47561. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47562. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47563. /**
  47564. * Base class for Camera Pointer Inputs.
  47565. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47566. * for example usage.
  47567. */
  47568. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47569. /**
  47570. * Defines the camera the input is attached to.
  47571. */
  47572. abstract camera: Camera;
  47573. /**
  47574. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47575. */
  47576. protected _altKey: boolean;
  47577. protected _ctrlKey: boolean;
  47578. protected _metaKey: boolean;
  47579. protected _shiftKey: boolean;
  47580. /**
  47581. * Which mouse buttons were pressed at time of last mouse event.
  47582. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47583. */
  47584. protected _buttonsPressed: number;
  47585. /**
  47586. * Defines the buttons associated with the input to handle camera move.
  47587. */
  47588. buttons: number[];
  47589. /**
  47590. * Attach the input controls to a specific dom element to get the input from.
  47591. * @param element Defines the element the controls should be listened from
  47592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47593. */
  47594. attachControl(noPreventDefault?: boolean): void;
  47595. /**
  47596. * Detach the current controls from the specified dom element.
  47597. */
  47598. detachControl(): void;
  47599. /**
  47600. * Gets the class name of the current input.
  47601. * @returns the class name
  47602. */
  47603. getClassName(): string;
  47604. /**
  47605. * Get the friendly name associated with the input class.
  47606. * @returns the input friendly name
  47607. */
  47608. getSimpleName(): string;
  47609. /**
  47610. * Called on pointer POINTERDOUBLETAP event.
  47611. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47612. */
  47613. protected onDoubleTap(type: string): void;
  47614. /**
  47615. * Called on pointer POINTERMOVE event if only a single touch is active.
  47616. * Override this method to provide functionality.
  47617. */
  47618. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47619. /**
  47620. * Called on pointer POINTERMOVE event if multiple touches are active.
  47621. * Override this method to provide functionality.
  47622. */
  47623. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47624. /**
  47625. * Called on JS contextmenu event.
  47626. * Override this method to provide functionality.
  47627. */
  47628. protected onContextMenu(evt: PointerEvent): void;
  47629. /**
  47630. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47631. * press.
  47632. * Override this method to provide functionality.
  47633. */
  47634. protected onButtonDown(evt: PointerEvent): void;
  47635. /**
  47636. * Called each time a new POINTERUP event occurs. Ie, for each button
  47637. * release.
  47638. * Override this method to provide functionality.
  47639. */
  47640. protected onButtonUp(evt: PointerEvent): void;
  47641. /**
  47642. * Called when window becomes inactive.
  47643. * Override this method to provide functionality.
  47644. */
  47645. protected onLostFocus(): void;
  47646. private _pointerInput;
  47647. private _observer;
  47648. private _onLostFocus;
  47649. private pointA;
  47650. private pointB;
  47651. }
  47652. }
  47653. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47654. import { Nullable } from "babylonjs/types";
  47655. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47656. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47657. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47658. /**
  47659. * Manage the pointers inputs to control an arc rotate camera.
  47660. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47661. */
  47662. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47663. /**
  47664. * Defines the camera the input is attached to.
  47665. */
  47666. camera: ArcRotateCamera;
  47667. /**
  47668. * Gets the class name of the current input.
  47669. * @returns the class name
  47670. */
  47671. getClassName(): string;
  47672. /**
  47673. * Defines the buttons associated with the input to handle camera move.
  47674. */
  47675. buttons: number[];
  47676. /**
  47677. * Defines the pointer angular sensibility along the X axis or how fast is
  47678. * the camera rotating.
  47679. */
  47680. angularSensibilityX: number;
  47681. /**
  47682. * Defines the pointer angular sensibility along the Y axis or how fast is
  47683. * the camera rotating.
  47684. */
  47685. angularSensibilityY: number;
  47686. /**
  47687. * Defines the pointer pinch precision or how fast is the camera zooming.
  47688. */
  47689. pinchPrecision: number;
  47690. /**
  47691. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47692. * from 0.
  47693. * It defines the percentage of current camera.radius to use as delta when
  47694. * pinch zoom is used.
  47695. */
  47696. pinchDeltaPercentage: number;
  47697. /**
  47698. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47699. * that any object in the plane at the camera's target point will scale
  47700. * perfectly with finger motion.
  47701. * Overrides pinchDeltaPercentage and pinchPrecision.
  47702. */
  47703. useNaturalPinchZoom: boolean;
  47704. /**
  47705. * Defines the pointer panning sensibility or how fast is the camera moving.
  47706. */
  47707. panningSensibility: number;
  47708. /**
  47709. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47710. */
  47711. multiTouchPanning: boolean;
  47712. /**
  47713. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47714. * zoom (pinch) through multitouch.
  47715. */
  47716. multiTouchPanAndZoom: boolean;
  47717. /**
  47718. * Revers pinch action direction.
  47719. */
  47720. pinchInwards: boolean;
  47721. private _isPanClick;
  47722. private _twoFingerActivityCount;
  47723. private _isPinching;
  47724. /**
  47725. * Called on pointer POINTERMOVE event if only a single touch is active.
  47726. */
  47727. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47728. /**
  47729. * Called on pointer POINTERDOUBLETAP event.
  47730. */
  47731. protected onDoubleTap(type: string): void;
  47732. /**
  47733. * Called on pointer POINTERMOVE event if multiple touches are active.
  47734. */
  47735. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47736. /**
  47737. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47738. * press.
  47739. */
  47740. protected onButtonDown(evt: PointerEvent): void;
  47741. /**
  47742. * Called each time a new POINTERUP event occurs. Ie, for each button
  47743. * release.
  47744. */
  47745. protected onButtonUp(evt: PointerEvent): void;
  47746. /**
  47747. * Called when window becomes inactive.
  47748. */
  47749. protected onLostFocus(): void;
  47750. }
  47751. }
  47752. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47753. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47754. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47755. /**
  47756. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47757. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47758. */
  47759. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47760. /**
  47761. * Defines the camera the input is attached to.
  47762. */
  47763. camera: ArcRotateCamera;
  47764. /**
  47765. * Defines the list of key codes associated with the up action (increase alpha)
  47766. */
  47767. keysUp: number[];
  47768. /**
  47769. * Defines the list of key codes associated with the down action (decrease alpha)
  47770. */
  47771. keysDown: number[];
  47772. /**
  47773. * Defines the list of key codes associated with the left action (increase beta)
  47774. */
  47775. keysLeft: number[];
  47776. /**
  47777. * Defines the list of key codes associated with the right action (decrease beta)
  47778. */
  47779. keysRight: number[];
  47780. /**
  47781. * Defines the list of key codes associated with the reset action.
  47782. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47783. */
  47784. keysReset: number[];
  47785. /**
  47786. * Defines the panning sensibility of the inputs.
  47787. * (How fast is the camera panning)
  47788. */
  47789. panningSensibility: number;
  47790. /**
  47791. * Defines the zooming sensibility of the inputs.
  47792. * (How fast is the camera zooming)
  47793. */
  47794. zoomingSensibility: number;
  47795. /**
  47796. * Defines whether maintaining the alt key down switch the movement mode from
  47797. * orientation to zoom.
  47798. */
  47799. useAltToZoom: boolean;
  47800. /**
  47801. * Rotation speed of the camera
  47802. */
  47803. angularSpeed: number;
  47804. private _keys;
  47805. private _ctrlPressed;
  47806. private _altPressed;
  47807. private _onCanvasBlurObserver;
  47808. private _onKeyboardObserver;
  47809. private _engine;
  47810. private _scene;
  47811. /**
  47812. * Attach the input controls to a specific dom element to get the input from.
  47813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47814. */
  47815. attachControl(noPreventDefault?: boolean): void;
  47816. /**
  47817. * Detach the current controls from the specified dom element.
  47818. */
  47819. detachControl(): void;
  47820. /**
  47821. * Update the current camera state depending on the inputs that have been used this frame.
  47822. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47823. */
  47824. checkInputs(): void;
  47825. /**
  47826. * Gets the class name of the current intput.
  47827. * @returns the class name
  47828. */
  47829. getClassName(): string;
  47830. /**
  47831. * Get the friendly name associated with the input class.
  47832. * @returns the input friendly name
  47833. */
  47834. getSimpleName(): string;
  47835. }
  47836. }
  47837. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47838. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47839. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47840. /**
  47841. * Manage the mouse wheel inputs to control an arc rotate camera.
  47842. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47843. */
  47844. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47845. /**
  47846. * Defines the camera the input is attached to.
  47847. */
  47848. camera: ArcRotateCamera;
  47849. /**
  47850. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47851. */
  47852. wheelPrecision: number;
  47853. /**
  47854. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47855. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47856. */
  47857. wheelDeltaPercentage: number;
  47858. private _wheel;
  47859. private _observer;
  47860. private computeDeltaFromMouseWheelLegacyEvent;
  47861. /**
  47862. * Attach the input controls to a specific dom element to get the input from.
  47863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47864. */
  47865. attachControl(noPreventDefault?: boolean): void;
  47866. /**
  47867. * Detach the current controls from the specified dom element.
  47868. */
  47869. detachControl(): void;
  47870. /**
  47871. * Gets the class name of the current intput.
  47872. * @returns the class name
  47873. */
  47874. getClassName(): string;
  47875. /**
  47876. * Get the friendly name associated with the input class.
  47877. * @returns the input friendly name
  47878. */
  47879. getSimpleName(): string;
  47880. }
  47881. }
  47882. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47883. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47884. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47885. /**
  47886. * Default Inputs manager for the ArcRotateCamera.
  47887. * It groups all the default supported inputs for ease of use.
  47888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47889. */
  47890. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47891. /**
  47892. * Instantiates a new ArcRotateCameraInputsManager.
  47893. * @param camera Defines the camera the inputs belong to
  47894. */
  47895. constructor(camera: ArcRotateCamera);
  47896. /**
  47897. * Add mouse wheel input support to the input manager.
  47898. * @returns the current input manager
  47899. */
  47900. addMouseWheel(): ArcRotateCameraInputsManager;
  47901. /**
  47902. * Add pointers input support to the input manager.
  47903. * @returns the current input manager
  47904. */
  47905. addPointers(): ArcRotateCameraInputsManager;
  47906. /**
  47907. * Add keyboard input support to the input manager.
  47908. * @returns the current input manager
  47909. */
  47910. addKeyboard(): ArcRotateCameraInputsManager;
  47911. }
  47912. }
  47913. declare module "babylonjs/Cameras/arcRotateCamera" {
  47914. import { Observable } from "babylonjs/Misc/observable";
  47915. import { Nullable } from "babylonjs/types";
  47916. import { Scene } from "babylonjs/scene";
  47917. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47919. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47920. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47921. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47922. import { Camera } from "babylonjs/Cameras/camera";
  47923. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47924. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47925. import { Collider } from "babylonjs/Collisions/collider";
  47926. /**
  47927. * This represents an orbital type of camera.
  47928. *
  47929. * 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.
  47930. * 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.
  47931. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47932. */
  47933. export class ArcRotateCamera extends TargetCamera {
  47934. /**
  47935. * Defines the rotation angle of the camera along the longitudinal axis.
  47936. */
  47937. alpha: number;
  47938. /**
  47939. * Defines the rotation angle of the camera along the latitudinal axis.
  47940. */
  47941. beta: number;
  47942. /**
  47943. * Defines the radius of the camera from it s target point.
  47944. */
  47945. radius: number;
  47946. protected _target: Vector3;
  47947. protected _targetHost: Nullable<AbstractMesh>;
  47948. /**
  47949. * Defines the target point of the camera.
  47950. * The camera looks towards it form the radius distance.
  47951. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47952. */
  47953. get target(): Vector3;
  47954. set target(value: Vector3);
  47955. /**
  47956. * Define the current local position of the camera in the scene
  47957. */
  47958. get position(): Vector3;
  47959. set position(newPosition: Vector3);
  47960. protected _upToYMatrix: Matrix;
  47961. protected _YToUpMatrix: Matrix;
  47962. /**
  47963. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47964. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47965. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47966. */
  47967. set upVector(vec: Vector3);
  47968. get upVector(): Vector3;
  47969. /**
  47970. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47971. */
  47972. setMatUp(): void;
  47973. /**
  47974. * Current inertia value on the longitudinal axis.
  47975. * The bigger this number the longer it will take for the camera to stop.
  47976. */
  47977. inertialAlphaOffset: number;
  47978. /**
  47979. * Current inertia value on the latitudinal axis.
  47980. * The bigger this number the longer it will take for the camera to stop.
  47981. */
  47982. inertialBetaOffset: number;
  47983. /**
  47984. * Current inertia value on the radius axis.
  47985. * The bigger this number the longer it will take for the camera to stop.
  47986. */
  47987. inertialRadiusOffset: number;
  47988. /**
  47989. * Minimum allowed angle on the longitudinal axis.
  47990. * This can help limiting how the Camera is able to move in the scene.
  47991. */
  47992. lowerAlphaLimit: Nullable<number>;
  47993. /**
  47994. * Maximum allowed angle on the longitudinal axis.
  47995. * This can help limiting how the Camera is able to move in the scene.
  47996. */
  47997. upperAlphaLimit: Nullable<number>;
  47998. /**
  47999. * Minimum allowed angle on the latitudinal axis.
  48000. * This can help limiting how the Camera is able to move in the scene.
  48001. */
  48002. lowerBetaLimit: number;
  48003. /**
  48004. * Maximum allowed angle on the latitudinal axis.
  48005. * This can help limiting how the Camera is able to move in the scene.
  48006. */
  48007. upperBetaLimit: number;
  48008. /**
  48009. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48010. * This can help limiting how the Camera is able to move in the scene.
  48011. */
  48012. lowerRadiusLimit: Nullable<number>;
  48013. /**
  48014. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48015. * This can help limiting how the Camera is able to move in the scene.
  48016. */
  48017. upperRadiusLimit: Nullable<number>;
  48018. /**
  48019. * Defines the current inertia value used during panning of the camera along the X axis.
  48020. */
  48021. inertialPanningX: number;
  48022. /**
  48023. * Defines the current inertia value used during panning of the camera along the Y axis.
  48024. */
  48025. inertialPanningY: number;
  48026. /**
  48027. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48028. * Basically if your fingers moves away from more than this distance you will be considered
  48029. * in pinch mode.
  48030. */
  48031. pinchToPanMaxDistance: number;
  48032. /**
  48033. * Defines the maximum distance the camera can pan.
  48034. * This could help keeping the cammera always in your scene.
  48035. */
  48036. panningDistanceLimit: Nullable<number>;
  48037. /**
  48038. * Defines the target of the camera before paning.
  48039. */
  48040. panningOriginTarget: Vector3;
  48041. /**
  48042. * Defines the value of the inertia used during panning.
  48043. * 0 would mean stop inertia and one would mean no decelleration at all.
  48044. */
  48045. panningInertia: number;
  48046. /**
  48047. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48048. */
  48049. get angularSensibilityX(): number;
  48050. set angularSensibilityX(value: number);
  48051. /**
  48052. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48053. */
  48054. get angularSensibilityY(): number;
  48055. set angularSensibilityY(value: number);
  48056. /**
  48057. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48058. */
  48059. get pinchPrecision(): number;
  48060. set pinchPrecision(value: number);
  48061. /**
  48062. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48063. * It will be used instead of pinchDeltaPrecision if different from 0.
  48064. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48065. */
  48066. get pinchDeltaPercentage(): number;
  48067. set pinchDeltaPercentage(value: number);
  48068. /**
  48069. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48070. * and pinch delta percentage.
  48071. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48072. * that any object in the plane at the camera's target point will scale
  48073. * perfectly with finger motion.
  48074. */
  48075. get useNaturalPinchZoom(): boolean;
  48076. set useNaturalPinchZoom(value: boolean);
  48077. /**
  48078. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48079. */
  48080. get panningSensibility(): number;
  48081. set panningSensibility(value: number);
  48082. /**
  48083. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48084. */
  48085. get keysUp(): number[];
  48086. set keysUp(value: number[]);
  48087. /**
  48088. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48089. */
  48090. get keysDown(): number[];
  48091. set keysDown(value: number[]);
  48092. /**
  48093. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48094. */
  48095. get keysLeft(): number[];
  48096. set keysLeft(value: number[]);
  48097. /**
  48098. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48099. */
  48100. get keysRight(): number[];
  48101. set keysRight(value: number[]);
  48102. /**
  48103. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48104. */
  48105. get wheelPrecision(): number;
  48106. set wheelPrecision(value: number);
  48107. /**
  48108. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48109. * It will be used instead of pinchDeltaPrecision if different from 0.
  48110. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48111. */
  48112. get wheelDeltaPercentage(): number;
  48113. set wheelDeltaPercentage(value: number);
  48114. /**
  48115. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48116. */
  48117. zoomOnFactor: number;
  48118. /**
  48119. * Defines a screen offset for the camera position.
  48120. */
  48121. targetScreenOffset: Vector2;
  48122. /**
  48123. * Allows the camera to be completely reversed.
  48124. * If false the camera can not arrive upside down.
  48125. */
  48126. allowUpsideDown: boolean;
  48127. /**
  48128. * Define if double tap/click is used to restore the previously saved state of the camera.
  48129. */
  48130. useInputToRestoreState: boolean;
  48131. /** @hidden */
  48132. _viewMatrix: Matrix;
  48133. /** @hidden */
  48134. _useCtrlForPanning: boolean;
  48135. /** @hidden */
  48136. _panningMouseButton: number;
  48137. /**
  48138. * Defines the input associated to the camera.
  48139. */
  48140. inputs: ArcRotateCameraInputsManager;
  48141. /** @hidden */
  48142. _reset: () => void;
  48143. /**
  48144. * Defines the allowed panning axis.
  48145. */
  48146. panningAxis: Vector3;
  48147. protected _localDirection: Vector3;
  48148. protected _transformedDirection: Vector3;
  48149. private _bouncingBehavior;
  48150. /**
  48151. * Gets the bouncing behavior of the camera if it has been enabled.
  48152. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48153. */
  48154. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48155. /**
  48156. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48157. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48158. */
  48159. get useBouncingBehavior(): boolean;
  48160. set useBouncingBehavior(value: boolean);
  48161. private _framingBehavior;
  48162. /**
  48163. * Gets the framing behavior of the camera if it has been enabled.
  48164. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48165. */
  48166. get framingBehavior(): Nullable<FramingBehavior>;
  48167. /**
  48168. * Defines if the framing behavior of the camera is enabled on the camera.
  48169. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48170. */
  48171. get useFramingBehavior(): boolean;
  48172. set useFramingBehavior(value: boolean);
  48173. private _autoRotationBehavior;
  48174. /**
  48175. * Gets the auto rotation behavior of the camera if it has been enabled.
  48176. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48177. */
  48178. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48179. /**
  48180. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48181. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48182. */
  48183. get useAutoRotationBehavior(): boolean;
  48184. set useAutoRotationBehavior(value: boolean);
  48185. /**
  48186. * Observable triggered when the mesh target has been changed on the camera.
  48187. */
  48188. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48189. /**
  48190. * Event raised when the camera is colliding with a mesh.
  48191. */
  48192. onCollide: (collidedMesh: AbstractMesh) => void;
  48193. /**
  48194. * Defines whether the camera should check collision with the objects oh the scene.
  48195. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48196. */
  48197. checkCollisions: boolean;
  48198. /**
  48199. * Defines the collision radius of the camera.
  48200. * This simulates a sphere around the camera.
  48201. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48202. */
  48203. collisionRadius: Vector3;
  48204. protected _collider: Collider;
  48205. protected _previousPosition: Vector3;
  48206. protected _collisionVelocity: Vector3;
  48207. protected _newPosition: Vector3;
  48208. protected _previousAlpha: number;
  48209. protected _previousBeta: number;
  48210. protected _previousRadius: number;
  48211. protected _collisionTriggered: boolean;
  48212. protected _targetBoundingCenter: Nullable<Vector3>;
  48213. private _computationVector;
  48214. /**
  48215. * Instantiates a new ArcRotateCamera in a given scene
  48216. * @param name Defines the name of the camera
  48217. * @param alpha Defines the camera rotation along the logitudinal axis
  48218. * @param beta Defines the camera rotation along the latitudinal axis
  48219. * @param radius Defines the camera distance from its target
  48220. * @param target Defines the camera target
  48221. * @param scene Defines the scene the camera belongs to
  48222. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48223. */
  48224. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48225. /** @hidden */
  48226. _initCache(): void;
  48227. /** @hidden */
  48228. _updateCache(ignoreParentClass?: boolean): void;
  48229. protected _getTargetPosition(): Vector3;
  48230. private _storedAlpha;
  48231. private _storedBeta;
  48232. private _storedRadius;
  48233. private _storedTarget;
  48234. private _storedTargetScreenOffset;
  48235. /**
  48236. * Stores the current state of the camera (alpha, beta, radius and target)
  48237. * @returns the camera itself
  48238. */
  48239. storeState(): Camera;
  48240. /**
  48241. * @hidden
  48242. * Restored camera state. You must call storeState() first
  48243. */
  48244. _restoreStateValues(): boolean;
  48245. /** @hidden */
  48246. _isSynchronizedViewMatrix(): boolean;
  48247. /**
  48248. * Attach the input controls to a specific dom element to get the input from.
  48249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48250. */
  48251. attachControl(noPreventDefault?: boolean): void;
  48252. /**
  48253. * Attach the input controls to a specific dom element to get the input from.
  48254. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48256. */
  48257. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48258. /**
  48259. * Attached controls to the current camera.
  48260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48261. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48262. */
  48263. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48264. /**
  48265. * Attached controls to the current camera.
  48266. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48268. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48269. */
  48270. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48271. /**
  48272. * Attached controls to the current camera.
  48273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48274. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48275. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48276. */
  48277. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48278. /**
  48279. * Detach the current controls from the specified dom element.
  48280. */
  48281. detachControl(): void;
  48282. /** @hidden */
  48283. _checkInputs(): void;
  48284. protected _checkLimits(): void;
  48285. /**
  48286. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48287. */
  48288. rebuildAnglesAndRadius(): void;
  48289. /**
  48290. * Use a position to define the current camera related information like alpha, beta and radius
  48291. * @param position Defines the position to set the camera at
  48292. */
  48293. setPosition(position: Vector3): void;
  48294. /**
  48295. * Defines the target the camera should look at.
  48296. * This will automatically adapt alpha beta and radius to fit within the new target.
  48297. * @param target Defines the new target as a Vector or a mesh
  48298. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48299. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48300. */
  48301. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48302. /** @hidden */
  48303. _getViewMatrix(): Matrix;
  48304. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48305. /**
  48306. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48307. * @param meshes Defines the mesh to zoom on
  48308. * @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)
  48309. */
  48310. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48311. /**
  48312. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48313. * The target will be changed but the radius
  48314. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48315. * @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)
  48316. */
  48317. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48318. min: Vector3;
  48319. max: Vector3;
  48320. distance: number;
  48321. }, doNotUpdateMaxZ?: boolean): void;
  48322. /**
  48323. * @override
  48324. * Override Camera.createRigCamera
  48325. */
  48326. createRigCamera(name: string, cameraIndex: number): Camera;
  48327. /**
  48328. * @hidden
  48329. * @override
  48330. * Override Camera._updateRigCameras
  48331. */
  48332. _updateRigCameras(): void;
  48333. /**
  48334. * Destroy the camera and release the current resources hold by it.
  48335. */
  48336. dispose(): void;
  48337. /**
  48338. * Gets the current object class name.
  48339. * @return the class name
  48340. */
  48341. getClassName(): string;
  48342. }
  48343. }
  48344. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48345. import { Behavior } from "babylonjs/Behaviors/behavior";
  48346. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48347. /**
  48348. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48349. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48350. */
  48351. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48352. /**
  48353. * Gets the name of the behavior.
  48354. */
  48355. get name(): string;
  48356. private _zoomStopsAnimation;
  48357. private _idleRotationSpeed;
  48358. private _idleRotationWaitTime;
  48359. private _idleRotationSpinupTime;
  48360. /**
  48361. * Sets the flag that indicates if user zooming should stop animation.
  48362. */
  48363. set zoomStopsAnimation(flag: boolean);
  48364. /**
  48365. * Gets the flag that indicates if user zooming should stop animation.
  48366. */
  48367. get zoomStopsAnimation(): boolean;
  48368. /**
  48369. * Sets the default speed at which the camera rotates around the model.
  48370. */
  48371. set idleRotationSpeed(speed: number);
  48372. /**
  48373. * Gets the default speed at which the camera rotates around the model.
  48374. */
  48375. get idleRotationSpeed(): number;
  48376. /**
  48377. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48378. */
  48379. set idleRotationWaitTime(time: number);
  48380. /**
  48381. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48382. */
  48383. get idleRotationWaitTime(): number;
  48384. /**
  48385. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48386. */
  48387. set idleRotationSpinupTime(time: number);
  48388. /**
  48389. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48390. */
  48391. get idleRotationSpinupTime(): number;
  48392. /**
  48393. * Gets a value indicating if the camera is currently rotating because of this behavior
  48394. */
  48395. get rotationInProgress(): boolean;
  48396. private _onPrePointerObservableObserver;
  48397. private _onAfterCheckInputsObserver;
  48398. private _attachedCamera;
  48399. private _isPointerDown;
  48400. private _lastFrameTime;
  48401. private _lastInteractionTime;
  48402. private _cameraRotationSpeed;
  48403. /**
  48404. * Initializes the behavior.
  48405. */
  48406. init(): void;
  48407. /**
  48408. * Attaches the behavior to its arc rotate camera.
  48409. * @param camera Defines the camera to attach the behavior to
  48410. */
  48411. attach(camera: ArcRotateCamera): void;
  48412. /**
  48413. * Detaches the behavior from its current arc rotate camera.
  48414. */
  48415. detach(): void;
  48416. /**
  48417. * Returns true if user is scrolling.
  48418. * @return true if user is scrolling.
  48419. */
  48420. private _userIsZooming;
  48421. private _lastFrameRadius;
  48422. private _shouldAnimationStopForInteraction;
  48423. /**
  48424. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48425. */
  48426. private _applyUserInteraction;
  48427. private _userIsMoving;
  48428. }
  48429. }
  48430. declare module "babylonjs/Behaviors/Cameras/index" {
  48431. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48432. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48433. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48434. }
  48435. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48436. import { Mesh } from "babylonjs/Meshes/mesh";
  48437. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48438. import { Behavior } from "babylonjs/Behaviors/behavior";
  48439. /**
  48440. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48441. */
  48442. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48443. private ui;
  48444. /**
  48445. * The name of the behavior
  48446. */
  48447. name: string;
  48448. /**
  48449. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48450. */
  48451. distanceAwayFromFace: number;
  48452. /**
  48453. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48454. */
  48455. distanceAwayFromBottomOfFace: number;
  48456. private _faceVectors;
  48457. private _target;
  48458. private _scene;
  48459. private _onRenderObserver;
  48460. private _tmpMatrix;
  48461. private _tmpVector;
  48462. /**
  48463. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48464. * @param ui The transform node that should be attched to the mesh
  48465. */
  48466. constructor(ui: TransformNode);
  48467. /**
  48468. * Initializes the behavior
  48469. */
  48470. init(): void;
  48471. private _closestFace;
  48472. private _zeroVector;
  48473. private _lookAtTmpMatrix;
  48474. private _lookAtToRef;
  48475. /**
  48476. * Attaches the AttachToBoxBehavior to the passed in mesh
  48477. * @param target The mesh that the specified node will be attached to
  48478. */
  48479. attach(target: Mesh): void;
  48480. /**
  48481. * Detaches the behavior from the mesh
  48482. */
  48483. detach(): void;
  48484. }
  48485. }
  48486. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48487. import { Behavior } from "babylonjs/Behaviors/behavior";
  48488. import { Mesh } from "babylonjs/Meshes/mesh";
  48489. /**
  48490. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48491. */
  48492. export class FadeInOutBehavior implements Behavior<Mesh> {
  48493. /**
  48494. * Time in milliseconds to delay before fading in (Default: 0)
  48495. */
  48496. delay: number;
  48497. /**
  48498. * Time in milliseconds for the mesh to fade in (Default: 300)
  48499. */
  48500. fadeInTime: number;
  48501. private _millisecondsPerFrame;
  48502. private _hovered;
  48503. private _hoverValue;
  48504. private _ownerNode;
  48505. /**
  48506. * Instatiates the FadeInOutBehavior
  48507. */
  48508. constructor();
  48509. /**
  48510. * The name of the behavior
  48511. */
  48512. get name(): string;
  48513. /**
  48514. * Initializes the behavior
  48515. */
  48516. init(): void;
  48517. /**
  48518. * Attaches the fade behavior on the passed in mesh
  48519. * @param ownerNode The mesh that will be faded in/out once attached
  48520. */
  48521. attach(ownerNode: Mesh): void;
  48522. /**
  48523. * Detaches the behavior from the mesh
  48524. */
  48525. detach(): void;
  48526. /**
  48527. * Triggers the mesh to begin fading in or out
  48528. * @param value if the object should fade in or out (true to fade in)
  48529. */
  48530. fadeIn(value: boolean): void;
  48531. private _update;
  48532. private _setAllVisibility;
  48533. }
  48534. }
  48535. declare module "babylonjs/Misc/pivotTools" {
  48536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48537. /**
  48538. * Class containing a set of static utilities functions for managing Pivots
  48539. * @hidden
  48540. */
  48541. export class PivotTools {
  48542. private static _PivotCached;
  48543. private static _OldPivotPoint;
  48544. private static _PivotTranslation;
  48545. private static _PivotTmpVector;
  48546. private static _PivotPostMultiplyPivotMatrix;
  48547. /** @hidden */
  48548. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48549. /** @hidden */
  48550. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48551. }
  48552. }
  48553. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48554. import { Scene } from "babylonjs/scene";
  48555. import { Vector4 } from "babylonjs/Maths/math.vector";
  48556. import { Mesh } from "babylonjs/Meshes/mesh";
  48557. import { Nullable } from "babylonjs/types";
  48558. import { Plane } from "babylonjs/Maths/math.plane";
  48559. /**
  48560. * Class containing static functions to help procedurally build meshes
  48561. */
  48562. export class PlaneBuilder {
  48563. /**
  48564. * Creates a plane mesh
  48565. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48566. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48567. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48571. * @param name defines the name of the mesh
  48572. * @param options defines the options used to create the mesh
  48573. * @param scene defines the hosting scene
  48574. * @returns the plane mesh
  48575. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48576. */
  48577. static CreatePlane(name: string, options: {
  48578. size?: number;
  48579. width?: number;
  48580. height?: number;
  48581. sideOrientation?: number;
  48582. frontUVs?: Vector4;
  48583. backUVs?: Vector4;
  48584. updatable?: boolean;
  48585. sourcePlane?: Plane;
  48586. }, scene?: Nullable<Scene>): Mesh;
  48587. }
  48588. }
  48589. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48590. import { Behavior } from "babylonjs/Behaviors/behavior";
  48591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48592. import { Observable } from "babylonjs/Misc/observable";
  48593. import { Vector3 } from "babylonjs/Maths/math.vector";
  48594. import { Ray } from "babylonjs/Culling/ray";
  48595. import "babylonjs/Meshes/Builders/planeBuilder";
  48596. /**
  48597. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48598. */
  48599. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48600. private static _AnyMouseID;
  48601. /**
  48602. * Abstract mesh the behavior is set on
  48603. */
  48604. attachedNode: AbstractMesh;
  48605. private _dragPlane;
  48606. private _scene;
  48607. private _pointerObserver;
  48608. private _beforeRenderObserver;
  48609. private static _planeScene;
  48610. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48611. /**
  48612. * 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)
  48613. */
  48614. maxDragAngle: number;
  48615. /**
  48616. * @hidden
  48617. */
  48618. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48619. /**
  48620. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48621. */
  48622. currentDraggingPointerID: number;
  48623. /**
  48624. * The last position where the pointer hit the drag plane in world space
  48625. */
  48626. lastDragPosition: Vector3;
  48627. /**
  48628. * If the behavior is currently in a dragging state
  48629. */
  48630. dragging: boolean;
  48631. /**
  48632. * 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)
  48633. */
  48634. dragDeltaRatio: number;
  48635. /**
  48636. * If the drag plane orientation should be updated during the dragging (Default: true)
  48637. */
  48638. updateDragPlane: boolean;
  48639. private _debugMode;
  48640. private _moving;
  48641. /**
  48642. * Fires each time the attached mesh is dragged with the pointer
  48643. * * delta between last drag position and current drag position in world space
  48644. * * dragDistance along the drag axis
  48645. * * dragPlaneNormal normal of the current drag plane used during the drag
  48646. * * dragPlanePoint in world space where the drag intersects the drag plane
  48647. */
  48648. onDragObservable: Observable<{
  48649. delta: Vector3;
  48650. dragPlanePoint: Vector3;
  48651. dragPlaneNormal: Vector3;
  48652. dragDistance: number;
  48653. pointerId: number;
  48654. }>;
  48655. /**
  48656. * Fires each time a drag begins (eg. mouse down on mesh)
  48657. */
  48658. onDragStartObservable: Observable<{
  48659. dragPlanePoint: Vector3;
  48660. pointerId: number;
  48661. }>;
  48662. /**
  48663. * Fires each time a drag ends (eg. mouse release after drag)
  48664. */
  48665. onDragEndObservable: Observable<{
  48666. dragPlanePoint: Vector3;
  48667. pointerId: number;
  48668. }>;
  48669. /**
  48670. * If the attached mesh should be moved when dragged
  48671. */
  48672. moveAttached: boolean;
  48673. /**
  48674. * If the drag behavior will react to drag events (Default: true)
  48675. */
  48676. enabled: boolean;
  48677. /**
  48678. * If pointer events should start and release the drag (Default: true)
  48679. */
  48680. startAndReleaseDragOnPointerEvents: boolean;
  48681. /**
  48682. * If camera controls should be detached during the drag
  48683. */
  48684. detachCameraControls: boolean;
  48685. /**
  48686. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48687. */
  48688. useObjectOrientationForDragging: boolean;
  48689. private _options;
  48690. /**
  48691. * Gets the options used by the behavior
  48692. */
  48693. get options(): {
  48694. dragAxis?: Vector3;
  48695. dragPlaneNormal?: Vector3;
  48696. };
  48697. /**
  48698. * Sets the options used by the behavior
  48699. */
  48700. set options(options: {
  48701. dragAxis?: Vector3;
  48702. dragPlaneNormal?: Vector3;
  48703. });
  48704. /**
  48705. * Creates a pointer drag behavior that can be attached to a mesh
  48706. * @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)
  48707. */
  48708. constructor(options?: {
  48709. dragAxis?: Vector3;
  48710. dragPlaneNormal?: Vector3;
  48711. });
  48712. /**
  48713. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48714. */
  48715. validateDrag: (targetPosition: Vector3) => boolean;
  48716. /**
  48717. * The name of the behavior
  48718. */
  48719. get name(): string;
  48720. /**
  48721. * Initializes the behavior
  48722. */
  48723. init(): void;
  48724. private _tmpVector;
  48725. private _alternatePickedPoint;
  48726. private _worldDragAxis;
  48727. private _targetPosition;
  48728. private _attachedToElement;
  48729. /**
  48730. * Attaches the drag behavior the passed in mesh
  48731. * @param ownerNode The mesh that will be dragged around once attached
  48732. * @param predicate Predicate to use for pick filtering
  48733. */
  48734. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48735. /**
  48736. * Force relase the drag action by code.
  48737. */
  48738. releaseDrag(): void;
  48739. private _startDragRay;
  48740. private _lastPointerRay;
  48741. /**
  48742. * Simulates the start of a pointer drag event on the behavior
  48743. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48744. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48745. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48746. */
  48747. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48748. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48749. private _dragDelta;
  48750. protected _moveDrag(ray: Ray): void;
  48751. private _pickWithRayOnDragPlane;
  48752. private _pointA;
  48753. private _pointC;
  48754. private _localAxis;
  48755. private _lookAt;
  48756. private _updateDragPlanePosition;
  48757. /**
  48758. * Detaches the behavior from the mesh
  48759. */
  48760. detach(): void;
  48761. }
  48762. }
  48763. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48764. import { Mesh } from "babylonjs/Meshes/mesh";
  48765. import { Behavior } from "babylonjs/Behaviors/behavior";
  48766. /**
  48767. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48768. */
  48769. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48770. private _dragBehaviorA;
  48771. private _dragBehaviorB;
  48772. private _startDistance;
  48773. private _initialScale;
  48774. private _targetScale;
  48775. private _ownerNode;
  48776. private _sceneRenderObserver;
  48777. /**
  48778. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48779. */
  48780. constructor();
  48781. /**
  48782. * The name of the behavior
  48783. */
  48784. get name(): string;
  48785. /**
  48786. * Initializes the behavior
  48787. */
  48788. init(): void;
  48789. private _getCurrentDistance;
  48790. /**
  48791. * Attaches the scale behavior the passed in mesh
  48792. * @param ownerNode The mesh that will be scaled around once attached
  48793. */
  48794. attach(ownerNode: Mesh): void;
  48795. /**
  48796. * Detaches the behavior from the mesh
  48797. */
  48798. detach(): void;
  48799. }
  48800. }
  48801. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48802. import { Behavior } from "babylonjs/Behaviors/behavior";
  48803. import { Mesh } from "babylonjs/Meshes/mesh";
  48804. import { Observable } from "babylonjs/Misc/observable";
  48805. /**
  48806. * 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
  48807. */
  48808. export class SixDofDragBehavior implements Behavior<Mesh> {
  48809. private static _virtualScene;
  48810. private _ownerNode;
  48811. private _sceneRenderObserver;
  48812. private _scene;
  48813. private _targetPosition;
  48814. private _virtualOriginMesh;
  48815. private _virtualDragMesh;
  48816. private _pointerObserver;
  48817. private _moving;
  48818. private _startingOrientation;
  48819. private _attachedToElement;
  48820. /**
  48821. * 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)
  48822. */
  48823. private zDragFactor;
  48824. /**
  48825. * If the object should rotate to face the drag origin
  48826. */
  48827. rotateDraggedObject: boolean;
  48828. /**
  48829. * If the behavior is currently in a dragging state
  48830. */
  48831. dragging: boolean;
  48832. /**
  48833. * 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)
  48834. */
  48835. dragDeltaRatio: number;
  48836. /**
  48837. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48838. */
  48839. currentDraggingPointerID: number;
  48840. /**
  48841. * If camera controls should be detached during the drag
  48842. */
  48843. detachCameraControls: boolean;
  48844. /**
  48845. * Fires each time a drag starts
  48846. */
  48847. onDragStartObservable: Observable<{}>;
  48848. /**
  48849. * Fires each time a drag ends (eg. mouse release after drag)
  48850. */
  48851. onDragEndObservable: Observable<{}>;
  48852. /**
  48853. * 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
  48854. */
  48855. constructor();
  48856. /**
  48857. * The name of the behavior
  48858. */
  48859. get name(): string;
  48860. /**
  48861. * Initializes the behavior
  48862. */
  48863. init(): void;
  48864. /**
  48865. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48866. */
  48867. private get _pointerCamera();
  48868. /**
  48869. * Attaches the scale behavior the passed in mesh
  48870. * @param ownerNode The mesh that will be scaled around once attached
  48871. */
  48872. attach(ownerNode: Mesh): void;
  48873. /**
  48874. * Detaches the behavior from the mesh
  48875. */
  48876. detach(): void;
  48877. }
  48878. }
  48879. declare module "babylonjs/Behaviors/Meshes/index" {
  48880. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48881. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48882. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48883. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48884. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48885. }
  48886. declare module "babylonjs/Behaviors/index" {
  48887. export * from "babylonjs/Behaviors/behavior";
  48888. export * from "babylonjs/Behaviors/Cameras/index";
  48889. export * from "babylonjs/Behaviors/Meshes/index";
  48890. }
  48891. declare module "babylonjs/Bones/boneIKController" {
  48892. import { Bone } from "babylonjs/Bones/bone";
  48893. import { Vector3 } from "babylonjs/Maths/math.vector";
  48894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48895. import { Nullable } from "babylonjs/types";
  48896. /**
  48897. * Class used to apply inverse kinematics to bones
  48898. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48899. */
  48900. export class BoneIKController {
  48901. private static _tmpVecs;
  48902. private static _tmpQuat;
  48903. private static _tmpMats;
  48904. /**
  48905. * Gets or sets the target mesh
  48906. */
  48907. targetMesh: AbstractMesh;
  48908. /** Gets or sets the mesh used as pole */
  48909. poleTargetMesh: AbstractMesh;
  48910. /**
  48911. * Gets or sets the bone used as pole
  48912. */
  48913. poleTargetBone: Nullable<Bone>;
  48914. /**
  48915. * Gets or sets the target position
  48916. */
  48917. targetPosition: Vector3;
  48918. /**
  48919. * Gets or sets the pole target position
  48920. */
  48921. poleTargetPosition: Vector3;
  48922. /**
  48923. * Gets or sets the pole target local offset
  48924. */
  48925. poleTargetLocalOffset: Vector3;
  48926. /**
  48927. * Gets or sets the pole angle
  48928. */
  48929. poleAngle: number;
  48930. /**
  48931. * Gets or sets the mesh associated with the controller
  48932. */
  48933. mesh: AbstractMesh;
  48934. /**
  48935. * 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)
  48936. */
  48937. slerpAmount: number;
  48938. private _bone1Quat;
  48939. private _bone1Mat;
  48940. private _bone2Ang;
  48941. private _bone1;
  48942. private _bone2;
  48943. private _bone1Length;
  48944. private _bone2Length;
  48945. private _maxAngle;
  48946. private _maxReach;
  48947. private _rightHandedSystem;
  48948. private _bendAxis;
  48949. private _slerping;
  48950. private _adjustRoll;
  48951. /**
  48952. * Gets or sets maximum allowed angle
  48953. */
  48954. get maxAngle(): number;
  48955. set maxAngle(value: number);
  48956. /**
  48957. * Creates a new BoneIKController
  48958. * @param mesh defines the mesh to control
  48959. * @param bone defines the bone to control
  48960. * @param options defines options to set up the controller
  48961. */
  48962. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48963. targetMesh?: AbstractMesh;
  48964. poleTargetMesh?: AbstractMesh;
  48965. poleTargetBone?: Bone;
  48966. poleTargetLocalOffset?: Vector3;
  48967. poleAngle?: number;
  48968. bendAxis?: Vector3;
  48969. maxAngle?: number;
  48970. slerpAmount?: number;
  48971. });
  48972. private _setMaxAngle;
  48973. /**
  48974. * Force the controller to update the bones
  48975. */
  48976. update(): void;
  48977. }
  48978. }
  48979. declare module "babylonjs/Bones/boneLookController" {
  48980. import { Vector3 } from "babylonjs/Maths/math.vector";
  48981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48982. import { Bone } from "babylonjs/Bones/bone";
  48983. import { Space } from "babylonjs/Maths/math.axis";
  48984. /**
  48985. * Class used to make a bone look toward a point in space
  48986. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48987. */
  48988. export class BoneLookController {
  48989. private static _tmpVecs;
  48990. private static _tmpQuat;
  48991. private static _tmpMats;
  48992. /**
  48993. * The target Vector3 that the bone will look at
  48994. */
  48995. target: Vector3;
  48996. /**
  48997. * The mesh that the bone is attached to
  48998. */
  48999. mesh: AbstractMesh;
  49000. /**
  49001. * The bone that will be looking to the target
  49002. */
  49003. bone: Bone;
  49004. /**
  49005. * The up axis of the coordinate system that is used when the bone is rotated
  49006. */
  49007. upAxis: Vector3;
  49008. /**
  49009. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49010. */
  49011. upAxisSpace: Space;
  49012. /**
  49013. * Used to make an adjustment to the yaw of the bone
  49014. */
  49015. adjustYaw: number;
  49016. /**
  49017. * Used to make an adjustment to the pitch of the bone
  49018. */
  49019. adjustPitch: number;
  49020. /**
  49021. * Used to make an adjustment to the roll of the bone
  49022. */
  49023. adjustRoll: number;
  49024. /**
  49025. * 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)
  49026. */
  49027. slerpAmount: number;
  49028. private _minYaw;
  49029. private _maxYaw;
  49030. private _minPitch;
  49031. private _maxPitch;
  49032. private _minYawSin;
  49033. private _minYawCos;
  49034. private _maxYawSin;
  49035. private _maxYawCos;
  49036. private _midYawConstraint;
  49037. private _minPitchTan;
  49038. private _maxPitchTan;
  49039. private _boneQuat;
  49040. private _slerping;
  49041. private _transformYawPitch;
  49042. private _transformYawPitchInv;
  49043. private _firstFrameSkipped;
  49044. private _yawRange;
  49045. private _fowardAxis;
  49046. /**
  49047. * Gets or sets the minimum yaw angle that the bone can look to
  49048. */
  49049. get minYaw(): number;
  49050. set minYaw(value: number);
  49051. /**
  49052. * Gets or sets the maximum yaw angle that the bone can look to
  49053. */
  49054. get maxYaw(): number;
  49055. set maxYaw(value: number);
  49056. /**
  49057. * Gets or sets the minimum pitch angle that the bone can look to
  49058. */
  49059. get minPitch(): number;
  49060. set minPitch(value: number);
  49061. /**
  49062. * Gets or sets the maximum pitch angle that the bone can look to
  49063. */
  49064. get maxPitch(): number;
  49065. set maxPitch(value: number);
  49066. /**
  49067. * Create a BoneLookController
  49068. * @param mesh the mesh that the bone belongs to
  49069. * @param bone the bone that will be looking to the target
  49070. * @param target the target Vector3 to look at
  49071. * @param options optional settings:
  49072. * * maxYaw: the maximum angle the bone will yaw to
  49073. * * minYaw: the minimum angle the bone will yaw to
  49074. * * maxPitch: the maximum angle the bone will pitch to
  49075. * * minPitch: the minimum angle the bone will yaw to
  49076. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49077. * * upAxis: the up axis of the coordinate system
  49078. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49079. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49080. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49081. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49082. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49083. * * adjustRoll: used to make an adjustment to the roll of the bone
  49084. **/
  49085. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49086. maxYaw?: number;
  49087. minYaw?: number;
  49088. maxPitch?: number;
  49089. minPitch?: number;
  49090. slerpAmount?: number;
  49091. upAxis?: Vector3;
  49092. upAxisSpace?: Space;
  49093. yawAxis?: Vector3;
  49094. pitchAxis?: Vector3;
  49095. adjustYaw?: number;
  49096. adjustPitch?: number;
  49097. adjustRoll?: number;
  49098. });
  49099. /**
  49100. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49101. */
  49102. update(): void;
  49103. private _getAngleDiff;
  49104. private _getAngleBetween;
  49105. private _isAngleBetween;
  49106. }
  49107. }
  49108. declare module "babylonjs/Bones/index" {
  49109. export * from "babylonjs/Bones/bone";
  49110. export * from "babylonjs/Bones/boneIKController";
  49111. export * from "babylonjs/Bones/boneLookController";
  49112. export * from "babylonjs/Bones/skeleton";
  49113. }
  49114. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49115. import { Nullable } from "babylonjs/types";
  49116. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49118. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49119. /**
  49120. * Manage the gamepad inputs to control an arc rotate camera.
  49121. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49122. */
  49123. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49124. /**
  49125. * Defines the camera the input is attached to.
  49126. */
  49127. camera: ArcRotateCamera;
  49128. /**
  49129. * Defines the gamepad the input is gathering event from.
  49130. */
  49131. gamepad: Nullable<Gamepad>;
  49132. /**
  49133. * Defines the gamepad rotation sensiblity.
  49134. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49135. */
  49136. gamepadRotationSensibility: number;
  49137. /**
  49138. * Defines the gamepad move sensiblity.
  49139. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49140. */
  49141. gamepadMoveSensibility: number;
  49142. private _yAxisScale;
  49143. /**
  49144. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49145. */
  49146. get invertYAxis(): boolean;
  49147. set invertYAxis(value: boolean);
  49148. private _onGamepadConnectedObserver;
  49149. private _onGamepadDisconnectedObserver;
  49150. /**
  49151. * Attach the input controls to a specific dom element to get the input from.
  49152. */
  49153. attachControl(): void;
  49154. /**
  49155. * Detach the current controls from the specified dom element.
  49156. */
  49157. detachControl(): 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. * Gets the class name of the current intput.
  49165. * @returns the class name
  49166. */
  49167. getClassName(): string;
  49168. /**
  49169. * Get the friendly name associated with the input class.
  49170. * @returns the input friendly name
  49171. */
  49172. getSimpleName(): string;
  49173. }
  49174. }
  49175. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49176. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49177. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49178. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49179. interface ArcRotateCameraInputsManager {
  49180. /**
  49181. * Add orientation input support to the input manager.
  49182. * @returns the current input manager
  49183. */
  49184. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49185. }
  49186. }
  49187. /**
  49188. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49189. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49190. */
  49191. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49192. /**
  49193. * Defines the camera the input is attached to.
  49194. */
  49195. camera: ArcRotateCamera;
  49196. /**
  49197. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49198. */
  49199. alphaCorrection: number;
  49200. /**
  49201. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49202. */
  49203. gammaCorrection: number;
  49204. private _alpha;
  49205. private _gamma;
  49206. private _dirty;
  49207. private _deviceOrientationHandler;
  49208. /**
  49209. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49210. */
  49211. constructor();
  49212. /**
  49213. * Attach the input controls to a specific dom element to get the input from.
  49214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49215. */
  49216. attachControl(noPreventDefault?: boolean): void;
  49217. /** @hidden */
  49218. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49219. /**
  49220. * Update the current camera state depending on the inputs that have been used this frame.
  49221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49222. */
  49223. checkInputs(): void;
  49224. /**
  49225. * Detach the current controls from the specified dom element.
  49226. */
  49227. detachControl(): void;
  49228. /**
  49229. * Gets the class name of the current intput.
  49230. * @returns the class name
  49231. */
  49232. getClassName(): string;
  49233. /**
  49234. * Get the friendly name associated with the input class.
  49235. * @returns the input friendly name
  49236. */
  49237. getSimpleName(): string;
  49238. }
  49239. }
  49240. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49241. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49242. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49243. /**
  49244. * Listen to mouse events to control the camera.
  49245. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49246. */
  49247. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49248. /**
  49249. * Defines the camera the input is attached to.
  49250. */
  49251. camera: FlyCamera;
  49252. /**
  49253. * Defines if touch is enabled. (Default is true.)
  49254. */
  49255. touchEnabled: boolean;
  49256. /**
  49257. * Defines the buttons associated with the input to handle camera rotation.
  49258. */
  49259. buttons: number[];
  49260. /**
  49261. * Assign buttons for Yaw control.
  49262. */
  49263. buttonsYaw: number[];
  49264. /**
  49265. * Assign buttons for Pitch control.
  49266. */
  49267. buttonsPitch: number[];
  49268. /**
  49269. * Assign buttons for Roll control.
  49270. */
  49271. buttonsRoll: number[];
  49272. /**
  49273. * Detect if any button is being pressed while mouse is moved.
  49274. * -1 = Mouse locked.
  49275. * 0 = Left button.
  49276. * 1 = Middle Button.
  49277. * 2 = Right Button.
  49278. */
  49279. activeButton: number;
  49280. /**
  49281. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49282. * Higher values reduce its sensitivity.
  49283. */
  49284. angularSensibility: number;
  49285. private _observer;
  49286. private _rollObserver;
  49287. private previousPosition;
  49288. private noPreventDefault;
  49289. private element;
  49290. /**
  49291. * Listen to mouse events to control the camera.
  49292. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49293. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49294. */
  49295. constructor(touchEnabled?: boolean);
  49296. /**
  49297. * Attach the mouse control to the HTML DOM element.
  49298. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49299. */
  49300. attachControl(noPreventDefault?: boolean): void;
  49301. /**
  49302. * Detach the current controls from the specified dom element.
  49303. */
  49304. detachControl(): void;
  49305. /**
  49306. * Gets the class name of the current input.
  49307. * @returns the class name.
  49308. */
  49309. getClassName(): string;
  49310. /**
  49311. * Get the friendly name associated with the input class.
  49312. * @returns the input's friendly name.
  49313. */
  49314. getSimpleName(): string;
  49315. private _pointerInput;
  49316. private _onMouseMove;
  49317. /**
  49318. * Rotate camera by mouse offset.
  49319. */
  49320. private rotateCamera;
  49321. }
  49322. }
  49323. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49324. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49325. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49326. /**
  49327. * Default Inputs manager for the FlyCamera.
  49328. * It groups all the default supported inputs for ease of use.
  49329. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49330. */
  49331. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49332. /**
  49333. * Instantiates a new FlyCameraInputsManager.
  49334. * @param camera Defines the camera the inputs belong to.
  49335. */
  49336. constructor(camera: FlyCamera);
  49337. /**
  49338. * Add keyboard input support to the input manager.
  49339. * @returns the new FlyCameraKeyboardMoveInput().
  49340. */
  49341. addKeyboard(): FlyCameraInputsManager;
  49342. /**
  49343. * Add mouse input support to the input manager.
  49344. * @param touchEnabled Enable touch screen support.
  49345. * @returns the new FlyCameraMouseInput().
  49346. */
  49347. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49348. }
  49349. }
  49350. declare module "babylonjs/Cameras/flyCamera" {
  49351. import { Scene } from "babylonjs/scene";
  49352. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49354. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49355. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49356. /**
  49357. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49358. * such as in a 3D Space Shooter or a Flight Simulator.
  49359. */
  49360. export class FlyCamera extends TargetCamera {
  49361. /**
  49362. * Define the collision ellipsoid of the camera.
  49363. * This is helpful for simulating a camera body, like a player's body.
  49364. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49365. */
  49366. ellipsoid: Vector3;
  49367. /**
  49368. * Define an offset for the position of the ellipsoid around the camera.
  49369. * This can be helpful if the camera is attached away from the player's body center,
  49370. * such as at its head.
  49371. */
  49372. ellipsoidOffset: Vector3;
  49373. /**
  49374. * Enable or disable collisions of the camera with the rest of the scene objects.
  49375. */
  49376. checkCollisions: boolean;
  49377. /**
  49378. * Enable or disable gravity on the camera.
  49379. */
  49380. applyGravity: boolean;
  49381. /**
  49382. * Define the current direction the camera is moving to.
  49383. */
  49384. cameraDirection: Vector3;
  49385. /**
  49386. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49387. * This overrides and empties cameraRotation.
  49388. */
  49389. rotationQuaternion: Quaternion;
  49390. /**
  49391. * Track Roll to maintain the wanted Rolling when looking around.
  49392. */
  49393. _trackRoll: number;
  49394. /**
  49395. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49396. */
  49397. rollCorrect: number;
  49398. /**
  49399. * Mimic a banked turn, Rolling the camera when Yawing.
  49400. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49401. */
  49402. bankedTurn: boolean;
  49403. /**
  49404. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49405. */
  49406. bankedTurnLimit: number;
  49407. /**
  49408. * Value of 0 disables the banked Roll.
  49409. * Value of 1 is equal to the Yaw angle in radians.
  49410. */
  49411. bankedTurnMultiplier: number;
  49412. /**
  49413. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49414. */
  49415. inputs: FlyCameraInputsManager;
  49416. /**
  49417. * Gets the input sensibility for mouse input.
  49418. * Higher values reduce sensitivity.
  49419. */
  49420. get angularSensibility(): number;
  49421. /**
  49422. * Sets the input sensibility for a mouse input.
  49423. * Higher values reduce sensitivity.
  49424. */
  49425. set angularSensibility(value: number);
  49426. /**
  49427. * Get the keys for camera movement forward.
  49428. */
  49429. get keysForward(): number[];
  49430. /**
  49431. * Set the keys for camera movement forward.
  49432. */
  49433. set keysForward(value: number[]);
  49434. /**
  49435. * Get the keys for camera movement backward.
  49436. */
  49437. get keysBackward(): number[];
  49438. set keysBackward(value: number[]);
  49439. /**
  49440. * Get the keys for camera movement up.
  49441. */
  49442. get keysUp(): number[];
  49443. /**
  49444. * Set the keys for camera movement up.
  49445. */
  49446. set keysUp(value: number[]);
  49447. /**
  49448. * Get the keys for camera movement down.
  49449. */
  49450. get keysDown(): number[];
  49451. /**
  49452. * Set the keys for camera movement down.
  49453. */
  49454. set keysDown(value: number[]);
  49455. /**
  49456. * Get the keys for camera movement left.
  49457. */
  49458. get keysLeft(): number[];
  49459. /**
  49460. * Set the keys for camera movement left.
  49461. */
  49462. set keysLeft(value: number[]);
  49463. /**
  49464. * Set the keys for camera movement right.
  49465. */
  49466. get keysRight(): number[];
  49467. /**
  49468. * Set the keys for camera movement right.
  49469. */
  49470. set keysRight(value: number[]);
  49471. /**
  49472. * Event raised when the camera collides with a mesh in the scene.
  49473. */
  49474. onCollide: (collidedMesh: AbstractMesh) => void;
  49475. private _collider;
  49476. private _needMoveForGravity;
  49477. private _oldPosition;
  49478. private _diffPosition;
  49479. private _newPosition;
  49480. /** @hidden */
  49481. _localDirection: Vector3;
  49482. /** @hidden */
  49483. _transformedDirection: Vector3;
  49484. /**
  49485. * Instantiates a FlyCamera.
  49486. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49487. * such as in a 3D Space Shooter or a Flight Simulator.
  49488. * @param name Define the name of the camera in the scene.
  49489. * @param position Define the starting position of the camera in the scene.
  49490. * @param scene Define the scene the camera belongs to.
  49491. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49492. */
  49493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49494. /**
  49495. * Attach the input controls to a specific dom element to get the input from.
  49496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49497. */
  49498. attachControl(noPreventDefault?: boolean): void;
  49499. /**
  49500. * Detach a control from the HTML DOM element.
  49501. * The camera will stop reacting to that input.
  49502. */
  49503. detachControl(): void;
  49504. private _collisionMask;
  49505. /**
  49506. * Get the mask that the camera ignores in collision events.
  49507. */
  49508. get collisionMask(): number;
  49509. /**
  49510. * Set the mask that the camera ignores in collision events.
  49511. */
  49512. set collisionMask(mask: number);
  49513. /** @hidden */
  49514. _collideWithWorld(displacement: Vector3): void;
  49515. /** @hidden */
  49516. private _onCollisionPositionChange;
  49517. /** @hidden */
  49518. _checkInputs(): void;
  49519. /** @hidden */
  49520. _decideIfNeedsToMove(): boolean;
  49521. /** @hidden */
  49522. _updatePosition(): void;
  49523. /**
  49524. * Restore the Roll to its target value at the rate specified.
  49525. * @param rate - Higher means slower restoring.
  49526. * @hidden
  49527. */
  49528. restoreRoll(rate: number): void;
  49529. /**
  49530. * Destroy the camera and release the current resources held by it.
  49531. */
  49532. dispose(): void;
  49533. /**
  49534. * Get the current object class name.
  49535. * @returns the class name.
  49536. */
  49537. getClassName(): string;
  49538. }
  49539. }
  49540. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49541. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49542. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49543. /**
  49544. * Listen to keyboard events to control the camera.
  49545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49546. */
  49547. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49548. /**
  49549. * Defines the camera the input is attached to.
  49550. */
  49551. camera: FlyCamera;
  49552. /**
  49553. * The list of keyboard keys used to control the forward move of the camera.
  49554. */
  49555. keysForward: number[];
  49556. /**
  49557. * The list of keyboard keys used to control the backward move of the camera.
  49558. */
  49559. keysBackward: number[];
  49560. /**
  49561. * The list of keyboard keys used to control the forward move of the camera.
  49562. */
  49563. keysUp: number[];
  49564. /**
  49565. * The list of keyboard keys used to control the backward move of the camera.
  49566. */
  49567. keysDown: number[];
  49568. /**
  49569. * The list of keyboard keys used to control the right strafe move of the camera.
  49570. */
  49571. keysRight: number[];
  49572. /**
  49573. * The list of keyboard keys used to control the left strafe move of the camera.
  49574. */
  49575. keysLeft: number[];
  49576. private _keys;
  49577. private _onCanvasBlurObserver;
  49578. private _onKeyboardObserver;
  49579. private _engine;
  49580. private _scene;
  49581. /**
  49582. * Attach the input controls to a specific dom element to get the input from.
  49583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49584. */
  49585. attachControl(noPreventDefault?: boolean): void;
  49586. /**
  49587. * Detach the current controls from the specified dom element.
  49588. */
  49589. detachControl(): void;
  49590. /**
  49591. * Gets the class name of the current intput.
  49592. * @returns the class name
  49593. */
  49594. getClassName(): string;
  49595. /** @hidden */
  49596. _onLostFocus(e: FocusEvent): void;
  49597. /**
  49598. * Get the friendly name associated with the input class.
  49599. * @returns the input friendly name
  49600. */
  49601. getSimpleName(): string;
  49602. /**
  49603. * Update the current camera state depending on the inputs that have been used this frame.
  49604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49605. */
  49606. checkInputs(): void;
  49607. }
  49608. }
  49609. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49610. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49611. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49612. /**
  49613. * Manage the mouse wheel inputs to control a follow camera.
  49614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49615. */
  49616. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49617. /**
  49618. * Defines the camera the input is attached to.
  49619. */
  49620. camera: FollowCamera;
  49621. /**
  49622. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49623. */
  49624. axisControlRadius: boolean;
  49625. /**
  49626. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49627. */
  49628. axisControlHeight: boolean;
  49629. /**
  49630. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49631. */
  49632. axisControlRotation: boolean;
  49633. /**
  49634. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49635. * relation to mouseWheel events.
  49636. */
  49637. wheelPrecision: number;
  49638. /**
  49639. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49640. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49641. */
  49642. wheelDeltaPercentage: number;
  49643. private _wheel;
  49644. private _observer;
  49645. /**
  49646. * Attach the input controls to a specific dom element to get the input from.
  49647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49648. */
  49649. attachControl(noPreventDefault?: boolean): void;
  49650. /**
  49651. * Detach the current controls from the specified dom element.
  49652. */
  49653. detachControl(): void;
  49654. /**
  49655. * Gets the class name of the current intput.
  49656. * @returns the class name
  49657. */
  49658. getClassName(): string;
  49659. /**
  49660. * Get the friendly name associated with the input class.
  49661. * @returns the input friendly name
  49662. */
  49663. getSimpleName(): string;
  49664. }
  49665. }
  49666. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49667. import { Nullable } from "babylonjs/types";
  49668. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49669. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49670. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49671. /**
  49672. * Manage the pointers inputs to control an follow camera.
  49673. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49674. */
  49675. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49676. /**
  49677. * Defines the camera the input is attached to.
  49678. */
  49679. camera: FollowCamera;
  49680. /**
  49681. * Gets the class name of the current input.
  49682. * @returns the class name
  49683. */
  49684. getClassName(): string;
  49685. /**
  49686. * Defines the pointer angular sensibility along the X axis or how fast is
  49687. * the camera rotating.
  49688. * A negative number will reverse the axis direction.
  49689. */
  49690. angularSensibilityX: number;
  49691. /**
  49692. * Defines the pointer angular sensibility along the Y axis or how fast is
  49693. * the camera rotating.
  49694. * A negative number will reverse the axis direction.
  49695. */
  49696. angularSensibilityY: number;
  49697. /**
  49698. * Defines the pointer pinch precision or how fast is the camera zooming.
  49699. * A negative number will reverse the axis direction.
  49700. */
  49701. pinchPrecision: number;
  49702. /**
  49703. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49704. * from 0.
  49705. * It defines the percentage of current camera.radius to use as delta when
  49706. * pinch zoom is used.
  49707. */
  49708. pinchDeltaPercentage: number;
  49709. /**
  49710. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49711. */
  49712. axisXControlRadius: boolean;
  49713. /**
  49714. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49715. */
  49716. axisXControlHeight: boolean;
  49717. /**
  49718. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49719. */
  49720. axisXControlRotation: boolean;
  49721. /**
  49722. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49723. */
  49724. axisYControlRadius: boolean;
  49725. /**
  49726. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49727. */
  49728. axisYControlHeight: boolean;
  49729. /**
  49730. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49731. */
  49732. axisYControlRotation: boolean;
  49733. /**
  49734. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49735. */
  49736. axisPinchControlRadius: boolean;
  49737. /**
  49738. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49739. */
  49740. axisPinchControlHeight: boolean;
  49741. /**
  49742. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49743. */
  49744. axisPinchControlRotation: boolean;
  49745. /**
  49746. * Log error messages if basic misconfiguration has occurred.
  49747. */
  49748. warningEnable: boolean;
  49749. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49750. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49751. private _warningCounter;
  49752. private _warning;
  49753. }
  49754. }
  49755. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49756. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49757. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49758. /**
  49759. * Default Inputs manager for the FollowCamera.
  49760. * It groups all the default supported inputs for ease of use.
  49761. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49762. */
  49763. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49764. /**
  49765. * Instantiates a new FollowCameraInputsManager.
  49766. * @param camera Defines the camera the inputs belong to
  49767. */
  49768. constructor(camera: FollowCamera);
  49769. /**
  49770. * Add keyboard input support to the input manager.
  49771. * @returns the current input manager
  49772. */
  49773. addKeyboard(): FollowCameraInputsManager;
  49774. /**
  49775. * Add mouse wheel input support to the input manager.
  49776. * @returns the current input manager
  49777. */
  49778. addMouseWheel(): FollowCameraInputsManager;
  49779. /**
  49780. * Add pointers input support to the input manager.
  49781. * @returns the current input manager
  49782. */
  49783. addPointers(): FollowCameraInputsManager;
  49784. /**
  49785. * Add orientation input support to the input manager.
  49786. * @returns the current input manager
  49787. */
  49788. addVRDeviceOrientation(): FollowCameraInputsManager;
  49789. }
  49790. }
  49791. declare module "babylonjs/Cameras/followCamera" {
  49792. import { Nullable } from "babylonjs/types";
  49793. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49794. import { Scene } from "babylonjs/scene";
  49795. import { Vector3 } from "babylonjs/Maths/math.vector";
  49796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49797. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49798. /**
  49799. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49800. * an arc rotate version arcFollowCamera are available.
  49801. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49802. */
  49803. export class FollowCamera extends TargetCamera {
  49804. /**
  49805. * Distance the follow camera should follow an object at
  49806. */
  49807. radius: number;
  49808. /**
  49809. * Minimum allowed distance of the camera to the axis of rotation
  49810. * (The camera can not get closer).
  49811. * This can help limiting how the Camera is able to move in the scene.
  49812. */
  49813. lowerRadiusLimit: Nullable<number>;
  49814. /**
  49815. * Maximum allowed distance of the camera to the axis of rotation
  49816. * (The camera can not get further).
  49817. * This can help limiting how the Camera is able to move in the scene.
  49818. */
  49819. upperRadiusLimit: Nullable<number>;
  49820. /**
  49821. * Define a rotation offset between the camera and the object it follows
  49822. */
  49823. rotationOffset: number;
  49824. /**
  49825. * Minimum allowed angle to camera position relative to target object.
  49826. * This can help limiting how the Camera is able to move in the scene.
  49827. */
  49828. lowerRotationOffsetLimit: Nullable<number>;
  49829. /**
  49830. * Maximum allowed angle to camera position relative to target object.
  49831. * This can help limiting how the Camera is able to move in the scene.
  49832. */
  49833. upperRotationOffsetLimit: Nullable<number>;
  49834. /**
  49835. * Define a height offset between the camera and the object it follows.
  49836. * It can help following an object from the top (like a car chaing a plane)
  49837. */
  49838. heightOffset: number;
  49839. /**
  49840. * Minimum allowed height of camera position relative to target object.
  49841. * This can help limiting how the Camera is able to move in the scene.
  49842. */
  49843. lowerHeightOffsetLimit: Nullable<number>;
  49844. /**
  49845. * Maximum allowed height of camera position relative to target object.
  49846. * This can help limiting how the Camera is able to move in the scene.
  49847. */
  49848. upperHeightOffsetLimit: Nullable<number>;
  49849. /**
  49850. * Define how fast the camera can accelerate to follow it s target.
  49851. */
  49852. cameraAcceleration: number;
  49853. /**
  49854. * Define the speed limit of the camera following an object.
  49855. */
  49856. maxCameraSpeed: number;
  49857. /**
  49858. * Define the target of the camera.
  49859. */
  49860. lockedTarget: Nullable<AbstractMesh>;
  49861. /**
  49862. * Defines the input associated with the camera.
  49863. */
  49864. inputs: FollowCameraInputsManager;
  49865. /**
  49866. * Instantiates the follow camera.
  49867. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49868. * @param name Define the name of the camera in the scene
  49869. * @param position Define the position of the camera
  49870. * @param scene Define the scene the camera belong to
  49871. * @param lockedTarget Define the target of the camera
  49872. */
  49873. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49874. private _follow;
  49875. /**
  49876. * Attach the input controls to a specific dom element to get the input from.
  49877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49878. */
  49879. attachControl(noPreventDefault?: boolean): void;
  49880. /**
  49881. * Detach the current controls from the specified dom element.
  49882. */
  49883. detachControl(): void;
  49884. /** @hidden */
  49885. _checkInputs(): void;
  49886. private _checkLimits;
  49887. /**
  49888. * Gets the camera class name.
  49889. * @returns the class name
  49890. */
  49891. getClassName(): string;
  49892. }
  49893. /**
  49894. * Arc Rotate version of the follow camera.
  49895. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49896. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49897. */
  49898. export class ArcFollowCamera extends TargetCamera {
  49899. /** The longitudinal angle of the camera */
  49900. alpha: number;
  49901. /** The latitudinal angle of the camera */
  49902. beta: number;
  49903. /** The radius of the camera from its target */
  49904. radius: number;
  49905. private _cartesianCoordinates;
  49906. /** Define the camera target (the mesh it should follow) */
  49907. private _meshTarget;
  49908. /**
  49909. * Instantiates a new ArcFollowCamera
  49910. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49911. * @param name Define the name of the camera
  49912. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49913. * @param beta Define the rotation angle of the camera around the elevation axis
  49914. * @param radius Define the radius of the camera from its target point
  49915. * @param target Define the target of the camera
  49916. * @param scene Define the scene the camera belongs to
  49917. */
  49918. constructor(name: string,
  49919. /** The longitudinal angle of the camera */
  49920. alpha: number,
  49921. /** The latitudinal angle of the camera */
  49922. beta: number,
  49923. /** The radius of the camera from its target */
  49924. radius: number,
  49925. /** Define the camera target (the mesh it should follow) */
  49926. target: Nullable<AbstractMesh>, scene: Scene);
  49927. private _follow;
  49928. /** @hidden */
  49929. _checkInputs(): void;
  49930. /**
  49931. * Returns the class name of the object.
  49932. * It is mostly used internally for serialization purposes.
  49933. */
  49934. getClassName(): string;
  49935. }
  49936. }
  49937. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49938. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49939. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49940. /**
  49941. * Manage the keyboard inputs to control the movement of a follow camera.
  49942. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49943. */
  49944. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49945. /**
  49946. * Defines the camera the input is attached to.
  49947. */
  49948. camera: FollowCamera;
  49949. /**
  49950. * Defines the list of key codes associated with the up action (increase heightOffset)
  49951. */
  49952. keysHeightOffsetIncr: number[];
  49953. /**
  49954. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49955. */
  49956. keysHeightOffsetDecr: number[];
  49957. /**
  49958. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49959. */
  49960. keysHeightOffsetModifierAlt: boolean;
  49961. /**
  49962. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49963. */
  49964. keysHeightOffsetModifierCtrl: boolean;
  49965. /**
  49966. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49967. */
  49968. keysHeightOffsetModifierShift: boolean;
  49969. /**
  49970. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49971. */
  49972. keysRotationOffsetIncr: number[];
  49973. /**
  49974. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49975. */
  49976. keysRotationOffsetDecr: number[];
  49977. /**
  49978. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49979. */
  49980. keysRotationOffsetModifierAlt: boolean;
  49981. /**
  49982. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49983. */
  49984. keysRotationOffsetModifierCtrl: boolean;
  49985. /**
  49986. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49987. */
  49988. keysRotationOffsetModifierShift: boolean;
  49989. /**
  49990. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49991. */
  49992. keysRadiusIncr: number[];
  49993. /**
  49994. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49995. */
  49996. keysRadiusDecr: number[];
  49997. /**
  49998. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49999. */
  50000. keysRadiusModifierAlt: boolean;
  50001. /**
  50002. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  50003. */
  50004. keysRadiusModifierCtrl: boolean;
  50005. /**
  50006. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50007. */
  50008. keysRadiusModifierShift: boolean;
  50009. /**
  50010. * Defines the rate of change of heightOffset.
  50011. */
  50012. heightSensibility: number;
  50013. /**
  50014. * Defines the rate of change of rotationOffset.
  50015. */
  50016. rotationSensibility: number;
  50017. /**
  50018. * Defines the rate of change of radius.
  50019. */
  50020. radiusSensibility: number;
  50021. private _keys;
  50022. private _ctrlPressed;
  50023. private _altPressed;
  50024. private _shiftPressed;
  50025. private _onCanvasBlurObserver;
  50026. private _onKeyboardObserver;
  50027. private _engine;
  50028. private _scene;
  50029. /**
  50030. * Attach the input controls to a specific dom element to get the input from.
  50031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50032. */
  50033. attachControl(noPreventDefault?: boolean): void;
  50034. /**
  50035. * Detach the current controls from the specified dom element.
  50036. */
  50037. detachControl(): void;
  50038. /**
  50039. * Update the current camera state depending on the inputs that have been used this frame.
  50040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50041. */
  50042. checkInputs(): void;
  50043. /**
  50044. * Gets the class name of the current input.
  50045. * @returns the class name
  50046. */
  50047. getClassName(): string;
  50048. /**
  50049. * Get the friendly name associated with the input class.
  50050. * @returns the input friendly name
  50051. */
  50052. getSimpleName(): string;
  50053. /**
  50054. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50055. * allow modification of the heightOffset value.
  50056. */
  50057. private _modifierHeightOffset;
  50058. /**
  50059. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50060. * allow modification of the rotationOffset value.
  50061. */
  50062. private _modifierRotationOffset;
  50063. /**
  50064. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50065. * allow modification of the radius value.
  50066. */
  50067. private _modifierRadius;
  50068. }
  50069. }
  50070. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50071. import { Nullable } from "babylonjs/types";
  50072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50074. import { Observable } from "babylonjs/Misc/observable";
  50075. module "babylonjs/Cameras/freeCameraInputsManager" {
  50076. interface FreeCameraInputsManager {
  50077. /**
  50078. * @hidden
  50079. */
  50080. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50081. /**
  50082. * Add orientation input support to the input manager.
  50083. * @returns the current input manager
  50084. */
  50085. addDeviceOrientation(): FreeCameraInputsManager;
  50086. }
  50087. }
  50088. /**
  50089. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50090. * Screen rotation is taken into account.
  50091. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50092. */
  50093. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50094. private _camera;
  50095. private _screenOrientationAngle;
  50096. private _constantTranform;
  50097. private _screenQuaternion;
  50098. private _alpha;
  50099. private _beta;
  50100. private _gamma;
  50101. /**
  50102. * Can be used to detect if a device orientation sensor is available on a device
  50103. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50104. * @returns a promise that will resolve on orientation change
  50105. */
  50106. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50107. /**
  50108. * @hidden
  50109. */
  50110. _onDeviceOrientationChangedObservable: Observable<void>;
  50111. /**
  50112. * Instantiates a new input
  50113. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50114. */
  50115. constructor();
  50116. /**
  50117. * Define the camera controlled by the input.
  50118. */
  50119. get camera(): FreeCamera;
  50120. set camera(camera: FreeCamera);
  50121. /**
  50122. * Attach the input controls to a specific dom element to get the input from.
  50123. */
  50124. attachControl(): void;
  50125. private _orientationChanged;
  50126. private _deviceOrientation;
  50127. /**
  50128. * Detach the current controls from the specified dom element.
  50129. */
  50130. detachControl(): void;
  50131. /**
  50132. * Update the current camera state depending on the inputs that have been used this frame.
  50133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50134. */
  50135. checkInputs(): void;
  50136. /**
  50137. * Gets the class name of the current intput.
  50138. * @returns the class name
  50139. */
  50140. getClassName(): string;
  50141. /**
  50142. * Get the friendly name associated with the input class.
  50143. * @returns the input friendly name
  50144. */
  50145. getSimpleName(): string;
  50146. }
  50147. }
  50148. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50149. import { Nullable } from "babylonjs/types";
  50150. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50151. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50152. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50153. /**
  50154. * Manage the gamepad inputs to control a free camera.
  50155. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50156. */
  50157. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50158. /**
  50159. * Define the camera the input is attached to.
  50160. */
  50161. camera: FreeCamera;
  50162. /**
  50163. * Define the Gamepad controlling the input
  50164. */
  50165. gamepad: Nullable<Gamepad>;
  50166. /**
  50167. * Defines the gamepad rotation sensiblity.
  50168. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50169. */
  50170. gamepadAngularSensibility: number;
  50171. /**
  50172. * Defines the gamepad move sensiblity.
  50173. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50174. */
  50175. gamepadMoveSensibility: number;
  50176. private _yAxisScale;
  50177. /**
  50178. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50179. */
  50180. get invertYAxis(): boolean;
  50181. set invertYAxis(value: boolean);
  50182. private _onGamepadConnectedObserver;
  50183. private _onGamepadDisconnectedObserver;
  50184. private _cameraTransform;
  50185. private _deltaTransform;
  50186. private _vector3;
  50187. private _vector2;
  50188. /**
  50189. * Attach the input controls to a specific dom element to get the input from.
  50190. */
  50191. attachControl(): void;
  50192. /**
  50193. * Detach the current controls from the specified dom element.
  50194. */
  50195. detachControl(): void;
  50196. /**
  50197. * Update the current camera state depending on the inputs that have been used this frame.
  50198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50199. */
  50200. checkInputs(): void;
  50201. /**
  50202. * Gets the class name of the current intput.
  50203. * @returns the class name
  50204. */
  50205. getClassName(): string;
  50206. /**
  50207. * Get the friendly name associated with the input class.
  50208. * @returns the input friendly name
  50209. */
  50210. getSimpleName(): string;
  50211. }
  50212. }
  50213. declare module "babylonjs/Misc/virtualJoystick" {
  50214. import { Nullable } from "babylonjs/types";
  50215. import { Vector3 } from "babylonjs/Maths/math.vector";
  50216. /**
  50217. * Defines the potential axis of a Joystick
  50218. */
  50219. export enum JoystickAxis {
  50220. /** X axis */
  50221. X = 0,
  50222. /** Y axis */
  50223. Y = 1,
  50224. /** Z axis */
  50225. Z = 2
  50226. }
  50227. /**
  50228. * Represents the different customization options available
  50229. * for VirtualJoystick
  50230. */
  50231. interface VirtualJoystickCustomizations {
  50232. /**
  50233. * Size of the joystick's puck
  50234. */
  50235. puckSize: number;
  50236. /**
  50237. * Size of the joystick's container
  50238. */
  50239. containerSize: number;
  50240. /**
  50241. * Color of the joystick && puck
  50242. */
  50243. color: string;
  50244. /**
  50245. * Image URL for the joystick's puck
  50246. */
  50247. puckImage?: string;
  50248. /**
  50249. * Image URL for the joystick's container
  50250. */
  50251. containerImage?: string;
  50252. /**
  50253. * Defines the unmoving position of the joystick container
  50254. */
  50255. position?: {
  50256. x: number;
  50257. y: number;
  50258. };
  50259. /**
  50260. * Defines whether or not the joystick container is always visible
  50261. */
  50262. alwaysVisible: boolean;
  50263. /**
  50264. * Defines whether or not to limit the movement of the puck to the joystick's container
  50265. */
  50266. limitToContainer: boolean;
  50267. }
  50268. /**
  50269. * Class used to define virtual joystick (used in touch mode)
  50270. */
  50271. export class VirtualJoystick {
  50272. /**
  50273. * Gets or sets a boolean indicating that left and right values must be inverted
  50274. */
  50275. reverseLeftRight: boolean;
  50276. /**
  50277. * Gets or sets a boolean indicating that up and down values must be inverted
  50278. */
  50279. reverseUpDown: boolean;
  50280. /**
  50281. * Gets the offset value for the position (ie. the change of the position value)
  50282. */
  50283. deltaPosition: Vector3;
  50284. /**
  50285. * Gets a boolean indicating if the virtual joystick was pressed
  50286. */
  50287. pressed: boolean;
  50288. /**
  50289. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50290. */
  50291. static Canvas: Nullable<HTMLCanvasElement>;
  50292. /**
  50293. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50294. */
  50295. limitToContainer: boolean;
  50296. private static _globalJoystickIndex;
  50297. private static _alwaysVisibleSticks;
  50298. private static vjCanvasContext;
  50299. private static vjCanvasWidth;
  50300. private static vjCanvasHeight;
  50301. private static halfWidth;
  50302. private static _GetDefaultOptions;
  50303. private _action;
  50304. private _axisTargetedByLeftAndRight;
  50305. private _axisTargetedByUpAndDown;
  50306. private _joystickSensibility;
  50307. private _inversedSensibility;
  50308. private _joystickPointerID;
  50309. private _joystickColor;
  50310. private _joystickPointerPos;
  50311. private _joystickPreviousPointerPos;
  50312. private _joystickPointerStartPos;
  50313. private _deltaJoystickVector;
  50314. private _leftJoystick;
  50315. private _touches;
  50316. private _joystickPosition;
  50317. private _alwaysVisible;
  50318. private _puckImage;
  50319. private _containerImage;
  50320. private _joystickPuckSize;
  50321. private _joystickContainerSize;
  50322. private _clearPuckSize;
  50323. private _clearContainerSize;
  50324. private _clearPuckSizeOffset;
  50325. private _clearContainerSizeOffset;
  50326. private _onPointerDownHandlerRef;
  50327. private _onPointerMoveHandlerRef;
  50328. private _onPointerUpHandlerRef;
  50329. private _onResize;
  50330. /**
  50331. * Creates a new virtual joystick
  50332. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50333. * @param customizations Defines the options we want to customize the VirtualJoystick
  50334. */
  50335. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50336. /**
  50337. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50338. * @param newJoystickSensibility defines the new sensibility
  50339. */
  50340. setJoystickSensibility(newJoystickSensibility: number): void;
  50341. private _onPointerDown;
  50342. private _onPointerMove;
  50343. private _onPointerUp;
  50344. /**
  50345. * Change the color of the virtual joystick
  50346. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50347. */
  50348. setJoystickColor(newColor: string): void;
  50349. /**
  50350. * Size of the joystick's container
  50351. */
  50352. set containerSize(newSize: number);
  50353. get containerSize(): number;
  50354. /**
  50355. * Size of the joystick's puck
  50356. */
  50357. set puckSize(newSize: number);
  50358. get puckSize(): number;
  50359. /**
  50360. * Clears the set position of the joystick
  50361. */
  50362. clearPosition(): void;
  50363. /**
  50364. * Defines whether or not the joystick container is always visible
  50365. */
  50366. set alwaysVisible(value: boolean);
  50367. get alwaysVisible(): boolean;
  50368. /**
  50369. * Sets the constant position of the Joystick container
  50370. * @param x X axis coordinate
  50371. * @param y Y axis coordinate
  50372. */
  50373. setPosition(x: number, y: number): void;
  50374. /**
  50375. * Defines a callback to call when the joystick is touched
  50376. * @param action defines the callback
  50377. */
  50378. setActionOnTouch(action: () => any): void;
  50379. /**
  50380. * Defines which axis you'd like to control for left & right
  50381. * @param axis defines the axis to use
  50382. */
  50383. setAxisForLeftRight(axis: JoystickAxis): void;
  50384. /**
  50385. * Defines which axis you'd like to control for up & down
  50386. * @param axis defines the axis to use
  50387. */
  50388. setAxisForUpDown(axis: JoystickAxis): void;
  50389. /**
  50390. * Clears the canvas from the previous puck / container draw
  50391. */
  50392. private _clearPreviousDraw;
  50393. /**
  50394. * Loads `urlPath` to be used for the container's image
  50395. * @param urlPath defines the urlPath of an image to use
  50396. */
  50397. setContainerImage(urlPath: string): void;
  50398. /**
  50399. * Loads `urlPath` to be used for the puck's image
  50400. * @param urlPath defines the urlPath of an image to use
  50401. */
  50402. setPuckImage(urlPath: string): void;
  50403. /**
  50404. * Draws the Virtual Joystick's container
  50405. */
  50406. private _drawContainer;
  50407. /**
  50408. * Draws the Virtual Joystick's puck
  50409. */
  50410. private _drawPuck;
  50411. private _drawVirtualJoystick;
  50412. /**
  50413. * Release internal HTML canvas
  50414. */
  50415. releaseCanvas(): void;
  50416. }
  50417. }
  50418. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50419. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50420. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50421. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50422. module "babylonjs/Cameras/freeCameraInputsManager" {
  50423. interface FreeCameraInputsManager {
  50424. /**
  50425. * Add virtual joystick input support to the input manager.
  50426. * @returns the current input manager
  50427. */
  50428. addVirtualJoystick(): FreeCameraInputsManager;
  50429. }
  50430. }
  50431. /**
  50432. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50434. */
  50435. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50436. /**
  50437. * Defines the camera the input is attached to.
  50438. */
  50439. camera: FreeCamera;
  50440. private _leftjoystick;
  50441. private _rightjoystick;
  50442. /**
  50443. * Gets the left stick of the virtual joystick.
  50444. * @returns The virtual Joystick
  50445. */
  50446. getLeftJoystick(): VirtualJoystick;
  50447. /**
  50448. * Gets the right stick of the virtual joystick.
  50449. * @returns The virtual Joystick
  50450. */
  50451. getRightJoystick(): VirtualJoystick;
  50452. /**
  50453. * Update the current camera state depending on the inputs that have been used this frame.
  50454. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50455. */
  50456. checkInputs(): void;
  50457. /**
  50458. * Attach the input controls to a specific dom element to get the input from.
  50459. */
  50460. attachControl(): void;
  50461. /**
  50462. * Detach the current controls from the specified dom element.
  50463. */
  50464. detachControl(): void;
  50465. /**
  50466. * Gets the class name of the current intput.
  50467. * @returns the class name
  50468. */
  50469. getClassName(): string;
  50470. /**
  50471. * Get the friendly name associated with the input class.
  50472. * @returns the input friendly name
  50473. */
  50474. getSimpleName(): string;
  50475. }
  50476. }
  50477. declare module "babylonjs/Cameras/Inputs/index" {
  50478. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50479. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50480. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50481. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50482. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50483. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50484. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50485. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50486. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50487. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50488. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50489. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50490. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50491. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50492. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50493. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50494. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50495. }
  50496. declare module "babylonjs/Cameras/touchCamera" {
  50497. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50498. import { Scene } from "babylonjs/scene";
  50499. import { Vector3 } from "babylonjs/Maths/math.vector";
  50500. /**
  50501. * This represents a FPS type of camera controlled by touch.
  50502. * This is like a universal camera minus the Gamepad controls.
  50503. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50504. */
  50505. export class TouchCamera extends FreeCamera {
  50506. /**
  50507. * Defines the touch sensibility for rotation.
  50508. * The higher the faster.
  50509. */
  50510. get touchAngularSensibility(): number;
  50511. set touchAngularSensibility(value: number);
  50512. /**
  50513. * Defines the touch sensibility for move.
  50514. * The higher the faster.
  50515. */
  50516. get touchMoveSensibility(): number;
  50517. set touchMoveSensibility(value: number);
  50518. /**
  50519. * Instantiates a new touch camera.
  50520. * This represents a FPS type of camera controlled by touch.
  50521. * This is like a universal camera minus the Gamepad controls.
  50522. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50523. * @param name Define the name of the camera in the scene
  50524. * @param position Define the start position of the camera in the scene
  50525. * @param scene Define the scene the camera belongs to
  50526. */
  50527. constructor(name: string, position: Vector3, scene: Scene);
  50528. /**
  50529. * Gets the current object class name.
  50530. * @return the class name
  50531. */
  50532. getClassName(): string;
  50533. /** @hidden */
  50534. _setupInputs(): void;
  50535. }
  50536. }
  50537. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50538. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50539. import { Scene } from "babylonjs/scene";
  50540. import { Vector3 } from "babylonjs/Maths/math.vector";
  50541. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50542. import { Axis } from "babylonjs/Maths/math.axis";
  50543. /**
  50544. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50545. * being tilted forward or back and left or right.
  50546. */
  50547. export class DeviceOrientationCamera extends FreeCamera {
  50548. private _initialQuaternion;
  50549. private _quaternionCache;
  50550. private _tmpDragQuaternion;
  50551. private _disablePointerInputWhenUsingDeviceOrientation;
  50552. /**
  50553. * Creates a new device orientation camera
  50554. * @param name The name of the camera
  50555. * @param position The start position camera
  50556. * @param scene The scene the camera belongs to
  50557. */
  50558. constructor(name: string, position: Vector3, scene: Scene);
  50559. /**
  50560. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50561. */
  50562. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50563. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50564. private _dragFactor;
  50565. /**
  50566. * Enabled turning on the y axis when the orientation sensor is active
  50567. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50568. */
  50569. enableHorizontalDragging(dragFactor?: number): void;
  50570. /**
  50571. * Gets the current instance class name ("DeviceOrientationCamera").
  50572. * This helps avoiding instanceof at run time.
  50573. * @returns the class name
  50574. */
  50575. getClassName(): string;
  50576. /**
  50577. * @hidden
  50578. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50579. */
  50580. _checkInputs(): void;
  50581. /**
  50582. * Reset the camera to its default orientation on the specified axis only.
  50583. * @param axis The axis to reset
  50584. */
  50585. resetToCurrentRotation(axis?: Axis): void;
  50586. }
  50587. }
  50588. declare module "babylonjs/Gamepads/xboxGamepad" {
  50589. import { Observable } from "babylonjs/Misc/observable";
  50590. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50591. /**
  50592. * Defines supported buttons for XBox360 compatible gamepads
  50593. */
  50594. export enum Xbox360Button {
  50595. /** A */
  50596. A = 0,
  50597. /** B */
  50598. B = 1,
  50599. /** X */
  50600. X = 2,
  50601. /** Y */
  50602. Y = 3,
  50603. /** Left button */
  50604. LB = 4,
  50605. /** Right button */
  50606. RB = 5,
  50607. /** Back */
  50608. Back = 8,
  50609. /** Start */
  50610. Start = 9,
  50611. /** Left stick */
  50612. LeftStick = 10,
  50613. /** Right stick */
  50614. RightStick = 11
  50615. }
  50616. /** Defines values for XBox360 DPad */
  50617. export enum Xbox360Dpad {
  50618. /** Up */
  50619. Up = 12,
  50620. /** Down */
  50621. Down = 13,
  50622. /** Left */
  50623. Left = 14,
  50624. /** Right */
  50625. Right = 15
  50626. }
  50627. /**
  50628. * Defines a XBox360 gamepad
  50629. */
  50630. export class Xbox360Pad extends Gamepad {
  50631. private _leftTrigger;
  50632. private _rightTrigger;
  50633. private _onlefttriggerchanged;
  50634. private _onrighttriggerchanged;
  50635. private _onbuttondown;
  50636. private _onbuttonup;
  50637. private _ondpaddown;
  50638. private _ondpadup;
  50639. /** Observable raised when a button is pressed */
  50640. onButtonDownObservable: Observable<Xbox360Button>;
  50641. /** Observable raised when a button is released */
  50642. onButtonUpObservable: Observable<Xbox360Button>;
  50643. /** Observable raised when a pad is pressed */
  50644. onPadDownObservable: Observable<Xbox360Dpad>;
  50645. /** Observable raised when a pad is released */
  50646. onPadUpObservable: Observable<Xbox360Dpad>;
  50647. private _buttonA;
  50648. private _buttonB;
  50649. private _buttonX;
  50650. private _buttonY;
  50651. private _buttonBack;
  50652. private _buttonStart;
  50653. private _buttonLB;
  50654. private _buttonRB;
  50655. private _buttonLeftStick;
  50656. private _buttonRightStick;
  50657. private _dPadUp;
  50658. private _dPadDown;
  50659. private _dPadLeft;
  50660. private _dPadRight;
  50661. private _isXboxOnePad;
  50662. /**
  50663. * Creates a new XBox360 gamepad object
  50664. * @param id defines the id of this gamepad
  50665. * @param index defines its index
  50666. * @param gamepad defines the internal HTML gamepad object
  50667. * @param xboxOne defines if it is a XBox One gamepad
  50668. */
  50669. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50670. /**
  50671. * Defines the callback to call when left trigger is pressed
  50672. * @param callback defines the callback to use
  50673. */
  50674. onlefttriggerchanged(callback: (value: number) => void): void;
  50675. /**
  50676. * Defines the callback to call when right trigger is pressed
  50677. * @param callback defines the callback to use
  50678. */
  50679. onrighttriggerchanged(callback: (value: number) => void): void;
  50680. /**
  50681. * Gets the left trigger value
  50682. */
  50683. get leftTrigger(): number;
  50684. /**
  50685. * Sets the left trigger value
  50686. */
  50687. set leftTrigger(newValue: number);
  50688. /**
  50689. * Gets the right trigger value
  50690. */
  50691. get rightTrigger(): number;
  50692. /**
  50693. * Sets the right trigger value
  50694. */
  50695. set rightTrigger(newValue: number);
  50696. /**
  50697. * Defines the callback to call when a button is pressed
  50698. * @param callback defines the callback to use
  50699. */
  50700. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50701. /**
  50702. * Defines the callback to call when a button is released
  50703. * @param callback defines the callback to use
  50704. */
  50705. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50706. /**
  50707. * Defines the callback to call when a pad is pressed
  50708. * @param callback defines the callback to use
  50709. */
  50710. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50711. /**
  50712. * Defines the callback to call when a pad is released
  50713. * @param callback defines the callback to use
  50714. */
  50715. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50716. private _setButtonValue;
  50717. private _setDPadValue;
  50718. /**
  50719. * Gets the value of the `A` button
  50720. */
  50721. get buttonA(): number;
  50722. /**
  50723. * Sets the value of the `A` button
  50724. */
  50725. set buttonA(value: number);
  50726. /**
  50727. * Gets the value of the `B` button
  50728. */
  50729. get buttonB(): number;
  50730. /**
  50731. * Sets the value of the `B` button
  50732. */
  50733. set buttonB(value: number);
  50734. /**
  50735. * Gets the value of the `X` button
  50736. */
  50737. get buttonX(): number;
  50738. /**
  50739. * Sets the value of the `X` button
  50740. */
  50741. set buttonX(value: number);
  50742. /**
  50743. * Gets the value of the `Y` button
  50744. */
  50745. get buttonY(): number;
  50746. /**
  50747. * Sets the value of the `Y` button
  50748. */
  50749. set buttonY(value: number);
  50750. /**
  50751. * Gets the value of the `Start` button
  50752. */
  50753. get buttonStart(): number;
  50754. /**
  50755. * Sets the value of the `Start` button
  50756. */
  50757. set buttonStart(value: number);
  50758. /**
  50759. * Gets the value of the `Back` button
  50760. */
  50761. get buttonBack(): number;
  50762. /**
  50763. * Sets the value of the `Back` button
  50764. */
  50765. set buttonBack(value: number);
  50766. /**
  50767. * Gets the value of the `Left` button
  50768. */
  50769. get buttonLB(): number;
  50770. /**
  50771. * Sets the value of the `Left` button
  50772. */
  50773. set buttonLB(value: number);
  50774. /**
  50775. * Gets the value of the `Right` button
  50776. */
  50777. get buttonRB(): number;
  50778. /**
  50779. * Sets the value of the `Right` button
  50780. */
  50781. set buttonRB(value: number);
  50782. /**
  50783. * Gets the value of the Left joystick
  50784. */
  50785. get buttonLeftStick(): number;
  50786. /**
  50787. * Sets the value of the Left joystick
  50788. */
  50789. set buttonLeftStick(value: number);
  50790. /**
  50791. * Gets the value of the Right joystick
  50792. */
  50793. get buttonRightStick(): number;
  50794. /**
  50795. * Sets the value of the Right joystick
  50796. */
  50797. set buttonRightStick(value: number);
  50798. /**
  50799. * Gets the value of D-pad up
  50800. */
  50801. get dPadUp(): number;
  50802. /**
  50803. * Sets the value of D-pad up
  50804. */
  50805. set dPadUp(value: number);
  50806. /**
  50807. * Gets the value of D-pad down
  50808. */
  50809. get dPadDown(): number;
  50810. /**
  50811. * Sets the value of D-pad down
  50812. */
  50813. set dPadDown(value: number);
  50814. /**
  50815. * Gets the value of D-pad left
  50816. */
  50817. get dPadLeft(): number;
  50818. /**
  50819. * Sets the value of D-pad left
  50820. */
  50821. set dPadLeft(value: number);
  50822. /**
  50823. * Gets the value of D-pad right
  50824. */
  50825. get dPadRight(): number;
  50826. /**
  50827. * Sets the value of D-pad right
  50828. */
  50829. set dPadRight(value: number);
  50830. /**
  50831. * Force the gamepad to synchronize with device values
  50832. */
  50833. update(): void;
  50834. /**
  50835. * Disposes the gamepad
  50836. */
  50837. dispose(): void;
  50838. }
  50839. }
  50840. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50841. import { Observable } from "babylonjs/Misc/observable";
  50842. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50843. /**
  50844. * Defines supported buttons for DualShock compatible gamepads
  50845. */
  50846. export enum DualShockButton {
  50847. /** Cross */
  50848. Cross = 0,
  50849. /** Circle */
  50850. Circle = 1,
  50851. /** Square */
  50852. Square = 2,
  50853. /** Triangle */
  50854. Triangle = 3,
  50855. /** L1 */
  50856. L1 = 4,
  50857. /** R1 */
  50858. R1 = 5,
  50859. /** Share */
  50860. Share = 8,
  50861. /** Options */
  50862. Options = 9,
  50863. /** Left stick */
  50864. LeftStick = 10,
  50865. /** Right stick */
  50866. RightStick = 11
  50867. }
  50868. /** Defines values for DualShock DPad */
  50869. export enum DualShockDpad {
  50870. /** Up */
  50871. Up = 12,
  50872. /** Down */
  50873. Down = 13,
  50874. /** Left */
  50875. Left = 14,
  50876. /** Right */
  50877. Right = 15
  50878. }
  50879. /**
  50880. * Defines a DualShock gamepad
  50881. */
  50882. export class DualShockPad extends Gamepad {
  50883. private _leftTrigger;
  50884. private _rightTrigger;
  50885. private _onlefttriggerchanged;
  50886. private _onrighttriggerchanged;
  50887. private _onbuttondown;
  50888. private _onbuttonup;
  50889. private _ondpaddown;
  50890. private _ondpadup;
  50891. /** Observable raised when a button is pressed */
  50892. onButtonDownObservable: Observable<DualShockButton>;
  50893. /** Observable raised when a button is released */
  50894. onButtonUpObservable: Observable<DualShockButton>;
  50895. /** Observable raised when a pad is pressed */
  50896. onPadDownObservable: Observable<DualShockDpad>;
  50897. /** Observable raised when a pad is released */
  50898. onPadUpObservable: Observable<DualShockDpad>;
  50899. private _buttonCross;
  50900. private _buttonCircle;
  50901. private _buttonSquare;
  50902. private _buttonTriangle;
  50903. private _buttonShare;
  50904. private _buttonOptions;
  50905. private _buttonL1;
  50906. private _buttonR1;
  50907. private _buttonLeftStick;
  50908. private _buttonRightStick;
  50909. private _dPadUp;
  50910. private _dPadDown;
  50911. private _dPadLeft;
  50912. private _dPadRight;
  50913. /**
  50914. * Creates a new DualShock gamepad object
  50915. * @param id defines the id of this gamepad
  50916. * @param index defines its index
  50917. * @param gamepad defines the internal HTML gamepad object
  50918. */
  50919. constructor(id: string, index: number, gamepad: any);
  50920. /**
  50921. * Defines the callback to call when left trigger is pressed
  50922. * @param callback defines the callback to use
  50923. */
  50924. onlefttriggerchanged(callback: (value: number) => void): void;
  50925. /**
  50926. * Defines the callback to call when right trigger is pressed
  50927. * @param callback defines the callback to use
  50928. */
  50929. onrighttriggerchanged(callback: (value: number) => void): void;
  50930. /**
  50931. * Gets the left trigger value
  50932. */
  50933. get leftTrigger(): number;
  50934. /**
  50935. * Sets the left trigger value
  50936. */
  50937. set leftTrigger(newValue: number);
  50938. /**
  50939. * Gets the right trigger value
  50940. */
  50941. get rightTrigger(): number;
  50942. /**
  50943. * Sets the right trigger value
  50944. */
  50945. set rightTrigger(newValue: number);
  50946. /**
  50947. * Defines the callback to call when a button is pressed
  50948. * @param callback defines the callback to use
  50949. */
  50950. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50951. /**
  50952. * Defines the callback to call when a button is released
  50953. * @param callback defines the callback to use
  50954. */
  50955. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50956. /**
  50957. * Defines the callback to call when a pad is pressed
  50958. * @param callback defines the callback to use
  50959. */
  50960. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50961. /**
  50962. * Defines the callback to call when a pad is released
  50963. * @param callback defines the callback to use
  50964. */
  50965. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50966. private _setButtonValue;
  50967. private _setDPadValue;
  50968. /**
  50969. * Gets the value of the `Cross` button
  50970. */
  50971. get buttonCross(): number;
  50972. /**
  50973. * Sets the value of the `Cross` button
  50974. */
  50975. set buttonCross(value: number);
  50976. /**
  50977. * Gets the value of the `Circle` button
  50978. */
  50979. get buttonCircle(): number;
  50980. /**
  50981. * Sets the value of the `Circle` button
  50982. */
  50983. set buttonCircle(value: number);
  50984. /**
  50985. * Gets the value of the `Square` button
  50986. */
  50987. get buttonSquare(): number;
  50988. /**
  50989. * Sets the value of the `Square` button
  50990. */
  50991. set buttonSquare(value: number);
  50992. /**
  50993. * Gets the value of the `Triangle` button
  50994. */
  50995. get buttonTriangle(): number;
  50996. /**
  50997. * Sets the value of the `Triangle` button
  50998. */
  50999. set buttonTriangle(value: number);
  51000. /**
  51001. * Gets the value of the `Options` button
  51002. */
  51003. get buttonOptions(): number;
  51004. /**
  51005. * Sets the value of the `Options` button
  51006. */
  51007. set buttonOptions(value: number);
  51008. /**
  51009. * Gets the value of the `Share` button
  51010. */
  51011. get buttonShare(): number;
  51012. /**
  51013. * Sets the value of the `Share` button
  51014. */
  51015. set buttonShare(value: number);
  51016. /**
  51017. * Gets the value of the `L1` button
  51018. */
  51019. get buttonL1(): number;
  51020. /**
  51021. * Sets the value of the `L1` button
  51022. */
  51023. set buttonL1(value: number);
  51024. /**
  51025. * Gets the value of the `R1` button
  51026. */
  51027. get buttonR1(): number;
  51028. /**
  51029. * Sets the value of the `R1` button
  51030. */
  51031. set buttonR1(value: number);
  51032. /**
  51033. * Gets the value of the Left joystick
  51034. */
  51035. get buttonLeftStick(): number;
  51036. /**
  51037. * Sets the value of the Left joystick
  51038. */
  51039. set buttonLeftStick(value: number);
  51040. /**
  51041. * Gets the value of the Right joystick
  51042. */
  51043. get buttonRightStick(): number;
  51044. /**
  51045. * Sets the value of the Right joystick
  51046. */
  51047. set buttonRightStick(value: number);
  51048. /**
  51049. * Gets the value of D-pad up
  51050. */
  51051. get dPadUp(): number;
  51052. /**
  51053. * Sets the value of D-pad up
  51054. */
  51055. set dPadUp(value: number);
  51056. /**
  51057. * Gets the value of D-pad down
  51058. */
  51059. get dPadDown(): number;
  51060. /**
  51061. * Sets the value of D-pad down
  51062. */
  51063. set dPadDown(value: number);
  51064. /**
  51065. * Gets the value of D-pad left
  51066. */
  51067. get dPadLeft(): number;
  51068. /**
  51069. * Sets the value of D-pad left
  51070. */
  51071. set dPadLeft(value: number);
  51072. /**
  51073. * Gets the value of D-pad right
  51074. */
  51075. get dPadRight(): number;
  51076. /**
  51077. * Sets the value of D-pad right
  51078. */
  51079. set dPadRight(value: number);
  51080. /**
  51081. * Force the gamepad to synchronize with device values
  51082. */
  51083. update(): void;
  51084. /**
  51085. * Disposes the gamepad
  51086. */
  51087. dispose(): void;
  51088. }
  51089. }
  51090. declare module "babylonjs/Gamepads/gamepadManager" {
  51091. import { Observable } from "babylonjs/Misc/observable";
  51092. import { Nullable } from "babylonjs/types";
  51093. import { Scene } from "babylonjs/scene";
  51094. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51095. /**
  51096. * Manager for handling gamepads
  51097. */
  51098. export class GamepadManager {
  51099. private _scene?;
  51100. private _babylonGamepads;
  51101. private _oneGamepadConnected;
  51102. /** @hidden */
  51103. _isMonitoring: boolean;
  51104. private _gamepadEventSupported;
  51105. private _gamepadSupport?;
  51106. /**
  51107. * observable to be triggered when the gamepad controller has been connected
  51108. */
  51109. onGamepadConnectedObservable: Observable<Gamepad>;
  51110. /**
  51111. * observable to be triggered when the gamepad controller has been disconnected
  51112. */
  51113. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51114. private _onGamepadConnectedEvent;
  51115. private _onGamepadDisconnectedEvent;
  51116. /**
  51117. * Initializes the gamepad manager
  51118. * @param _scene BabylonJS scene
  51119. */
  51120. constructor(_scene?: Scene | undefined);
  51121. /**
  51122. * The gamepads in the game pad manager
  51123. */
  51124. get gamepads(): Gamepad[];
  51125. /**
  51126. * Get the gamepad controllers based on type
  51127. * @param type The type of gamepad controller
  51128. * @returns Nullable gamepad
  51129. */
  51130. getGamepadByType(type?: number): Nullable<Gamepad>;
  51131. /**
  51132. * Disposes the gamepad manager
  51133. */
  51134. dispose(): void;
  51135. private _addNewGamepad;
  51136. private _startMonitoringGamepads;
  51137. private _stopMonitoringGamepads;
  51138. /** @hidden */
  51139. _checkGamepadsStatus(): void;
  51140. private _updateGamepadObjects;
  51141. }
  51142. }
  51143. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51144. import { Nullable } from "babylonjs/types";
  51145. import { Scene } from "babylonjs/scene";
  51146. import { ISceneComponent } from "babylonjs/sceneComponent";
  51147. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51148. module "babylonjs/scene" {
  51149. interface Scene {
  51150. /** @hidden */
  51151. _gamepadManager: Nullable<GamepadManager>;
  51152. /**
  51153. * Gets the gamepad manager associated with the scene
  51154. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51155. */
  51156. gamepadManager: GamepadManager;
  51157. }
  51158. }
  51159. module "babylonjs/Cameras/freeCameraInputsManager" {
  51160. /**
  51161. * Interface representing a free camera inputs manager
  51162. */
  51163. interface FreeCameraInputsManager {
  51164. /**
  51165. * Adds gamepad input support to the FreeCameraInputsManager.
  51166. * @returns the FreeCameraInputsManager
  51167. */
  51168. addGamepad(): FreeCameraInputsManager;
  51169. }
  51170. }
  51171. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51172. /**
  51173. * Interface representing an arc rotate camera inputs manager
  51174. */
  51175. interface ArcRotateCameraInputsManager {
  51176. /**
  51177. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51178. * @returns the camera inputs manager
  51179. */
  51180. addGamepad(): ArcRotateCameraInputsManager;
  51181. }
  51182. }
  51183. /**
  51184. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51185. */
  51186. export class GamepadSystemSceneComponent implements ISceneComponent {
  51187. /**
  51188. * The component name helpfull to identify the component in the list of scene components.
  51189. */
  51190. readonly name: string;
  51191. /**
  51192. * The scene the component belongs to.
  51193. */
  51194. scene: Scene;
  51195. /**
  51196. * Creates a new instance of the component for the given scene
  51197. * @param scene Defines the scene to register the component in
  51198. */
  51199. constructor(scene: Scene);
  51200. /**
  51201. * Registers the component in a given scene
  51202. */
  51203. register(): void;
  51204. /**
  51205. * Rebuilds the elements related to this component in case of
  51206. * context lost for instance.
  51207. */
  51208. rebuild(): void;
  51209. /**
  51210. * Disposes the component and the associated ressources
  51211. */
  51212. dispose(): void;
  51213. private _beforeCameraUpdate;
  51214. }
  51215. }
  51216. declare module "babylonjs/Cameras/universalCamera" {
  51217. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51218. import { Scene } from "babylonjs/scene";
  51219. import { Vector3 } from "babylonjs/Maths/math.vector";
  51220. import "babylonjs/Gamepads/gamepadSceneComponent";
  51221. /**
  51222. * 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,
  51223. * which still works and will still be found in many Playgrounds.
  51224. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51225. */
  51226. export class UniversalCamera extends TouchCamera {
  51227. /**
  51228. * Defines the gamepad rotation sensiblity.
  51229. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51230. */
  51231. get gamepadAngularSensibility(): number;
  51232. set gamepadAngularSensibility(value: number);
  51233. /**
  51234. * Defines the gamepad move sensiblity.
  51235. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51236. */
  51237. get gamepadMoveSensibility(): number;
  51238. set gamepadMoveSensibility(value: number);
  51239. /**
  51240. * 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,
  51241. * which still works and will still be found in many Playgrounds.
  51242. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51243. * @param name Define the name of the camera in the scene
  51244. * @param position Define the start position of the camera in the scene
  51245. * @param scene Define the scene the camera belongs to
  51246. */
  51247. constructor(name: string, position: Vector3, scene: Scene);
  51248. /**
  51249. * Gets the current object class name.
  51250. * @return the class name
  51251. */
  51252. getClassName(): string;
  51253. }
  51254. }
  51255. declare module "babylonjs/Cameras/gamepadCamera" {
  51256. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51257. import { Scene } from "babylonjs/scene";
  51258. import { Vector3 } from "babylonjs/Maths/math.vector";
  51259. /**
  51260. * This represents a FPS type of camera. This is only here for back compat purpose.
  51261. * Please use the UniversalCamera instead as both are identical.
  51262. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51263. */
  51264. export class GamepadCamera extends UniversalCamera {
  51265. /**
  51266. * Instantiates a new Gamepad Camera
  51267. * This represents a FPS type of camera. This is only here for back compat purpose.
  51268. * Please use the UniversalCamera instead as both are identical.
  51269. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51270. * @param name Define the name of the camera in the scene
  51271. * @param position Define the start position of the camera in the scene
  51272. * @param scene Define the scene the camera belongs to
  51273. */
  51274. constructor(name: string, position: Vector3, scene: Scene);
  51275. /**
  51276. * Gets the current object class name.
  51277. * @return the class name
  51278. */
  51279. getClassName(): string;
  51280. }
  51281. }
  51282. declare module "babylonjs/Shaders/pass.fragment" {
  51283. /** @hidden */
  51284. export var passPixelShader: {
  51285. name: string;
  51286. shader: string;
  51287. };
  51288. }
  51289. declare module "babylonjs/Shaders/passCube.fragment" {
  51290. /** @hidden */
  51291. export var passCubePixelShader: {
  51292. name: string;
  51293. shader: string;
  51294. };
  51295. }
  51296. declare module "babylonjs/PostProcesses/passPostProcess" {
  51297. import { Nullable } from "babylonjs/types";
  51298. import { Camera } from "babylonjs/Cameras/camera";
  51299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51300. import { Engine } from "babylonjs/Engines/engine";
  51301. import "babylonjs/Shaders/pass.fragment";
  51302. import "babylonjs/Shaders/passCube.fragment";
  51303. import { Scene } from "babylonjs/scene";
  51304. /**
  51305. * PassPostProcess which produces an output the same as it's input
  51306. */
  51307. export class PassPostProcess extends PostProcess {
  51308. /**
  51309. * Gets a string identifying the name of the class
  51310. * @returns "PassPostProcess" string
  51311. */
  51312. getClassName(): string;
  51313. /**
  51314. * Creates the PassPostProcess
  51315. * @param name The name of the effect.
  51316. * @param options The required width/height ratio to downsize to before computing the render pass.
  51317. * @param camera The camera to apply the render pass to.
  51318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51319. * @param engine The engine which the post process will be applied. (default: current engine)
  51320. * @param reusable If the post process can be reused on the same frame. (default: false)
  51321. * @param textureType The type of texture to be used when performing the post processing.
  51322. * @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)
  51323. */
  51324. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51325. /** @hidden */
  51326. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51327. }
  51328. /**
  51329. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51330. */
  51331. export class PassCubePostProcess extends PostProcess {
  51332. private _face;
  51333. /**
  51334. * Gets or sets the cube face to display.
  51335. * * 0 is +X
  51336. * * 1 is -X
  51337. * * 2 is +Y
  51338. * * 3 is -Y
  51339. * * 4 is +Z
  51340. * * 5 is -Z
  51341. */
  51342. get face(): number;
  51343. set face(value: number);
  51344. /**
  51345. * Gets a string identifying the name of the class
  51346. * @returns "PassCubePostProcess" string
  51347. */
  51348. getClassName(): string;
  51349. /**
  51350. * Creates the PassCubePostProcess
  51351. * @param name The name of the effect.
  51352. * @param options The required width/height ratio to downsize to before computing the render pass.
  51353. * @param camera The camera to apply the render pass to.
  51354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51355. * @param engine The engine which the post process will be applied. (default: current engine)
  51356. * @param reusable If the post process can be reused on the same frame. (default: false)
  51357. * @param textureType The type of texture to be used when performing the post processing.
  51358. * @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)
  51359. */
  51360. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51361. /** @hidden */
  51362. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51363. }
  51364. }
  51365. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51366. /** @hidden */
  51367. export var anaglyphPixelShader: {
  51368. name: string;
  51369. shader: string;
  51370. };
  51371. }
  51372. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51373. import { Engine } from "babylonjs/Engines/engine";
  51374. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51375. import { Camera } from "babylonjs/Cameras/camera";
  51376. import "babylonjs/Shaders/anaglyph.fragment";
  51377. /**
  51378. * Postprocess used to generate anaglyphic rendering
  51379. */
  51380. export class AnaglyphPostProcess extends PostProcess {
  51381. private _passedProcess;
  51382. /**
  51383. * Gets a string identifying the name of the class
  51384. * @returns "AnaglyphPostProcess" string
  51385. */
  51386. getClassName(): string;
  51387. /**
  51388. * Creates a new AnaglyphPostProcess
  51389. * @param name defines postprocess name
  51390. * @param options defines creation options or target ratio scale
  51391. * @param rigCameras defines cameras using this postprocess
  51392. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51393. * @param engine defines hosting engine
  51394. * @param reusable defines if the postprocess will be reused multiple times per frame
  51395. */
  51396. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51397. }
  51398. }
  51399. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51400. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51401. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51402. import { Scene } from "babylonjs/scene";
  51403. import { Vector3 } from "babylonjs/Maths/math.vector";
  51404. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51405. /**
  51406. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51407. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51408. */
  51409. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51410. /**
  51411. * Creates a new AnaglyphArcRotateCamera
  51412. * @param name defines camera name
  51413. * @param alpha defines alpha angle (in radians)
  51414. * @param beta defines beta angle (in radians)
  51415. * @param radius defines radius
  51416. * @param target defines camera target
  51417. * @param interaxialDistance defines distance between each color axis
  51418. * @param scene defines the hosting scene
  51419. */
  51420. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51421. /**
  51422. * Gets camera class name
  51423. * @returns AnaglyphArcRotateCamera
  51424. */
  51425. getClassName(): string;
  51426. }
  51427. }
  51428. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51429. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51430. import { Scene } from "babylonjs/scene";
  51431. import { Vector3 } from "babylonjs/Maths/math.vector";
  51432. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51433. /**
  51434. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51435. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51436. */
  51437. export class AnaglyphFreeCamera extends FreeCamera {
  51438. /**
  51439. * Creates a new AnaglyphFreeCamera
  51440. * @param name defines camera name
  51441. * @param position defines initial position
  51442. * @param interaxialDistance defines distance between each color axis
  51443. * @param scene defines the hosting scene
  51444. */
  51445. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51446. /**
  51447. * Gets camera class name
  51448. * @returns AnaglyphFreeCamera
  51449. */
  51450. getClassName(): string;
  51451. }
  51452. }
  51453. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51454. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51455. import { Scene } from "babylonjs/scene";
  51456. import { Vector3 } from "babylonjs/Maths/math.vector";
  51457. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51458. /**
  51459. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51460. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51461. */
  51462. export class AnaglyphGamepadCamera extends GamepadCamera {
  51463. /**
  51464. * Creates a new AnaglyphGamepadCamera
  51465. * @param name defines camera name
  51466. * @param position defines initial position
  51467. * @param interaxialDistance defines distance between each color axis
  51468. * @param scene defines the hosting scene
  51469. */
  51470. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51471. /**
  51472. * Gets camera class name
  51473. * @returns AnaglyphGamepadCamera
  51474. */
  51475. getClassName(): string;
  51476. }
  51477. }
  51478. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51479. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51480. import { Scene } from "babylonjs/scene";
  51481. import { Vector3 } from "babylonjs/Maths/math.vector";
  51482. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51483. /**
  51484. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51485. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51486. */
  51487. export class AnaglyphUniversalCamera extends UniversalCamera {
  51488. /**
  51489. * Creates a new AnaglyphUniversalCamera
  51490. * @param name defines camera name
  51491. * @param position defines initial position
  51492. * @param interaxialDistance defines distance between each color axis
  51493. * @param scene defines the hosting scene
  51494. */
  51495. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51496. /**
  51497. * Gets camera class name
  51498. * @returns AnaglyphUniversalCamera
  51499. */
  51500. getClassName(): string;
  51501. }
  51502. }
  51503. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51504. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51505. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51506. import { Scene } from "babylonjs/scene";
  51507. import { Vector3 } from "babylonjs/Maths/math.vector";
  51508. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51509. /**
  51510. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51511. * @see https://doc.babylonjs.com/features/cameras
  51512. */
  51513. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51514. /**
  51515. * Creates a new StereoscopicArcRotateCamera
  51516. * @param name defines camera name
  51517. * @param alpha defines alpha angle (in radians)
  51518. * @param beta defines beta angle (in radians)
  51519. * @param radius defines radius
  51520. * @param target defines camera target
  51521. * @param interaxialDistance defines distance between each color axis
  51522. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51523. * @param scene defines the hosting scene
  51524. */
  51525. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51526. /**
  51527. * Gets camera class name
  51528. * @returns StereoscopicArcRotateCamera
  51529. */
  51530. getClassName(): string;
  51531. }
  51532. }
  51533. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51534. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51535. import { Scene } from "babylonjs/scene";
  51536. import { Vector3 } from "babylonjs/Maths/math.vector";
  51537. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51538. /**
  51539. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51540. * @see https://doc.babylonjs.com/features/cameras
  51541. */
  51542. export class StereoscopicFreeCamera extends FreeCamera {
  51543. /**
  51544. * Creates a new StereoscopicFreeCamera
  51545. * @param name defines camera name
  51546. * @param position defines initial position
  51547. * @param interaxialDistance defines distance between each color axis
  51548. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51549. * @param scene defines the hosting scene
  51550. */
  51551. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51552. /**
  51553. * Gets camera class name
  51554. * @returns StereoscopicFreeCamera
  51555. */
  51556. getClassName(): string;
  51557. }
  51558. }
  51559. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51560. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51561. import { Scene } from "babylonjs/scene";
  51562. import { Vector3 } from "babylonjs/Maths/math.vector";
  51563. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51564. /**
  51565. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51566. * @see https://doc.babylonjs.com/features/cameras
  51567. */
  51568. export class StereoscopicGamepadCamera extends GamepadCamera {
  51569. /**
  51570. * Creates a new StereoscopicGamepadCamera
  51571. * @param name defines camera name
  51572. * @param position defines initial position
  51573. * @param interaxialDistance defines distance between each color axis
  51574. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51575. * @param scene defines the hosting scene
  51576. */
  51577. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51578. /**
  51579. * Gets camera class name
  51580. * @returns StereoscopicGamepadCamera
  51581. */
  51582. getClassName(): string;
  51583. }
  51584. }
  51585. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51586. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51587. import { Scene } from "babylonjs/scene";
  51588. import { Vector3 } from "babylonjs/Maths/math.vector";
  51589. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51590. /**
  51591. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51592. * @see https://doc.babylonjs.com/features/cameras
  51593. */
  51594. export class StereoscopicUniversalCamera extends UniversalCamera {
  51595. /**
  51596. * Creates a new StereoscopicUniversalCamera
  51597. * @param name defines camera name
  51598. * @param position defines initial position
  51599. * @param interaxialDistance defines distance between each color axis
  51600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51601. * @param scene defines the hosting scene
  51602. */
  51603. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51604. /**
  51605. * Gets camera class name
  51606. * @returns StereoscopicUniversalCamera
  51607. */
  51608. getClassName(): string;
  51609. }
  51610. }
  51611. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51612. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51613. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51614. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51615. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51616. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51617. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51618. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51619. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51620. }
  51621. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51622. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51623. import { Scene } from "babylonjs/scene";
  51624. import { Vector3 } from "babylonjs/Maths/math.vector";
  51625. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51626. /**
  51627. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51628. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51629. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51630. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51631. */
  51632. export class VirtualJoysticksCamera extends FreeCamera {
  51633. /**
  51634. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51635. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51636. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51637. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51638. * @param name Define the name of the camera in the scene
  51639. * @param position Define the start position of the camera in the scene
  51640. * @param scene Define the scene the camera belongs to
  51641. */
  51642. constructor(name: string, position: Vector3, scene: Scene);
  51643. /**
  51644. * Gets the current object class name.
  51645. * @return the class name
  51646. */
  51647. getClassName(): string;
  51648. }
  51649. }
  51650. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51651. import { Matrix } from "babylonjs/Maths/math.vector";
  51652. /**
  51653. * This represents all the required metrics to create a VR camera.
  51654. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51655. */
  51656. export class VRCameraMetrics {
  51657. /**
  51658. * Define the horizontal resolution off the screen.
  51659. */
  51660. hResolution: number;
  51661. /**
  51662. * Define the vertical resolution off the screen.
  51663. */
  51664. vResolution: number;
  51665. /**
  51666. * Define the horizontal screen size.
  51667. */
  51668. hScreenSize: number;
  51669. /**
  51670. * Define the vertical screen size.
  51671. */
  51672. vScreenSize: number;
  51673. /**
  51674. * Define the vertical screen center position.
  51675. */
  51676. vScreenCenter: number;
  51677. /**
  51678. * Define the distance of the eyes to the screen.
  51679. */
  51680. eyeToScreenDistance: number;
  51681. /**
  51682. * Define the distance between both lenses
  51683. */
  51684. lensSeparationDistance: number;
  51685. /**
  51686. * Define the distance between both viewer's eyes.
  51687. */
  51688. interpupillaryDistance: number;
  51689. /**
  51690. * Define the distortion factor of the VR postprocess.
  51691. * Please, touch with care.
  51692. */
  51693. distortionK: number[];
  51694. /**
  51695. * Define the chromatic aberration correction factors for the VR post process.
  51696. */
  51697. chromaAbCorrection: number[];
  51698. /**
  51699. * Define the scale factor of the post process.
  51700. * The smaller the better but the slower.
  51701. */
  51702. postProcessScaleFactor: number;
  51703. /**
  51704. * Define an offset for the lens center.
  51705. */
  51706. lensCenterOffset: number;
  51707. /**
  51708. * Define if the current vr camera should compensate the distortion of the lense or not.
  51709. */
  51710. compensateDistortion: boolean;
  51711. /**
  51712. * Defines if multiview should be enabled when rendering (Default: false)
  51713. */
  51714. multiviewEnabled: boolean;
  51715. /**
  51716. * Gets the rendering aspect ratio based on the provided resolutions.
  51717. */
  51718. get aspectRatio(): number;
  51719. /**
  51720. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51721. */
  51722. get aspectRatioFov(): number;
  51723. /**
  51724. * @hidden
  51725. */
  51726. get leftHMatrix(): Matrix;
  51727. /**
  51728. * @hidden
  51729. */
  51730. get rightHMatrix(): Matrix;
  51731. /**
  51732. * @hidden
  51733. */
  51734. get leftPreViewMatrix(): Matrix;
  51735. /**
  51736. * @hidden
  51737. */
  51738. get rightPreViewMatrix(): Matrix;
  51739. /**
  51740. * Get the default VRMetrics based on the most generic setup.
  51741. * @returns the default vr metrics
  51742. */
  51743. static GetDefault(): VRCameraMetrics;
  51744. }
  51745. }
  51746. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51747. /** @hidden */
  51748. export var vrDistortionCorrectionPixelShader: {
  51749. name: string;
  51750. shader: string;
  51751. };
  51752. }
  51753. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51754. import { Camera } from "babylonjs/Cameras/camera";
  51755. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51756. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51757. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51758. /**
  51759. * VRDistortionCorrectionPostProcess used for mobile VR
  51760. */
  51761. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51762. private _isRightEye;
  51763. private _distortionFactors;
  51764. private _postProcessScaleFactor;
  51765. private _lensCenterOffset;
  51766. private _scaleIn;
  51767. private _scaleFactor;
  51768. private _lensCenter;
  51769. /**
  51770. * Gets a string identifying the name of the class
  51771. * @returns "VRDistortionCorrectionPostProcess" string
  51772. */
  51773. getClassName(): string;
  51774. /**
  51775. * Initializes the VRDistortionCorrectionPostProcess
  51776. * @param name The name of the effect.
  51777. * @param camera The camera to apply the render pass to.
  51778. * @param isRightEye If this is for the right eye distortion
  51779. * @param vrMetrics All the required metrics for the VR camera
  51780. */
  51781. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51782. }
  51783. }
  51784. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51785. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51786. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51787. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51788. import { Scene } from "babylonjs/scene";
  51789. import { Vector3 } from "babylonjs/Maths/math.vector";
  51790. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51791. import "babylonjs/Cameras/RigModes/vrRigMode";
  51792. /**
  51793. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51794. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51795. */
  51796. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51797. /**
  51798. * Creates a new VRDeviceOrientationArcRotateCamera
  51799. * @param name defines camera name
  51800. * @param alpha defines the camera rotation along the logitudinal axis
  51801. * @param beta defines the camera rotation along the latitudinal axis
  51802. * @param radius defines the camera distance from its target
  51803. * @param target defines the camera target
  51804. * @param scene defines the scene the camera belongs to
  51805. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51806. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51807. */
  51808. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51809. /**
  51810. * Gets camera class name
  51811. * @returns VRDeviceOrientationArcRotateCamera
  51812. */
  51813. getClassName(): string;
  51814. }
  51815. }
  51816. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51817. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51818. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51819. import { Scene } from "babylonjs/scene";
  51820. import { Vector3 } from "babylonjs/Maths/math.vector";
  51821. import "babylonjs/Cameras/RigModes/vrRigMode";
  51822. /**
  51823. * Camera used to simulate VR rendering (based on FreeCamera)
  51824. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51825. */
  51826. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51827. /**
  51828. * Creates a new VRDeviceOrientationFreeCamera
  51829. * @param name defines camera name
  51830. * @param position defines the start position of the camera
  51831. * @param scene defines the scene the camera belongs to
  51832. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51833. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51834. */
  51835. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51836. /**
  51837. * Gets camera class name
  51838. * @returns VRDeviceOrientationFreeCamera
  51839. */
  51840. getClassName(): string;
  51841. }
  51842. }
  51843. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51844. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51845. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51846. import { Scene } from "babylonjs/scene";
  51847. import { Vector3 } from "babylonjs/Maths/math.vector";
  51848. import "babylonjs/Gamepads/gamepadSceneComponent";
  51849. /**
  51850. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51851. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51852. */
  51853. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51854. /**
  51855. * Creates a new VRDeviceOrientationGamepadCamera
  51856. * @param name defines camera name
  51857. * @param position defines the start position of the camera
  51858. * @param scene defines the scene the camera belongs to
  51859. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51860. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51861. */
  51862. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51863. /**
  51864. * Gets camera class name
  51865. * @returns VRDeviceOrientationGamepadCamera
  51866. */
  51867. getClassName(): string;
  51868. }
  51869. }
  51870. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51871. import { Scene } from "babylonjs/scene";
  51872. import { Texture } from "babylonjs/Materials/Textures/texture";
  51873. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51874. /**
  51875. * A class extending Texture allowing drawing on a texture
  51876. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51877. */
  51878. export class DynamicTexture extends Texture {
  51879. private _generateMipMaps;
  51880. private _canvas;
  51881. private _context;
  51882. /**
  51883. * Creates a DynamicTexture
  51884. * @param name defines the name of the texture
  51885. * @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
  51886. * @param scene defines the scene where you want the texture
  51887. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51888. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51889. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51890. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51891. */
  51892. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51893. /**
  51894. * Get the current class name of the texture useful for serialization or dynamic coding.
  51895. * @returns "DynamicTexture"
  51896. */
  51897. getClassName(): string;
  51898. /**
  51899. * Gets the current state of canRescale
  51900. */
  51901. get canRescale(): boolean;
  51902. private _recreate;
  51903. /**
  51904. * Scales the texture
  51905. * @param ratio the scale factor to apply to both width and height
  51906. */
  51907. scale(ratio: number): void;
  51908. /**
  51909. * Resizes the texture
  51910. * @param width the new width
  51911. * @param height the new height
  51912. */
  51913. scaleTo(width: number, height: number): void;
  51914. /**
  51915. * Gets the context of the canvas used by the texture
  51916. * @returns the canvas context of the dynamic texture
  51917. */
  51918. getContext(): CanvasRenderingContext2D;
  51919. /**
  51920. * Clears the texture
  51921. */
  51922. clear(): void;
  51923. /**
  51924. * Updates the texture
  51925. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51926. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51927. */
  51928. update(invertY?: boolean, premulAlpha?: boolean): void;
  51929. /**
  51930. * Draws text onto the texture
  51931. * @param text defines the text to be drawn
  51932. * @param x defines the placement of the text from the left
  51933. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51934. * @param font defines the font to be used with font-style, font-size, font-name
  51935. * @param color defines the color used for the text
  51936. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51937. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51938. * @param update defines whether texture is immediately update (default is true)
  51939. */
  51940. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51941. /**
  51942. * Clones the texture
  51943. * @returns the clone of the texture.
  51944. */
  51945. clone(): DynamicTexture;
  51946. /**
  51947. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51948. * @returns a serialized dynamic texture object
  51949. */
  51950. serialize(): any;
  51951. private _IsCanvasElement;
  51952. /** @hidden */
  51953. _rebuild(): void;
  51954. }
  51955. }
  51956. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51957. import { Scene } from "babylonjs/scene";
  51958. import { Color3 } from "babylonjs/Maths/math.color";
  51959. import { Mesh } from "babylonjs/Meshes/mesh";
  51960. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51961. import { Nullable } from "babylonjs/types";
  51962. /**
  51963. * Class containing static functions to help procedurally build meshes
  51964. */
  51965. export class GroundBuilder {
  51966. /**
  51967. * Creates a ground mesh
  51968. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51969. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51971. * @param name defines the name of the mesh
  51972. * @param options defines the options used to create the mesh
  51973. * @param scene defines the hosting scene
  51974. * @returns the ground mesh
  51975. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51976. */
  51977. static CreateGround(name: string, options: {
  51978. width?: number;
  51979. height?: number;
  51980. subdivisions?: number;
  51981. subdivisionsX?: number;
  51982. subdivisionsY?: number;
  51983. updatable?: boolean;
  51984. }, scene: any): Mesh;
  51985. /**
  51986. * Creates a tiled ground mesh
  51987. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51988. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51989. * * 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
  51990. * * 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
  51991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51992. * @param name defines the name of the mesh
  51993. * @param options defines the options used to create the mesh
  51994. * @param scene defines the hosting scene
  51995. * @returns the tiled ground mesh
  51996. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51997. */
  51998. static CreateTiledGround(name: string, options: {
  51999. xmin: number;
  52000. zmin: number;
  52001. xmax: number;
  52002. zmax: number;
  52003. subdivisions?: {
  52004. w: number;
  52005. h: number;
  52006. };
  52007. precision?: {
  52008. w: number;
  52009. h: number;
  52010. };
  52011. updatable?: boolean;
  52012. }, scene?: Nullable<Scene>): Mesh;
  52013. /**
  52014. * Creates a ground mesh from a height map
  52015. * * The parameter `url` sets the URL of the height map image resource.
  52016. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52017. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52018. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52019. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52020. * * 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.
  52021. * * 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).
  52022. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52024. * @param name defines the name of the mesh
  52025. * @param url defines the url to the height map
  52026. * @param options defines the options used to create the mesh
  52027. * @param scene defines the hosting scene
  52028. * @returns the ground mesh
  52029. * @see https://doc.babylonjs.com/babylon101/height_map
  52030. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52031. */
  52032. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52033. width?: number;
  52034. height?: number;
  52035. subdivisions?: number;
  52036. minHeight?: number;
  52037. maxHeight?: number;
  52038. colorFilter?: Color3;
  52039. alphaFilter?: number;
  52040. updatable?: boolean;
  52041. onReady?: (mesh: GroundMesh) => void;
  52042. }, scene?: Nullable<Scene>): GroundMesh;
  52043. }
  52044. }
  52045. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52046. import { Vector4 } from "babylonjs/Maths/math.vector";
  52047. import { Mesh } from "babylonjs/Meshes/mesh";
  52048. /**
  52049. * Class containing static functions to help procedurally build meshes
  52050. */
  52051. export class TorusBuilder {
  52052. /**
  52053. * Creates a torus mesh
  52054. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52055. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52056. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52060. * @param name defines the name of the mesh
  52061. * @param options defines the options used to create the mesh
  52062. * @param scene defines the hosting scene
  52063. * @returns the torus mesh
  52064. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52065. */
  52066. static CreateTorus(name: string, options: {
  52067. diameter?: number;
  52068. thickness?: number;
  52069. tessellation?: number;
  52070. updatable?: boolean;
  52071. sideOrientation?: number;
  52072. frontUVs?: Vector4;
  52073. backUVs?: Vector4;
  52074. }, scene: any): Mesh;
  52075. }
  52076. }
  52077. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52078. import { Vector4 } from "babylonjs/Maths/math.vector";
  52079. import { Color4 } from "babylonjs/Maths/math.color";
  52080. import { Mesh } from "babylonjs/Meshes/mesh";
  52081. /**
  52082. * Class containing static functions to help procedurally build meshes
  52083. */
  52084. export class CylinderBuilder {
  52085. /**
  52086. * Creates a cylinder or a cone mesh
  52087. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52088. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52089. * * 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.
  52090. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52091. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52092. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52093. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52094. * * 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).
  52095. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52096. * * 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).
  52097. * * 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
  52098. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52099. * * 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
  52100. * * 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.
  52101. * * If `enclose` is false, a ring surface is one element.
  52102. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52103. * * 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
  52104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52107. * @param name defines the name of the mesh
  52108. * @param options defines the options used to create the mesh
  52109. * @param scene defines the hosting scene
  52110. * @returns the cylinder mesh
  52111. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52112. */
  52113. static CreateCylinder(name: string, options: {
  52114. height?: number;
  52115. diameterTop?: number;
  52116. diameterBottom?: number;
  52117. diameter?: number;
  52118. tessellation?: number;
  52119. subdivisions?: number;
  52120. arc?: number;
  52121. faceColors?: Color4[];
  52122. faceUV?: Vector4[];
  52123. updatable?: boolean;
  52124. hasRings?: boolean;
  52125. enclose?: boolean;
  52126. cap?: number;
  52127. sideOrientation?: number;
  52128. frontUVs?: Vector4;
  52129. backUVs?: Vector4;
  52130. }, scene: any): Mesh;
  52131. }
  52132. }
  52133. declare module "babylonjs/XR/webXRTypes" {
  52134. import { Nullable } from "babylonjs/types";
  52135. import { IDisposable } from "babylonjs/scene";
  52136. /**
  52137. * States of the webXR experience
  52138. */
  52139. export enum WebXRState {
  52140. /**
  52141. * Transitioning to being in XR mode
  52142. */
  52143. ENTERING_XR = 0,
  52144. /**
  52145. * Transitioning to non XR mode
  52146. */
  52147. EXITING_XR = 1,
  52148. /**
  52149. * In XR mode and presenting
  52150. */
  52151. IN_XR = 2,
  52152. /**
  52153. * Not entered XR mode
  52154. */
  52155. NOT_IN_XR = 3
  52156. }
  52157. /**
  52158. * The state of the XR camera's tracking
  52159. */
  52160. export enum WebXRTrackingState {
  52161. /**
  52162. * No transformation received, device is not being tracked
  52163. */
  52164. NOT_TRACKING = 0,
  52165. /**
  52166. * Tracking lost - using emulated position
  52167. */
  52168. TRACKING_LOST = 1,
  52169. /**
  52170. * Transformation tracking works normally
  52171. */
  52172. TRACKING = 2
  52173. }
  52174. /**
  52175. * Abstraction of the XR render target
  52176. */
  52177. export interface WebXRRenderTarget extends IDisposable {
  52178. /**
  52179. * xrpresent context of the canvas which can be used to display/mirror xr content
  52180. */
  52181. canvasContext: WebGLRenderingContext;
  52182. /**
  52183. * xr layer for the canvas
  52184. */
  52185. xrLayer: Nullable<XRWebGLLayer>;
  52186. /**
  52187. * Initializes the xr layer for the session
  52188. * @param xrSession xr session
  52189. * @returns a promise that will resolve once the XR Layer has been created
  52190. */
  52191. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52192. }
  52193. }
  52194. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52195. import { Nullable } from "babylonjs/types";
  52196. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52197. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52198. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52199. import { Observable } from "babylonjs/Misc/observable";
  52200. /**
  52201. * COnfiguration object for WebXR output canvas
  52202. */
  52203. export class WebXRManagedOutputCanvasOptions {
  52204. /**
  52205. * An optional canvas in case you wish to create it yourself and provide it here.
  52206. * If not provided, a new canvas will be created
  52207. */
  52208. canvasElement?: HTMLCanvasElement;
  52209. /**
  52210. * Options for this XR Layer output
  52211. */
  52212. canvasOptions?: XRWebGLLayerInit;
  52213. /**
  52214. * CSS styling for a newly created canvas (if not provided)
  52215. */
  52216. newCanvasCssStyle?: string;
  52217. /**
  52218. * Get the default values of the configuration object
  52219. * @param engine defines the engine to use (can be null)
  52220. * @returns default values of this configuration object
  52221. */
  52222. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52223. }
  52224. /**
  52225. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52226. */
  52227. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52228. private _options;
  52229. private _canvas;
  52230. private _engine;
  52231. private _originalCanvasSize;
  52232. /**
  52233. * Rendering context of the canvas which can be used to display/mirror xr content
  52234. */
  52235. canvasContext: WebGLRenderingContext;
  52236. /**
  52237. * xr layer for the canvas
  52238. */
  52239. xrLayer: Nullable<XRWebGLLayer>;
  52240. /**
  52241. * Obseervers registered here will be triggered when the xr layer was initialized
  52242. */
  52243. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52244. /**
  52245. * Initializes the canvas to be added/removed upon entering/exiting xr
  52246. * @param _xrSessionManager The XR Session manager
  52247. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52248. */
  52249. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52250. /**
  52251. * Disposes of the object
  52252. */
  52253. dispose(): void;
  52254. /**
  52255. * Initializes the xr layer for the session
  52256. * @param xrSession xr session
  52257. * @returns a promise that will resolve once the XR Layer has been created
  52258. */
  52259. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52260. private _addCanvas;
  52261. private _removeCanvas;
  52262. private _setCanvasSize;
  52263. private _setManagedOutputCanvas;
  52264. }
  52265. }
  52266. declare module "babylonjs/XR/webXRSessionManager" {
  52267. import { Observable } from "babylonjs/Misc/observable";
  52268. import { Nullable } from "babylonjs/types";
  52269. import { IDisposable, Scene } from "babylonjs/scene";
  52270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52271. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52272. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52273. /**
  52274. * Manages an XRSession to work with Babylon's engine
  52275. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52276. */
  52277. export class WebXRSessionManager implements IDisposable {
  52278. /** The scene which the session should be created for */
  52279. scene: Scene;
  52280. private _referenceSpace;
  52281. private _rttProvider;
  52282. private _sessionEnded;
  52283. private _xrNavigator;
  52284. private baseLayer;
  52285. /**
  52286. * The base reference space from which the session started. good if you want to reset your
  52287. * reference space
  52288. */
  52289. baseReferenceSpace: XRReferenceSpace;
  52290. /**
  52291. * Current XR frame
  52292. */
  52293. currentFrame: Nullable<XRFrame>;
  52294. /** WebXR timestamp updated every frame */
  52295. currentTimestamp: number;
  52296. /**
  52297. * Used just in case of a failure to initialize an immersive session.
  52298. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52299. */
  52300. defaultHeightCompensation: number;
  52301. /**
  52302. * Fires every time a new xrFrame arrives which can be used to update the camera
  52303. */
  52304. onXRFrameObservable: Observable<XRFrame>;
  52305. /**
  52306. * Fires when the reference space changed
  52307. */
  52308. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52309. /**
  52310. * Fires when the xr session is ended either by the device or manually done
  52311. */
  52312. onXRSessionEnded: Observable<any>;
  52313. /**
  52314. * Fires when the xr session is ended either by the device or manually done
  52315. */
  52316. onXRSessionInit: Observable<XRSession>;
  52317. /**
  52318. * Underlying xr session
  52319. */
  52320. session: XRSession;
  52321. /**
  52322. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52323. * or get the offset the player is currently at.
  52324. */
  52325. viewerReferenceSpace: XRReferenceSpace;
  52326. /**
  52327. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52328. * @param scene The scene which the session should be created for
  52329. */
  52330. constructor(
  52331. /** The scene which the session should be created for */
  52332. scene: Scene);
  52333. /**
  52334. * The current reference space used in this session. This reference space can constantly change!
  52335. * It is mainly used to offset the camera's position.
  52336. */
  52337. get referenceSpace(): XRReferenceSpace;
  52338. /**
  52339. * Set a new reference space and triggers the observable
  52340. */
  52341. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52342. /**
  52343. * Disposes of the session manager
  52344. */
  52345. dispose(): void;
  52346. /**
  52347. * Stops the xrSession and restores the render loop
  52348. * @returns Promise which resolves after it exits XR
  52349. */
  52350. exitXRAsync(): Promise<void>;
  52351. /**
  52352. * Gets the correct render target texture to be rendered this frame for this eye
  52353. * @param eye the eye for which to get the render target
  52354. * @returns the render target for the specified eye
  52355. */
  52356. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52357. /**
  52358. * Creates a WebXRRenderTarget object for the XR session
  52359. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52360. * @param options optional options to provide when creating a new render target
  52361. * @returns a WebXR render target to which the session can render
  52362. */
  52363. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52364. /**
  52365. * Initializes the manager
  52366. * After initialization enterXR can be called to start an XR session
  52367. * @returns Promise which resolves after it is initialized
  52368. */
  52369. initializeAsync(): Promise<void>;
  52370. /**
  52371. * Initializes an xr session
  52372. * @param xrSessionMode mode to initialize
  52373. * @param xrSessionInit defines optional and required values to pass to the session builder
  52374. * @returns a promise which will resolve once the session has been initialized
  52375. */
  52376. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52377. /**
  52378. * Checks if a session would be supported for the creation options specified
  52379. * @param sessionMode session mode to check if supported eg. immersive-vr
  52380. * @returns A Promise that resolves to true if supported and false if not
  52381. */
  52382. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52383. /**
  52384. * Resets the reference space to the one started the session
  52385. */
  52386. resetReferenceSpace(): void;
  52387. /**
  52388. * Starts rendering to the xr layer
  52389. */
  52390. runXRRenderLoop(): void;
  52391. /**
  52392. * Sets the reference space on the xr session
  52393. * @param referenceSpaceType space to set
  52394. * @returns a promise that will resolve once the reference space has been set
  52395. */
  52396. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52397. /**
  52398. * Updates the render state of the session
  52399. * @param state state to set
  52400. * @returns a promise that resolves once the render state has been updated
  52401. */
  52402. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52403. /**
  52404. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52405. * @param sessionMode defines the session to test
  52406. * @returns a promise with boolean as final value
  52407. */
  52408. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52409. private _createRenderTargetTexture;
  52410. }
  52411. }
  52412. declare module "babylonjs/XR/webXRCamera" {
  52413. import { Vector3 } from "babylonjs/Maths/math.vector";
  52414. import { Scene } from "babylonjs/scene";
  52415. import { Camera } from "babylonjs/Cameras/camera";
  52416. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52417. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52418. import { Observable } from "babylonjs/Misc/observable";
  52419. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52420. /**
  52421. * WebXR Camera which holds the views for the xrSession
  52422. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52423. */
  52424. export class WebXRCamera extends FreeCamera {
  52425. private _xrSessionManager;
  52426. private _firstFrame;
  52427. private _referenceQuaternion;
  52428. private _referencedPosition;
  52429. private _xrInvPositionCache;
  52430. private _xrInvQuaternionCache;
  52431. private _trackingState;
  52432. /**
  52433. * Observable raised before camera teleportation
  52434. */
  52435. onBeforeCameraTeleport: Observable<Vector3>;
  52436. /**
  52437. * Observable raised after camera teleportation
  52438. */
  52439. onAfterCameraTeleport: Observable<Vector3>;
  52440. /**
  52441. * Notifies when the camera's tracking state has changed.
  52442. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52443. */
  52444. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52445. /**
  52446. * Should position compensation execute on first frame.
  52447. * This is used when copying the position from a native (non XR) camera
  52448. */
  52449. compensateOnFirstFrame: boolean;
  52450. /**
  52451. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52452. * @param name the name of the camera
  52453. * @param scene the scene to add the camera to
  52454. * @param _xrSessionManager a constructed xr session manager
  52455. */
  52456. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52457. /**
  52458. * Get the current XR tracking state of the camera
  52459. */
  52460. get trackingState(): WebXRTrackingState;
  52461. private _setTrackingState;
  52462. /**
  52463. * Return the user's height, unrelated to the current ground.
  52464. * This will be the y position of this camera, when ground level is 0.
  52465. */
  52466. get realWorldHeight(): number;
  52467. /** @hidden */
  52468. _updateForDualEyeDebugging(): void;
  52469. /**
  52470. * Sets this camera's transformation based on a non-vr camera
  52471. * @param otherCamera the non-vr camera to copy the transformation from
  52472. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52473. */
  52474. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52475. /**
  52476. * Gets the current instance class name ("WebXRCamera").
  52477. * @returns the class name
  52478. */
  52479. getClassName(): string;
  52480. private _rotate180;
  52481. private _updateFromXRSession;
  52482. private _updateNumberOfRigCameras;
  52483. private _updateReferenceSpace;
  52484. private _updateReferenceSpaceOffset;
  52485. }
  52486. }
  52487. declare module "babylonjs/XR/webXRFeaturesManager" {
  52488. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52489. import { IDisposable } from "babylonjs/scene";
  52490. /**
  52491. * Defining the interface required for a (webxr) feature
  52492. */
  52493. export interface IWebXRFeature extends IDisposable {
  52494. /**
  52495. * Is this feature attached
  52496. */
  52497. attached: boolean;
  52498. /**
  52499. * Should auto-attach be disabled?
  52500. */
  52501. disableAutoAttach: boolean;
  52502. /**
  52503. * Attach the feature to the session
  52504. * Will usually be called by the features manager
  52505. *
  52506. * @param force should attachment be forced (even when already attached)
  52507. * @returns true if successful.
  52508. */
  52509. attach(force?: boolean): boolean;
  52510. /**
  52511. * Detach the feature from the session
  52512. * Will usually be called by the features manager
  52513. *
  52514. * @returns true if successful.
  52515. */
  52516. detach(): boolean;
  52517. /**
  52518. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52519. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52520. *
  52521. * @returns whether or not the feature is compatible in this environment
  52522. */
  52523. isCompatible(): boolean;
  52524. /**
  52525. * Was this feature disposed;
  52526. */
  52527. isDisposed: boolean;
  52528. /**
  52529. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52530. */
  52531. xrNativeFeatureName?: string;
  52532. /**
  52533. * A list of (Babylon WebXR) features this feature depends on
  52534. */
  52535. dependsOn?: string[];
  52536. }
  52537. /**
  52538. * A list of the currently available features without referencing them
  52539. */
  52540. export class WebXRFeatureName {
  52541. /**
  52542. * The name of the anchor system feature
  52543. */
  52544. static readonly ANCHOR_SYSTEM: string;
  52545. /**
  52546. * The name of the background remover feature
  52547. */
  52548. static readonly BACKGROUND_REMOVER: string;
  52549. /**
  52550. * The name of the hit test feature
  52551. */
  52552. static readonly HIT_TEST: string;
  52553. /**
  52554. * physics impostors for xr controllers feature
  52555. */
  52556. static readonly PHYSICS_CONTROLLERS: string;
  52557. /**
  52558. * The name of the plane detection feature
  52559. */
  52560. static readonly PLANE_DETECTION: string;
  52561. /**
  52562. * The name of the pointer selection feature
  52563. */
  52564. static readonly POINTER_SELECTION: string;
  52565. /**
  52566. * The name of the teleportation feature
  52567. */
  52568. static readonly TELEPORTATION: string;
  52569. /**
  52570. * The name of the feature points feature.
  52571. */
  52572. static readonly FEATURE_POINTS: string;
  52573. /**
  52574. * The name of the hand tracking feature.
  52575. */
  52576. static readonly HAND_TRACKING: string;
  52577. }
  52578. /**
  52579. * Defining the constructor of a feature. Used to register the modules.
  52580. */
  52581. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52582. /**
  52583. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52584. * It is mainly used in AR sessions.
  52585. *
  52586. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52587. */
  52588. export class WebXRFeaturesManager implements IDisposable {
  52589. private _xrSessionManager;
  52590. private static readonly _AvailableFeatures;
  52591. private _features;
  52592. /**
  52593. * constructs a new features manages.
  52594. *
  52595. * @param _xrSessionManager an instance of WebXRSessionManager
  52596. */
  52597. constructor(_xrSessionManager: WebXRSessionManager);
  52598. /**
  52599. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52600. * Mainly used internally.
  52601. *
  52602. * @param featureName the name of the feature to register
  52603. * @param constructorFunction the function used to construct the module
  52604. * @param version the (babylon) version of the module
  52605. * @param stable is that a stable version of this module
  52606. */
  52607. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52608. /**
  52609. * Returns a constructor of a specific feature.
  52610. *
  52611. * @param featureName the name of the feature to construct
  52612. * @param version the version of the feature to load
  52613. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52614. * @param options optional options provided to the module.
  52615. * @returns a function that, when called, will return a new instance of this feature
  52616. */
  52617. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52618. /**
  52619. * Can be used to return the list of features currently registered
  52620. *
  52621. * @returns an Array of available features
  52622. */
  52623. static GetAvailableFeatures(): string[];
  52624. /**
  52625. * Gets the versions available for a specific feature
  52626. * @param featureName the name of the feature
  52627. * @returns an array with the available versions
  52628. */
  52629. static GetAvailableVersions(featureName: string): string[];
  52630. /**
  52631. * Return the latest unstable version of this feature
  52632. * @param featureName the name of the feature to search
  52633. * @returns the version number. if not found will return -1
  52634. */
  52635. static GetLatestVersionOfFeature(featureName: string): number;
  52636. /**
  52637. * Return the latest stable version of this feature
  52638. * @param featureName the name of the feature to search
  52639. * @returns the version number. if not found will return -1
  52640. */
  52641. static GetStableVersionOfFeature(featureName: string): number;
  52642. /**
  52643. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52644. * Can be used during a session to start a feature
  52645. * @param featureName the name of feature to attach
  52646. */
  52647. attachFeature(featureName: string): void;
  52648. /**
  52649. * Can be used inside a session or when the session ends to detach a specific feature
  52650. * @param featureName the name of the feature to detach
  52651. */
  52652. detachFeature(featureName: string): void;
  52653. /**
  52654. * Used to disable an already-enabled feature
  52655. * The feature will be disposed and will be recreated once enabled.
  52656. * @param featureName the feature to disable
  52657. * @returns true if disable was successful
  52658. */
  52659. disableFeature(featureName: string | {
  52660. Name: string;
  52661. }): boolean;
  52662. /**
  52663. * dispose this features manager
  52664. */
  52665. dispose(): void;
  52666. /**
  52667. * 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.
  52668. * 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.
  52669. *
  52670. * @param featureName the name of the feature to load or the class of the feature
  52671. * @param version optional version to load. if not provided the latest version will be enabled
  52672. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52673. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52674. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52675. * @returns a new constructed feature or throws an error if feature not found.
  52676. */
  52677. enableFeature(featureName: string | {
  52678. Name: string;
  52679. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52680. /**
  52681. * get the implementation of an enabled feature.
  52682. * @param featureName the name of the feature to load
  52683. * @returns the feature class, if found
  52684. */
  52685. getEnabledFeature(featureName: string): IWebXRFeature;
  52686. /**
  52687. * Get the list of enabled features
  52688. * @returns an array of enabled features
  52689. */
  52690. getEnabledFeatures(): string[];
  52691. /**
  52692. * This function will exten the session creation configuration object with enabled features.
  52693. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52694. * according to the defined "required" variable, provided during enableFeature call
  52695. * @param xrSessionInit the xr Session init object to extend
  52696. *
  52697. * @returns an extended XRSessionInit object
  52698. */
  52699. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52700. }
  52701. }
  52702. declare module "babylonjs/XR/webXRExperienceHelper" {
  52703. import { Observable } from "babylonjs/Misc/observable";
  52704. import { IDisposable, Scene } from "babylonjs/scene";
  52705. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52706. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52707. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52708. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52709. /**
  52710. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52711. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52712. */
  52713. export class WebXRExperienceHelper implements IDisposable {
  52714. private scene;
  52715. private _nonVRCamera;
  52716. private _originalSceneAutoClear;
  52717. private _supported;
  52718. /**
  52719. * Camera used to render xr content
  52720. */
  52721. camera: WebXRCamera;
  52722. /** A features manager for this xr session */
  52723. featuresManager: WebXRFeaturesManager;
  52724. /**
  52725. * Observers registered here will be triggered after the camera's initial transformation is set
  52726. * This can be used to set a different ground level or an extra rotation.
  52727. *
  52728. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52729. * to the position set after this observable is done executing.
  52730. */
  52731. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52732. /**
  52733. * Fires when the state of the experience helper has changed
  52734. */
  52735. onStateChangedObservable: Observable<WebXRState>;
  52736. /** Session manager used to keep track of xr session */
  52737. sessionManager: WebXRSessionManager;
  52738. /**
  52739. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52740. */
  52741. state: WebXRState;
  52742. /**
  52743. * Creates a WebXRExperienceHelper
  52744. * @param scene The scene the helper should be created in
  52745. */
  52746. private constructor();
  52747. /**
  52748. * Creates the experience helper
  52749. * @param scene the scene to attach the experience helper to
  52750. * @returns a promise for the experience helper
  52751. */
  52752. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52753. /**
  52754. * Disposes of the experience helper
  52755. */
  52756. dispose(): void;
  52757. /**
  52758. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52759. * @param sessionMode options for the XR session
  52760. * @param referenceSpaceType frame of reference of the XR session
  52761. * @param renderTarget the output canvas that will be used to enter XR mode
  52762. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52763. * @returns promise that resolves after xr mode has entered
  52764. */
  52765. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52766. /**
  52767. * Exits XR mode and returns the scene to its original state
  52768. * @returns promise that resolves after xr mode has exited
  52769. */
  52770. exitXRAsync(): Promise<void>;
  52771. private _nonXRToXRCamera;
  52772. private _setState;
  52773. }
  52774. }
  52775. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52776. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52777. import { Observable } from "babylonjs/Misc/observable";
  52778. import { IDisposable } from "babylonjs/scene";
  52779. /**
  52780. * X-Y values for axes in WebXR
  52781. */
  52782. export interface IWebXRMotionControllerAxesValue {
  52783. /**
  52784. * The value of the x axis
  52785. */
  52786. x: number;
  52787. /**
  52788. * The value of the y-axis
  52789. */
  52790. y: number;
  52791. }
  52792. /**
  52793. * changed / previous values for the values of this component
  52794. */
  52795. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52796. /**
  52797. * current (this frame) value
  52798. */
  52799. current: T;
  52800. /**
  52801. * previous (last change) value
  52802. */
  52803. previous: T;
  52804. }
  52805. /**
  52806. * Represents changes in the component between current frame and last values recorded
  52807. */
  52808. export interface IWebXRMotionControllerComponentChanges {
  52809. /**
  52810. * will be populated with previous and current values if axes changed
  52811. */
  52812. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52813. /**
  52814. * will be populated with previous and current values if pressed changed
  52815. */
  52816. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52817. /**
  52818. * will be populated with previous and current values if touched changed
  52819. */
  52820. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52821. /**
  52822. * will be populated with previous and current values if value changed
  52823. */
  52824. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52825. }
  52826. /**
  52827. * This class represents a single component (for example button or thumbstick) of a motion controller
  52828. */
  52829. export class WebXRControllerComponent implements IDisposable {
  52830. /**
  52831. * the id of this component
  52832. */
  52833. id: string;
  52834. /**
  52835. * the type of the component
  52836. */
  52837. type: MotionControllerComponentType;
  52838. private _buttonIndex;
  52839. private _axesIndices;
  52840. private _axes;
  52841. private _changes;
  52842. private _currentValue;
  52843. private _hasChanges;
  52844. private _pressed;
  52845. private _touched;
  52846. /**
  52847. * button component type
  52848. */
  52849. static BUTTON_TYPE: MotionControllerComponentType;
  52850. /**
  52851. * squeeze component type
  52852. */
  52853. static SQUEEZE_TYPE: MotionControllerComponentType;
  52854. /**
  52855. * Thumbstick component type
  52856. */
  52857. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52858. /**
  52859. * Touchpad component type
  52860. */
  52861. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52862. /**
  52863. * trigger component type
  52864. */
  52865. static TRIGGER_TYPE: MotionControllerComponentType;
  52866. /**
  52867. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52868. * the axes data changes
  52869. */
  52870. onAxisValueChangedObservable: Observable<{
  52871. x: number;
  52872. y: number;
  52873. }>;
  52874. /**
  52875. * Observers registered here will be triggered when the state of a button changes
  52876. * State change is either pressed / touched / value
  52877. */
  52878. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52879. /**
  52880. * Creates a new component for a motion controller.
  52881. * It is created by the motion controller itself
  52882. *
  52883. * @param id the id of this component
  52884. * @param type the type of the component
  52885. * @param _buttonIndex index in the buttons array of the gamepad
  52886. * @param _axesIndices indices of the values in the axes array of the gamepad
  52887. */
  52888. constructor(
  52889. /**
  52890. * the id of this component
  52891. */
  52892. id: string,
  52893. /**
  52894. * the type of the component
  52895. */
  52896. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52897. /**
  52898. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52899. */
  52900. get axes(): IWebXRMotionControllerAxesValue;
  52901. /**
  52902. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52903. */
  52904. get changes(): IWebXRMotionControllerComponentChanges;
  52905. /**
  52906. * Return whether or not the component changed the last frame
  52907. */
  52908. get hasChanges(): boolean;
  52909. /**
  52910. * is the button currently pressed
  52911. */
  52912. get pressed(): boolean;
  52913. /**
  52914. * is the button currently touched
  52915. */
  52916. get touched(): boolean;
  52917. /**
  52918. * Get the current value of this component
  52919. */
  52920. get value(): number;
  52921. /**
  52922. * Dispose this component
  52923. */
  52924. dispose(): void;
  52925. /**
  52926. * Are there axes correlating to this component
  52927. * @return true is axes data is available
  52928. */
  52929. isAxes(): boolean;
  52930. /**
  52931. * Is this component a button (hence - pressable)
  52932. * @returns true if can be pressed
  52933. */
  52934. isButton(): boolean;
  52935. /**
  52936. * update this component using the gamepad object it is in. Called on every frame
  52937. * @param nativeController the native gamepad controller object
  52938. */
  52939. update(nativeController: IMinimalMotionControllerObject): void;
  52940. }
  52941. }
  52942. declare module "babylonjs/Loading/sceneLoader" {
  52943. import { Observable } from "babylonjs/Misc/observable";
  52944. import { Nullable } from "babylonjs/types";
  52945. import { Scene } from "babylonjs/scene";
  52946. import { Engine } from "babylonjs/Engines/engine";
  52947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52948. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52949. import { AssetContainer } from "babylonjs/assetContainer";
  52950. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52951. import { Skeleton } from "babylonjs/Bones/skeleton";
  52952. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52953. import { WebRequest } from "babylonjs/Misc/webRequest";
  52954. /**
  52955. * Interface used to represent data loading progression
  52956. */
  52957. export interface ISceneLoaderProgressEvent {
  52958. /**
  52959. * Defines if data length to load can be evaluated
  52960. */
  52961. readonly lengthComputable: boolean;
  52962. /**
  52963. * Defines the loaded data length
  52964. */
  52965. readonly loaded: number;
  52966. /**
  52967. * Defines the data length to load
  52968. */
  52969. readonly total: number;
  52970. }
  52971. /**
  52972. * Interface used by SceneLoader plugins to define supported file extensions
  52973. */
  52974. export interface ISceneLoaderPluginExtensions {
  52975. /**
  52976. * Defines the list of supported extensions
  52977. */
  52978. [extension: string]: {
  52979. isBinary: boolean;
  52980. };
  52981. }
  52982. /**
  52983. * Interface used by SceneLoader plugin factory
  52984. */
  52985. export interface ISceneLoaderPluginFactory {
  52986. /**
  52987. * Defines the name of the factory
  52988. */
  52989. name: string;
  52990. /**
  52991. * Function called to create a new plugin
  52992. * @return the new plugin
  52993. */
  52994. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52995. /**
  52996. * The callback that returns true if the data can be directly loaded.
  52997. * @param data string containing the file data
  52998. * @returns if the data can be loaded directly
  52999. */
  53000. canDirectLoad?(data: string): boolean;
  53001. }
  53002. /**
  53003. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53004. */
  53005. export interface ISceneLoaderPluginBase {
  53006. /**
  53007. * The friendly name of this plugin.
  53008. */
  53009. name: string;
  53010. /**
  53011. * The file extensions supported by this plugin.
  53012. */
  53013. extensions: string | ISceneLoaderPluginExtensions;
  53014. /**
  53015. * The callback called when loading from a url.
  53016. * @param scene scene loading this url
  53017. * @param url url to load
  53018. * @param onSuccess callback called when the file successfully loads
  53019. * @param onProgress callback called while file is loading (if the server supports this mode)
  53020. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53021. * @param onError callback called when the file fails to load
  53022. * @returns a file request object
  53023. */
  53024. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53025. /**
  53026. * The callback called when loading from a file object.
  53027. * @param scene scene loading this file
  53028. * @param file defines the file to load
  53029. * @param onSuccess defines the callback to call when data is loaded
  53030. * @param onProgress defines the callback to call during loading process
  53031. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53032. * @param onError defines the callback to call when an error occurs
  53033. * @returns a file request object
  53034. */
  53035. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53036. /**
  53037. * The callback that returns true if the data can be directly loaded.
  53038. * @param data string containing the file data
  53039. * @returns if the data can be loaded directly
  53040. */
  53041. canDirectLoad?(data: string): boolean;
  53042. /**
  53043. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53044. * @param scene scene loading this data
  53045. * @param data string containing the data
  53046. * @returns data to pass to the plugin
  53047. */
  53048. directLoad?(scene: Scene, data: string): any;
  53049. /**
  53050. * The callback that allows custom handling of the root url based on the response url.
  53051. * @param rootUrl the original root url
  53052. * @param responseURL the response url if available
  53053. * @returns the new root url
  53054. */
  53055. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53056. }
  53057. /**
  53058. * Interface used to define a SceneLoader plugin
  53059. */
  53060. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53061. /**
  53062. * Import meshes into a scene.
  53063. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53064. * @param scene The scene to import into
  53065. * @param data The data to import
  53066. * @param rootUrl The root url for scene and resources
  53067. * @param meshes The meshes array to import into
  53068. * @param particleSystems The particle systems array to import into
  53069. * @param skeletons The skeletons array to import into
  53070. * @param onError The callback when import fails
  53071. * @returns True if successful or false otherwise
  53072. */
  53073. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53074. /**
  53075. * Load into a scene.
  53076. * @param scene The scene to load into
  53077. * @param data The data to import
  53078. * @param rootUrl The root url for scene and resources
  53079. * @param onError The callback when import fails
  53080. * @returns True if successful or false otherwise
  53081. */
  53082. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53083. /**
  53084. * Load into an asset container.
  53085. * @param scene The scene to load into
  53086. * @param data The data to import
  53087. * @param rootUrl The root url for scene and resources
  53088. * @param onError The callback when import fails
  53089. * @returns The loaded asset container
  53090. */
  53091. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53092. }
  53093. /**
  53094. * Interface used to define an async SceneLoader plugin
  53095. */
  53096. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53097. /**
  53098. * Import meshes into a scene.
  53099. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53100. * @param scene The scene to import into
  53101. * @param data The data to import
  53102. * @param rootUrl The root url for scene and resources
  53103. * @param onProgress The callback when the load progresses
  53104. * @param fileName Defines the name of the file to load
  53105. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  53106. */
  53107. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  53108. meshes: AbstractMesh[];
  53109. particleSystems: IParticleSystem[];
  53110. skeletons: Skeleton[];
  53111. animationGroups: AnimationGroup[];
  53112. }>;
  53113. /**
  53114. * Load into a scene.
  53115. * @param scene The scene to load into
  53116. * @param data The data to import
  53117. * @param rootUrl The root url for scene and resources
  53118. * @param onProgress The callback when the load progresses
  53119. * @param fileName Defines the name of the file to load
  53120. * @returns Nothing
  53121. */
  53122. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53123. /**
  53124. * Load into an asset container.
  53125. * @param scene The scene to load into
  53126. * @param data The data to import
  53127. * @param rootUrl The root url for scene and resources
  53128. * @param onProgress The callback when the load progresses
  53129. * @param fileName Defines the name of the file to load
  53130. * @returns The loaded asset container
  53131. */
  53132. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53133. }
  53134. /**
  53135. * Mode that determines how to handle old animation groups before loading new ones.
  53136. */
  53137. export enum SceneLoaderAnimationGroupLoadingMode {
  53138. /**
  53139. * Reset all old animations to initial state then dispose them.
  53140. */
  53141. Clean = 0,
  53142. /**
  53143. * Stop all old animations.
  53144. */
  53145. Stop = 1,
  53146. /**
  53147. * Restart old animations from first frame.
  53148. */
  53149. Sync = 2,
  53150. /**
  53151. * Old animations remains untouched.
  53152. */
  53153. NoSync = 3
  53154. }
  53155. /**
  53156. * Defines a plugin registered by the SceneLoader
  53157. */
  53158. interface IRegisteredPlugin {
  53159. /**
  53160. * Defines the plugin to use
  53161. */
  53162. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53163. /**
  53164. * Defines if the plugin supports binary data
  53165. */
  53166. isBinary: boolean;
  53167. }
  53168. /**
  53169. * Class used to load scene from various file formats using registered plugins
  53170. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53171. */
  53172. export class SceneLoader {
  53173. /**
  53174. * No logging while loading
  53175. */
  53176. static readonly NO_LOGGING: number;
  53177. /**
  53178. * Minimal logging while loading
  53179. */
  53180. static readonly MINIMAL_LOGGING: number;
  53181. /**
  53182. * Summary logging while loading
  53183. */
  53184. static readonly SUMMARY_LOGGING: number;
  53185. /**
  53186. * Detailled logging while loading
  53187. */
  53188. static readonly DETAILED_LOGGING: number;
  53189. /**
  53190. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53191. */
  53192. static get ForceFullSceneLoadingForIncremental(): boolean;
  53193. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53194. /**
  53195. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53196. */
  53197. static get ShowLoadingScreen(): boolean;
  53198. static set ShowLoadingScreen(value: boolean);
  53199. /**
  53200. * Defines the current logging level (while loading the scene)
  53201. * @ignorenaming
  53202. */
  53203. static get loggingLevel(): number;
  53204. static set loggingLevel(value: number);
  53205. /**
  53206. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53207. */
  53208. static get CleanBoneMatrixWeights(): boolean;
  53209. static set CleanBoneMatrixWeights(value: boolean);
  53210. /**
  53211. * Event raised when a plugin is used to load a scene
  53212. */
  53213. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53214. private static _registeredPlugins;
  53215. private static _showingLoadingScreen;
  53216. /**
  53217. * Gets the default plugin (used to load Babylon files)
  53218. * @returns the .babylon plugin
  53219. */
  53220. static GetDefaultPlugin(): IRegisteredPlugin;
  53221. private static _GetPluginForExtension;
  53222. private static _GetPluginForDirectLoad;
  53223. private static _GetPluginForFilename;
  53224. private static _GetDirectLoad;
  53225. private static _LoadData;
  53226. private static _GetFileInfo;
  53227. /**
  53228. * Gets a plugin that can load the given extension
  53229. * @param extension defines the extension to load
  53230. * @returns a plugin or null if none works
  53231. */
  53232. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53233. /**
  53234. * Gets a boolean indicating that the given extension can be loaded
  53235. * @param extension defines the extension to load
  53236. * @returns true if the extension is supported
  53237. */
  53238. static IsPluginForExtensionAvailable(extension: string): boolean;
  53239. /**
  53240. * Adds a new plugin to the list of registered plugins
  53241. * @param plugin defines the plugin to add
  53242. */
  53243. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53244. /**
  53245. * Import meshes into a scene
  53246. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53247. * @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)
  53248. * @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)
  53249. * @param scene the instance of BABYLON.Scene to append to
  53250. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53251. * @param onProgress a callback with a progress event for each file being loaded
  53252. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53253. * @param pluginExtension the extension used to determine the plugin
  53254. * @returns The loaded plugin
  53255. */
  53256. 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>;
  53257. /**
  53258. * Import meshes into a scene
  53259. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53260. * @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)
  53261. * @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)
  53262. * @param scene the instance of BABYLON.Scene to append to
  53263. * @param onProgress a callback with a progress event for each file being loaded
  53264. * @param pluginExtension the extension used to determine the plugin
  53265. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53266. */
  53267. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  53268. meshes: AbstractMesh[];
  53269. particleSystems: IParticleSystem[];
  53270. skeletons: Skeleton[];
  53271. animationGroups: AnimationGroup[];
  53272. }>;
  53273. /**
  53274. * Load a scene
  53275. * @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)
  53276. * @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)
  53277. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53278. * @param onSuccess a callback with the scene when import succeeds
  53279. * @param onProgress a callback with a progress event for each file being loaded
  53280. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53281. * @param pluginExtension the extension used to determine the plugin
  53282. * @returns The loaded plugin
  53283. */
  53284. 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>;
  53285. /**
  53286. * Load a scene
  53287. * @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)
  53288. * @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)
  53289. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53290. * @param onProgress a callback with a progress event for each file being loaded
  53291. * @param pluginExtension the extension used to determine the plugin
  53292. * @returns The loaded scene
  53293. */
  53294. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53295. /**
  53296. * Append a scene
  53297. * @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)
  53298. * @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)
  53299. * @param scene is the instance of BABYLON.Scene to append to
  53300. * @param onSuccess a callback with the scene when import succeeds
  53301. * @param onProgress a callback with a progress event for each file being loaded
  53302. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53303. * @param pluginExtension the extension used to determine the plugin
  53304. * @returns The loaded plugin
  53305. */
  53306. 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>;
  53307. /**
  53308. * Append a scene
  53309. * @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)
  53310. * @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)
  53311. * @param scene is the instance of BABYLON.Scene to append to
  53312. * @param onProgress a callback with a progress event for each file being loaded
  53313. * @param pluginExtension the extension used to determine the plugin
  53314. * @returns The given scene
  53315. */
  53316. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53317. /**
  53318. * Load a scene into an asset container
  53319. * @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)
  53320. * @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)
  53321. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53322. * @param onSuccess a callback with the scene when import succeeds
  53323. * @param onProgress a callback with a progress event for each file being loaded
  53324. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53325. * @param pluginExtension the extension used to determine the plugin
  53326. * @returns The loaded plugin
  53327. */
  53328. 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>;
  53329. /**
  53330. * Load a scene into an asset container
  53331. * @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)
  53332. * @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)
  53333. * @param scene is the instance of Scene to append to
  53334. * @param onProgress a callback with a progress event for each file being loaded
  53335. * @param pluginExtension the extension used to determine the plugin
  53336. * @returns The loaded asset container
  53337. */
  53338. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53339. /**
  53340. * Import animations from a file into a scene
  53341. * @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)
  53342. * @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)
  53343. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53344. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53345. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53346. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53347. * @param onSuccess a callback with the scene when import succeeds
  53348. * @param onProgress a callback with a progress event for each file being loaded
  53349. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53350. * @param pluginExtension the extension used to determine the plugin
  53351. */
  53352. 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;
  53353. /**
  53354. * Import animations from a file into a scene
  53355. * @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)
  53356. * @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)
  53357. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53358. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53359. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53360. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53361. * @param onSuccess a callback with the scene when import succeeds
  53362. * @param onProgress a callback with a progress event for each file being loaded
  53363. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53364. * @param pluginExtension the extension used to determine the plugin
  53365. * @returns the updated scene with imported animations
  53366. */
  53367. 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>;
  53368. }
  53369. }
  53370. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53371. import { IDisposable, Scene } from "babylonjs/scene";
  53372. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53373. import { Observable } from "babylonjs/Misc/observable";
  53374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53375. import { Nullable } from "babylonjs/types";
  53376. /**
  53377. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53378. */
  53379. export type MotionControllerHandedness = "none" | "left" | "right";
  53380. /**
  53381. * The type of components available in motion controllers.
  53382. * This is not the name of the component.
  53383. */
  53384. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53385. /**
  53386. * The state of a controller component
  53387. */
  53388. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53389. /**
  53390. * The schema of motion controller layout.
  53391. * No object will be initialized using this interface
  53392. * This is used just to define the profile.
  53393. */
  53394. export interface IMotionControllerLayout {
  53395. /**
  53396. * Path to load the assets. Usually relative to the base path
  53397. */
  53398. assetPath: string;
  53399. /**
  53400. * Available components (unsorted)
  53401. */
  53402. components: {
  53403. /**
  53404. * A map of component Ids
  53405. */
  53406. [componentId: string]: {
  53407. /**
  53408. * The type of input the component outputs
  53409. */
  53410. type: MotionControllerComponentType;
  53411. /**
  53412. * The indices of this component in the gamepad object
  53413. */
  53414. gamepadIndices: {
  53415. /**
  53416. * Index of button
  53417. */
  53418. button?: number;
  53419. /**
  53420. * If available, index of x-axis
  53421. */
  53422. xAxis?: number;
  53423. /**
  53424. * If available, index of y-axis
  53425. */
  53426. yAxis?: number;
  53427. };
  53428. /**
  53429. * The mesh's root node name
  53430. */
  53431. rootNodeName: string;
  53432. /**
  53433. * Animation definitions for this model
  53434. */
  53435. visualResponses: {
  53436. [stateKey: string]: {
  53437. /**
  53438. * What property will be animated
  53439. */
  53440. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53441. /**
  53442. * What states influence this visual response
  53443. */
  53444. states: MotionControllerComponentStateType[];
  53445. /**
  53446. * Type of animation - movement or visibility
  53447. */
  53448. valueNodeProperty: "transform" | "visibility";
  53449. /**
  53450. * Base node name to move. Its position will be calculated according to the min and max nodes
  53451. */
  53452. valueNodeName?: string;
  53453. /**
  53454. * Minimum movement node
  53455. */
  53456. minNodeName?: string;
  53457. /**
  53458. * Max movement node
  53459. */
  53460. maxNodeName?: string;
  53461. };
  53462. };
  53463. /**
  53464. * If touch enabled, what is the name of node to display user feedback
  53465. */
  53466. touchPointNodeName?: string;
  53467. };
  53468. };
  53469. /**
  53470. * Is it xr standard mapping or not
  53471. */
  53472. gamepadMapping: "" | "xr-standard";
  53473. /**
  53474. * Base root node of this entire model
  53475. */
  53476. rootNodeName: string;
  53477. /**
  53478. * Defines the main button component id
  53479. */
  53480. selectComponentId: string;
  53481. }
  53482. /**
  53483. * A definition for the layout map in the input profile
  53484. */
  53485. export interface IMotionControllerLayoutMap {
  53486. /**
  53487. * Layouts with handedness type as a key
  53488. */
  53489. [handedness: string]: IMotionControllerLayout;
  53490. }
  53491. /**
  53492. * The XR Input profile schema
  53493. * Profiles can be found here:
  53494. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53495. */
  53496. export interface IMotionControllerProfile {
  53497. /**
  53498. * fallback profiles for this profileId
  53499. */
  53500. fallbackProfileIds: string[];
  53501. /**
  53502. * The layout map, with handedness as key
  53503. */
  53504. layouts: IMotionControllerLayoutMap;
  53505. /**
  53506. * The id of this profile
  53507. * correlates to the profile(s) in the xrInput.profiles array
  53508. */
  53509. profileId: string;
  53510. }
  53511. /**
  53512. * A helper-interface for the 3 meshes needed for controller button animation
  53513. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53514. */
  53515. export interface IMotionControllerButtonMeshMap {
  53516. /**
  53517. * the mesh that defines the pressed value mesh position.
  53518. * This is used to find the max-position of this button
  53519. */
  53520. pressedMesh: AbstractMesh;
  53521. /**
  53522. * the mesh that defines the unpressed value mesh position.
  53523. * This is used to find the min (or initial) position of this button
  53524. */
  53525. unpressedMesh: AbstractMesh;
  53526. /**
  53527. * The mesh that will be changed when value changes
  53528. */
  53529. valueMesh: AbstractMesh;
  53530. }
  53531. /**
  53532. * A helper-interface for the 3 meshes needed for controller axis animation.
  53533. * This will be expanded when touchpad animations are fully supported
  53534. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53535. */
  53536. export interface IMotionControllerMeshMap {
  53537. /**
  53538. * the mesh that defines the maximum value mesh position.
  53539. */
  53540. maxMesh?: AbstractMesh;
  53541. /**
  53542. * the mesh that defines the minimum value mesh position.
  53543. */
  53544. minMesh?: AbstractMesh;
  53545. /**
  53546. * The mesh that will be changed when axis value changes
  53547. */
  53548. valueMesh?: AbstractMesh;
  53549. }
  53550. /**
  53551. * The elements needed for change-detection of the gamepad objects in motion controllers
  53552. */
  53553. export interface IMinimalMotionControllerObject {
  53554. /**
  53555. * Available axes of this controller
  53556. */
  53557. axes: number[];
  53558. /**
  53559. * An array of available buttons
  53560. */
  53561. buttons: Array<{
  53562. /**
  53563. * Value of the button/trigger
  53564. */
  53565. value: number;
  53566. /**
  53567. * If the button/trigger is currently touched
  53568. */
  53569. touched: boolean;
  53570. /**
  53571. * If the button/trigger is currently pressed
  53572. */
  53573. pressed: boolean;
  53574. }>;
  53575. /**
  53576. * EXPERIMENTAL haptic support.
  53577. */
  53578. hapticActuators?: Array<{
  53579. pulse: (value: number, duration: number) => Promise<boolean>;
  53580. }>;
  53581. }
  53582. /**
  53583. * An Abstract Motion controller
  53584. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53585. * Each component has an observable to check for changes in value and state
  53586. */
  53587. export abstract class WebXRAbstractMotionController implements IDisposable {
  53588. protected scene: Scene;
  53589. protected layout: IMotionControllerLayout;
  53590. /**
  53591. * The gamepad object correlating to this controller
  53592. */
  53593. gamepadObject: IMinimalMotionControllerObject;
  53594. /**
  53595. * handedness (left/right/none) of this controller
  53596. */
  53597. handedness: MotionControllerHandedness;
  53598. private _initComponent;
  53599. private _modelReady;
  53600. /**
  53601. * A map of components (WebXRControllerComponent) in this motion controller
  53602. * Components have a ComponentType and can also have both button and axis definitions
  53603. */
  53604. readonly components: {
  53605. [id: string]: WebXRControllerComponent;
  53606. };
  53607. /**
  53608. * Disable the model's animation. Can be set at any time.
  53609. */
  53610. disableAnimation: boolean;
  53611. /**
  53612. * Observers registered here will be triggered when the model of this controller is done loading
  53613. */
  53614. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53615. /**
  53616. * The profile id of this motion controller
  53617. */
  53618. abstract profileId: string;
  53619. /**
  53620. * The root mesh of the model. It is null if the model was not yet initialized
  53621. */
  53622. rootMesh: Nullable<AbstractMesh>;
  53623. /**
  53624. * constructs a new abstract motion controller
  53625. * @param scene the scene to which the model of the controller will be added
  53626. * @param layout The profile layout to load
  53627. * @param gamepadObject The gamepad object correlating to this controller
  53628. * @param handedness handedness (left/right/none) of this controller
  53629. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53630. */
  53631. constructor(scene: Scene, layout: IMotionControllerLayout,
  53632. /**
  53633. * The gamepad object correlating to this controller
  53634. */
  53635. gamepadObject: IMinimalMotionControllerObject,
  53636. /**
  53637. * handedness (left/right/none) of this controller
  53638. */
  53639. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53640. /**
  53641. * Dispose this controller, the model mesh and all its components
  53642. */
  53643. dispose(): void;
  53644. /**
  53645. * Returns all components of specific type
  53646. * @param type the type to search for
  53647. * @return an array of components with this type
  53648. */
  53649. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53650. /**
  53651. * get a component based an its component id as defined in layout.components
  53652. * @param id the id of the component
  53653. * @returns the component correlates to the id or undefined if not found
  53654. */
  53655. getComponent(id: string): WebXRControllerComponent;
  53656. /**
  53657. * Get the list of components available in this motion controller
  53658. * @returns an array of strings correlating to available components
  53659. */
  53660. getComponentIds(): string[];
  53661. /**
  53662. * Get the first component of specific type
  53663. * @param type type of component to find
  53664. * @return a controller component or null if not found
  53665. */
  53666. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53667. /**
  53668. * Get the main (Select) component of this controller as defined in the layout
  53669. * @returns the main component of this controller
  53670. */
  53671. getMainComponent(): WebXRControllerComponent;
  53672. /**
  53673. * Loads the model correlating to this controller
  53674. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53675. * @returns A promise fulfilled with the result of the model loading
  53676. */
  53677. loadModel(): Promise<boolean>;
  53678. /**
  53679. * Update this model using the current XRFrame
  53680. * @param xrFrame the current xr frame to use and update the model
  53681. */
  53682. updateFromXRFrame(xrFrame: XRFrame): void;
  53683. /**
  53684. * Backwards compatibility due to a deeply-integrated typo
  53685. */
  53686. get handness(): XREye;
  53687. /**
  53688. * Pulse (vibrate) this controller
  53689. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53690. * Consecutive calls to this function will cancel the last pulse call
  53691. *
  53692. * @param value the strength of the pulse in 0.0...1.0 range
  53693. * @param duration Duration of the pulse in milliseconds
  53694. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53695. * @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
  53696. */
  53697. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53698. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53699. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53700. /**
  53701. * Moves the axis on the controller mesh based on its current state
  53702. * @param axis the index of the axis
  53703. * @param axisValue the value of the axis which determines the meshes new position
  53704. * @hidden
  53705. */
  53706. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53707. /**
  53708. * Update the model itself with the current frame data
  53709. * @param xrFrame the frame to use for updating the model mesh
  53710. */
  53711. protected updateModel(xrFrame: XRFrame): void;
  53712. /**
  53713. * Get the filename and path for this controller's model
  53714. * @returns a map of filename and path
  53715. */
  53716. protected abstract _getFilenameAndPath(): {
  53717. filename: string;
  53718. path: string;
  53719. };
  53720. /**
  53721. * This function is called before the mesh is loaded. It checks for loading constraints.
  53722. * For example, this function can check if the GLB loader is available
  53723. * If this function returns false, the generic controller will be loaded instead
  53724. * @returns Is the client ready to load the mesh
  53725. */
  53726. protected abstract _getModelLoadingConstraints(): boolean;
  53727. /**
  53728. * This function will be called after the model was successfully loaded and can be used
  53729. * for mesh transformations before it is available for the user
  53730. * @param meshes the loaded meshes
  53731. */
  53732. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53733. /**
  53734. * Set the root mesh for this controller. Important for the WebXR controller class
  53735. * @param meshes the loaded meshes
  53736. */
  53737. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53738. /**
  53739. * A function executed each frame that updates the mesh (if needed)
  53740. * @param xrFrame the current xrFrame
  53741. */
  53742. protected abstract _updateModel(xrFrame: XRFrame): void;
  53743. private _getGenericFilenameAndPath;
  53744. private _getGenericParentMesh;
  53745. }
  53746. }
  53747. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53748. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53750. import { Scene } from "babylonjs/scene";
  53751. /**
  53752. * A generic trigger-only motion controller for WebXR
  53753. */
  53754. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53755. /**
  53756. * Static version of the profile id of this controller
  53757. */
  53758. static ProfileId: string;
  53759. profileId: string;
  53760. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53761. protected _getFilenameAndPath(): {
  53762. filename: string;
  53763. path: string;
  53764. };
  53765. protected _getModelLoadingConstraints(): boolean;
  53766. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53767. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53768. protected _updateModel(): void;
  53769. }
  53770. }
  53771. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53772. import { Vector4 } from "babylonjs/Maths/math.vector";
  53773. import { Mesh } from "babylonjs/Meshes/mesh";
  53774. import { Scene } from "babylonjs/scene";
  53775. import { Nullable } from "babylonjs/types";
  53776. /**
  53777. * Class containing static functions to help procedurally build meshes
  53778. */
  53779. export class SphereBuilder {
  53780. /**
  53781. * Creates a sphere mesh
  53782. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53783. * * 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`)
  53784. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53785. * * 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
  53786. * * 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)
  53787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53790. * @param name defines the name of the mesh
  53791. * @param options defines the options used to create the mesh
  53792. * @param scene defines the hosting scene
  53793. * @returns the sphere mesh
  53794. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53795. */
  53796. static CreateSphere(name: string, options: {
  53797. segments?: number;
  53798. diameter?: number;
  53799. diameterX?: number;
  53800. diameterY?: number;
  53801. diameterZ?: number;
  53802. arc?: number;
  53803. slice?: number;
  53804. sideOrientation?: number;
  53805. frontUVs?: Vector4;
  53806. backUVs?: Vector4;
  53807. updatable?: boolean;
  53808. }, scene?: Nullable<Scene>): Mesh;
  53809. }
  53810. }
  53811. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53813. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53814. import { Scene } from "babylonjs/scene";
  53815. /**
  53816. * A profiled motion controller has its profile loaded from an online repository.
  53817. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53818. */
  53819. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53820. private _repositoryUrl;
  53821. private _buttonMeshMapping;
  53822. private _touchDots;
  53823. /**
  53824. * The profile ID of this controller. Will be populated when the controller initializes.
  53825. */
  53826. profileId: string;
  53827. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53828. dispose(): void;
  53829. protected _getFilenameAndPath(): {
  53830. filename: string;
  53831. path: string;
  53832. };
  53833. protected _getModelLoadingConstraints(): boolean;
  53834. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53835. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53836. protected _updateModel(_xrFrame: XRFrame): void;
  53837. }
  53838. }
  53839. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53840. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53841. import { Scene } from "babylonjs/scene";
  53842. /**
  53843. * A construction function type to create a new controller based on an xrInput object
  53844. */
  53845. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53846. /**
  53847. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53848. *
  53849. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53850. * it should be replaced with auto-loaded controllers.
  53851. *
  53852. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53853. */
  53854. export class WebXRMotionControllerManager {
  53855. private static _AvailableControllers;
  53856. private static _Fallbacks;
  53857. private static _ProfileLoadingPromises;
  53858. private static _ProfilesList;
  53859. /**
  53860. * The base URL of the online controller repository. Can be changed at any time.
  53861. */
  53862. static BaseRepositoryUrl: string;
  53863. /**
  53864. * Which repository gets priority - local or online
  53865. */
  53866. static PrioritizeOnlineRepository: boolean;
  53867. /**
  53868. * Use the online repository, or use only locally-defined controllers
  53869. */
  53870. static UseOnlineRepository: boolean;
  53871. /**
  53872. * Clear the cache used for profile loading and reload when requested again
  53873. */
  53874. static ClearProfilesCache(): void;
  53875. /**
  53876. * Register the default fallbacks.
  53877. * This function is called automatically when this file is imported.
  53878. */
  53879. static DefaultFallbacks(): void;
  53880. /**
  53881. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53882. * @param profileId the profile to which a fallback needs to be found
  53883. * @return an array with corresponding fallback profiles
  53884. */
  53885. static FindFallbackWithProfileId(profileId: string): string[];
  53886. /**
  53887. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53888. * The order of search:
  53889. *
  53890. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53891. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53892. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53893. * 4) return the generic trigger controller if none were found
  53894. *
  53895. * @param xrInput the xrInput to which a new controller is initialized
  53896. * @param scene the scene to which the model will be added
  53897. * @param forceProfile force a certain profile for this controller
  53898. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53899. */
  53900. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53901. /**
  53902. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53903. *
  53904. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53905. *
  53906. * @param type the profile type to register
  53907. * @param constructFunction the function to be called when loading this profile
  53908. */
  53909. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53910. /**
  53911. * Register a fallback to a specific profile.
  53912. * @param profileId the profileId that will receive the fallbacks
  53913. * @param fallbacks A list of fallback profiles
  53914. */
  53915. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53916. /**
  53917. * Will update the list of profiles available in the repository
  53918. * @return a promise that resolves to a map of profiles available online
  53919. */
  53920. static UpdateProfilesList(): Promise<{
  53921. [profile: string]: string;
  53922. }>;
  53923. private static _LoadProfileFromRepository;
  53924. private static _LoadProfilesFromAvailableControllers;
  53925. }
  53926. }
  53927. declare module "babylonjs/XR/webXRInputSource" {
  53928. import { Observable } from "babylonjs/Misc/observable";
  53929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53930. import { Ray } from "babylonjs/Culling/ray";
  53931. import { Scene } from "babylonjs/scene";
  53932. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53933. /**
  53934. * Configuration options for the WebXR controller creation
  53935. */
  53936. export interface IWebXRControllerOptions {
  53937. /**
  53938. * Should the controller mesh be animated when a user interacts with it
  53939. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53940. */
  53941. disableMotionControllerAnimation?: boolean;
  53942. /**
  53943. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53944. */
  53945. doNotLoadControllerMesh?: boolean;
  53946. /**
  53947. * Force a specific controller type for this controller.
  53948. * This can be used when creating your own profile or when testing different controllers
  53949. */
  53950. forceControllerProfile?: string;
  53951. /**
  53952. * Defines a rendering group ID for meshes that will be loaded.
  53953. * This is for the default controllers only.
  53954. */
  53955. renderingGroupId?: number;
  53956. }
  53957. /**
  53958. * Represents an XR controller
  53959. */
  53960. export class WebXRInputSource {
  53961. private _scene;
  53962. /** The underlying input source for the controller */
  53963. inputSource: XRInputSource;
  53964. private _options;
  53965. private _tmpVector;
  53966. private _uniqueId;
  53967. private _disposed;
  53968. /**
  53969. * 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
  53970. */
  53971. grip?: AbstractMesh;
  53972. /**
  53973. * If available, this is the gamepad object related to this controller.
  53974. * Using this object it is possible to get click events and trackpad changes of the
  53975. * webxr controller that is currently being used.
  53976. */
  53977. motionController?: WebXRAbstractMotionController;
  53978. /**
  53979. * Event that fires when the controller is removed/disposed.
  53980. * The object provided as event data is this controller, after associated assets were disposed.
  53981. * uniqueId is still available.
  53982. */
  53983. onDisposeObservable: Observable<WebXRInputSource>;
  53984. /**
  53985. * Will be triggered when the mesh associated with the motion controller is done loading.
  53986. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53987. * A shortened version of controller -> motion controller -> on mesh loaded.
  53988. */
  53989. onMeshLoadedObservable: Observable<AbstractMesh>;
  53990. /**
  53991. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53992. */
  53993. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53994. /**
  53995. * Pointer which can be used to select objects or attach a visible laser to
  53996. */
  53997. pointer: AbstractMesh;
  53998. /**
  53999. * Creates the input source object
  54000. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54001. * @param _scene the scene which the controller should be associated to
  54002. * @param inputSource the underlying input source for the controller
  54003. * @param _options options for this controller creation
  54004. */
  54005. constructor(_scene: Scene,
  54006. /** The underlying input source for the controller */
  54007. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54008. /**
  54009. * Get this controllers unique id
  54010. */
  54011. get uniqueId(): string;
  54012. /**
  54013. * Disposes of the object
  54014. */
  54015. dispose(): void;
  54016. /**
  54017. * Gets a world space ray coming from the pointer or grip
  54018. * @param result the resulting ray
  54019. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54020. */
  54021. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54022. /**
  54023. * Updates the controller pose based on the given XRFrame
  54024. * @param xrFrame xr frame to update the pose with
  54025. * @param referenceSpace reference space to use
  54026. */
  54027. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54028. }
  54029. }
  54030. declare module "babylonjs/XR/webXRInput" {
  54031. import { Observable } from "babylonjs/Misc/observable";
  54032. import { IDisposable } from "babylonjs/scene";
  54033. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54034. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54035. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54036. /**
  54037. * The schema for initialization options of the XR Input class
  54038. */
  54039. export interface IWebXRInputOptions {
  54040. /**
  54041. * If set to true no model will be automatically loaded
  54042. */
  54043. doNotLoadControllerMeshes?: boolean;
  54044. /**
  54045. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54046. * If not found, the xr input profile data will be used.
  54047. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54048. */
  54049. forceInputProfile?: string;
  54050. /**
  54051. * Do not send a request to the controller repository to load the profile.
  54052. *
  54053. * Instead, use the controllers available in babylon itself.
  54054. */
  54055. disableOnlineControllerRepository?: boolean;
  54056. /**
  54057. * A custom URL for the controllers repository
  54058. */
  54059. customControllersRepositoryURL?: string;
  54060. /**
  54061. * Should the controller model's components not move according to the user input
  54062. */
  54063. disableControllerAnimation?: boolean;
  54064. /**
  54065. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54066. */
  54067. controllerOptions?: IWebXRControllerOptions;
  54068. }
  54069. /**
  54070. * XR input used to track XR inputs such as controllers/rays
  54071. */
  54072. export class WebXRInput implements IDisposable {
  54073. /**
  54074. * the xr session manager for this session
  54075. */
  54076. xrSessionManager: WebXRSessionManager;
  54077. /**
  54078. * the WebXR camera for this session. Mainly used for teleportation
  54079. */
  54080. xrCamera: WebXRCamera;
  54081. private readonly options;
  54082. /**
  54083. * XR controllers being tracked
  54084. */
  54085. controllers: Array<WebXRInputSource>;
  54086. private _frameObserver;
  54087. private _sessionEndedObserver;
  54088. private _sessionInitObserver;
  54089. /**
  54090. * Event when a controller has been connected/added
  54091. */
  54092. onControllerAddedObservable: Observable<WebXRInputSource>;
  54093. /**
  54094. * Event when a controller has been removed/disconnected
  54095. */
  54096. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54097. /**
  54098. * Initializes the WebXRInput
  54099. * @param xrSessionManager the xr session manager for this session
  54100. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54101. * @param options = initialization options for this xr input
  54102. */
  54103. constructor(
  54104. /**
  54105. * the xr session manager for this session
  54106. */
  54107. xrSessionManager: WebXRSessionManager,
  54108. /**
  54109. * the WebXR camera for this session. Mainly used for teleportation
  54110. */
  54111. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54112. private _onInputSourcesChange;
  54113. private _addAndRemoveControllers;
  54114. /**
  54115. * Disposes of the object
  54116. */
  54117. dispose(): void;
  54118. }
  54119. }
  54120. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54121. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54122. import { Observable, EventState } from "babylonjs/Misc/observable";
  54123. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54124. /**
  54125. * This is the base class for all WebXR features.
  54126. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54127. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54128. */
  54129. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54130. protected _xrSessionManager: WebXRSessionManager;
  54131. private _attached;
  54132. private _removeOnDetach;
  54133. /**
  54134. * Is this feature disposed?
  54135. */
  54136. isDisposed: boolean;
  54137. /**
  54138. * Should auto-attach be disabled?
  54139. */
  54140. disableAutoAttach: boolean;
  54141. /**
  54142. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54143. */
  54144. xrNativeFeatureName: string;
  54145. /**
  54146. * Construct a new (abstract) WebXR feature
  54147. * @param _xrSessionManager the xr session manager for this feature
  54148. */
  54149. constructor(_xrSessionManager: WebXRSessionManager);
  54150. /**
  54151. * Is this feature attached
  54152. */
  54153. get attached(): boolean;
  54154. /**
  54155. * attach this feature
  54156. *
  54157. * @param force should attachment be forced (even when already attached)
  54158. * @returns true if successful, false is failed or already attached
  54159. */
  54160. attach(force?: boolean): boolean;
  54161. /**
  54162. * detach this feature.
  54163. *
  54164. * @returns true if successful, false if failed or already detached
  54165. */
  54166. detach(): boolean;
  54167. /**
  54168. * Dispose this feature and all of the resources attached
  54169. */
  54170. dispose(): void;
  54171. /**
  54172. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54173. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54174. *
  54175. * @returns whether or not the feature is compatible in this environment
  54176. */
  54177. isCompatible(): boolean;
  54178. /**
  54179. * This is used to register callbacks that will automatically be removed when detach is called.
  54180. * @param observable the observable to which the observer will be attached
  54181. * @param callback the callback to register
  54182. */
  54183. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54184. /**
  54185. * Code in this function will be executed on each xrFrame received from the browser.
  54186. * This function will not execute after the feature is detached.
  54187. * @param _xrFrame the current frame
  54188. */
  54189. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54190. }
  54191. }
  54192. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54193. import { IDisposable, Scene } from "babylonjs/scene";
  54194. import { Nullable } from "babylonjs/types";
  54195. import { Observable } from "babylonjs/Misc/observable";
  54196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54197. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54198. import { Camera } from "babylonjs/Cameras/camera";
  54199. /**
  54200. * Renders a layer on top of an existing scene
  54201. */
  54202. export class UtilityLayerRenderer implements IDisposable {
  54203. /** the original scene that will be rendered on top of */
  54204. originalScene: Scene;
  54205. private _pointerCaptures;
  54206. private _lastPointerEvents;
  54207. private static _DefaultUtilityLayer;
  54208. private static _DefaultKeepDepthUtilityLayer;
  54209. private _sharedGizmoLight;
  54210. private _renderCamera;
  54211. /**
  54212. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54213. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54214. * @returns the camera that is used when rendering the utility layer
  54215. */
  54216. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54217. /**
  54218. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54219. * @param cam the camera that should be used when rendering the utility layer
  54220. */
  54221. setRenderCamera(cam: Nullable<Camera>): void;
  54222. /**
  54223. * @hidden
  54224. * Light which used by gizmos to get light shading
  54225. */
  54226. _getSharedGizmoLight(): HemisphericLight;
  54227. /**
  54228. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54229. */
  54230. pickUtilitySceneFirst: boolean;
  54231. /**
  54232. * 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)
  54233. */
  54234. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54235. /**
  54236. * 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)
  54237. */
  54238. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54239. /**
  54240. * The scene that is rendered on top of the original scene
  54241. */
  54242. utilityLayerScene: Scene;
  54243. /**
  54244. * If the utility layer should automatically be rendered on top of existing scene
  54245. */
  54246. shouldRender: boolean;
  54247. /**
  54248. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54249. */
  54250. onlyCheckPointerDownEvents: boolean;
  54251. /**
  54252. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54253. */
  54254. processAllEvents: boolean;
  54255. /**
  54256. * Observable raised when the pointer move from the utility layer scene to the main scene
  54257. */
  54258. onPointerOutObservable: Observable<number>;
  54259. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54260. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54261. private _afterRenderObserver;
  54262. private _sceneDisposeObserver;
  54263. private _originalPointerObserver;
  54264. /**
  54265. * Instantiates a UtilityLayerRenderer
  54266. * @param originalScene the original scene that will be rendered on top of
  54267. * @param handleEvents boolean indicating if the utility layer should handle events
  54268. */
  54269. constructor(
  54270. /** the original scene that will be rendered on top of */
  54271. originalScene: Scene, handleEvents?: boolean);
  54272. private _notifyObservers;
  54273. /**
  54274. * Renders the utility layers scene on top of the original scene
  54275. */
  54276. render(): void;
  54277. /**
  54278. * Disposes of the renderer
  54279. */
  54280. dispose(): void;
  54281. private _updateCamera;
  54282. }
  54283. }
  54284. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54285. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54287. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54288. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54289. import { Scene } from "babylonjs/scene";
  54290. import { Nullable } from "babylonjs/types";
  54291. import { Color3 } from "babylonjs/Maths/math.color";
  54292. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54293. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54294. /**
  54295. * Options interface for the pointer selection module
  54296. */
  54297. export interface IWebXRControllerPointerSelectionOptions {
  54298. /**
  54299. * if provided, this scene will be used to render meshes.
  54300. */
  54301. customUtilityLayerScene?: Scene;
  54302. /**
  54303. * 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)
  54304. * If not disabled, the last picked point will be used to execute a pointer up event
  54305. * If disabled, pointer up event will be triggered right after the pointer down event.
  54306. * Used in screen and gaze target ray mode only
  54307. */
  54308. disablePointerUpOnTouchOut: boolean;
  54309. /**
  54310. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54311. */
  54312. forceGazeMode: boolean;
  54313. /**
  54314. * 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
  54315. * to start a new countdown to the pointer down event.
  54316. * Defaults to 1.
  54317. */
  54318. gazeModePointerMovedFactor?: number;
  54319. /**
  54320. * Different button type to use instead of the main component
  54321. */
  54322. overrideButtonId?: string;
  54323. /**
  54324. * use this rendering group id for the meshes (optional)
  54325. */
  54326. renderingGroupId?: number;
  54327. /**
  54328. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54329. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54330. * 3000 means 3 seconds between pointing at something and selecting it
  54331. */
  54332. timeToSelect?: number;
  54333. /**
  54334. * Should meshes created here be added to a utility layer or the main scene
  54335. */
  54336. useUtilityLayer?: boolean;
  54337. /**
  54338. * Optional WebXR camera to be used for gaze selection
  54339. */
  54340. gazeCamera?: WebXRCamera;
  54341. /**
  54342. * the xr input to use with this pointer selection
  54343. */
  54344. xrInput: WebXRInput;
  54345. /**
  54346. * Should the scene pointerX and pointerY update be disabled
  54347. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54348. * Disable in VR, if not needed.
  54349. * The first rig camera (left eye) will be used to calculate the projection
  54350. */
  54351. disableScenePointerVectorUpdate: boolean;
  54352. /**
  54353. * Enable pointer selection on all controllers instead of switching between them
  54354. */
  54355. enablePointerSelectionOnAllControllers?: boolean;
  54356. /**
  54357. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54358. * If switch is enabled, it will still allow the user to switch between the different controllers
  54359. */
  54360. preferredHandedness?: XRHandedness;
  54361. /**
  54362. * Disable switching the pointer selection from one controller to the other.
  54363. * 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
  54364. */
  54365. disableSwitchOnClick?: boolean;
  54366. /**
  54367. * The maximum distance of the pointer selection feature. Defaults to 100.
  54368. */
  54369. maxPointerDistance?: number;
  54370. }
  54371. /**
  54372. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54373. */
  54374. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54375. private readonly _options;
  54376. private static _idCounter;
  54377. private _attachController;
  54378. private _controllers;
  54379. private _scene;
  54380. private _tmpVectorForPickCompare;
  54381. private _attachedController;
  54382. /**
  54383. * The module's name
  54384. */
  54385. static readonly Name: string;
  54386. /**
  54387. * The (Babylon) version of this module.
  54388. * This is an integer representing the implementation version.
  54389. * This number does not correspond to the WebXR specs version
  54390. */
  54391. static readonly Version: number;
  54392. /**
  54393. * Disable lighting on the laser pointer (so it will always be visible)
  54394. */
  54395. disablePointerLighting: boolean;
  54396. /**
  54397. * Disable lighting on the selection mesh (so it will always be visible)
  54398. */
  54399. disableSelectionMeshLighting: boolean;
  54400. /**
  54401. * Should the laser pointer be displayed
  54402. */
  54403. displayLaserPointer: boolean;
  54404. /**
  54405. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54406. */
  54407. displaySelectionMesh: boolean;
  54408. /**
  54409. * This color will be set to the laser pointer when selection is triggered
  54410. */
  54411. laserPointerPickedColor: Color3;
  54412. /**
  54413. * Default color of the laser pointer
  54414. */
  54415. laserPointerDefaultColor: Color3;
  54416. /**
  54417. * default color of the selection ring
  54418. */
  54419. selectionMeshDefaultColor: Color3;
  54420. /**
  54421. * This color will be applied to the selection ring when selection is triggered
  54422. */
  54423. selectionMeshPickedColor: Color3;
  54424. /**
  54425. * Optional filter to be used for ray selection. This predicate shares behavior with
  54426. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54427. */
  54428. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54429. /**
  54430. * constructs a new background remover module
  54431. * @param _xrSessionManager the session manager for this module
  54432. * @param _options read-only options to be used in this module
  54433. */
  54434. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54435. /**
  54436. * attach this feature
  54437. * Will usually be called by the features manager
  54438. *
  54439. * @returns true if successful.
  54440. */
  54441. attach(): boolean;
  54442. /**
  54443. * detach this feature.
  54444. * Will usually be called by the features manager
  54445. *
  54446. * @returns true if successful.
  54447. */
  54448. detach(): boolean;
  54449. /**
  54450. * Will get the mesh under a specific pointer.
  54451. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54452. * @param controllerId the controllerId to check
  54453. * @returns The mesh under pointer or null if no mesh is under the pointer
  54454. */
  54455. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54456. /**
  54457. * Get the xr controller that correlates to the pointer id in the pointer event
  54458. *
  54459. * @param id the pointer id to search for
  54460. * @returns the controller that correlates to this id or null if not found
  54461. */
  54462. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54463. private _identityMatrix;
  54464. private _screenCoordinatesRef;
  54465. private _viewportRef;
  54466. protected _onXRFrame(_xrFrame: XRFrame): void;
  54467. private _attachGazeMode;
  54468. private _attachScreenRayMode;
  54469. private _attachTrackedPointerRayMode;
  54470. private _convertNormalToDirectionOfRay;
  54471. private _detachController;
  54472. private _generateNewMeshPair;
  54473. private _pickingMoved;
  54474. private _updatePointerDistance;
  54475. /** @hidden */
  54476. get lasterPointerDefaultColor(): Color3;
  54477. }
  54478. }
  54479. declare module "babylonjs/XR/webXREnterExitUI" {
  54480. import { Nullable } from "babylonjs/types";
  54481. import { Observable } from "babylonjs/Misc/observable";
  54482. import { IDisposable, Scene } from "babylonjs/scene";
  54483. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54484. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54485. /**
  54486. * Button which can be used to enter a different mode of XR
  54487. */
  54488. export class WebXREnterExitUIButton {
  54489. /** button element */
  54490. element: HTMLElement;
  54491. /** XR initialization options for the button */
  54492. sessionMode: XRSessionMode;
  54493. /** Reference space type */
  54494. referenceSpaceType: XRReferenceSpaceType;
  54495. /**
  54496. * Creates a WebXREnterExitUIButton
  54497. * @param element button element
  54498. * @param sessionMode XR initialization session mode
  54499. * @param referenceSpaceType the type of reference space to be used
  54500. */
  54501. constructor(
  54502. /** button element */
  54503. element: HTMLElement,
  54504. /** XR initialization options for the button */
  54505. sessionMode: XRSessionMode,
  54506. /** Reference space type */
  54507. referenceSpaceType: XRReferenceSpaceType);
  54508. /**
  54509. * Extendable function which can be used to update the button's visuals when the state changes
  54510. * @param activeButton the current active button in the UI
  54511. */
  54512. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54513. }
  54514. /**
  54515. * Options to create the webXR UI
  54516. */
  54517. export class WebXREnterExitUIOptions {
  54518. /**
  54519. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54520. */
  54521. customButtons?: Array<WebXREnterExitUIButton>;
  54522. /**
  54523. * A reference space type to use when creating the default button.
  54524. * Default is local-floor
  54525. */
  54526. referenceSpaceType?: XRReferenceSpaceType;
  54527. /**
  54528. * Context to enter xr with
  54529. */
  54530. renderTarget?: Nullable<WebXRRenderTarget>;
  54531. /**
  54532. * A session mode to use when creating the default button.
  54533. * Default is immersive-vr
  54534. */
  54535. sessionMode?: XRSessionMode;
  54536. /**
  54537. * A list of optional features to init the session with
  54538. */
  54539. optionalFeatures?: string[];
  54540. /**
  54541. * A list of optional features to init the session with
  54542. */
  54543. requiredFeatures?: string[];
  54544. /**
  54545. * If defined, this function will be executed if the UI encounters an error when entering XR
  54546. */
  54547. onError?: (error: any) => void;
  54548. }
  54549. /**
  54550. * UI to allow the user to enter/exit XR mode
  54551. */
  54552. export class WebXREnterExitUI implements IDisposable {
  54553. private scene;
  54554. /** version of the options passed to this UI */
  54555. options: WebXREnterExitUIOptions;
  54556. private _activeButton;
  54557. private _buttons;
  54558. /**
  54559. * The HTML Div Element to which buttons are added.
  54560. */
  54561. readonly overlay: HTMLDivElement;
  54562. /**
  54563. * Fired every time the active button is changed.
  54564. *
  54565. * When xr is entered via a button that launches xr that button will be the callback parameter
  54566. *
  54567. * When exiting xr the callback parameter will be null)
  54568. */
  54569. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54570. /**
  54571. *
  54572. * @param scene babylon scene object to use
  54573. * @param options (read-only) version of the options passed to this UI
  54574. */
  54575. private constructor();
  54576. /**
  54577. * Creates UI to allow the user to enter/exit XR mode
  54578. * @param scene the scene to add the ui to
  54579. * @param helper the xr experience helper to enter/exit xr with
  54580. * @param options options to configure the UI
  54581. * @returns the created ui
  54582. */
  54583. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54584. /**
  54585. * Disposes of the XR UI component
  54586. */
  54587. dispose(): void;
  54588. private _updateButtons;
  54589. }
  54590. }
  54591. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54592. import { Vector3 } from "babylonjs/Maths/math.vector";
  54593. import { Color4 } from "babylonjs/Maths/math.color";
  54594. import { Nullable } from "babylonjs/types";
  54595. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54596. import { Scene } from "babylonjs/scene";
  54597. /**
  54598. * Class containing static functions to help procedurally build meshes
  54599. */
  54600. export class LinesBuilder {
  54601. /**
  54602. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54603. * * 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
  54604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54605. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54606. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54607. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54608. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54609. * * 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
  54610. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54613. * @param name defines the name of the new line system
  54614. * @param options defines the options used to create the line system
  54615. * @param scene defines the hosting scene
  54616. * @returns a new line system mesh
  54617. */
  54618. static CreateLineSystem(name: string, options: {
  54619. lines: Vector3[][];
  54620. updatable?: boolean;
  54621. instance?: Nullable<LinesMesh>;
  54622. colors?: Nullable<Color4[][]>;
  54623. useVertexAlpha?: boolean;
  54624. }, scene: Nullable<Scene>): LinesMesh;
  54625. /**
  54626. * Creates a line mesh
  54627. * 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
  54628. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54629. * * The parameter `points` is an array successive Vector3
  54630. * * 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
  54631. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54632. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54633. * * When updating an instance, remember that only point positions can change, not the number of points
  54634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54636. * @param name defines the name of the new line system
  54637. * @param options defines the options used to create the line system
  54638. * @param scene defines the hosting scene
  54639. * @returns a new line mesh
  54640. */
  54641. static CreateLines(name: string, options: {
  54642. points: Vector3[];
  54643. updatable?: boolean;
  54644. instance?: Nullable<LinesMesh>;
  54645. colors?: Color4[];
  54646. useVertexAlpha?: boolean;
  54647. }, scene?: Nullable<Scene>): LinesMesh;
  54648. /**
  54649. * Creates a dashed line mesh
  54650. * * 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
  54651. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54652. * * The parameter `points` is an array successive Vector3
  54653. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54654. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54655. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54656. * * 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
  54657. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54658. * * When updating an instance, remember that only point positions can change, not the number of points
  54659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54660. * @param name defines the name of the mesh
  54661. * @param options defines the options used to create the mesh
  54662. * @param scene defines the hosting scene
  54663. * @returns the dashed line mesh
  54664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54665. */
  54666. static CreateDashedLines(name: string, options: {
  54667. points: Vector3[];
  54668. dashSize?: number;
  54669. gapSize?: number;
  54670. dashNb?: number;
  54671. updatable?: boolean;
  54672. instance?: LinesMesh;
  54673. useVertexAlpha?: boolean;
  54674. }, scene?: Nullable<Scene>): LinesMesh;
  54675. }
  54676. }
  54677. declare module "babylonjs/Misc/timer" {
  54678. import { Observable, Observer } from "babylonjs/Misc/observable";
  54679. import { Nullable } from "babylonjs/types";
  54680. import { IDisposable } from "babylonjs/scene";
  54681. /**
  54682. * Construction options for a timer
  54683. */
  54684. export interface ITimerOptions<T> {
  54685. /**
  54686. * Time-to-end
  54687. */
  54688. timeout: number;
  54689. /**
  54690. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54691. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54692. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54693. */
  54694. contextObservable: Observable<T>;
  54695. /**
  54696. * Optional parameters when adding an observer to the observable
  54697. */
  54698. observableParameters?: {
  54699. mask?: number;
  54700. insertFirst?: boolean;
  54701. scope?: any;
  54702. };
  54703. /**
  54704. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54705. */
  54706. breakCondition?: (data?: ITimerData<T>) => boolean;
  54707. /**
  54708. * Will be triggered when the time condition has met
  54709. */
  54710. onEnded?: (data: ITimerData<any>) => void;
  54711. /**
  54712. * Will be triggered when the break condition has met (prematurely ended)
  54713. */
  54714. onAborted?: (data: ITimerData<any>) => void;
  54715. /**
  54716. * Optional function to execute on each tick (or count)
  54717. */
  54718. onTick?: (data: ITimerData<any>) => void;
  54719. }
  54720. /**
  54721. * An interface defining the data sent by the timer
  54722. */
  54723. export interface ITimerData<T> {
  54724. /**
  54725. * When did it start
  54726. */
  54727. startTime: number;
  54728. /**
  54729. * Time now
  54730. */
  54731. currentTime: number;
  54732. /**
  54733. * Time passed since started
  54734. */
  54735. deltaTime: number;
  54736. /**
  54737. * How much is completed, in [0.0...1.0].
  54738. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54739. */
  54740. completeRate: number;
  54741. /**
  54742. * What the registered observable sent in the last count
  54743. */
  54744. payload: T;
  54745. }
  54746. /**
  54747. * The current state of the timer
  54748. */
  54749. export enum TimerState {
  54750. /**
  54751. * Timer initialized, not yet started
  54752. */
  54753. INIT = 0,
  54754. /**
  54755. * Timer started and counting
  54756. */
  54757. STARTED = 1,
  54758. /**
  54759. * Timer ended (whether aborted or time reached)
  54760. */
  54761. ENDED = 2
  54762. }
  54763. /**
  54764. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54765. *
  54766. * @param options options with which to initialize this timer
  54767. */
  54768. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54769. /**
  54770. * An advanced implementation of a timer class
  54771. */
  54772. export class AdvancedTimer<T = any> implements IDisposable {
  54773. /**
  54774. * Will notify each time the timer calculates the remaining time
  54775. */
  54776. onEachCountObservable: Observable<ITimerData<T>>;
  54777. /**
  54778. * Will trigger when the timer was aborted due to the break condition
  54779. */
  54780. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54781. /**
  54782. * Will trigger when the timer ended successfully
  54783. */
  54784. onTimerEndedObservable: Observable<ITimerData<T>>;
  54785. /**
  54786. * Will trigger when the timer state has changed
  54787. */
  54788. onStateChangedObservable: Observable<TimerState>;
  54789. private _observer;
  54790. private _contextObservable;
  54791. private _observableParameters;
  54792. private _startTime;
  54793. private _timer;
  54794. private _state;
  54795. private _breakCondition;
  54796. private _timeToEnd;
  54797. private _breakOnNextTick;
  54798. /**
  54799. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54800. * @param options construction options for this advanced timer
  54801. */
  54802. constructor(options: ITimerOptions<T>);
  54803. /**
  54804. * set a breaking condition for this timer. Default is to never break during count
  54805. * @param predicate the new break condition. Returns true to break, false otherwise
  54806. */
  54807. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54808. /**
  54809. * Reset ALL associated observables in this advanced timer
  54810. */
  54811. clearObservables(): void;
  54812. /**
  54813. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54814. *
  54815. * @param timeToEnd how much time to measure until timer ended
  54816. */
  54817. start(timeToEnd?: number): void;
  54818. /**
  54819. * Will force a stop on the next tick.
  54820. */
  54821. stop(): void;
  54822. /**
  54823. * Dispose this timer, clearing all resources
  54824. */
  54825. dispose(): void;
  54826. private _setState;
  54827. private _tick;
  54828. private _stop;
  54829. }
  54830. }
  54831. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54832. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54833. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54834. import { Nullable } from "babylonjs/types";
  54835. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54837. import { Vector3 } from "babylonjs/Maths/math.vector";
  54838. import { Material } from "babylonjs/Materials/material";
  54839. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54840. import { Scene } from "babylonjs/scene";
  54841. /**
  54842. * The options container for the teleportation module
  54843. */
  54844. export interface IWebXRTeleportationOptions {
  54845. /**
  54846. * if provided, this scene will be used to render meshes.
  54847. */
  54848. customUtilityLayerScene?: Scene;
  54849. /**
  54850. * Values to configure the default target mesh
  54851. */
  54852. defaultTargetMeshOptions?: {
  54853. /**
  54854. * Fill color of the teleportation area
  54855. */
  54856. teleportationFillColor?: string;
  54857. /**
  54858. * Border color for the teleportation area
  54859. */
  54860. teleportationBorderColor?: string;
  54861. /**
  54862. * Disable the mesh's animation sequence
  54863. */
  54864. disableAnimation?: boolean;
  54865. /**
  54866. * Disable lighting on the material or the ring and arrow
  54867. */
  54868. disableLighting?: boolean;
  54869. /**
  54870. * Override the default material of the torus and arrow
  54871. */
  54872. torusArrowMaterial?: Material;
  54873. };
  54874. /**
  54875. * A list of meshes to use as floor meshes.
  54876. * Meshes can be added and removed after initializing the feature using the
  54877. * addFloorMesh and removeFloorMesh functions
  54878. * If empty, rotation will still work
  54879. */
  54880. floorMeshes?: AbstractMesh[];
  54881. /**
  54882. * use this rendering group id for the meshes (optional)
  54883. */
  54884. renderingGroupId?: number;
  54885. /**
  54886. * Should teleportation move only to snap points
  54887. */
  54888. snapPointsOnly?: boolean;
  54889. /**
  54890. * An array of points to which the teleportation will snap to.
  54891. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54892. */
  54893. snapPositions?: Vector3[];
  54894. /**
  54895. * How close should the teleportation ray be in order to snap to position.
  54896. * Default to 0.8 units (meters)
  54897. */
  54898. snapToPositionRadius?: number;
  54899. /**
  54900. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54901. * If you want to support rotation, make sure your mesh has a direction indicator.
  54902. *
  54903. * When left untouched, the default mesh will be initialized.
  54904. */
  54905. teleportationTargetMesh?: AbstractMesh;
  54906. /**
  54907. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54908. */
  54909. timeToTeleport?: number;
  54910. /**
  54911. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54912. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54913. */
  54914. useMainComponentOnly?: boolean;
  54915. /**
  54916. * Should meshes created here be added to a utility layer or the main scene
  54917. */
  54918. useUtilityLayer?: boolean;
  54919. /**
  54920. * Babylon XR Input class for controller
  54921. */
  54922. xrInput: WebXRInput;
  54923. /**
  54924. * Meshes that the teleportation ray cannot go through
  54925. */
  54926. pickBlockerMeshes?: AbstractMesh[];
  54927. }
  54928. /**
  54929. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54930. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54931. * the input of the attached controllers.
  54932. */
  54933. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54934. private _options;
  54935. private _controllers;
  54936. private _currentTeleportationControllerId;
  54937. private _floorMeshes;
  54938. private _quadraticBezierCurve;
  54939. private _selectionFeature;
  54940. private _snapToPositions;
  54941. private _snappedToPoint;
  54942. private _teleportationRingMaterial?;
  54943. private _tmpRay;
  54944. private _tmpVector;
  54945. private _tmpQuaternion;
  54946. /**
  54947. * The module's name
  54948. */
  54949. static readonly Name: string;
  54950. /**
  54951. * The (Babylon) version of this module.
  54952. * This is an integer representing the implementation version.
  54953. * This number does not correspond to the webxr specs version
  54954. */
  54955. static readonly Version: number;
  54956. /**
  54957. * Is movement backwards enabled
  54958. */
  54959. backwardsMovementEnabled: boolean;
  54960. /**
  54961. * Distance to travel when moving backwards
  54962. */
  54963. backwardsTeleportationDistance: number;
  54964. /**
  54965. * The distance from the user to the inspection point in the direction of the controller
  54966. * A higher number will allow the user to move further
  54967. * defaults to 5 (meters, in xr units)
  54968. */
  54969. parabolicCheckRadius: number;
  54970. /**
  54971. * Should the module support parabolic ray on top of direct ray
  54972. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54973. * Very helpful when moving between floors / different heights
  54974. */
  54975. parabolicRayEnabled: boolean;
  54976. /**
  54977. * How much rotation should be applied when rotating right and left
  54978. */
  54979. rotationAngle: number;
  54980. /**
  54981. * Is rotation enabled when moving forward?
  54982. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54983. */
  54984. rotationEnabled: boolean;
  54985. /**
  54986. * constructs a new anchor system
  54987. * @param _xrSessionManager an instance of WebXRSessionManager
  54988. * @param _options configuration object for this feature
  54989. */
  54990. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54991. /**
  54992. * Get the snapPointsOnly flag
  54993. */
  54994. get snapPointsOnly(): boolean;
  54995. /**
  54996. * Sets the snapPointsOnly flag
  54997. * @param snapToPoints should teleportation be exclusively to snap points
  54998. */
  54999. set snapPointsOnly(snapToPoints: boolean);
  55000. /**
  55001. * Add a new mesh to the floor meshes array
  55002. * @param mesh the mesh to use as floor mesh
  55003. */
  55004. addFloorMesh(mesh: AbstractMesh): void;
  55005. /**
  55006. * Add a new snap-to point to fix teleportation to this position
  55007. * @param newSnapPoint The new Snap-To point
  55008. */
  55009. addSnapPoint(newSnapPoint: Vector3): void;
  55010. attach(): boolean;
  55011. detach(): boolean;
  55012. dispose(): void;
  55013. /**
  55014. * Remove a mesh from the floor meshes array
  55015. * @param mesh the mesh to remove
  55016. */
  55017. removeFloorMesh(mesh: AbstractMesh): void;
  55018. /**
  55019. * Remove a mesh from the floor meshes array using its name
  55020. * @param name the mesh name to remove
  55021. */
  55022. removeFloorMeshByName(name: string): void;
  55023. /**
  55024. * 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
  55025. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55026. * @returns was the point found and removed or not
  55027. */
  55028. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55029. /**
  55030. * This function sets a selection feature that will be disabled when
  55031. * the forward ray is shown and will be reattached when hidden.
  55032. * This is used to remove the selection rays when moving.
  55033. * @param selectionFeature the feature to disable when forward movement is enabled
  55034. */
  55035. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55036. protected _onXRFrame(_xrFrame: XRFrame): void;
  55037. private _attachController;
  55038. private _createDefaultTargetMesh;
  55039. private _detachController;
  55040. private _findClosestSnapPointWithRadius;
  55041. private _setTargetMeshPosition;
  55042. private _setTargetMeshVisibility;
  55043. private _showParabolicPath;
  55044. private _teleportForward;
  55045. }
  55046. }
  55047. declare module "babylonjs/XR/webXRDefaultExperience" {
  55048. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55049. import { Scene } from "babylonjs/scene";
  55050. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55051. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55052. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55053. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55055. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55056. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55057. /**
  55058. * Options for the default xr helper
  55059. */
  55060. export class WebXRDefaultExperienceOptions {
  55061. /**
  55062. * Enable or disable default UI to enter XR
  55063. */
  55064. disableDefaultUI?: boolean;
  55065. /**
  55066. * Should teleportation not initialize. defaults to false.
  55067. */
  55068. disableTeleportation?: boolean;
  55069. /**
  55070. * Floor meshes that will be used for teleport
  55071. */
  55072. floorMeshes?: Array<AbstractMesh>;
  55073. /**
  55074. * If set to true, the first frame will not be used to reset position
  55075. * The first frame is mainly used when copying transformation from the old camera
  55076. * Mainly used in AR
  55077. */
  55078. ignoreNativeCameraTransformation?: boolean;
  55079. /**
  55080. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55081. */
  55082. inputOptions?: IWebXRInputOptions;
  55083. /**
  55084. * optional configuration for the output canvas
  55085. */
  55086. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55087. /**
  55088. * optional UI options. This can be used among other to change session mode and reference space type
  55089. */
  55090. uiOptions?: WebXREnterExitUIOptions;
  55091. /**
  55092. * When loading teleportation and pointer select, use stable versions instead of latest.
  55093. */
  55094. useStablePlugins?: boolean;
  55095. /**
  55096. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55097. */
  55098. renderingGroupId?: number;
  55099. /**
  55100. * A list of optional features to init the session with
  55101. * If set to true, all features we support will be added
  55102. */
  55103. optionalFeatures?: boolean | string[];
  55104. }
  55105. /**
  55106. * Default experience which provides a similar setup to the previous webVRExperience
  55107. */
  55108. export class WebXRDefaultExperience {
  55109. /**
  55110. * Base experience
  55111. */
  55112. baseExperience: WebXRExperienceHelper;
  55113. /**
  55114. * Enables ui for entering/exiting xr
  55115. */
  55116. enterExitUI: WebXREnterExitUI;
  55117. /**
  55118. * Input experience extension
  55119. */
  55120. input: WebXRInput;
  55121. /**
  55122. * Enables laser pointer and selection
  55123. */
  55124. pointerSelection: WebXRControllerPointerSelection;
  55125. /**
  55126. * Default target xr should render to
  55127. */
  55128. renderTarget: WebXRRenderTarget;
  55129. /**
  55130. * Enables teleportation
  55131. */
  55132. teleportation: WebXRMotionControllerTeleportation;
  55133. private constructor();
  55134. /**
  55135. * Creates the default xr experience
  55136. * @param scene scene
  55137. * @param options options for basic configuration
  55138. * @returns resulting WebXRDefaultExperience
  55139. */
  55140. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55141. /**
  55142. * DIsposes of the experience helper
  55143. */
  55144. dispose(): void;
  55145. }
  55146. }
  55147. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55148. import { Observable } from "babylonjs/Misc/observable";
  55149. import { Nullable } from "babylonjs/types";
  55150. import { Camera } from "babylonjs/Cameras/camera";
  55151. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55152. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55153. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55154. import { Scene } from "babylonjs/scene";
  55155. import { Vector3 } from "babylonjs/Maths/math.vector";
  55156. import { Color3 } from "babylonjs/Maths/math.color";
  55157. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55159. import { Mesh } from "babylonjs/Meshes/mesh";
  55160. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55161. import { EasingFunction } from "babylonjs/Animations/easing";
  55162. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55163. import "babylonjs/Meshes/Builders/groundBuilder";
  55164. import "babylonjs/Meshes/Builders/torusBuilder";
  55165. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55166. import "babylonjs/Gamepads/gamepadSceneComponent";
  55167. import "babylonjs/Animations/animatable";
  55168. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55169. /**
  55170. * Options to modify the vr teleportation behavior.
  55171. */
  55172. export interface VRTeleportationOptions {
  55173. /**
  55174. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55175. */
  55176. floorMeshName?: string;
  55177. /**
  55178. * A list of meshes to be used as the teleportation floor. (default: empty)
  55179. */
  55180. floorMeshes?: Mesh[];
  55181. /**
  55182. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55183. */
  55184. teleportationMode?: number;
  55185. /**
  55186. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55187. */
  55188. teleportationTime?: number;
  55189. /**
  55190. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55191. */
  55192. teleportationSpeed?: number;
  55193. /**
  55194. * The easing function used in the animation or null for Linear. (default CircleEase)
  55195. */
  55196. easingFunction?: EasingFunction;
  55197. }
  55198. /**
  55199. * Options to modify the vr experience helper's behavior.
  55200. */
  55201. export interface VRExperienceHelperOptions extends WebVROptions {
  55202. /**
  55203. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55204. */
  55205. createDeviceOrientationCamera?: boolean;
  55206. /**
  55207. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55208. */
  55209. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55210. /**
  55211. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55212. */
  55213. laserToggle?: boolean;
  55214. /**
  55215. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55216. */
  55217. floorMeshes?: Mesh[];
  55218. /**
  55219. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55220. */
  55221. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55222. /**
  55223. * Defines if WebXR should be used instead of WebVR (if available)
  55224. */
  55225. useXR?: boolean;
  55226. }
  55227. /**
  55228. * Event containing information after VR has been entered
  55229. */
  55230. export class OnAfterEnteringVRObservableEvent {
  55231. /**
  55232. * If entering vr was successful
  55233. */
  55234. success: boolean;
  55235. }
  55236. /**
  55237. * Helps to quickly add VR support to an existing scene.
  55238. * See https://doc.babylonjs.com/how_to/webvr_helper
  55239. */
  55240. export class VRExperienceHelper {
  55241. /** Options to modify the vr experience helper's behavior. */
  55242. webVROptions: VRExperienceHelperOptions;
  55243. private _scene;
  55244. private _position;
  55245. private _btnVR;
  55246. private _btnVRDisplayed;
  55247. private _webVRsupported;
  55248. private _webVRready;
  55249. private _webVRrequesting;
  55250. private _webVRpresenting;
  55251. private _hasEnteredVR;
  55252. private _fullscreenVRpresenting;
  55253. private _inputElement;
  55254. private _webVRCamera;
  55255. private _vrDeviceOrientationCamera;
  55256. private _deviceOrientationCamera;
  55257. private _existingCamera;
  55258. private _onKeyDown;
  55259. private _onVrDisplayPresentChange;
  55260. private _onVRDisplayChanged;
  55261. private _onVRRequestPresentStart;
  55262. private _onVRRequestPresentComplete;
  55263. /**
  55264. * 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)
  55265. */
  55266. enableGazeEvenWhenNoPointerLock: boolean;
  55267. /**
  55268. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55269. */
  55270. exitVROnDoubleTap: boolean;
  55271. /**
  55272. * Observable raised right before entering VR.
  55273. */
  55274. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55275. /**
  55276. * Observable raised when entering VR has completed.
  55277. */
  55278. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55279. /**
  55280. * Observable raised when exiting VR.
  55281. */
  55282. onExitingVRObservable: Observable<VRExperienceHelper>;
  55283. /**
  55284. * Observable raised when controller mesh is loaded.
  55285. */
  55286. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55287. /** Return this.onEnteringVRObservable
  55288. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55289. */
  55290. get onEnteringVR(): Observable<VRExperienceHelper>;
  55291. /** Return this.onExitingVRObservable
  55292. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55293. */
  55294. get onExitingVR(): Observable<VRExperienceHelper>;
  55295. /** Return this.onControllerMeshLoadedObservable
  55296. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55297. */
  55298. get onControllerMeshLoaded(): Observable<WebVRController>;
  55299. private _rayLength;
  55300. private _useCustomVRButton;
  55301. private _teleportationRequested;
  55302. private _teleportActive;
  55303. private _floorMeshName;
  55304. private _floorMeshesCollection;
  55305. private _teleportationMode;
  55306. private _teleportationTime;
  55307. private _teleportationSpeed;
  55308. private _teleportationEasing;
  55309. private _rotationAllowed;
  55310. private _teleportBackwardsVector;
  55311. private _teleportationTarget;
  55312. private _isDefaultTeleportationTarget;
  55313. private _postProcessMove;
  55314. private _teleportationFillColor;
  55315. private _teleportationBorderColor;
  55316. private _rotationAngle;
  55317. private _haloCenter;
  55318. private _cameraGazer;
  55319. private _padSensibilityUp;
  55320. private _padSensibilityDown;
  55321. private _leftController;
  55322. private _rightController;
  55323. private _gazeColor;
  55324. private _laserColor;
  55325. private _pickedLaserColor;
  55326. private _pickedGazeColor;
  55327. /**
  55328. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55329. */
  55330. onNewMeshSelected: Observable<AbstractMesh>;
  55331. /**
  55332. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55333. * This observable will provide the mesh and the controller used to select the mesh
  55334. */
  55335. onMeshSelectedWithController: Observable<{
  55336. mesh: AbstractMesh;
  55337. controller: WebVRController;
  55338. }>;
  55339. /**
  55340. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55341. */
  55342. onNewMeshPicked: Observable<PickingInfo>;
  55343. private _circleEase;
  55344. /**
  55345. * Observable raised before camera teleportation
  55346. */
  55347. onBeforeCameraTeleport: Observable<Vector3>;
  55348. /**
  55349. * Observable raised after camera teleportation
  55350. */
  55351. onAfterCameraTeleport: Observable<Vector3>;
  55352. /**
  55353. * Observable raised when current selected mesh gets unselected
  55354. */
  55355. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55356. private _raySelectionPredicate;
  55357. /**
  55358. * To be optionaly changed by user to define custom ray selection
  55359. */
  55360. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55361. /**
  55362. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55363. */
  55364. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55365. /**
  55366. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55367. */
  55368. teleportationEnabled: boolean;
  55369. private _defaultHeight;
  55370. private _teleportationInitialized;
  55371. private _interactionsEnabled;
  55372. private _interactionsRequested;
  55373. private _displayGaze;
  55374. private _displayLaserPointer;
  55375. /**
  55376. * The mesh used to display where the user is going to teleport.
  55377. */
  55378. get teleportationTarget(): Mesh;
  55379. /**
  55380. * Sets the mesh to be used to display where the user is going to teleport.
  55381. */
  55382. set teleportationTarget(value: Mesh);
  55383. /**
  55384. * 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
  55385. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55386. * See https://doc.babylonjs.com/resources/baking_transformations
  55387. */
  55388. get gazeTrackerMesh(): Mesh;
  55389. set gazeTrackerMesh(value: Mesh);
  55390. /**
  55391. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55392. */
  55393. updateGazeTrackerScale: boolean;
  55394. /**
  55395. * If the gaze trackers color should be updated when selecting meshes
  55396. */
  55397. updateGazeTrackerColor: boolean;
  55398. /**
  55399. * If the controller laser color should be updated when selecting meshes
  55400. */
  55401. updateControllerLaserColor: boolean;
  55402. /**
  55403. * The gaze tracking mesh corresponding to the left controller
  55404. */
  55405. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55406. /**
  55407. * The gaze tracking mesh corresponding to the right controller
  55408. */
  55409. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55410. /**
  55411. * If the ray of the gaze should be displayed.
  55412. */
  55413. get displayGaze(): boolean;
  55414. /**
  55415. * Sets if the ray of the gaze should be displayed.
  55416. */
  55417. set displayGaze(value: boolean);
  55418. /**
  55419. * If the ray of the LaserPointer should be displayed.
  55420. */
  55421. get displayLaserPointer(): boolean;
  55422. /**
  55423. * Sets if the ray of the LaserPointer should be displayed.
  55424. */
  55425. set displayLaserPointer(value: boolean);
  55426. /**
  55427. * The deviceOrientationCamera used as the camera when not in VR.
  55428. */
  55429. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55430. /**
  55431. * Based on the current WebVR support, returns the current VR camera used.
  55432. */
  55433. get currentVRCamera(): Nullable<Camera>;
  55434. /**
  55435. * The webVRCamera which is used when in VR.
  55436. */
  55437. get webVRCamera(): WebVRFreeCamera;
  55438. /**
  55439. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55440. */
  55441. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55442. /**
  55443. * The html button that is used to trigger entering into VR.
  55444. */
  55445. get vrButton(): Nullable<HTMLButtonElement>;
  55446. private get _teleportationRequestInitiated();
  55447. /**
  55448. * Defines whether or not Pointer lock should be requested when switching to
  55449. * full screen.
  55450. */
  55451. requestPointerLockOnFullScreen: boolean;
  55452. /**
  55453. * If asking to force XR, this will be populated with the default xr experience
  55454. */
  55455. xr: WebXRDefaultExperience;
  55456. /**
  55457. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55458. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55459. */
  55460. xrTestDone: boolean;
  55461. /**
  55462. * Instantiates a VRExperienceHelper.
  55463. * Helps to quickly add VR support to an existing scene.
  55464. * @param scene The scene the VRExperienceHelper belongs to.
  55465. * @param webVROptions Options to modify the vr experience helper's behavior.
  55466. */
  55467. constructor(scene: Scene,
  55468. /** Options to modify the vr experience helper's behavior. */
  55469. webVROptions?: VRExperienceHelperOptions);
  55470. private completeVRInit;
  55471. private _onDefaultMeshLoaded;
  55472. private _onResize;
  55473. private _onFullscreenChange;
  55474. /**
  55475. * Gets a value indicating if we are currently in VR mode.
  55476. */
  55477. get isInVRMode(): boolean;
  55478. private onVrDisplayPresentChange;
  55479. private onVRDisplayChanged;
  55480. private moveButtonToBottomRight;
  55481. private displayVRButton;
  55482. private updateButtonVisibility;
  55483. private _cachedAngularSensibility;
  55484. /**
  55485. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55486. * Otherwise, will use the fullscreen API.
  55487. */
  55488. enterVR(): void;
  55489. /**
  55490. * Attempt to exit VR, or fullscreen.
  55491. */
  55492. exitVR(): void;
  55493. /**
  55494. * The position of the vr experience helper.
  55495. */
  55496. get position(): Vector3;
  55497. /**
  55498. * Sets the position of the vr experience helper.
  55499. */
  55500. set position(value: Vector3);
  55501. /**
  55502. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55503. */
  55504. enableInteractions(): void;
  55505. private get _noControllerIsActive();
  55506. private beforeRender;
  55507. private _isTeleportationFloor;
  55508. /**
  55509. * Adds a floor mesh to be used for teleportation.
  55510. * @param floorMesh the mesh to be used for teleportation.
  55511. */
  55512. addFloorMesh(floorMesh: Mesh): void;
  55513. /**
  55514. * Removes a floor mesh from being used for teleportation.
  55515. * @param floorMesh the mesh to be removed.
  55516. */
  55517. removeFloorMesh(floorMesh: Mesh): void;
  55518. /**
  55519. * Enables interactions and teleportation using the VR controllers and gaze.
  55520. * @param vrTeleportationOptions options to modify teleportation behavior.
  55521. */
  55522. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55523. private _onNewGamepadConnected;
  55524. private _tryEnableInteractionOnController;
  55525. private _onNewGamepadDisconnected;
  55526. private _enableInteractionOnController;
  55527. private _checkTeleportWithRay;
  55528. private _checkRotate;
  55529. private _checkTeleportBackwards;
  55530. private _enableTeleportationOnController;
  55531. private _createTeleportationCircles;
  55532. private _displayTeleportationTarget;
  55533. private _hideTeleportationTarget;
  55534. private _rotateCamera;
  55535. private _moveTeleportationSelectorTo;
  55536. private _workingVector;
  55537. private _workingQuaternion;
  55538. private _workingMatrix;
  55539. /**
  55540. * Time Constant Teleportation Mode
  55541. */
  55542. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55543. /**
  55544. * Speed Constant Teleportation Mode
  55545. */
  55546. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55547. /**
  55548. * Teleports the users feet to the desired location
  55549. * @param location The location where the user's feet should be placed
  55550. */
  55551. teleportCamera(location: Vector3): void;
  55552. private _convertNormalToDirectionOfRay;
  55553. private _castRayAndSelectObject;
  55554. private _notifySelectedMeshUnselected;
  55555. /**
  55556. * Permanently set new colors for the laser pointer
  55557. * @param color the new laser color
  55558. * @param pickedColor the new laser color when picked mesh detected
  55559. */
  55560. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55561. /**
  55562. * Set lighting enabled / disabled on the laser pointer of both controllers
  55563. * @param enabled should the lighting be enabled on the laser pointer
  55564. */
  55565. setLaserLightingState(enabled?: boolean): void;
  55566. /**
  55567. * Permanently set new colors for the gaze pointer
  55568. * @param color the new gaze color
  55569. * @param pickedColor the new gaze color when picked mesh detected
  55570. */
  55571. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55572. /**
  55573. * Sets the color of the laser ray from the vr controllers.
  55574. * @param color new color for the ray.
  55575. */
  55576. changeLaserColor(color: Color3): void;
  55577. /**
  55578. * Sets the color of the ray from the vr headsets gaze.
  55579. * @param color new color for the ray.
  55580. */
  55581. changeGazeColor(color: Color3): void;
  55582. /**
  55583. * Exits VR and disposes of the vr experience helper
  55584. */
  55585. dispose(): void;
  55586. /**
  55587. * Gets the name of the VRExperienceHelper class
  55588. * @returns "VRExperienceHelper"
  55589. */
  55590. getClassName(): string;
  55591. }
  55592. }
  55593. declare module "babylonjs/Cameras/VR/index" {
  55594. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55595. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55596. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55597. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55598. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55599. export * from "babylonjs/Cameras/VR/webVRCamera";
  55600. }
  55601. declare module "babylonjs/Cameras/RigModes/index" {
  55602. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55603. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55604. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55605. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55606. }
  55607. declare module "babylonjs/Cameras/index" {
  55608. export * from "babylonjs/Cameras/Inputs/index";
  55609. export * from "babylonjs/Cameras/cameraInputsManager";
  55610. export * from "babylonjs/Cameras/camera";
  55611. export * from "babylonjs/Cameras/targetCamera";
  55612. export * from "babylonjs/Cameras/freeCamera";
  55613. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55614. export * from "babylonjs/Cameras/touchCamera";
  55615. export * from "babylonjs/Cameras/arcRotateCamera";
  55616. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55617. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55618. export * from "babylonjs/Cameras/flyCamera";
  55619. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55620. export * from "babylonjs/Cameras/followCamera";
  55621. export * from "babylonjs/Cameras/followCameraInputsManager";
  55622. export * from "babylonjs/Cameras/gamepadCamera";
  55623. export * from "babylonjs/Cameras/Stereoscopic/index";
  55624. export * from "babylonjs/Cameras/universalCamera";
  55625. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55626. export * from "babylonjs/Cameras/VR/index";
  55627. export * from "babylonjs/Cameras/RigModes/index";
  55628. }
  55629. declare module "babylonjs/Collisions/index" {
  55630. export * from "babylonjs/Collisions/collider";
  55631. export * from "babylonjs/Collisions/collisionCoordinator";
  55632. export * from "babylonjs/Collisions/pickingInfo";
  55633. export * from "babylonjs/Collisions/intersectionInfo";
  55634. export * from "babylonjs/Collisions/meshCollisionData";
  55635. }
  55636. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55637. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55638. import { Vector3 } from "babylonjs/Maths/math.vector";
  55639. import { Ray } from "babylonjs/Culling/ray";
  55640. import { Plane } from "babylonjs/Maths/math.plane";
  55641. /**
  55642. * Contains an array of blocks representing the octree
  55643. */
  55644. export interface IOctreeContainer<T> {
  55645. /**
  55646. * Blocks within the octree
  55647. */
  55648. blocks: Array<OctreeBlock<T>>;
  55649. }
  55650. /**
  55651. * Class used to store a cell in an octree
  55652. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55653. */
  55654. export class OctreeBlock<T> {
  55655. /**
  55656. * Gets the content of the current block
  55657. */
  55658. entries: T[];
  55659. /**
  55660. * Gets the list of block children
  55661. */
  55662. blocks: Array<OctreeBlock<T>>;
  55663. private _depth;
  55664. private _maxDepth;
  55665. private _capacity;
  55666. private _minPoint;
  55667. private _maxPoint;
  55668. private _boundingVectors;
  55669. private _creationFunc;
  55670. /**
  55671. * Creates a new block
  55672. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55673. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55674. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55675. * @param depth defines the current depth of this block in the octree
  55676. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55677. * @param creationFunc defines a callback to call when an element is added to the block
  55678. */
  55679. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55680. /**
  55681. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55682. */
  55683. get capacity(): number;
  55684. /**
  55685. * Gets the minimum vector (in world space) of the block's bounding box
  55686. */
  55687. get minPoint(): Vector3;
  55688. /**
  55689. * Gets the maximum vector (in world space) of the block's bounding box
  55690. */
  55691. get maxPoint(): Vector3;
  55692. /**
  55693. * Add a new element to this block
  55694. * @param entry defines the element to add
  55695. */
  55696. addEntry(entry: T): void;
  55697. /**
  55698. * Remove an element from this block
  55699. * @param entry defines the element to remove
  55700. */
  55701. removeEntry(entry: T): void;
  55702. /**
  55703. * Add an array of elements to this block
  55704. * @param entries defines the array of elements to add
  55705. */
  55706. addEntries(entries: T[]): void;
  55707. /**
  55708. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55709. * @param frustumPlanes defines the frustum planes to test
  55710. * @param selection defines the array to store current content if selection is positive
  55711. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55712. */
  55713. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55714. /**
  55715. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55716. * @param sphereCenter defines the bounding sphere center
  55717. * @param sphereRadius defines the bounding sphere radius
  55718. * @param selection defines the array to store current content if selection is positive
  55719. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55720. */
  55721. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55722. /**
  55723. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55724. * @param ray defines the ray to test with
  55725. * @param selection defines the array to store current content if selection is positive
  55726. */
  55727. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55728. /**
  55729. * Subdivide the content into child blocks (this block will then be empty)
  55730. */
  55731. createInnerBlocks(): void;
  55732. /**
  55733. * @hidden
  55734. */
  55735. 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;
  55736. }
  55737. }
  55738. declare module "babylonjs/Culling/Octrees/octree" {
  55739. import { SmartArray } from "babylonjs/Misc/smartArray";
  55740. import { Vector3 } from "babylonjs/Maths/math.vector";
  55741. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55743. import { Ray } from "babylonjs/Culling/ray";
  55744. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55745. import { Plane } from "babylonjs/Maths/math.plane";
  55746. /**
  55747. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55748. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55749. */
  55750. export class Octree<T> {
  55751. /** 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.) */
  55752. maxDepth: number;
  55753. /**
  55754. * Blocks within the octree containing objects
  55755. */
  55756. blocks: Array<OctreeBlock<T>>;
  55757. /**
  55758. * Content stored in the octree
  55759. */
  55760. dynamicContent: T[];
  55761. private _maxBlockCapacity;
  55762. private _selectionContent;
  55763. private _creationFunc;
  55764. /**
  55765. * Creates a octree
  55766. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55767. * @param creationFunc function to be used to instatiate the octree
  55768. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55769. * @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.)
  55770. */
  55771. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55772. /** 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.) */
  55773. maxDepth?: number);
  55774. /**
  55775. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55776. * @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);
  55777. * @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);
  55778. * @param entries meshes to be added to the octree blocks
  55779. */
  55780. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55781. /**
  55782. * Adds a mesh to the octree
  55783. * @param entry Mesh to add to the octree
  55784. */
  55785. addMesh(entry: T): void;
  55786. /**
  55787. * Remove an element from the octree
  55788. * @param entry defines the element to remove
  55789. */
  55790. removeMesh(entry: T): void;
  55791. /**
  55792. * Selects an array of meshes within the frustum
  55793. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55794. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55795. * @returns array of meshes within the frustum
  55796. */
  55797. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55798. /**
  55799. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55800. * @param sphereCenter defines the bounding sphere center
  55801. * @param sphereRadius defines the bounding sphere radius
  55802. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55803. * @returns an array of objects that intersect the sphere
  55804. */
  55805. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55806. /**
  55807. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55808. * @param ray defines the ray to test with
  55809. * @returns array of intersected objects
  55810. */
  55811. intersectsRay(ray: Ray): SmartArray<T>;
  55812. /**
  55813. * Adds a mesh into the octree block if it intersects the block
  55814. */
  55815. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55816. /**
  55817. * Adds a submesh into the octree block if it intersects the block
  55818. */
  55819. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55820. }
  55821. }
  55822. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55823. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55824. import { Scene } from "babylonjs/scene";
  55825. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55827. import { Ray } from "babylonjs/Culling/ray";
  55828. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55829. import { Collider } from "babylonjs/Collisions/collider";
  55830. module "babylonjs/scene" {
  55831. interface Scene {
  55832. /**
  55833. * @hidden
  55834. * Backing Filed
  55835. */
  55836. _selectionOctree: Octree<AbstractMesh>;
  55837. /**
  55838. * Gets the octree used to boost mesh selection (picking)
  55839. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55840. */
  55841. selectionOctree: Octree<AbstractMesh>;
  55842. /**
  55843. * Creates or updates the octree used to boost selection (picking)
  55844. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55845. * @param maxCapacity defines the maximum capacity per leaf
  55846. * @param maxDepth defines the maximum depth of the octree
  55847. * @returns an octree of AbstractMesh
  55848. */
  55849. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55850. }
  55851. }
  55852. module "babylonjs/Meshes/abstractMesh" {
  55853. interface AbstractMesh {
  55854. /**
  55855. * @hidden
  55856. * Backing Field
  55857. */
  55858. _submeshesOctree: Octree<SubMesh>;
  55859. /**
  55860. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55861. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55862. * @param maxCapacity defines the maximum size of each block (64 by default)
  55863. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55864. * @returns the new octree
  55865. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55866. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55867. */
  55868. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55869. }
  55870. }
  55871. /**
  55872. * Defines the octree scene component responsible to manage any octrees
  55873. * in a given scene.
  55874. */
  55875. export class OctreeSceneComponent {
  55876. /**
  55877. * The component name help to identify the component in the list of scene components.
  55878. */
  55879. readonly name: string;
  55880. /**
  55881. * The scene the component belongs to.
  55882. */
  55883. scene: Scene;
  55884. /**
  55885. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55886. */
  55887. readonly checksIsEnabled: boolean;
  55888. /**
  55889. * Creates a new instance of the component for the given scene
  55890. * @param scene Defines the scene to register the component in
  55891. */
  55892. constructor(scene: Scene);
  55893. /**
  55894. * Registers the component in a given scene
  55895. */
  55896. register(): void;
  55897. /**
  55898. * Return the list of active meshes
  55899. * @returns the list of active meshes
  55900. */
  55901. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55902. /**
  55903. * Return the list of active sub meshes
  55904. * @param mesh The mesh to get the candidates sub meshes from
  55905. * @returns the list of active sub meshes
  55906. */
  55907. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55908. private _tempRay;
  55909. /**
  55910. * Return the list of sub meshes intersecting with a given local ray
  55911. * @param mesh defines the mesh to find the submesh for
  55912. * @param localRay defines the ray in local space
  55913. * @returns the list of intersecting sub meshes
  55914. */
  55915. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55916. /**
  55917. * Return the list of sub meshes colliding with a collider
  55918. * @param mesh defines the mesh to find the submesh for
  55919. * @param collider defines the collider to evaluate the collision against
  55920. * @returns the list of colliding sub meshes
  55921. */
  55922. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55923. /**
  55924. * Rebuilds the elements related to this component in case of
  55925. * context lost for instance.
  55926. */
  55927. rebuild(): void;
  55928. /**
  55929. * Disposes the component and the associated ressources.
  55930. */
  55931. dispose(): void;
  55932. }
  55933. }
  55934. declare module "babylonjs/Culling/Octrees/index" {
  55935. export * from "babylonjs/Culling/Octrees/octree";
  55936. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55937. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55938. }
  55939. declare module "babylonjs/Culling/index" {
  55940. export * from "babylonjs/Culling/boundingBox";
  55941. export * from "babylonjs/Culling/boundingInfo";
  55942. export * from "babylonjs/Culling/boundingSphere";
  55943. export * from "babylonjs/Culling/Octrees/index";
  55944. export * from "babylonjs/Culling/ray";
  55945. }
  55946. declare module "babylonjs/Gizmos/gizmo" {
  55947. import { Nullable } from "babylonjs/types";
  55948. import { IDisposable } from "babylonjs/scene";
  55949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55950. import { Mesh } from "babylonjs/Meshes/mesh";
  55951. import { Node } from "babylonjs/node";
  55952. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55953. /**
  55954. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55955. */
  55956. export class Gizmo implements IDisposable {
  55957. /** The utility layer the gizmo will be added to */
  55958. gizmoLayer: UtilityLayerRenderer;
  55959. /**
  55960. * The root mesh of the gizmo
  55961. */
  55962. _rootMesh: Mesh;
  55963. private _attachedMesh;
  55964. private _attachedNode;
  55965. /**
  55966. * Ratio for the scale of the gizmo (Default: 1)
  55967. */
  55968. protected _scaleRatio: number;
  55969. /**
  55970. * boolean updated by pointermove when a gizmo mesh is hovered
  55971. */
  55972. protected _isHovered: boolean;
  55973. /**
  55974. * Ratio for the scale of the gizmo (Default: 1)
  55975. */
  55976. set scaleRatio(value: number);
  55977. get scaleRatio(): number;
  55978. /**
  55979. * True when the mouse pointer is hovered a gizmo mesh
  55980. */
  55981. get isHovered(): boolean;
  55982. /**
  55983. * If a custom mesh has been set (Default: false)
  55984. */
  55985. protected _customMeshSet: boolean;
  55986. /**
  55987. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55988. * * When set, interactions will be enabled
  55989. */
  55990. get attachedMesh(): Nullable<AbstractMesh>;
  55991. set attachedMesh(value: Nullable<AbstractMesh>);
  55992. /**
  55993. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55994. * * When set, interactions will be enabled
  55995. */
  55996. get attachedNode(): Nullable<Node>;
  55997. set attachedNode(value: Nullable<Node>);
  55998. /**
  55999. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56000. * @param mesh The mesh to replace the default mesh of the gizmo
  56001. */
  56002. setCustomMesh(mesh: Mesh): void;
  56003. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56004. /**
  56005. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56006. */
  56007. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56008. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56009. /**
  56010. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56011. */
  56012. updateGizmoPositionToMatchAttachedMesh: boolean;
  56013. /**
  56014. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56015. */
  56016. updateScale: boolean;
  56017. protected _interactionsEnabled: boolean;
  56018. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56019. private _beforeRenderObserver;
  56020. private _tempQuaternion;
  56021. private _tempVector;
  56022. private _tempVector2;
  56023. private _tempMatrix1;
  56024. private _tempMatrix2;
  56025. private _rightHandtoLeftHandMatrix;
  56026. /**
  56027. * Creates a gizmo
  56028. * @param gizmoLayer The utility layer the gizmo will be added to
  56029. */
  56030. constructor(
  56031. /** The utility layer the gizmo will be added to */
  56032. gizmoLayer?: UtilityLayerRenderer);
  56033. /**
  56034. * Updates the gizmo to match the attached mesh's position/rotation
  56035. */
  56036. protected _update(): void;
  56037. /**
  56038. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56039. * @param value Node, TransformNode or mesh
  56040. */
  56041. protected _matrixChanged(): void;
  56042. /**
  56043. * Disposes of the gizmo
  56044. */
  56045. dispose(): void;
  56046. }
  56047. }
  56048. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56049. import { Observable } from "babylonjs/Misc/observable";
  56050. import { Nullable } from "babylonjs/types";
  56051. import { Vector3 } from "babylonjs/Maths/math.vector";
  56052. import { Color3 } from "babylonjs/Maths/math.color";
  56053. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56054. import { Node } from "babylonjs/node";
  56055. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56056. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56057. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56058. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56059. import { Scene } from "babylonjs/scene";
  56060. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56061. /**
  56062. * Single plane drag gizmo
  56063. */
  56064. export class PlaneDragGizmo extends Gizmo {
  56065. /**
  56066. * Drag behavior responsible for the gizmos dragging interactions
  56067. */
  56068. dragBehavior: PointerDragBehavior;
  56069. private _pointerObserver;
  56070. /**
  56071. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56072. */
  56073. snapDistance: number;
  56074. /**
  56075. * Event that fires each time the gizmo snaps to a new location.
  56076. * * snapDistance is the the change in distance
  56077. */
  56078. onSnapObservable: Observable<{
  56079. snapDistance: number;
  56080. }>;
  56081. private _plane;
  56082. private _coloredMaterial;
  56083. private _hoverMaterial;
  56084. private _isEnabled;
  56085. private _parent;
  56086. /** @hidden */
  56087. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56088. /** @hidden */
  56089. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56090. /**
  56091. * Creates a PlaneDragGizmo
  56092. * @param gizmoLayer The utility layer the gizmo will be added to
  56093. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56094. * @param color The color of the gizmo
  56095. */
  56096. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56097. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56098. /**
  56099. * If the gizmo is enabled
  56100. */
  56101. set isEnabled(value: boolean);
  56102. get isEnabled(): boolean;
  56103. /**
  56104. * Disposes of the gizmo
  56105. */
  56106. dispose(): void;
  56107. }
  56108. }
  56109. declare module "babylonjs/Gizmos/positionGizmo" {
  56110. import { Observable } from "babylonjs/Misc/observable";
  56111. import { Nullable } from "babylonjs/types";
  56112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56113. import { Node } from "babylonjs/node";
  56114. import { Mesh } from "babylonjs/Meshes/mesh";
  56115. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56116. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  56117. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  56118. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56119. /**
  56120. * Gizmo that enables dragging a mesh along 3 axis
  56121. */
  56122. export class PositionGizmo extends Gizmo {
  56123. /**
  56124. * Internal gizmo used for interactions on the x axis
  56125. */
  56126. xGizmo: AxisDragGizmo;
  56127. /**
  56128. * Internal gizmo used for interactions on the y axis
  56129. */
  56130. yGizmo: AxisDragGizmo;
  56131. /**
  56132. * Internal gizmo used for interactions on the z axis
  56133. */
  56134. zGizmo: AxisDragGizmo;
  56135. /**
  56136. * Internal gizmo used for interactions on the yz plane
  56137. */
  56138. xPlaneGizmo: PlaneDragGizmo;
  56139. /**
  56140. * Internal gizmo used for interactions on the xz plane
  56141. */
  56142. yPlaneGizmo: PlaneDragGizmo;
  56143. /**
  56144. * Internal gizmo used for interactions on the xy plane
  56145. */
  56146. zPlaneGizmo: PlaneDragGizmo;
  56147. /**
  56148. * private variables
  56149. */
  56150. private _meshAttached;
  56151. private _nodeAttached;
  56152. private _snapDistance;
  56153. /** Fires an event when any of it's sub gizmos are dragged */
  56154. onDragStartObservable: Observable<unknown>;
  56155. /** Fires an event when any of it's sub gizmos are released from dragging */
  56156. onDragEndObservable: Observable<unknown>;
  56157. /**
  56158. * If set to true, planar drag is enabled
  56159. */
  56160. private _planarGizmoEnabled;
  56161. get attachedMesh(): Nullable<AbstractMesh>;
  56162. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56163. get attachedNode(): Nullable<Node>;
  56164. set attachedNode(node: Nullable<Node>);
  56165. /**
  56166. * True when the mouse pointer is hovering a gizmo mesh
  56167. */
  56168. get isHovered(): boolean;
  56169. /**
  56170. * Creates a PositionGizmo
  56171. * @param gizmoLayer The utility layer the gizmo will be added to
  56172. @param thickness display gizmo axis thickness
  56173. */
  56174. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56175. /**
  56176. * If the planar drag gizmo is enabled
  56177. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  56178. */
  56179. set planarGizmoEnabled(value: boolean);
  56180. get planarGizmoEnabled(): boolean;
  56181. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56182. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56183. /**
  56184. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56185. */
  56186. set snapDistance(value: number);
  56187. get snapDistance(): number;
  56188. /**
  56189. * Ratio for the scale of the gizmo (Default: 1)
  56190. */
  56191. set scaleRatio(value: number);
  56192. get scaleRatio(): number;
  56193. /**
  56194. * Disposes of the gizmo
  56195. */
  56196. dispose(): void;
  56197. /**
  56198. * CustomMeshes are not supported by this gizmo
  56199. * @param mesh The mesh to replace the default mesh of the gizmo
  56200. */
  56201. setCustomMesh(mesh: Mesh): void;
  56202. }
  56203. }
  56204. declare module "babylonjs/Gizmos/axisDragGizmo" {
  56205. import { Observable } from "babylonjs/Misc/observable";
  56206. import { Nullable } from "babylonjs/types";
  56207. import { Vector3 } from "babylonjs/Maths/math.vector";
  56208. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56209. import { Node } from "babylonjs/node";
  56210. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56211. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56212. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56213. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56214. import { Scene } from "babylonjs/scene";
  56215. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56216. import { Color3 } from "babylonjs/Maths/math.color";
  56217. /**
  56218. * Single axis drag gizmo
  56219. */
  56220. export class AxisDragGizmo extends Gizmo {
  56221. /**
  56222. * Drag behavior responsible for the gizmos dragging interactions
  56223. */
  56224. dragBehavior: PointerDragBehavior;
  56225. private _pointerObserver;
  56226. /**
  56227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56228. */
  56229. snapDistance: number;
  56230. /**
  56231. * Event that fires each time the gizmo snaps to a new location.
  56232. * * snapDistance is the the change in distance
  56233. */
  56234. onSnapObservable: Observable<{
  56235. snapDistance: number;
  56236. }>;
  56237. private _isEnabled;
  56238. private _parent;
  56239. private _arrow;
  56240. private _coloredMaterial;
  56241. private _hoverMaterial;
  56242. /** @hidden */
  56243. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  56244. /** @hidden */
  56245. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56246. /**
  56247. * Creates an AxisDragGizmo
  56248. * @param gizmoLayer The utility layer the gizmo will be added to
  56249. * @param dragAxis The axis which the gizmo will be able to drag on
  56250. * @param color The color of the gizmo
  56251. * @param thickness display gizmo axis thickness
  56252. */
  56253. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  56254. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56255. /**
  56256. * If the gizmo is enabled
  56257. */
  56258. set isEnabled(value: boolean);
  56259. get isEnabled(): boolean;
  56260. /**
  56261. * Disposes of the gizmo
  56262. */
  56263. dispose(): void;
  56264. }
  56265. }
  56266. declare module "babylonjs/Debug/axesViewer" {
  56267. import { Vector3 } from "babylonjs/Maths/math.vector";
  56268. import { Nullable } from "babylonjs/types";
  56269. import { Scene } from "babylonjs/scene";
  56270. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56271. /**
  56272. * The Axes viewer will show 3 axes in a specific point in space
  56273. */
  56274. export class AxesViewer {
  56275. private _xAxis;
  56276. private _yAxis;
  56277. private _zAxis;
  56278. private _scaleLinesFactor;
  56279. private _instanced;
  56280. /**
  56281. * Gets the hosting scene
  56282. */
  56283. scene: Nullable<Scene>;
  56284. /**
  56285. * Gets or sets a number used to scale line length
  56286. */
  56287. scaleLines: number;
  56288. /** Gets the node hierarchy used to render x-axis */
  56289. get xAxis(): TransformNode;
  56290. /** Gets the node hierarchy used to render y-axis */
  56291. get yAxis(): TransformNode;
  56292. /** Gets the node hierarchy used to render z-axis */
  56293. get zAxis(): TransformNode;
  56294. /**
  56295. * Creates a new AxesViewer
  56296. * @param scene defines the hosting scene
  56297. * @param scaleLines defines a number used to scale line length (1 by default)
  56298. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  56299. * @param xAxis defines the node hierarchy used to render the x-axis
  56300. * @param yAxis defines the node hierarchy used to render the y-axis
  56301. * @param zAxis defines the node hierarchy used to render the z-axis
  56302. */
  56303. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  56304. /**
  56305. * Force the viewer to update
  56306. * @param position defines the position of the viewer
  56307. * @param xaxis defines the x axis of the viewer
  56308. * @param yaxis defines the y axis of the viewer
  56309. * @param zaxis defines the z axis of the viewer
  56310. */
  56311. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  56312. /**
  56313. * Creates an instance of this axes viewer.
  56314. * @returns a new axes viewer with instanced meshes
  56315. */
  56316. createInstance(): AxesViewer;
  56317. /** Releases resources */
  56318. dispose(): void;
  56319. private static _SetRenderingGroupId;
  56320. }
  56321. }
  56322. declare module "babylonjs/Debug/boneAxesViewer" {
  56323. import { Nullable } from "babylonjs/types";
  56324. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  56325. import { Vector3 } from "babylonjs/Maths/math.vector";
  56326. import { Mesh } from "babylonjs/Meshes/mesh";
  56327. import { Bone } from "babylonjs/Bones/bone";
  56328. import { Scene } from "babylonjs/scene";
  56329. /**
  56330. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  56331. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  56332. */
  56333. export class BoneAxesViewer extends AxesViewer {
  56334. /**
  56335. * Gets or sets the target mesh where to display the axes viewer
  56336. */
  56337. mesh: Nullable<Mesh>;
  56338. /**
  56339. * Gets or sets the target bone where to display the axes viewer
  56340. */
  56341. bone: Nullable<Bone>;
  56342. /** Gets current position */
  56343. pos: Vector3;
  56344. /** Gets direction of X axis */
  56345. xaxis: Vector3;
  56346. /** Gets direction of Y axis */
  56347. yaxis: Vector3;
  56348. /** Gets direction of Z axis */
  56349. zaxis: Vector3;
  56350. /**
  56351. * Creates a new BoneAxesViewer
  56352. * @param scene defines the hosting scene
  56353. * @param bone defines the target bone
  56354. * @param mesh defines the target mesh
  56355. * @param scaleLines defines a scaling factor for line length (1 by default)
  56356. */
  56357. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56358. /**
  56359. * Force the viewer to update
  56360. */
  56361. update(): void;
  56362. /** Releases resources */
  56363. dispose(): void;
  56364. }
  56365. }
  56366. declare module "babylonjs/Debug/debugLayer" {
  56367. import { Scene } from "babylonjs/scene";
  56368. /**
  56369. * Interface used to define scene explorer extensibility option
  56370. */
  56371. export interface IExplorerExtensibilityOption {
  56372. /**
  56373. * Define the option label
  56374. */
  56375. label: string;
  56376. /**
  56377. * Defines the action to execute on click
  56378. */
  56379. action: (entity: any) => void;
  56380. }
  56381. /**
  56382. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56383. */
  56384. export interface IExplorerExtensibilityGroup {
  56385. /**
  56386. * Defines a predicate to test if a given type mut be extended
  56387. */
  56388. predicate: (entity: any) => boolean;
  56389. /**
  56390. * Gets the list of options added to a type
  56391. */
  56392. entries: IExplorerExtensibilityOption[];
  56393. }
  56394. /**
  56395. * Interface used to define the options to use to create the Inspector
  56396. */
  56397. export interface IInspectorOptions {
  56398. /**
  56399. * Display in overlay mode (default: false)
  56400. */
  56401. overlay?: boolean;
  56402. /**
  56403. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56404. */
  56405. globalRoot?: HTMLElement;
  56406. /**
  56407. * Display the Scene explorer
  56408. */
  56409. showExplorer?: boolean;
  56410. /**
  56411. * Display the property inspector
  56412. */
  56413. showInspector?: boolean;
  56414. /**
  56415. * Display in embed mode (both panes on the right)
  56416. */
  56417. embedMode?: boolean;
  56418. /**
  56419. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56420. */
  56421. handleResize?: boolean;
  56422. /**
  56423. * Allow the panes to popup (default: true)
  56424. */
  56425. enablePopup?: boolean;
  56426. /**
  56427. * Allow the panes to be closed by users (default: true)
  56428. */
  56429. enableClose?: boolean;
  56430. /**
  56431. * Optional list of extensibility entries
  56432. */
  56433. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56434. /**
  56435. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56436. */
  56437. inspectorURL?: string;
  56438. /**
  56439. * Optional initial tab (default to DebugLayerTab.Properties)
  56440. */
  56441. initialTab?: DebugLayerTab;
  56442. }
  56443. module "babylonjs/scene" {
  56444. interface Scene {
  56445. /**
  56446. * @hidden
  56447. * Backing field
  56448. */
  56449. _debugLayer: DebugLayer;
  56450. /**
  56451. * Gets the debug layer (aka Inspector) associated with the scene
  56452. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56453. */
  56454. debugLayer: DebugLayer;
  56455. }
  56456. }
  56457. /**
  56458. * Enum of inspector action tab
  56459. */
  56460. export enum DebugLayerTab {
  56461. /**
  56462. * Properties tag (default)
  56463. */
  56464. Properties = 0,
  56465. /**
  56466. * Debug tab
  56467. */
  56468. Debug = 1,
  56469. /**
  56470. * Statistics tab
  56471. */
  56472. Statistics = 2,
  56473. /**
  56474. * Tools tab
  56475. */
  56476. Tools = 3,
  56477. /**
  56478. * Settings tab
  56479. */
  56480. Settings = 4
  56481. }
  56482. /**
  56483. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56484. * what is happening in your scene
  56485. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56486. */
  56487. export class DebugLayer {
  56488. /**
  56489. * Define the url to get the inspector script from.
  56490. * By default it uses the babylonjs CDN.
  56491. * @ignoreNaming
  56492. */
  56493. static InspectorURL: string;
  56494. private _scene;
  56495. private BJSINSPECTOR;
  56496. private _onPropertyChangedObservable?;
  56497. /**
  56498. * Observable triggered when a property is changed through the inspector.
  56499. */
  56500. get onPropertyChangedObservable(): any;
  56501. /**
  56502. * Instantiates a new debug layer.
  56503. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56504. * what is happening in your scene
  56505. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56506. * @param scene Defines the scene to inspect
  56507. */
  56508. constructor(scene: Scene);
  56509. /** Creates the inspector window. */
  56510. private _createInspector;
  56511. /**
  56512. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56513. * @param entity defines the entity to select
  56514. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56515. */
  56516. select(entity: any, lineContainerTitles?: string | string[]): void;
  56517. /** Get the inspector from bundle or global */
  56518. private _getGlobalInspector;
  56519. /**
  56520. * Get if the inspector is visible or not.
  56521. * @returns true if visible otherwise, false
  56522. */
  56523. isVisible(): boolean;
  56524. /**
  56525. * Hide the inspector and close its window.
  56526. */
  56527. hide(): void;
  56528. /**
  56529. * Update the scene in the inspector
  56530. */
  56531. setAsActiveScene(): void;
  56532. /**
  56533. * Launch the debugLayer.
  56534. * @param config Define the configuration of the inspector
  56535. * @return a promise fulfilled when the debug layer is visible
  56536. */
  56537. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56538. }
  56539. }
  56540. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56541. import { Nullable } from "babylonjs/types";
  56542. import { Scene } from "babylonjs/scene";
  56543. import { Vector4 } from "babylonjs/Maths/math.vector";
  56544. import { Color4 } from "babylonjs/Maths/math.color";
  56545. import { Mesh } from "babylonjs/Meshes/mesh";
  56546. /**
  56547. * Class containing static functions to help procedurally build meshes
  56548. */
  56549. export class BoxBuilder {
  56550. /**
  56551. * Creates a box mesh
  56552. * * The parameter `size` sets the size (float) of each box side (default 1)
  56553. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56554. * * 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)
  56555. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56559. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56560. * @param name defines the name of the mesh
  56561. * @param options defines the options used to create the mesh
  56562. * @param scene defines the hosting scene
  56563. * @returns the box mesh
  56564. */
  56565. static CreateBox(name: string, options: {
  56566. size?: number;
  56567. width?: number;
  56568. height?: number;
  56569. depth?: number;
  56570. faceUV?: Vector4[];
  56571. faceColors?: Color4[];
  56572. sideOrientation?: number;
  56573. frontUVs?: Vector4;
  56574. backUVs?: Vector4;
  56575. wrap?: boolean;
  56576. topBaseAt?: number;
  56577. bottomBaseAt?: number;
  56578. updatable?: boolean;
  56579. }, scene?: Nullable<Scene>): Mesh;
  56580. }
  56581. }
  56582. declare module "babylonjs/Debug/physicsViewer" {
  56583. import { Nullable } from "babylonjs/types";
  56584. import { Scene } from "babylonjs/scene";
  56585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56586. import { Mesh } from "babylonjs/Meshes/mesh";
  56587. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56588. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56589. /**
  56590. * Used to show the physics impostor around the specific mesh
  56591. */
  56592. export class PhysicsViewer {
  56593. /** @hidden */
  56594. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56595. /** @hidden */
  56596. protected _meshes: Array<Nullable<AbstractMesh>>;
  56597. /** @hidden */
  56598. protected _scene: Nullable<Scene>;
  56599. /** @hidden */
  56600. protected _numMeshes: number;
  56601. /** @hidden */
  56602. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56603. private _renderFunction;
  56604. private _utilityLayer;
  56605. private _debugBoxMesh;
  56606. private _debugSphereMesh;
  56607. private _debugCylinderMesh;
  56608. private _debugMaterial;
  56609. private _debugMeshMeshes;
  56610. /**
  56611. * Creates a new PhysicsViewer
  56612. * @param scene defines the hosting scene
  56613. */
  56614. constructor(scene: Scene);
  56615. /** @hidden */
  56616. protected _updateDebugMeshes(): void;
  56617. /**
  56618. * Renders a specified physic impostor
  56619. * @param impostor defines the impostor to render
  56620. * @param targetMesh defines the mesh represented by the impostor
  56621. * @returns the new debug mesh used to render the impostor
  56622. */
  56623. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56624. /**
  56625. * Hides a specified physic impostor
  56626. * @param impostor defines the impostor to hide
  56627. */
  56628. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56629. private _getDebugMaterial;
  56630. private _getDebugBoxMesh;
  56631. private _getDebugSphereMesh;
  56632. private _getDebugCylinderMesh;
  56633. private _getDebugMeshMesh;
  56634. private _getDebugMesh;
  56635. /** Releases all resources */
  56636. dispose(): void;
  56637. }
  56638. }
  56639. declare module "babylonjs/Debug/rayHelper" {
  56640. import { Nullable } from "babylonjs/types";
  56641. import { Ray } from "babylonjs/Culling/ray";
  56642. import { Vector3 } from "babylonjs/Maths/math.vector";
  56643. import { Color3 } from "babylonjs/Maths/math.color";
  56644. import { Scene } from "babylonjs/scene";
  56645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56646. import "babylonjs/Meshes/Builders/linesBuilder";
  56647. /**
  56648. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56649. * in order to better appreciate the issue one might have.
  56650. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56651. */
  56652. export class RayHelper {
  56653. /**
  56654. * Defines the ray we are currently tryin to visualize.
  56655. */
  56656. ray: Nullable<Ray>;
  56657. private _renderPoints;
  56658. private _renderLine;
  56659. private _renderFunction;
  56660. private _scene;
  56661. private _onAfterRenderObserver;
  56662. private _onAfterStepObserver;
  56663. private _attachedToMesh;
  56664. private _meshSpaceDirection;
  56665. private _meshSpaceOrigin;
  56666. /**
  56667. * Helper function to create a colored helper in a scene in one line.
  56668. * @param ray Defines the ray we are currently tryin to visualize
  56669. * @param scene Defines the scene the ray is used in
  56670. * @param color Defines the color we want to see the ray in
  56671. * @returns The newly created ray helper.
  56672. */
  56673. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56674. /**
  56675. * Instantiate a new ray helper.
  56676. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56677. * in order to better appreciate the issue one might have.
  56678. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56679. * @param ray Defines the ray we are currently tryin to visualize
  56680. */
  56681. constructor(ray: Ray);
  56682. /**
  56683. * Shows the ray we are willing to debug.
  56684. * @param scene Defines the scene the ray needs to be rendered in
  56685. * @param color Defines the color the ray needs to be rendered in
  56686. */
  56687. show(scene: Scene, color?: Color3): void;
  56688. /**
  56689. * Hides the ray we are debugging.
  56690. */
  56691. hide(): void;
  56692. private _render;
  56693. /**
  56694. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56695. * @param mesh Defines the mesh we want the helper attached to
  56696. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56697. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56698. * @param length Defines the length of the ray
  56699. */
  56700. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56701. /**
  56702. * Detach the ray helper from the mesh it has previously been attached to.
  56703. */
  56704. detachFromMesh(): void;
  56705. private _updateToMesh;
  56706. /**
  56707. * Dispose the helper and release its associated resources.
  56708. */
  56709. dispose(): void;
  56710. }
  56711. }
  56712. declare module "babylonjs/Debug/ISkeletonViewer" {
  56713. import { Skeleton } from "babylonjs/Bones/skeleton";
  56714. import { Color3 } from "babylonjs/Maths/math.color";
  56715. /**
  56716. * Defines the options associated with the creation of a SkeletonViewer.
  56717. */
  56718. export interface ISkeletonViewerOptions {
  56719. /** Should the system pause animations before building the Viewer? */
  56720. pauseAnimations: boolean;
  56721. /** Should the system return the skeleton to rest before building? */
  56722. returnToRest: boolean;
  56723. /** public Display Mode of the Viewer */
  56724. displayMode: number;
  56725. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56726. displayOptions: ISkeletonViewerDisplayOptions;
  56727. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56728. computeBonesUsingShaders: boolean;
  56729. /** Flag ignore non weighted bones */
  56730. useAllBones: boolean;
  56731. }
  56732. /**
  56733. * Defines how to display the various bone meshes for the viewer.
  56734. */
  56735. export interface ISkeletonViewerDisplayOptions {
  56736. /** How far down to start tapering the bone spurs */
  56737. midStep?: number;
  56738. /** How big is the midStep? */
  56739. midStepFactor?: number;
  56740. /** Base for the Sphere Size */
  56741. sphereBaseSize?: number;
  56742. /** The ratio of the sphere to the longest bone in units */
  56743. sphereScaleUnit?: number;
  56744. /** Ratio for the Sphere Size */
  56745. sphereFactor?: number;
  56746. /** Whether a spur should attach its far end to the child bone position */
  56747. spurFollowsChild?: boolean;
  56748. /** Whether to show local axes or not */
  56749. showLocalAxes?: boolean;
  56750. /** Length of each local axis */
  56751. localAxesSize?: number;
  56752. }
  56753. /**
  56754. * Defines the constructor options for the BoneWeight Shader.
  56755. */
  56756. export interface IBoneWeightShaderOptions {
  56757. /** Skeleton to Map */
  56758. skeleton: Skeleton;
  56759. /** Colors for Uninfluenced bones */
  56760. colorBase?: Color3;
  56761. /** Colors for 0.0-0.25 Weight bones */
  56762. colorZero?: Color3;
  56763. /** Color for 0.25-0.5 Weight Influence */
  56764. colorQuarter?: Color3;
  56765. /** Color for 0.5-0.75 Weight Influence */
  56766. colorHalf?: Color3;
  56767. /** Color for 0.75-1 Weight Influence */
  56768. colorFull?: Color3;
  56769. /** Color for Zero Weight Influence */
  56770. targetBoneIndex?: number;
  56771. }
  56772. /**
  56773. * Simple structure of the gradient steps for the Color Map.
  56774. */
  56775. export interface ISkeletonMapShaderColorMapKnot {
  56776. /** Color of the Knot */
  56777. color: Color3;
  56778. /** Location of the Knot */
  56779. location: number;
  56780. }
  56781. /**
  56782. * Defines the constructor options for the SkeletonMap Shader.
  56783. */
  56784. export interface ISkeletonMapShaderOptions {
  56785. /** Skeleton to Map */
  56786. skeleton: Skeleton;
  56787. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56788. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56789. }
  56790. }
  56791. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56792. import { Nullable } from "babylonjs/types";
  56793. import { Scene } from "babylonjs/scene";
  56794. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56795. import { Color4 } from "babylonjs/Maths/math.color";
  56796. import { Mesh } from "babylonjs/Meshes/mesh";
  56797. /**
  56798. * Class containing static functions to help procedurally build meshes
  56799. */
  56800. export class RibbonBuilder {
  56801. /**
  56802. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56803. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56804. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56805. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56806. * * 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
  56807. * * 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
  56808. * * 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
  56809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56812. * * 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
  56813. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56814. * * 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
  56815. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56817. * @param name defines the name of the mesh
  56818. * @param options defines the options used to create the mesh
  56819. * @param scene defines the hosting scene
  56820. * @returns the ribbon mesh
  56821. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56822. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56823. */
  56824. static CreateRibbon(name: string, options: {
  56825. pathArray: Vector3[][];
  56826. closeArray?: boolean;
  56827. closePath?: boolean;
  56828. offset?: number;
  56829. updatable?: boolean;
  56830. sideOrientation?: number;
  56831. frontUVs?: Vector4;
  56832. backUVs?: Vector4;
  56833. instance?: Mesh;
  56834. invertUV?: boolean;
  56835. uvs?: Vector2[];
  56836. colors?: Color4[];
  56837. }, scene?: Nullable<Scene>): Mesh;
  56838. }
  56839. }
  56840. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56841. import { Nullable } from "babylonjs/types";
  56842. import { Scene } from "babylonjs/scene";
  56843. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56844. import { Mesh } from "babylonjs/Meshes/mesh";
  56845. /**
  56846. * Class containing static functions to help procedurally build meshes
  56847. */
  56848. export class ShapeBuilder {
  56849. /**
  56850. * 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.
  56851. * * 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.
  56852. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56853. * * 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.
  56854. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56855. * * 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
  56856. * * 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
  56857. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56860. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56862. * @param name defines the name of the mesh
  56863. * @param options defines the options used to create the mesh
  56864. * @param scene defines the hosting scene
  56865. * @returns the extruded shape mesh
  56866. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56868. */
  56869. static ExtrudeShape(name: string, options: {
  56870. shape: Vector3[];
  56871. path: Vector3[];
  56872. scale?: number;
  56873. rotation?: number;
  56874. cap?: number;
  56875. updatable?: boolean;
  56876. sideOrientation?: number;
  56877. frontUVs?: Vector4;
  56878. backUVs?: Vector4;
  56879. instance?: Mesh;
  56880. invertUV?: boolean;
  56881. }, scene?: Nullable<Scene>): Mesh;
  56882. /**
  56883. * Creates an custom extruded shape mesh.
  56884. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56885. * * 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.
  56886. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56887. * * 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
  56888. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56889. * * 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
  56890. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56891. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56892. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56893. * * 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
  56894. * * 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
  56895. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56900. * @param name defines the name of the mesh
  56901. * @param options defines the options used to create the mesh
  56902. * @param scene defines the hosting scene
  56903. * @returns the custom extruded shape mesh
  56904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56907. */
  56908. static ExtrudeShapeCustom(name: string, options: {
  56909. shape: Vector3[];
  56910. path: Vector3[];
  56911. scaleFunction?: any;
  56912. rotationFunction?: any;
  56913. ribbonCloseArray?: boolean;
  56914. ribbonClosePath?: boolean;
  56915. cap?: number;
  56916. updatable?: boolean;
  56917. sideOrientation?: number;
  56918. frontUVs?: Vector4;
  56919. backUVs?: Vector4;
  56920. instance?: Mesh;
  56921. invertUV?: boolean;
  56922. }, scene?: Nullable<Scene>): Mesh;
  56923. private static _ExtrudeShapeGeneric;
  56924. }
  56925. }
  56926. declare module "babylonjs/Debug/skeletonViewer" {
  56927. import { Color3 } from "babylonjs/Maths/math.color";
  56928. import { Scene } from "babylonjs/scene";
  56929. import { Nullable } from "babylonjs/types";
  56930. import { Skeleton } from "babylonjs/Bones/skeleton";
  56931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56932. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56933. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56934. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56935. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56936. /**
  56937. * Class used to render a debug view of a given skeleton
  56938. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56939. */
  56940. export class SkeletonViewer {
  56941. /** defines the skeleton to render */
  56942. skeleton: Skeleton;
  56943. /** defines the mesh attached to the skeleton */
  56944. mesh: AbstractMesh;
  56945. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56946. autoUpdateBonesMatrices: boolean;
  56947. /** defines the rendering group id to use with the viewer */
  56948. renderingGroupId: number;
  56949. /** is the options for the viewer */
  56950. options: Partial<ISkeletonViewerOptions>;
  56951. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56952. static readonly DISPLAY_LINES: number;
  56953. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56954. static readonly DISPLAY_SPHERES: number;
  56955. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56956. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56957. /** public static method to create a BoneWeight Shader
  56958. * @param options The constructor options
  56959. * @param scene The scene that the shader is scoped to
  56960. * @returns The created ShaderMaterial
  56961. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56962. */
  56963. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56964. /** public static method to create a BoneWeight Shader
  56965. * @param options The constructor options
  56966. * @param scene The scene that the shader is scoped to
  56967. * @returns The created ShaderMaterial
  56968. */
  56969. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56970. /** private static method to create a BoneWeight Shader
  56971. * @param size The size of the buffer to create (usually the bone count)
  56972. * @param colorMap The gradient data to generate
  56973. * @param scene The scene that the shader is scoped to
  56974. * @returns an Array of floats from the color gradient values
  56975. */
  56976. private static _CreateBoneMapColorBuffer;
  56977. /** If SkeletonViewer scene scope. */
  56978. private _scene;
  56979. /** Gets or sets the color used to render the skeleton */
  56980. color: Color3;
  56981. /** Array of the points of the skeleton fo the line view. */
  56982. private _debugLines;
  56983. /** The SkeletonViewers Mesh. */
  56984. private _debugMesh;
  56985. /** The local axes Meshes. */
  56986. private _localAxes;
  56987. /** If SkeletonViewer is enabled. */
  56988. private _isEnabled;
  56989. /** If SkeletonViewer is ready. */
  56990. private _ready;
  56991. /** SkeletonViewer render observable. */
  56992. private _obs;
  56993. /** The Utility Layer to render the gizmos in. */
  56994. private _utilityLayer;
  56995. private _boneIndices;
  56996. /** Gets the Scene. */
  56997. get scene(): Scene;
  56998. /** Gets the utilityLayer. */
  56999. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  57000. /** Checks Ready Status. */
  57001. get isReady(): Boolean;
  57002. /** Sets Ready Status. */
  57003. set ready(value: boolean);
  57004. /** Gets the debugMesh */
  57005. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  57006. /** Sets the debugMesh */
  57007. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  57008. /** Gets the displayMode */
  57009. get displayMode(): number;
  57010. /** Sets the displayMode */
  57011. set displayMode(value: number);
  57012. /**
  57013. * Creates a new SkeletonViewer
  57014. * @param skeleton defines the skeleton to render
  57015. * @param mesh defines the mesh attached to the skeleton
  57016. * @param scene defines the hosting scene
  57017. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  57018. * @param renderingGroupId defines the rendering group id to use with the viewer
  57019. * @param options All of the extra constructor options for the SkeletonViewer
  57020. */
  57021. constructor(
  57022. /** defines the skeleton to render */
  57023. skeleton: Skeleton,
  57024. /** defines the mesh attached to the skeleton */
  57025. mesh: AbstractMesh,
  57026. /** The Scene scope*/
  57027. scene: Scene,
  57028. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57029. autoUpdateBonesMatrices?: boolean,
  57030. /** defines the rendering group id to use with the viewer */
  57031. renderingGroupId?: number,
  57032. /** is the options for the viewer */
  57033. options?: Partial<ISkeletonViewerOptions>);
  57034. /** The Dynamic bindings for the update functions */
  57035. private _bindObs;
  57036. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  57037. update(): void;
  57038. /** Gets or sets a boolean indicating if the viewer is enabled */
  57039. set isEnabled(value: boolean);
  57040. get isEnabled(): boolean;
  57041. private _getBonePosition;
  57042. private _getLinesForBonesWithLength;
  57043. private _getLinesForBonesNoLength;
  57044. /** function to revert the mesh and scene back to the initial state. */
  57045. private _revert;
  57046. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  57047. private _getAbsoluteBindPoseToRef;
  57048. /** function to build and bind sphere joint points and spur bone representations. */
  57049. private _buildSpheresAndSpurs;
  57050. private _buildLocalAxes;
  57051. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  57052. private _displayLinesUpdate;
  57053. /** Changes the displayMode of the skeleton viewer
  57054. * @param mode The displayMode numerical value
  57055. */
  57056. changeDisplayMode(mode: number): void;
  57057. /** Sets a display option of the skeleton viewer
  57058. *
  57059. * | Option | Type | Default | Description |
  57060. * | ---------------- | ------- | ------- | ----------- |
  57061. * | 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`. |
  57062. * | 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`. |
  57063. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  57064. * | 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`. |
  57065. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  57066. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  57067. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  57068. *
  57069. * @param option String of the option name
  57070. * @param value The numerical option value
  57071. */
  57072. changeDisplayOptions(option: string, value: number): void;
  57073. /** Release associated resources */
  57074. dispose(): void;
  57075. }
  57076. }
  57077. declare module "babylonjs/Debug/index" {
  57078. export * from "babylonjs/Debug/axesViewer";
  57079. export * from "babylonjs/Debug/boneAxesViewer";
  57080. export * from "babylonjs/Debug/debugLayer";
  57081. export * from "babylonjs/Debug/physicsViewer";
  57082. export * from "babylonjs/Debug/rayHelper";
  57083. export * from "babylonjs/Debug/skeletonViewer";
  57084. export * from "babylonjs/Debug/ISkeletonViewer";
  57085. }
  57086. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  57087. /**
  57088. * Enum for Device Types
  57089. */
  57090. export enum DeviceType {
  57091. /** Generic */
  57092. Generic = 0,
  57093. /** Keyboard */
  57094. Keyboard = 1,
  57095. /** Mouse */
  57096. Mouse = 2,
  57097. /** Touch Pointers */
  57098. Touch = 3,
  57099. /** PS4 Dual Shock */
  57100. DualShock = 4,
  57101. /** Xbox */
  57102. Xbox = 5,
  57103. /** Switch Controller */
  57104. Switch = 6
  57105. }
  57106. /**
  57107. * Enum for All Pointers (Touch/Mouse)
  57108. */
  57109. export enum PointerInput {
  57110. /** Horizontal Axis */
  57111. Horizontal = 0,
  57112. /** Vertical Axis */
  57113. Vertical = 1,
  57114. /** Left Click or Touch */
  57115. LeftClick = 2,
  57116. /** Middle Click */
  57117. MiddleClick = 3,
  57118. /** Right Click */
  57119. RightClick = 4,
  57120. /** Browser Back */
  57121. BrowserBack = 5,
  57122. /** Browser Forward */
  57123. BrowserForward = 6
  57124. }
  57125. /**
  57126. * Enum for Dual Shock Gamepad
  57127. */
  57128. export enum DualShockInput {
  57129. /** Cross */
  57130. Cross = 0,
  57131. /** Circle */
  57132. Circle = 1,
  57133. /** Square */
  57134. Square = 2,
  57135. /** Triangle */
  57136. Triangle = 3,
  57137. /** L1 */
  57138. L1 = 4,
  57139. /** R1 */
  57140. R1 = 5,
  57141. /** L2 */
  57142. L2 = 6,
  57143. /** R2 */
  57144. R2 = 7,
  57145. /** Share */
  57146. Share = 8,
  57147. /** Options */
  57148. Options = 9,
  57149. /** L3 */
  57150. L3 = 10,
  57151. /** R3 */
  57152. R3 = 11,
  57153. /** DPadUp */
  57154. DPadUp = 12,
  57155. /** DPadDown */
  57156. DPadDown = 13,
  57157. /** DPadLeft */
  57158. DPadLeft = 14,
  57159. /** DRight */
  57160. DPadRight = 15,
  57161. /** Home */
  57162. Home = 16,
  57163. /** TouchPad */
  57164. TouchPad = 17,
  57165. /** LStickXAxis */
  57166. LStickXAxis = 18,
  57167. /** LStickYAxis */
  57168. LStickYAxis = 19,
  57169. /** RStickXAxis */
  57170. RStickXAxis = 20,
  57171. /** RStickYAxis */
  57172. RStickYAxis = 21
  57173. }
  57174. /**
  57175. * Enum for Xbox Gamepad
  57176. */
  57177. export enum XboxInput {
  57178. /** A */
  57179. A = 0,
  57180. /** B */
  57181. B = 1,
  57182. /** X */
  57183. X = 2,
  57184. /** Y */
  57185. Y = 3,
  57186. /** LB */
  57187. LB = 4,
  57188. /** RB */
  57189. RB = 5,
  57190. /** LT */
  57191. LT = 6,
  57192. /** RT */
  57193. RT = 7,
  57194. /** Back */
  57195. Back = 8,
  57196. /** Start */
  57197. Start = 9,
  57198. /** LS */
  57199. LS = 10,
  57200. /** RS */
  57201. RS = 11,
  57202. /** DPadUp */
  57203. DPadUp = 12,
  57204. /** DPadDown */
  57205. DPadDown = 13,
  57206. /** DPadLeft */
  57207. DPadLeft = 14,
  57208. /** DRight */
  57209. DPadRight = 15,
  57210. /** Home */
  57211. Home = 16,
  57212. /** LStickXAxis */
  57213. LStickXAxis = 17,
  57214. /** LStickYAxis */
  57215. LStickYAxis = 18,
  57216. /** RStickXAxis */
  57217. RStickXAxis = 19,
  57218. /** RStickYAxis */
  57219. RStickYAxis = 20
  57220. }
  57221. /**
  57222. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  57223. */
  57224. export enum SwitchInput {
  57225. /** B */
  57226. B = 0,
  57227. /** A */
  57228. A = 1,
  57229. /** Y */
  57230. Y = 2,
  57231. /** X */
  57232. X = 3,
  57233. /** L */
  57234. L = 4,
  57235. /** R */
  57236. R = 5,
  57237. /** ZL */
  57238. ZL = 6,
  57239. /** ZR */
  57240. ZR = 7,
  57241. /** Minus */
  57242. Minus = 8,
  57243. /** Plus */
  57244. Plus = 9,
  57245. /** LS */
  57246. LS = 10,
  57247. /** RS */
  57248. RS = 11,
  57249. /** DPadUp */
  57250. DPadUp = 12,
  57251. /** DPadDown */
  57252. DPadDown = 13,
  57253. /** DPadLeft */
  57254. DPadLeft = 14,
  57255. /** DRight */
  57256. DPadRight = 15,
  57257. /** Home */
  57258. Home = 16,
  57259. /** Capture */
  57260. Capture = 17,
  57261. /** LStickXAxis */
  57262. LStickXAxis = 18,
  57263. /** LStickYAxis */
  57264. LStickYAxis = 19,
  57265. /** RStickXAxis */
  57266. RStickXAxis = 20,
  57267. /** RStickYAxis */
  57268. RStickYAxis = 21
  57269. }
  57270. }
  57271. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  57272. import { Engine } from "babylonjs/Engines/engine";
  57273. import { IDisposable } from "babylonjs/scene";
  57274. import { Nullable } from "babylonjs/types";
  57275. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57276. /**
  57277. * This class will take all inputs from Keyboard, Pointer, and
  57278. * any Gamepads and provide a polling system that all devices
  57279. * will use. This class assumes that there will only be one
  57280. * pointer device and one keyboard.
  57281. */
  57282. export class DeviceInputSystem implements IDisposable {
  57283. /**
  57284. * Returns onDeviceConnected callback property
  57285. * @returns Callback with function to execute when a device is connected
  57286. */
  57287. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  57288. /**
  57289. * Sets callback function when a device is connected and executes against all connected devices
  57290. * @param callback Function to execute when a device is connected
  57291. */
  57292. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  57293. /**
  57294. * Callback to be triggered when a device is disconnected
  57295. */
  57296. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  57297. /**
  57298. * Callback to be triggered when event driven input is updated
  57299. */
  57300. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  57301. private _inputs;
  57302. private _gamepads;
  57303. private _keyboardActive;
  57304. private _pointerActive;
  57305. private _elementToAttachTo;
  57306. private _keyboardDownEvent;
  57307. private _keyboardUpEvent;
  57308. private _pointerMoveEvent;
  57309. private _pointerDownEvent;
  57310. private _pointerUpEvent;
  57311. private _gamepadConnectedEvent;
  57312. private _gamepadDisconnectedEvent;
  57313. private _onDeviceConnected;
  57314. private static _MAX_KEYCODES;
  57315. private static _MAX_POINTER_INPUTS;
  57316. private constructor();
  57317. /**
  57318. * Creates a new DeviceInputSystem instance
  57319. * @param engine Engine to pull input element from
  57320. * @returns The new instance
  57321. */
  57322. static Create(engine: Engine): DeviceInputSystem;
  57323. /**
  57324. * Checks for current device input value, given an id and input index
  57325. * @param deviceName Id of connected device
  57326. * @param inputIndex Index of device input
  57327. * @returns Current value of input
  57328. */
  57329. /**
  57330. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  57331. * @param deviceType Enum specifiying device type
  57332. * @param deviceSlot "Slot" or index that device is referenced in
  57333. * @param inputIndex Id of input to be checked
  57334. * @returns Current value of input
  57335. */
  57336. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  57337. /**
  57338. * Dispose of all the eventlisteners
  57339. */
  57340. dispose(): void;
  57341. /**
  57342. * Checks for existing connections to devices and register them, if necessary
  57343. * Currently handles gamepads and mouse
  57344. */
  57345. private _checkForConnectedDevices;
  57346. /**
  57347. * Add a gamepad to the DeviceInputSystem
  57348. * @param gamepad A single DOM Gamepad object
  57349. */
  57350. private _addGamePad;
  57351. /**
  57352. * Add pointer device to DeviceInputSystem
  57353. * @param deviceType Type of Pointer to add
  57354. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  57355. * @param currentX Current X at point of adding
  57356. * @param currentY Current Y at point of adding
  57357. */
  57358. private _addPointerDevice;
  57359. /**
  57360. * Add device and inputs to device array
  57361. * @param deviceType Enum specifiying device type
  57362. * @param deviceSlot "Slot" or index that device is referenced in
  57363. * @param numberOfInputs Number of input entries to create for given device
  57364. */
  57365. private _registerDevice;
  57366. /**
  57367. * Given a specific device name, remove that device from the device map
  57368. * @param deviceType Enum specifiying device type
  57369. * @param deviceSlot "Slot" or index that device is referenced in
  57370. */
  57371. private _unregisterDevice;
  57372. /**
  57373. * Handle all actions that come from keyboard interaction
  57374. */
  57375. private _handleKeyActions;
  57376. /**
  57377. * Handle all actions that come from pointer interaction
  57378. */
  57379. private _handlePointerActions;
  57380. /**
  57381. * Handle all actions that come from gamepad interaction
  57382. */
  57383. private _handleGamepadActions;
  57384. /**
  57385. * Update all non-event based devices with each frame
  57386. * @param deviceType Enum specifiying device type
  57387. * @param deviceSlot "Slot" or index that device is referenced in
  57388. * @param inputIndex Id of input to be checked
  57389. */
  57390. private _updateDevice;
  57391. /**
  57392. * Gets DeviceType from the device name
  57393. * @param deviceName Name of Device from DeviceInputSystem
  57394. * @returns DeviceType enum value
  57395. */
  57396. private _getGamepadDeviceType;
  57397. }
  57398. }
  57399. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57400. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57401. /**
  57402. * Type to handle enforcement of inputs
  57403. */
  57404. 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;
  57405. }
  57406. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57407. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57408. import { Engine } from "babylonjs/Engines/engine";
  57409. import { IDisposable } from "babylonjs/scene";
  57410. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57411. import { Nullable } from "babylonjs/types";
  57412. import { Observable } from "babylonjs/Misc/observable";
  57413. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57414. /**
  57415. * Class that handles all input for a specific device
  57416. */
  57417. export class DeviceSource<T extends DeviceType> {
  57418. /** Type of device */
  57419. readonly deviceType: DeviceType;
  57420. /** "Slot" or index that device is referenced in */
  57421. readonly deviceSlot: number;
  57422. /**
  57423. * Observable to handle device input changes per device
  57424. */
  57425. readonly onInputChangedObservable: Observable<{
  57426. inputIndex: DeviceInput<T>;
  57427. previousState: Nullable<number>;
  57428. currentState: Nullable<number>;
  57429. }>;
  57430. private readonly _deviceInputSystem;
  57431. /**
  57432. * Default Constructor
  57433. * @param deviceInputSystem Reference to DeviceInputSystem
  57434. * @param deviceType Type of device
  57435. * @param deviceSlot "Slot" or index that device is referenced in
  57436. */
  57437. constructor(deviceInputSystem: DeviceInputSystem,
  57438. /** Type of device */
  57439. deviceType: DeviceType,
  57440. /** "Slot" or index that device is referenced in */
  57441. deviceSlot?: number);
  57442. /**
  57443. * Get input for specific input
  57444. * @param inputIndex index of specific input on device
  57445. * @returns Input value from DeviceInputSystem
  57446. */
  57447. getInput(inputIndex: DeviceInput<T>): number;
  57448. }
  57449. /**
  57450. * Class to keep track of devices
  57451. */
  57452. export class DeviceSourceManager implements IDisposable {
  57453. /**
  57454. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  57455. */
  57456. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  57457. /**
  57458. * Observable to be triggered when after a device is disconnected
  57459. */
  57460. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  57461. private readonly _devices;
  57462. private readonly _firstDevice;
  57463. private readonly _deviceInputSystem;
  57464. /**
  57465. * Default Constructor
  57466. * @param engine engine to pull input element from
  57467. */
  57468. constructor(engine: Engine);
  57469. /**
  57470. * Gets a DeviceSource, given a type and slot
  57471. * @param deviceType Enum specifying device type
  57472. * @param deviceSlot "Slot" or index that device is referenced in
  57473. * @returns DeviceSource object
  57474. */
  57475. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57476. /**
  57477. * Gets an array of DeviceSource objects for a given device type
  57478. * @param deviceType Enum specifying device type
  57479. * @returns Array of DeviceSource objects
  57480. */
  57481. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57482. /**
  57483. * Returns a read-only list of all available devices
  57484. * @returns Read-only array with active devices
  57485. */
  57486. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  57487. /**
  57488. * Dispose of DeviceInputSystem and other parts
  57489. */
  57490. dispose(): void;
  57491. /**
  57492. * Function to add device name to device list
  57493. * @param deviceType Enum specifying device type
  57494. * @param deviceSlot "Slot" or index that device is referenced in
  57495. */
  57496. private _addDevice;
  57497. /**
  57498. * Function to remove device name to device list
  57499. * @param deviceType Enum specifying device type
  57500. * @param deviceSlot "Slot" or index that device is referenced in
  57501. */
  57502. private _removeDevice;
  57503. /**
  57504. * Updates array storing first connected device of each type
  57505. * @param type Type of Device
  57506. */
  57507. private _updateFirstDevices;
  57508. }
  57509. }
  57510. declare module "babylonjs/DeviceInput/index" {
  57511. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57512. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57513. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57514. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57515. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57516. }
  57517. declare module "babylonjs/Engines/nullEngine" {
  57518. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57519. import { Engine } from "babylonjs/Engines/engine";
  57520. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57521. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57523. import { Effect } from "babylonjs/Materials/effect";
  57524. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57525. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57526. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57527. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57528. /**
  57529. * Options to create the null engine
  57530. */
  57531. export class NullEngineOptions {
  57532. /**
  57533. * Render width (Default: 512)
  57534. */
  57535. renderWidth: number;
  57536. /**
  57537. * Render height (Default: 256)
  57538. */
  57539. renderHeight: number;
  57540. /**
  57541. * Texture size (Default: 512)
  57542. */
  57543. textureSize: number;
  57544. /**
  57545. * If delta time between frames should be constant
  57546. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57547. */
  57548. deterministicLockstep: boolean;
  57549. /**
  57550. * Maximum about of steps between frames (Default: 4)
  57551. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57552. */
  57553. lockstepMaxSteps: number;
  57554. /**
  57555. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57556. */
  57557. useHighPrecisionMatrix?: boolean;
  57558. }
  57559. /**
  57560. * The null engine class provides support for headless version of babylon.js.
  57561. * This can be used in server side scenario or for testing purposes
  57562. */
  57563. export class NullEngine extends Engine {
  57564. private _options;
  57565. /**
  57566. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57567. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57568. * @returns true if engine is in deterministic lock step mode
  57569. */
  57570. isDeterministicLockStep(): boolean;
  57571. /**
  57572. * Gets the max steps when engine is running in deterministic lock step
  57573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57574. * @returns the max steps
  57575. */
  57576. getLockstepMaxSteps(): number;
  57577. /**
  57578. * Gets the current hardware scaling level.
  57579. * By default the hardware scaling level is computed from the window device ratio.
  57580. * 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.
  57581. * @returns a number indicating the current hardware scaling level
  57582. */
  57583. getHardwareScalingLevel(): number;
  57584. constructor(options?: NullEngineOptions);
  57585. /**
  57586. * Creates a vertex buffer
  57587. * @param vertices the data for the vertex buffer
  57588. * @returns the new WebGL static buffer
  57589. */
  57590. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57591. /**
  57592. * Creates a new index buffer
  57593. * @param indices defines the content of the index buffer
  57594. * @param updatable defines if the index buffer must be updatable
  57595. * @returns a new webGL buffer
  57596. */
  57597. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57598. /**
  57599. * Clear the current render buffer or the current render target (if any is set up)
  57600. * @param color defines the color to use
  57601. * @param backBuffer defines if the back buffer must be cleared
  57602. * @param depth defines if the depth buffer must be cleared
  57603. * @param stencil defines if the stencil buffer must be cleared
  57604. */
  57605. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57606. /**
  57607. * Gets the current render width
  57608. * @param useScreen defines if screen size must be used (or the current render target if any)
  57609. * @returns a number defining the current render width
  57610. */
  57611. getRenderWidth(useScreen?: boolean): number;
  57612. /**
  57613. * Gets the current render height
  57614. * @param useScreen defines if screen size must be used (or the current render target if any)
  57615. * @returns a number defining the current render height
  57616. */
  57617. getRenderHeight(useScreen?: boolean): number;
  57618. /**
  57619. * Set the WebGL's viewport
  57620. * @param viewport defines the viewport element to be used
  57621. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57622. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57623. */
  57624. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57625. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57626. /**
  57627. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57628. * @param pipelineContext defines the pipeline context to use
  57629. * @param uniformsNames defines the list of uniform names
  57630. * @returns an array of webGL uniform locations
  57631. */
  57632. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57633. /**
  57634. * Gets the lsit of active attributes for a given webGL program
  57635. * @param pipelineContext defines the pipeline context to use
  57636. * @param attributesNames defines the list of attribute names to get
  57637. * @returns an array of indices indicating the offset of each attribute
  57638. */
  57639. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57640. /**
  57641. * Binds an effect to the webGL context
  57642. * @param effect defines the effect to bind
  57643. */
  57644. bindSamplers(effect: Effect): void;
  57645. /**
  57646. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57647. * @param effect defines the effect to activate
  57648. */
  57649. enableEffect(effect: Effect): void;
  57650. /**
  57651. * Set various states to the webGL context
  57652. * @param culling defines backface culling state
  57653. * @param zOffset defines the value to apply to zOffset (0 by default)
  57654. * @param force defines if states must be applied even if cache is up to date
  57655. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57656. */
  57657. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57658. /**
  57659. * Set the value of an uniform to an array of int32
  57660. * @param uniform defines the webGL uniform location where to store the value
  57661. * @param array defines the array of int32 to store
  57662. * @returns true if value was set
  57663. */
  57664. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57665. /**
  57666. * Set the value of an uniform to an array of int32 (stored as vec2)
  57667. * @param uniform defines the webGL uniform location where to store the value
  57668. * @param array defines the array of int32 to store
  57669. * @returns true if value was set
  57670. */
  57671. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57672. /**
  57673. * Set the value of an uniform to an array of int32 (stored as vec3)
  57674. * @param uniform defines the webGL uniform location where to store the value
  57675. * @param array defines the array of int32 to store
  57676. * @returns true if value was set
  57677. */
  57678. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57679. /**
  57680. * Set the value of an uniform to an array of int32 (stored as vec4)
  57681. * @param uniform defines the webGL uniform location where to store the value
  57682. * @param array defines the array of int32 to store
  57683. * @returns true if value was set
  57684. */
  57685. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57686. /**
  57687. * Set the value of an uniform to an array of float32
  57688. * @param uniform defines the webGL uniform location where to store the value
  57689. * @param array defines the array of float32 to store
  57690. * @returns true if value was set
  57691. */
  57692. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57693. /**
  57694. * Set the value of an uniform to an array of float32 (stored as vec2)
  57695. * @param uniform defines the webGL uniform location where to store the value
  57696. * @param array defines the array of float32 to store
  57697. * @returns true if value was set
  57698. */
  57699. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57700. /**
  57701. * Set the value of an uniform to an array of float32 (stored as vec3)
  57702. * @param uniform defines the webGL uniform location where to store the value
  57703. * @param array defines the array of float32 to store
  57704. * @returns true if value was set
  57705. */
  57706. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57707. /**
  57708. * Set the value of an uniform to an array of float32 (stored as vec4)
  57709. * @param uniform defines the webGL uniform location where to store the value
  57710. * @param array defines the array of float32 to store
  57711. * @returns true if value was set
  57712. */
  57713. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57714. /**
  57715. * Set the value of an uniform to an array of number
  57716. * @param uniform defines the webGL uniform location where to store the value
  57717. * @param array defines the array of number to store
  57718. * @returns true if value was set
  57719. */
  57720. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57721. /**
  57722. * Set the value of an uniform to an array of number (stored as vec2)
  57723. * @param uniform defines the webGL uniform location where to store the value
  57724. * @param array defines the array of number to store
  57725. * @returns true if value was set
  57726. */
  57727. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57728. /**
  57729. * Set the value of an uniform to an array of number (stored as vec3)
  57730. * @param uniform defines the webGL uniform location where to store the value
  57731. * @param array defines the array of number to store
  57732. * @returns true if value was set
  57733. */
  57734. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57735. /**
  57736. * Set the value of an uniform to an array of number (stored as vec4)
  57737. * @param uniform defines the webGL uniform location where to store the value
  57738. * @param array defines the array of number to store
  57739. * @returns true if value was set
  57740. */
  57741. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57742. /**
  57743. * Set the value of an uniform to an array of float32 (stored as matrices)
  57744. * @param uniform defines the webGL uniform location where to store the value
  57745. * @param matrices defines the array of float32 to store
  57746. * @returns true if value was set
  57747. */
  57748. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57749. /**
  57750. * Set the value of an uniform to a matrix (3x3)
  57751. * @param uniform defines the webGL uniform location where to store the value
  57752. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57753. * @returns true if value was set
  57754. */
  57755. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57756. /**
  57757. * Set the value of an uniform to a matrix (2x2)
  57758. * @param uniform defines the webGL uniform location where to store the value
  57759. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57760. * @returns true if value was set
  57761. */
  57762. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57763. /**
  57764. * Set the value of an uniform to a number (float)
  57765. * @param uniform defines the webGL uniform location where to store the value
  57766. * @param value defines the float number to store
  57767. * @returns true if value was set
  57768. */
  57769. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57770. /**
  57771. * Set the value of an uniform to a vec2
  57772. * @param uniform defines the webGL uniform location where to store the value
  57773. * @param x defines the 1st component of the value
  57774. * @param y defines the 2nd component of the value
  57775. * @returns true if value was set
  57776. */
  57777. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57778. /**
  57779. * Set the value of an uniform to a vec3
  57780. * @param uniform defines the webGL uniform location where to store the value
  57781. * @param x defines the 1st component of the value
  57782. * @param y defines the 2nd component of the value
  57783. * @param z defines the 3rd component of the value
  57784. * @returns true if value was set
  57785. */
  57786. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57787. /**
  57788. * Set the value of an uniform to a boolean
  57789. * @param uniform defines the webGL uniform location where to store the value
  57790. * @param bool defines the boolean to store
  57791. * @returns true if value was set
  57792. */
  57793. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57794. /**
  57795. * Set the value of an uniform to a vec4
  57796. * @param uniform defines the webGL uniform location where to store the value
  57797. * @param x defines the 1st component of the value
  57798. * @param y defines the 2nd component of the value
  57799. * @param z defines the 3rd component of the value
  57800. * @param w defines the 4th component of the value
  57801. * @returns true if value was set
  57802. */
  57803. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57804. /**
  57805. * Sets the current alpha mode
  57806. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57807. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57808. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57809. */
  57810. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57811. /**
  57812. * Bind webGl buffers directly to the webGL context
  57813. * @param vertexBuffers defines the vertex buffer to bind
  57814. * @param indexBuffer defines the index buffer to bind
  57815. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57816. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57817. * @param effect defines the effect associated with the vertex buffer
  57818. */
  57819. bindBuffers(vertexBuffers: {
  57820. [key: string]: VertexBuffer;
  57821. }, indexBuffer: DataBuffer, effect: Effect): void;
  57822. /**
  57823. * Force the entire cache to be cleared
  57824. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57825. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57826. */
  57827. wipeCaches(bruteForce?: boolean): void;
  57828. /**
  57829. * Send a draw order
  57830. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57831. * @param indexStart defines the starting index
  57832. * @param indexCount defines the number of index to draw
  57833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57834. */
  57835. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57836. /**
  57837. * Draw a list of indexed primitives
  57838. * @param fillMode defines the primitive to use
  57839. * @param indexStart defines the starting index
  57840. * @param indexCount defines the number of index to draw
  57841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57842. */
  57843. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57844. /**
  57845. * Draw a list of unindexed primitives
  57846. * @param fillMode defines the primitive to use
  57847. * @param verticesStart defines the index of first vertex to draw
  57848. * @param verticesCount defines the count of vertices to draw
  57849. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57850. */
  57851. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57852. /** @hidden */
  57853. _createTexture(): WebGLTexture;
  57854. /** @hidden */
  57855. _releaseTexture(texture: InternalTexture): void;
  57856. /**
  57857. * Usually called from Texture.ts.
  57858. * Passed information to create a WebGLTexture
  57859. * @param urlArg defines a value which contains one of the following:
  57860. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57861. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57862. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57863. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57864. * @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)
  57865. * @param scene needed for loading to the correct scene
  57866. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57867. * @param onLoad optional callback to be called upon successful completion
  57868. * @param onError optional callback to be called upon failure
  57869. * @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
  57870. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57871. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57872. * @param forcedExtension defines the extension to use to pick the right loader
  57873. * @param mimeType defines an optional mime type
  57874. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57875. */
  57876. 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;
  57877. /**
  57878. * Creates a new render target texture
  57879. * @param size defines the size of the texture
  57880. * @param options defines the options used to create the texture
  57881. * @returns a new render target texture stored in an InternalTexture
  57882. */
  57883. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57884. /**
  57885. * Update the sampling mode of a given texture
  57886. * @param samplingMode defines the required sampling mode
  57887. * @param texture defines the texture to update
  57888. */
  57889. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57890. /**
  57891. * Binds the frame buffer to the specified texture.
  57892. * @param texture The texture to render to or null for the default canvas
  57893. * @param faceIndex The face of the texture to render to in case of cube texture
  57894. * @param requiredWidth The width of the target to render to
  57895. * @param requiredHeight The height of the target to render to
  57896. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57897. * @param lodLevel defines le lod level to bind to the frame buffer
  57898. */
  57899. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57900. /**
  57901. * Unbind the current render target texture from the webGL context
  57902. * @param texture defines the render target texture to unbind
  57903. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57904. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57905. */
  57906. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57907. /**
  57908. * Creates a dynamic vertex buffer
  57909. * @param vertices the data for the dynamic vertex buffer
  57910. * @returns the new WebGL dynamic buffer
  57911. */
  57912. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57913. /**
  57914. * Update the content of a dynamic texture
  57915. * @param texture defines the texture to update
  57916. * @param canvas defines the canvas containing the source
  57917. * @param invertY defines if data must be stored with Y axis inverted
  57918. * @param premulAlpha defines if alpha is stored as premultiplied
  57919. * @param format defines the format of the data
  57920. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57921. */
  57922. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57923. /**
  57924. * Gets a boolean indicating if all created effects are ready
  57925. * @returns true if all effects are ready
  57926. */
  57927. areAllEffectsReady(): boolean;
  57928. /**
  57929. * @hidden
  57930. * Get the current error code of the webGL context
  57931. * @returns the error code
  57932. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57933. */
  57934. getError(): number;
  57935. /** @hidden */
  57936. _getUnpackAlignement(): number;
  57937. /** @hidden */
  57938. _unpackFlipY(value: boolean): void;
  57939. /**
  57940. * Update a dynamic index buffer
  57941. * @param indexBuffer defines the target index buffer
  57942. * @param indices defines the data to update
  57943. * @param offset defines the offset in the target index buffer where update should start
  57944. */
  57945. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57946. /**
  57947. * Updates a dynamic vertex buffer.
  57948. * @param vertexBuffer the vertex buffer to update
  57949. * @param vertices the data used to update the vertex buffer
  57950. * @param byteOffset the byte offset of the data (optional)
  57951. * @param byteLength the byte length of the data (optional)
  57952. */
  57953. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57954. /** @hidden */
  57955. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57956. /** @hidden */
  57957. _bindTexture(channel: number, texture: InternalTexture): void;
  57958. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57959. /**
  57960. * 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
  57961. */
  57962. releaseEffects(): void;
  57963. displayLoadingUI(): void;
  57964. hideLoadingUI(): void;
  57965. /** @hidden */
  57966. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57967. /** @hidden */
  57968. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57969. /** @hidden */
  57970. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57971. /** @hidden */
  57972. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57973. }
  57974. }
  57975. declare module "babylonjs/Instrumentation/timeToken" {
  57976. import { Nullable } from "babylonjs/types";
  57977. /**
  57978. * @hidden
  57979. **/
  57980. export class _TimeToken {
  57981. _startTimeQuery: Nullable<WebGLQuery>;
  57982. _endTimeQuery: Nullable<WebGLQuery>;
  57983. _timeElapsedQuery: Nullable<WebGLQuery>;
  57984. _timeElapsedQueryEnded: boolean;
  57985. }
  57986. }
  57987. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57988. import { Nullable, int } from "babylonjs/types";
  57989. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57990. /** @hidden */
  57991. export class _OcclusionDataStorage {
  57992. /** @hidden */
  57993. occlusionInternalRetryCounter: number;
  57994. /** @hidden */
  57995. isOcclusionQueryInProgress: boolean;
  57996. /** @hidden */
  57997. isOccluded: boolean;
  57998. /** @hidden */
  57999. occlusionRetryCount: number;
  58000. /** @hidden */
  58001. occlusionType: number;
  58002. /** @hidden */
  58003. occlusionQueryAlgorithmType: number;
  58004. }
  58005. module "babylonjs/Engines/engine" {
  58006. interface Engine {
  58007. /**
  58008. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  58009. * @return the new query
  58010. */
  58011. createQuery(): WebGLQuery;
  58012. /**
  58013. * Delete and release a webGL query
  58014. * @param query defines the query to delete
  58015. * @return the current engine
  58016. */
  58017. deleteQuery(query: WebGLQuery): Engine;
  58018. /**
  58019. * Check if a given query has resolved and got its value
  58020. * @param query defines the query to check
  58021. * @returns true if the query got its value
  58022. */
  58023. isQueryResultAvailable(query: WebGLQuery): boolean;
  58024. /**
  58025. * Gets the value of a given query
  58026. * @param query defines the query to check
  58027. * @returns the value of the query
  58028. */
  58029. getQueryResult(query: WebGLQuery): number;
  58030. /**
  58031. * Initiates an occlusion query
  58032. * @param algorithmType defines the algorithm to use
  58033. * @param query defines the query to use
  58034. * @returns the current engine
  58035. * @see https://doc.babylonjs.com/features/occlusionquery
  58036. */
  58037. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  58038. /**
  58039. * Ends an occlusion query
  58040. * @see https://doc.babylonjs.com/features/occlusionquery
  58041. * @param algorithmType defines the algorithm to use
  58042. * @returns the current engine
  58043. */
  58044. endOcclusionQuery(algorithmType: number): Engine;
  58045. /**
  58046. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  58047. * Please note that only one query can be issued at a time
  58048. * @returns a time token used to track the time span
  58049. */
  58050. startTimeQuery(): Nullable<_TimeToken>;
  58051. /**
  58052. * Ends a time query
  58053. * @param token defines the token used to measure the time span
  58054. * @returns the time spent (in ns)
  58055. */
  58056. endTimeQuery(token: _TimeToken): int;
  58057. /** @hidden */
  58058. _currentNonTimestampToken: Nullable<_TimeToken>;
  58059. /** @hidden */
  58060. _createTimeQuery(): WebGLQuery;
  58061. /** @hidden */
  58062. _deleteTimeQuery(query: WebGLQuery): void;
  58063. /** @hidden */
  58064. _getGlAlgorithmType(algorithmType: number): number;
  58065. /** @hidden */
  58066. _getTimeQueryResult(query: WebGLQuery): any;
  58067. /** @hidden */
  58068. _getTimeQueryAvailability(query: WebGLQuery): any;
  58069. }
  58070. }
  58071. module "babylonjs/Meshes/abstractMesh" {
  58072. interface AbstractMesh {
  58073. /**
  58074. * Backing filed
  58075. * @hidden
  58076. */
  58077. __occlusionDataStorage: _OcclusionDataStorage;
  58078. /**
  58079. * Access property
  58080. * @hidden
  58081. */
  58082. _occlusionDataStorage: _OcclusionDataStorage;
  58083. /**
  58084. * 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.
  58085. * The default value is -1 which means don't break the query and wait till the result
  58086. * @see https://doc.babylonjs.com/features/occlusionquery
  58087. */
  58088. occlusionRetryCount: number;
  58089. /**
  58090. * 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:
  58091. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  58092. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  58093. * * 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.
  58094. * @see https://doc.babylonjs.com/features/occlusionquery
  58095. */
  58096. occlusionType: number;
  58097. /**
  58098. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  58099. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  58100. * * 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.
  58101. * @see https://doc.babylonjs.com/features/occlusionquery
  58102. */
  58103. occlusionQueryAlgorithmType: number;
  58104. /**
  58105. * 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
  58106. * @see https://doc.babylonjs.com/features/occlusionquery
  58107. */
  58108. isOccluded: boolean;
  58109. /**
  58110. * Flag to check the progress status of the query
  58111. * @see https://doc.babylonjs.com/features/occlusionquery
  58112. */
  58113. isOcclusionQueryInProgress: boolean;
  58114. }
  58115. }
  58116. }
  58117. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  58118. import { Nullable } from "babylonjs/types";
  58119. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58120. /** @hidden */
  58121. export var _forceTransformFeedbackToBundle: boolean;
  58122. module "babylonjs/Engines/engine" {
  58123. interface Engine {
  58124. /**
  58125. * Creates a webGL transform feedback object
  58126. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  58127. * @returns the webGL transform feedback object
  58128. */
  58129. createTransformFeedback(): WebGLTransformFeedback;
  58130. /**
  58131. * Delete a webGL transform feedback object
  58132. * @param value defines the webGL transform feedback object to delete
  58133. */
  58134. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  58135. /**
  58136. * Bind a webGL transform feedback object to the webgl context
  58137. * @param value defines the webGL transform feedback object to bind
  58138. */
  58139. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  58140. /**
  58141. * Begins a transform feedback operation
  58142. * @param usePoints defines if points or triangles must be used
  58143. */
  58144. beginTransformFeedback(usePoints: boolean): void;
  58145. /**
  58146. * Ends a transform feedback operation
  58147. */
  58148. endTransformFeedback(): void;
  58149. /**
  58150. * Specify the varyings to use with transform feedback
  58151. * @param program defines the associated webGL program
  58152. * @param value defines the list of strings representing the varying names
  58153. */
  58154. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  58155. /**
  58156. * Bind a webGL buffer for a transform feedback operation
  58157. * @param value defines the webGL buffer to bind
  58158. */
  58159. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  58160. }
  58161. }
  58162. }
  58163. declare module "babylonjs/Engines/Extensions/engine.views" {
  58164. import { Camera } from "babylonjs/Cameras/camera";
  58165. import { Nullable } from "babylonjs/types";
  58166. /**
  58167. * Class used to define an additional view for the engine
  58168. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58169. */
  58170. export class EngineView {
  58171. /** Defines the canvas where to render the view */
  58172. target: HTMLCanvasElement;
  58173. /** Defines an optional camera used to render the view (will use active camera else) */
  58174. camera?: Camera;
  58175. }
  58176. module "babylonjs/Engines/engine" {
  58177. interface Engine {
  58178. /**
  58179. * Gets or sets the HTML element to use for attaching events
  58180. */
  58181. inputElement: Nullable<HTMLElement>;
  58182. /**
  58183. * Gets the current engine view
  58184. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58185. */
  58186. activeView: Nullable<EngineView>;
  58187. /** Gets or sets the list of views */
  58188. views: EngineView[];
  58189. /**
  58190. * Register a new child canvas
  58191. * @param canvas defines the canvas to register
  58192. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  58193. * @returns the associated view
  58194. */
  58195. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  58196. /**
  58197. * Remove a registered child canvas
  58198. * @param canvas defines the canvas to remove
  58199. * @returns the current engine
  58200. */
  58201. unRegisterView(canvas: HTMLCanvasElement): Engine;
  58202. }
  58203. }
  58204. }
  58205. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  58206. import { Nullable } from "babylonjs/types";
  58207. module "babylonjs/Engines/engine" {
  58208. interface Engine {
  58209. /** @hidden */
  58210. _excludedCompressedTextures: string[];
  58211. /** @hidden */
  58212. _textureFormatInUse: string;
  58213. /**
  58214. * Gets the list of texture formats supported
  58215. */
  58216. readonly texturesSupported: Array<string>;
  58217. /**
  58218. * Gets the texture format in use
  58219. */
  58220. readonly textureFormatInUse: Nullable<string>;
  58221. /**
  58222. * Set the compressed texture extensions or file names to skip.
  58223. *
  58224. * @param skippedFiles defines the list of those texture files you want to skip
  58225. * Example: [".dds", ".env", "myfile.png"]
  58226. */
  58227. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  58228. /**
  58229. * Set the compressed texture format to use, based on the formats you have, and the formats
  58230. * supported by the hardware / browser.
  58231. *
  58232. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  58233. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  58234. * to API arguments needed to compressed textures. This puts the burden on the container
  58235. * generator to house the arcane code for determining these for current & future formats.
  58236. *
  58237. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58238. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58239. *
  58240. * Note: The result of this call is not taken into account when a texture is base64.
  58241. *
  58242. * @param formatsAvailable defines the list of those format families you have created
  58243. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  58244. *
  58245. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  58246. * @returns The extension selected.
  58247. */
  58248. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  58249. }
  58250. }
  58251. }
  58252. declare module "babylonjs/Engines/Extensions/index" {
  58253. export * from "babylonjs/Engines/Extensions/engine.alpha";
  58254. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  58255. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  58256. export * from "babylonjs/Engines/Extensions/engine.multiview";
  58257. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  58258. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58259. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  58260. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  58261. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  58262. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  58263. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58264. export * from "babylonjs/Engines/Extensions/engine.webVR";
  58265. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  58266. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  58267. export * from "babylonjs/Engines/Extensions/engine.views";
  58268. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  58269. import "babylonjs/Engines/Extensions/engine.textureSelector";
  58270. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  58271. }
  58272. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  58273. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58274. /** @hidden */
  58275. export var rgbdEncodePixelShader: {
  58276. name: string;
  58277. shader: string;
  58278. };
  58279. }
  58280. declare module "babylonjs/Misc/environmentTextureTools" {
  58281. import { Nullable } from "babylonjs/types";
  58282. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58283. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58284. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58285. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58286. import "babylonjs/Engines/Extensions/engine.readTexture";
  58287. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58288. import "babylonjs/Shaders/rgbdEncode.fragment";
  58289. import "babylonjs/Shaders/rgbdDecode.fragment";
  58290. /**
  58291. * Raw texture data and descriptor sufficient for WebGL texture upload
  58292. */
  58293. export interface EnvironmentTextureInfo {
  58294. /**
  58295. * Version of the environment map
  58296. */
  58297. version: number;
  58298. /**
  58299. * Width of image
  58300. */
  58301. width: number;
  58302. /**
  58303. * Irradiance information stored in the file.
  58304. */
  58305. irradiance: any;
  58306. /**
  58307. * Specular information stored in the file.
  58308. */
  58309. specular: any;
  58310. }
  58311. /**
  58312. * Defines One Image in the file. It requires only the position in the file
  58313. * as well as the length.
  58314. */
  58315. interface BufferImageData {
  58316. /**
  58317. * Length of the image data.
  58318. */
  58319. length: number;
  58320. /**
  58321. * Position of the data from the null terminator delimiting the end of the JSON.
  58322. */
  58323. position: number;
  58324. }
  58325. /**
  58326. * Defines the specular data enclosed in the file.
  58327. * This corresponds to the version 1 of the data.
  58328. */
  58329. export interface EnvironmentTextureSpecularInfoV1 {
  58330. /**
  58331. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  58332. */
  58333. specularDataPosition?: number;
  58334. /**
  58335. * This contains all the images data needed to reconstruct the cubemap.
  58336. */
  58337. mipmaps: Array<BufferImageData>;
  58338. /**
  58339. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  58340. */
  58341. lodGenerationScale: number;
  58342. }
  58343. /**
  58344. * Sets of helpers addressing the serialization and deserialization of environment texture
  58345. * stored in a BabylonJS env file.
  58346. * Those files are usually stored as .env files.
  58347. */
  58348. export class EnvironmentTextureTools {
  58349. /**
  58350. * Magic number identifying the env file.
  58351. */
  58352. private static _MagicBytes;
  58353. /**
  58354. * Gets the environment info from an env file.
  58355. * @param data The array buffer containing the .env bytes.
  58356. * @returns the environment file info (the json header) if successfully parsed.
  58357. */
  58358. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  58359. /**
  58360. * Creates an environment texture from a loaded cube texture.
  58361. * @param texture defines the cube texture to convert in env file
  58362. * @return a promise containing the environment data if succesfull.
  58363. */
  58364. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  58365. /**
  58366. * Creates a JSON representation of the spherical data.
  58367. * @param texture defines the texture containing the polynomials
  58368. * @return the JSON representation of the spherical info
  58369. */
  58370. private static _CreateEnvTextureIrradiance;
  58371. /**
  58372. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58373. * @param data the image data
  58374. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58375. * @return the views described by info providing access to the underlying buffer
  58376. */
  58377. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58378. /**
  58379. * Uploads the texture info contained in the env file to the GPU.
  58380. * @param texture defines the internal texture to upload to
  58381. * @param data defines the data to load
  58382. * @param info defines the texture info retrieved through the GetEnvInfo method
  58383. * @returns a promise
  58384. */
  58385. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58386. private static _OnImageReadyAsync;
  58387. /**
  58388. * Uploads the levels of image data to the GPU.
  58389. * @param texture defines the internal texture to upload to
  58390. * @param imageData defines the array buffer views of image data [mipmap][face]
  58391. * @returns a promise
  58392. */
  58393. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58394. /**
  58395. * Uploads spherical polynomials information to the texture.
  58396. * @param texture defines the texture we are trying to upload the information to
  58397. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58398. */
  58399. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58400. /** @hidden */
  58401. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58402. }
  58403. }
  58404. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58405. /**
  58406. * Class used to inline functions in shader code
  58407. */
  58408. export class ShaderCodeInliner {
  58409. private static readonly _RegexpFindFunctionNameAndType;
  58410. private _sourceCode;
  58411. private _functionDescr;
  58412. private _numMaxIterations;
  58413. /** Gets or sets the token used to mark the functions to inline */
  58414. inlineToken: string;
  58415. /** Gets or sets the debug mode */
  58416. debug: boolean;
  58417. /** Gets the code after the inlining process */
  58418. get code(): string;
  58419. /**
  58420. * Initializes the inliner
  58421. * @param sourceCode shader code source to inline
  58422. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58423. */
  58424. constructor(sourceCode: string, numMaxIterations?: number);
  58425. /**
  58426. * Start the processing of the shader code
  58427. */
  58428. processCode(): void;
  58429. private _collectFunctions;
  58430. private _processInlining;
  58431. private _extractBetweenMarkers;
  58432. private _skipWhitespaces;
  58433. private _removeComments;
  58434. private _replaceFunctionCallsByCode;
  58435. private _findBackward;
  58436. private _escapeRegExp;
  58437. private _replaceNames;
  58438. }
  58439. }
  58440. declare module "babylonjs/Engines/nativeEngine" {
  58441. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58442. import { Engine } from "babylonjs/Engines/engine";
  58443. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58444. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58446. import { Effect } from "babylonjs/Materials/effect";
  58447. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58448. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58449. import { IColor4Like } from "babylonjs/Maths/math.like";
  58450. import { Scene } from "babylonjs/scene";
  58451. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58452. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58453. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58454. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58455. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58456. /**
  58457. * Container for accessors for natively-stored mesh data buffers.
  58458. */
  58459. class NativeDataBuffer extends DataBuffer {
  58460. /**
  58461. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58462. */
  58463. nativeIndexBuffer?: any;
  58464. /**
  58465. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58466. */
  58467. nativeVertexBuffer?: any;
  58468. }
  58469. /** @hidden */
  58470. class NativeTexture extends InternalTexture {
  58471. getInternalTexture(): InternalTexture;
  58472. getViewCount(): number;
  58473. }
  58474. /** @hidden */
  58475. export class NativeEngine extends Engine {
  58476. private readonly _native;
  58477. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58478. private readonly INVALID_HANDLE;
  58479. private _boundBuffersVertexArray;
  58480. private _currentDepthTest;
  58481. getHardwareScalingLevel(): number;
  58482. constructor();
  58483. dispose(): void;
  58484. /**
  58485. * Can be used to override the current requestAnimationFrame requester.
  58486. * @hidden
  58487. */
  58488. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58489. /**
  58490. * Override default engine behavior.
  58491. * @param color
  58492. * @param backBuffer
  58493. * @param depth
  58494. * @param stencil
  58495. */
  58496. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58497. /**
  58498. * Gets host document
  58499. * @returns the host document object
  58500. */
  58501. getHostDocument(): Nullable<Document>;
  58502. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58503. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58504. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58505. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58506. [key: string]: VertexBuffer;
  58507. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58508. bindBuffers(vertexBuffers: {
  58509. [key: string]: VertexBuffer;
  58510. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58511. recordVertexArrayObject(vertexBuffers: {
  58512. [key: string]: VertexBuffer;
  58513. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58514. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58515. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58516. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58517. /**
  58518. * Draw a list of indexed primitives
  58519. * @param fillMode defines the primitive to use
  58520. * @param indexStart defines the starting index
  58521. * @param indexCount defines the number of index to draw
  58522. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58523. */
  58524. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58525. /**
  58526. * Draw a list of unindexed primitives
  58527. * @param fillMode defines the primitive to use
  58528. * @param verticesStart defines the index of first vertex to draw
  58529. * @param verticesCount defines the count of vertices to draw
  58530. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58531. */
  58532. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58533. createPipelineContext(): IPipelineContext;
  58534. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58535. /** @hidden */
  58536. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58537. /** @hidden */
  58538. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58539. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58540. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58541. protected _setProgram(program: WebGLProgram): void;
  58542. _releaseEffect(effect: Effect): void;
  58543. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58544. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58545. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58546. bindSamplers(effect: Effect): void;
  58547. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58548. getRenderWidth(useScreen?: boolean): number;
  58549. getRenderHeight(useScreen?: boolean): number;
  58550. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58551. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58552. /**
  58553. * Set the z offset to apply to current rendering
  58554. * @param value defines the offset to apply
  58555. */
  58556. setZOffset(value: number): void;
  58557. /**
  58558. * Gets the current value of the zOffset
  58559. * @returns the current zOffset state
  58560. */
  58561. getZOffset(): number;
  58562. /**
  58563. * Enable or disable depth buffering
  58564. * @param enable defines the state to set
  58565. */
  58566. setDepthBuffer(enable: boolean): void;
  58567. /**
  58568. * Gets a boolean indicating if depth writing is enabled
  58569. * @returns the current depth writing state
  58570. */
  58571. getDepthWrite(): boolean;
  58572. setDepthFunctionToGreater(): void;
  58573. setDepthFunctionToGreaterOrEqual(): void;
  58574. setDepthFunctionToLess(): void;
  58575. setDepthFunctionToLessOrEqual(): void;
  58576. /**
  58577. * Enable or disable depth writing
  58578. * @param enable defines the state to set
  58579. */
  58580. setDepthWrite(enable: boolean): void;
  58581. /**
  58582. * Enable or disable color writing
  58583. * @param enable defines the state to set
  58584. */
  58585. setColorWrite(enable: boolean): void;
  58586. /**
  58587. * Gets a boolean indicating if color writing is enabled
  58588. * @returns the current color writing state
  58589. */
  58590. getColorWrite(): boolean;
  58591. /**
  58592. * Sets alpha constants used by some alpha blending modes
  58593. * @param r defines the red component
  58594. * @param g defines the green component
  58595. * @param b defines the blue component
  58596. * @param a defines the alpha component
  58597. */
  58598. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58599. /**
  58600. * Sets the current alpha mode
  58601. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58602. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58603. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58604. */
  58605. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58606. /**
  58607. * Gets the current alpha mode
  58608. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58609. * @returns the current alpha mode
  58610. */
  58611. getAlphaMode(): number;
  58612. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58613. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58614. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58615. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58616. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58617. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58618. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58619. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58620. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58621. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58622. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58623. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58624. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58625. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58626. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58627. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58628. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58629. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58630. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58631. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58632. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58633. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58634. wipeCaches(bruteForce?: boolean): void;
  58635. _createTexture(): WebGLTexture;
  58636. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58637. /**
  58638. * Update the content of a dynamic texture
  58639. * @param texture defines the texture to update
  58640. * @param canvas defines the canvas containing the source
  58641. * @param invertY defines if data must be stored with Y axis inverted
  58642. * @param premulAlpha defines if alpha is stored as premultiplied
  58643. * @param format defines the format of the data
  58644. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58645. */
  58646. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58647. /**
  58648. * Usually called from Texture.ts.
  58649. * Passed information to create a WebGLTexture
  58650. * @param url defines a value which contains one of the following:
  58651. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58652. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58653. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58655. * @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)
  58656. * @param scene needed for loading to the correct scene
  58657. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58658. * @param onLoad optional callback to be called upon successful completion
  58659. * @param onError optional callback to be called upon failure
  58660. * @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
  58661. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58662. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58663. * @param forcedExtension defines the extension to use to pick the right loader
  58664. * @param mimeType defines an optional mime type
  58665. * @param loaderOptions options to be passed to the loader
  58666. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58667. */
  58668. 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;
  58669. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58670. _releaseFramebufferObjects(texture: InternalTexture): void;
  58671. /**
  58672. * Creates a cube texture
  58673. * @param rootUrl defines the url where the files to load is located
  58674. * @param scene defines the current scene
  58675. * @param files defines the list of files to load (1 per face)
  58676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58677. * @param onLoad defines an optional callback raised when the texture is loaded
  58678. * @param onError defines an optional callback raised if there is an issue to load the texture
  58679. * @param format defines the format of the data
  58680. * @param forcedExtension defines the extension to use to pick the right loader
  58681. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58682. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58683. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58684. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58685. * @returns the cube texture as an InternalTexture
  58686. */
  58687. 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;
  58688. createRenderTargetTexture(size: number | {
  58689. width: number;
  58690. height: number;
  58691. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58692. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58693. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58694. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58695. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58696. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58697. /**
  58698. * Updates a dynamic vertex buffer.
  58699. * @param vertexBuffer the vertex buffer to update
  58700. * @param data the data used to update the vertex buffer
  58701. * @param byteOffset the byte offset of the data (optional)
  58702. * @param byteLength the byte length of the data (optional)
  58703. */
  58704. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58705. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58706. private _updateAnisotropicLevel;
  58707. private _getAddressMode;
  58708. /** @hidden */
  58709. _bindTexture(channel: number, texture: InternalTexture): void;
  58710. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58711. releaseEffects(): void;
  58712. /** @hidden */
  58713. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58714. /** @hidden */
  58715. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58716. /** @hidden */
  58717. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58718. /** @hidden */
  58719. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58720. private _getNativeSamplingMode;
  58721. private _getNativeTextureFormat;
  58722. private _getNativeAlphaMode;
  58723. private _getNativeAttribType;
  58724. }
  58725. }
  58726. declare module "babylonjs/Engines/index" {
  58727. export * from "babylonjs/Engines/constants";
  58728. export * from "babylonjs/Engines/engineCapabilities";
  58729. export * from "babylonjs/Engines/instancingAttributeInfo";
  58730. export * from "babylonjs/Engines/thinEngine";
  58731. export * from "babylonjs/Engines/engine";
  58732. export * from "babylonjs/Engines/engineStore";
  58733. export * from "babylonjs/Engines/nullEngine";
  58734. export * from "babylonjs/Engines/Extensions/index";
  58735. export * from "babylonjs/Engines/IPipelineContext";
  58736. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58737. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58738. export * from "babylonjs/Engines/nativeEngine";
  58739. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58740. export * from "babylonjs/Engines/performanceConfigurator";
  58741. }
  58742. declare module "babylonjs/Events/clipboardEvents" {
  58743. /**
  58744. * Gather the list of clipboard event types as constants.
  58745. */
  58746. export class ClipboardEventTypes {
  58747. /**
  58748. * The clipboard event is fired when a copy command is active (pressed).
  58749. */
  58750. static readonly COPY: number;
  58751. /**
  58752. * The clipboard event is fired when a cut command is active (pressed).
  58753. */
  58754. static readonly CUT: number;
  58755. /**
  58756. * The clipboard event is fired when a paste command is active (pressed).
  58757. */
  58758. static readonly PASTE: number;
  58759. }
  58760. /**
  58761. * This class is used to store clipboard related info for the onClipboardObservable event.
  58762. */
  58763. export class ClipboardInfo {
  58764. /**
  58765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58766. */
  58767. type: number;
  58768. /**
  58769. * Defines the related dom event
  58770. */
  58771. event: ClipboardEvent;
  58772. /**
  58773. *Creates an instance of ClipboardInfo.
  58774. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58775. * @param event Defines the related dom event
  58776. */
  58777. constructor(
  58778. /**
  58779. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58780. */
  58781. type: number,
  58782. /**
  58783. * Defines the related dom event
  58784. */
  58785. event: ClipboardEvent);
  58786. /**
  58787. * Get the clipboard event's type from the keycode.
  58788. * @param keyCode Defines the keyCode for the current keyboard event.
  58789. * @return {number}
  58790. */
  58791. static GetTypeFromCharacter(keyCode: number): number;
  58792. }
  58793. }
  58794. declare module "babylonjs/Events/index" {
  58795. export * from "babylonjs/Events/keyboardEvents";
  58796. export * from "babylonjs/Events/pointerEvents";
  58797. export * from "babylonjs/Events/clipboardEvents";
  58798. }
  58799. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58800. import { Scene } from "babylonjs/scene";
  58801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58802. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58804. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58805. /**
  58806. * Google Daydream controller
  58807. */
  58808. export class DaydreamController extends WebVRController {
  58809. /**
  58810. * Base Url for the controller model.
  58811. */
  58812. static MODEL_BASE_URL: string;
  58813. /**
  58814. * File name for the controller model.
  58815. */
  58816. static MODEL_FILENAME: string;
  58817. /**
  58818. * Gamepad Id prefix used to identify Daydream Controller.
  58819. */
  58820. static readonly GAMEPAD_ID_PREFIX: string;
  58821. /**
  58822. * Creates a new DaydreamController from a gamepad
  58823. * @param vrGamepad the gamepad that the controller should be created from
  58824. */
  58825. constructor(vrGamepad: any);
  58826. /**
  58827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58828. * @param scene scene in which to add meshes
  58829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58830. */
  58831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58832. /**
  58833. * Called once for each button that changed state since the last frame
  58834. * @param buttonIdx Which button index changed
  58835. * @param state New state of the button
  58836. * @param changes Which properties on the state changed since last frame
  58837. */
  58838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58839. }
  58840. }
  58841. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58842. import { Scene } from "babylonjs/scene";
  58843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58844. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58845. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58846. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58847. /**
  58848. * Gear VR Controller
  58849. */
  58850. export class GearVRController extends WebVRController {
  58851. /**
  58852. * Base Url for the controller model.
  58853. */
  58854. static MODEL_BASE_URL: string;
  58855. /**
  58856. * File name for the controller model.
  58857. */
  58858. static MODEL_FILENAME: string;
  58859. /**
  58860. * Gamepad Id prefix used to identify this controller.
  58861. */
  58862. static readonly GAMEPAD_ID_PREFIX: string;
  58863. private readonly _buttonIndexToObservableNameMap;
  58864. /**
  58865. * Creates a new GearVRController from a gamepad
  58866. * @param vrGamepad the gamepad that the controller should be created from
  58867. */
  58868. constructor(vrGamepad: any);
  58869. /**
  58870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58871. * @param scene scene in which to add meshes
  58872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58873. */
  58874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58875. /**
  58876. * Called once for each button that changed state since the last frame
  58877. * @param buttonIdx Which button index changed
  58878. * @param state New state of the button
  58879. * @param changes Which properties on the state changed since last frame
  58880. */
  58881. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58882. }
  58883. }
  58884. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58885. import { Scene } from "babylonjs/scene";
  58886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58887. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58888. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58889. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58890. /**
  58891. * Generic Controller
  58892. */
  58893. export class GenericController extends WebVRController {
  58894. /**
  58895. * Base Url for the controller model.
  58896. */
  58897. static readonly MODEL_BASE_URL: string;
  58898. /**
  58899. * File name for the controller model.
  58900. */
  58901. static readonly MODEL_FILENAME: string;
  58902. /**
  58903. * Creates a new GenericController 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. * Called once for each button that changed state since the last frame
  58915. * @param buttonIdx Which button index changed
  58916. * @param state New state of the button
  58917. * @param changes Which properties on the state changed since last frame
  58918. */
  58919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58920. }
  58921. }
  58922. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58923. import { Observable } from "babylonjs/Misc/observable";
  58924. import { Scene } from "babylonjs/scene";
  58925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58926. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58927. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58928. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58929. /**
  58930. * Oculus Touch Controller
  58931. */
  58932. export class OculusTouchController extends WebVRController {
  58933. /**
  58934. * Base Url for the controller model.
  58935. */
  58936. static MODEL_BASE_URL: string;
  58937. /**
  58938. * File name for the left controller model.
  58939. */
  58940. static MODEL_LEFT_FILENAME: string;
  58941. /**
  58942. * File name for the right controller model.
  58943. */
  58944. static MODEL_RIGHT_FILENAME: string;
  58945. /**
  58946. * Base Url for the Quest controller model.
  58947. */
  58948. static QUEST_MODEL_BASE_URL: string;
  58949. /**
  58950. * @hidden
  58951. * If the controllers are running on a device that needs the updated Quest controller models
  58952. */
  58953. static _IsQuest: boolean;
  58954. /**
  58955. * Fired when the secondary trigger on this controller is modified
  58956. */
  58957. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58958. /**
  58959. * Fired when the thumb rest on this controller is modified
  58960. */
  58961. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58962. /**
  58963. * Creates a new OculusTouchController from a gamepad
  58964. * @param vrGamepad the gamepad that the controller should be created from
  58965. */
  58966. constructor(vrGamepad: any);
  58967. /**
  58968. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58969. * @param scene scene in which to add meshes
  58970. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58971. */
  58972. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58973. /**
  58974. * Fired when the A button on this controller is modified
  58975. */
  58976. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58977. /**
  58978. * Fired when the B button on this controller is modified
  58979. */
  58980. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58981. /**
  58982. * Fired when the X button on this controller is modified
  58983. */
  58984. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58985. /**
  58986. * Fired when the Y button on this controller is modified
  58987. */
  58988. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58989. /**
  58990. * Called once for each button that changed state since the last frame
  58991. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58992. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58993. * 2) secondary trigger (same)
  58994. * 3) A (right) X (left), touch, pressed = value
  58995. * 4) B / Y
  58996. * 5) thumb rest
  58997. * @param buttonIdx Which button index changed
  58998. * @param state New state of the button
  58999. * @param changes Which properties on the state changed since last frame
  59000. */
  59001. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59002. }
  59003. }
  59004. declare module "babylonjs/Gamepads/Controllers/viveController" {
  59005. import { Scene } from "babylonjs/scene";
  59006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59007. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59008. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59009. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59010. import { Observable } from "babylonjs/Misc/observable";
  59011. /**
  59012. * Vive Controller
  59013. */
  59014. export class ViveController extends WebVRController {
  59015. /**
  59016. * Base Url for the controller model.
  59017. */
  59018. static MODEL_BASE_URL: string;
  59019. /**
  59020. * File name for the controller model.
  59021. */
  59022. static MODEL_FILENAME: string;
  59023. /**
  59024. * Creates a new ViveController from a gamepad
  59025. * @param vrGamepad the gamepad that the controller should be created from
  59026. */
  59027. constructor(vrGamepad: any);
  59028. /**
  59029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59030. * @param scene scene in which to add meshes
  59031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59032. */
  59033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59034. /**
  59035. * Fired when the left button on this controller is modified
  59036. */
  59037. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59038. /**
  59039. * Fired when the right button on this controller is modified
  59040. */
  59041. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59042. /**
  59043. * Fired when the menu button on this controller is modified
  59044. */
  59045. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59046. /**
  59047. * Called once for each button that changed state since the last frame
  59048. * Vive mapping:
  59049. * 0: touchpad
  59050. * 1: trigger
  59051. * 2: left AND right buttons
  59052. * 3: menu button
  59053. * @param buttonIdx Which button index changed
  59054. * @param state New state of the button
  59055. * @param changes Which properties on the state changed since last frame
  59056. */
  59057. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59058. }
  59059. }
  59060. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  59061. import { Observable } from "babylonjs/Misc/observable";
  59062. import { Scene } from "babylonjs/scene";
  59063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59064. import { Ray } from "babylonjs/Culling/ray";
  59065. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59066. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59067. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59068. /**
  59069. * Defines the WindowsMotionController object that the state of the windows motion controller
  59070. */
  59071. export class WindowsMotionController extends WebVRController {
  59072. /**
  59073. * The base url used to load the left and right controller models
  59074. */
  59075. static MODEL_BASE_URL: string;
  59076. /**
  59077. * The name of the left controller model file
  59078. */
  59079. static MODEL_LEFT_FILENAME: string;
  59080. /**
  59081. * The name of the right controller model file
  59082. */
  59083. static MODEL_RIGHT_FILENAME: string;
  59084. /**
  59085. * The controller name prefix for this controller type
  59086. */
  59087. static readonly GAMEPAD_ID_PREFIX: string;
  59088. /**
  59089. * The controller id pattern for this controller type
  59090. */
  59091. private static readonly GAMEPAD_ID_PATTERN;
  59092. private _loadedMeshInfo;
  59093. protected readonly _mapping: {
  59094. buttons: string[];
  59095. buttonMeshNames: {
  59096. trigger: string;
  59097. menu: string;
  59098. grip: string;
  59099. thumbstick: string;
  59100. trackpad: string;
  59101. };
  59102. buttonObservableNames: {
  59103. trigger: string;
  59104. menu: string;
  59105. grip: string;
  59106. thumbstick: string;
  59107. trackpad: string;
  59108. };
  59109. axisMeshNames: string[];
  59110. pointingPoseMeshName: string;
  59111. };
  59112. /**
  59113. * Fired when the trackpad on this controller is clicked
  59114. */
  59115. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59116. /**
  59117. * Fired when the trackpad on this controller is modified
  59118. */
  59119. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59120. /**
  59121. * The current x and y values of this controller's trackpad
  59122. */
  59123. trackpad: StickValues;
  59124. /**
  59125. * Creates a new WindowsMotionController from a gamepad
  59126. * @param vrGamepad the gamepad that the controller should be created from
  59127. */
  59128. constructor(vrGamepad: any);
  59129. /**
  59130. * Fired when the trigger on this controller is modified
  59131. */
  59132. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59133. /**
  59134. * Fired when the menu button on this controller is modified
  59135. */
  59136. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59137. /**
  59138. * Fired when the grip button on this controller is modified
  59139. */
  59140. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59141. /**
  59142. * Fired when the thumbstick button on this controller is modified
  59143. */
  59144. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59145. /**
  59146. * Fired when the touchpad button on this controller is modified
  59147. */
  59148. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59149. /**
  59150. * Fired when the touchpad values on this controller are modified
  59151. */
  59152. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  59153. protected _updateTrackpad(): void;
  59154. /**
  59155. * Called once per frame by the engine.
  59156. */
  59157. update(): void;
  59158. /**
  59159. * Called once for each button that changed state since the last frame
  59160. * @param buttonIdx Which button index changed
  59161. * @param state New state of the button
  59162. * @param changes Which properties on the state changed since last frame
  59163. */
  59164. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59165. /**
  59166. * Moves the buttons on the controller mesh based on their current state
  59167. * @param buttonName the name of the button to move
  59168. * @param buttonValue the value of the button which determines the buttons new position
  59169. */
  59170. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  59171. /**
  59172. * Moves the axis on the controller mesh based on its current state
  59173. * @param axis the index of the axis
  59174. * @param axisValue the value of the axis which determines the meshes new position
  59175. * @hidden
  59176. */
  59177. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  59178. /**
  59179. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59180. * @param scene scene in which to add meshes
  59181. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59182. */
  59183. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  59184. /**
  59185. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  59186. * can be transformed by button presses and axes values, based on this._mapping.
  59187. *
  59188. * @param scene scene in which the meshes exist
  59189. * @param meshes list of meshes that make up the controller model to process
  59190. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  59191. */
  59192. private processModel;
  59193. private createMeshInfo;
  59194. /**
  59195. * Gets the ray of the controller in the direction the controller is pointing
  59196. * @param length the length the resulting ray should be
  59197. * @returns a ray in the direction the controller is pointing
  59198. */
  59199. getForwardRay(length?: number): Ray;
  59200. /**
  59201. * Disposes of the controller
  59202. */
  59203. dispose(): void;
  59204. }
  59205. /**
  59206. * This class represents a new windows motion controller in XR.
  59207. */
  59208. export class XRWindowsMotionController extends WindowsMotionController {
  59209. /**
  59210. * Changing the original WIndowsMotionController mapping to fir the new mapping
  59211. */
  59212. protected readonly _mapping: {
  59213. buttons: string[];
  59214. buttonMeshNames: {
  59215. trigger: string;
  59216. menu: string;
  59217. grip: string;
  59218. thumbstick: string;
  59219. trackpad: string;
  59220. };
  59221. buttonObservableNames: {
  59222. trigger: string;
  59223. menu: string;
  59224. grip: string;
  59225. thumbstick: string;
  59226. trackpad: string;
  59227. };
  59228. axisMeshNames: string[];
  59229. pointingPoseMeshName: string;
  59230. };
  59231. /**
  59232. * Construct a new XR-Based windows motion controller
  59233. *
  59234. * @param gamepadInfo the gamepad object from the browser
  59235. */
  59236. constructor(gamepadInfo: any);
  59237. /**
  59238. * holds the thumbstick values (X,Y)
  59239. */
  59240. thumbstickValues: StickValues;
  59241. /**
  59242. * Fired when the thumbstick on this controller is clicked
  59243. */
  59244. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  59245. /**
  59246. * Fired when the thumbstick on this controller is modified
  59247. */
  59248. onThumbstickValuesChangedObservable: Observable<StickValues>;
  59249. /**
  59250. * Fired when the touchpad button on this controller is modified
  59251. */
  59252. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59253. /**
  59254. * Fired when the touchpad values on this controller are modified
  59255. */
  59256. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59257. /**
  59258. * Fired when the thumbstick button on this controller is modified
  59259. * here to prevent breaking changes
  59260. */
  59261. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59262. /**
  59263. * updating the thumbstick(!) and not the trackpad.
  59264. * This is named this way due to the difference between WebVR and XR and to avoid
  59265. * changing the parent class.
  59266. */
  59267. protected _updateTrackpad(): void;
  59268. /**
  59269. * Disposes the class with joy
  59270. */
  59271. dispose(): void;
  59272. }
  59273. }
  59274. declare module "babylonjs/Gamepads/Controllers/index" {
  59275. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  59276. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  59277. export * from "babylonjs/Gamepads/Controllers/genericController";
  59278. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  59279. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59280. export * from "babylonjs/Gamepads/Controllers/viveController";
  59281. export * from "babylonjs/Gamepads/Controllers/webVRController";
  59282. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  59283. }
  59284. declare module "babylonjs/Gamepads/index" {
  59285. export * from "babylonjs/Gamepads/Controllers/index";
  59286. export * from "babylonjs/Gamepads/gamepad";
  59287. export * from "babylonjs/Gamepads/gamepadManager";
  59288. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  59289. export * from "babylonjs/Gamepads/xboxGamepad";
  59290. export * from "babylonjs/Gamepads/dualShockGamepad";
  59291. }
  59292. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59293. import { Scene } from "babylonjs/scene";
  59294. import { Vector4 } from "babylonjs/Maths/math.vector";
  59295. import { Color4 } from "babylonjs/Maths/math.color";
  59296. import { Mesh } from "babylonjs/Meshes/mesh";
  59297. import { Nullable } from "babylonjs/types";
  59298. /**
  59299. * Class containing static functions to help procedurally build meshes
  59300. */
  59301. export class PolyhedronBuilder {
  59302. /**
  59303. * Creates a polyhedron mesh
  59304. * * 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
  59305. * * The parameter `size` (positive float, default 1) sets the polygon size
  59306. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59307. * * 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`
  59308. * * 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
  59309. * * 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)`)
  59310. * * 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
  59311. * * 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
  59312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59315. * @param name defines the name of the mesh
  59316. * @param options defines the options used to create the mesh
  59317. * @param scene defines the hosting scene
  59318. * @returns the polyhedron mesh
  59319. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59320. */
  59321. static CreatePolyhedron(name: string, options: {
  59322. type?: number;
  59323. size?: number;
  59324. sizeX?: number;
  59325. sizeY?: number;
  59326. sizeZ?: number;
  59327. custom?: any;
  59328. faceUV?: Vector4[];
  59329. faceColors?: Color4[];
  59330. flat?: boolean;
  59331. updatable?: boolean;
  59332. sideOrientation?: number;
  59333. frontUVs?: Vector4;
  59334. backUVs?: Vector4;
  59335. }, scene?: Nullable<Scene>): Mesh;
  59336. }
  59337. }
  59338. declare module "babylonjs/Gizmos/scaleGizmo" {
  59339. import { Observable } from "babylonjs/Misc/observable";
  59340. import { Nullable } from "babylonjs/types";
  59341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59342. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59343. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59344. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59345. import { Node } from "babylonjs/node";
  59346. /**
  59347. * Gizmo that enables scaling a mesh along 3 axis
  59348. */
  59349. export class ScaleGizmo extends Gizmo {
  59350. /**
  59351. * Internal gizmo used for interactions on the x axis
  59352. */
  59353. xGizmo: AxisScaleGizmo;
  59354. /**
  59355. * Internal gizmo used for interactions on the y axis
  59356. */
  59357. yGizmo: AxisScaleGizmo;
  59358. /**
  59359. * Internal gizmo used for interactions on the z axis
  59360. */
  59361. zGizmo: AxisScaleGizmo;
  59362. /**
  59363. * Internal gizmo used to scale all axis equally
  59364. */
  59365. uniformScaleGizmo: AxisScaleGizmo;
  59366. private _meshAttached;
  59367. private _nodeAttached;
  59368. private _snapDistance;
  59369. private _uniformScalingMesh;
  59370. private _octahedron;
  59371. private _sensitivity;
  59372. /** Fires an event when any of it's sub gizmos are dragged */
  59373. onDragStartObservable: Observable<unknown>;
  59374. /** Fires an event when any of it's sub gizmos are released from dragging */
  59375. onDragEndObservable: Observable<unknown>;
  59376. get attachedMesh(): Nullable<AbstractMesh>;
  59377. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59378. get attachedNode(): Nullable<Node>;
  59379. set attachedNode(node: Nullable<Node>);
  59380. /**
  59381. * True when the mouse pointer is hovering a gizmo mesh
  59382. */
  59383. get isHovered(): boolean;
  59384. /**
  59385. * Creates a ScaleGizmo
  59386. * @param gizmoLayer The utility layer the gizmo will be added to
  59387. * @param thickness display gizmo axis thickness
  59388. */
  59389. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59390. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59391. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59392. /**
  59393. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59394. */
  59395. set snapDistance(value: number);
  59396. get snapDistance(): number;
  59397. /**
  59398. * Ratio for the scale of the gizmo (Default: 1)
  59399. */
  59400. set scaleRatio(value: number);
  59401. get scaleRatio(): number;
  59402. /**
  59403. * Sensitivity factor for dragging (Default: 1)
  59404. */
  59405. set sensitivity(value: number);
  59406. get sensitivity(): number;
  59407. /**
  59408. * Disposes of the gizmo
  59409. */
  59410. dispose(): void;
  59411. }
  59412. }
  59413. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59414. import { Observable } from "babylonjs/Misc/observable";
  59415. import { Nullable } from "babylonjs/types";
  59416. import { Vector3 } from "babylonjs/Maths/math.vector";
  59417. import { Node } from "babylonjs/node";
  59418. import { Mesh } from "babylonjs/Meshes/mesh";
  59419. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59420. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59421. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59422. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59423. import { Color3 } from "babylonjs/Maths/math.color";
  59424. /**
  59425. * Single axis scale gizmo
  59426. */
  59427. export class AxisScaleGizmo extends Gizmo {
  59428. /**
  59429. * Drag behavior responsible for the gizmos dragging interactions
  59430. */
  59431. dragBehavior: PointerDragBehavior;
  59432. private _pointerObserver;
  59433. /**
  59434. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59435. */
  59436. snapDistance: number;
  59437. /**
  59438. * Event that fires each time the gizmo snaps to a new location.
  59439. * * snapDistance is the the change in distance
  59440. */
  59441. onSnapObservable: Observable<{
  59442. snapDistance: number;
  59443. }>;
  59444. /**
  59445. * If the scaling operation should be done on all axis (default: false)
  59446. */
  59447. uniformScaling: boolean;
  59448. /**
  59449. * Custom sensitivity value for the drag strength
  59450. */
  59451. sensitivity: number;
  59452. private _isEnabled;
  59453. private _parent;
  59454. private _arrow;
  59455. private _coloredMaterial;
  59456. private _hoverMaterial;
  59457. /**
  59458. * Creates an AxisScaleGizmo
  59459. * @param gizmoLayer The utility layer the gizmo will be added to
  59460. * @param dragAxis The axis which the gizmo will be able to scale on
  59461. * @param color The color of the gizmo
  59462. * @param thickness display gizmo axis thickness
  59463. */
  59464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59465. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59466. /**
  59467. * If the gizmo is enabled
  59468. */
  59469. set isEnabled(value: boolean);
  59470. get isEnabled(): boolean;
  59471. /**
  59472. * Disposes of the gizmo
  59473. */
  59474. dispose(): void;
  59475. /**
  59476. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59477. * @param mesh The mesh to replace the default mesh of the gizmo
  59478. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59479. */
  59480. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59481. }
  59482. }
  59483. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59484. import { Observable } from "babylonjs/Misc/observable";
  59485. import { Nullable } from "babylonjs/types";
  59486. import { Vector3 } from "babylonjs/Maths/math.vector";
  59487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59488. import { Mesh } from "babylonjs/Meshes/mesh";
  59489. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59490. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59491. import { Color3 } from "babylonjs/Maths/math.color";
  59492. import "babylonjs/Meshes/Builders/boxBuilder";
  59493. /**
  59494. * Bounding box gizmo
  59495. */
  59496. export class BoundingBoxGizmo extends Gizmo {
  59497. private _lineBoundingBox;
  59498. private _rotateSpheresParent;
  59499. private _scaleBoxesParent;
  59500. private _boundingDimensions;
  59501. private _renderObserver;
  59502. private _pointerObserver;
  59503. private _scaleDragSpeed;
  59504. private _tmpQuaternion;
  59505. private _tmpVector;
  59506. private _tmpRotationMatrix;
  59507. /**
  59508. * 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)
  59509. */
  59510. ignoreChildren: boolean;
  59511. /**
  59512. * 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)
  59513. */
  59514. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59515. /**
  59516. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59517. */
  59518. rotationSphereSize: number;
  59519. /**
  59520. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59521. */
  59522. scaleBoxSize: number;
  59523. /**
  59524. * 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)
  59525. */
  59526. fixedDragMeshScreenSize: boolean;
  59527. /**
  59528. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59529. */
  59530. fixedDragMeshScreenSizeDistanceFactor: number;
  59531. /**
  59532. * Fired when a rotation sphere or scale box is dragged
  59533. */
  59534. onDragStartObservable: Observable<{}>;
  59535. /**
  59536. * Fired when a scale box is dragged
  59537. */
  59538. onScaleBoxDragObservable: Observable<{}>;
  59539. /**
  59540. * Fired when a scale box drag is ended
  59541. */
  59542. onScaleBoxDragEndObservable: Observable<{}>;
  59543. /**
  59544. * Fired when a rotation sphere is dragged
  59545. */
  59546. onRotationSphereDragObservable: Observable<{}>;
  59547. /**
  59548. * Fired when a rotation sphere drag is ended
  59549. */
  59550. onRotationSphereDragEndObservable: Observable<{}>;
  59551. /**
  59552. * 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)
  59553. */
  59554. scalePivot: Nullable<Vector3>;
  59555. /**
  59556. * Mesh used as a pivot to rotate the attached node
  59557. */
  59558. private _anchorMesh;
  59559. private _existingMeshScale;
  59560. private _dragMesh;
  59561. private pointerDragBehavior;
  59562. private coloredMaterial;
  59563. private hoverColoredMaterial;
  59564. /**
  59565. * Sets the color of the bounding box gizmo
  59566. * @param color the color to set
  59567. */
  59568. setColor(color: Color3): void;
  59569. /**
  59570. * Creates an BoundingBoxGizmo
  59571. * @param gizmoLayer The utility layer the gizmo will be added to
  59572. * @param color The color of the gizmo
  59573. */
  59574. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59575. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59576. private _selectNode;
  59577. /**
  59578. * Updates the bounding box information for the Gizmo
  59579. */
  59580. updateBoundingBox(): void;
  59581. private _updateRotationSpheres;
  59582. private _updateScaleBoxes;
  59583. /**
  59584. * Enables rotation on the specified axis and disables rotation on the others
  59585. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59586. */
  59587. setEnabledRotationAxis(axis: string): void;
  59588. /**
  59589. * Enables/disables scaling
  59590. * @param enable if scaling should be enabled
  59591. * @param homogeneousScaling defines if scaling should only be homogeneous
  59592. */
  59593. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59594. private _updateDummy;
  59595. /**
  59596. * Enables a pointer drag behavior on the bounding box of the gizmo
  59597. */
  59598. enableDragBehavior(): void;
  59599. /**
  59600. * Disposes of the gizmo
  59601. */
  59602. dispose(): void;
  59603. /**
  59604. * 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)
  59605. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59606. * @returns the bounding box mesh with the passed in mesh as a child
  59607. */
  59608. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59609. /**
  59610. * CustomMeshes are not supported by this gizmo
  59611. * @param mesh The mesh to replace the default mesh of the gizmo
  59612. */
  59613. setCustomMesh(mesh: Mesh): void;
  59614. }
  59615. }
  59616. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59617. import { Observable } from "babylonjs/Misc/observable";
  59618. import { Nullable } from "babylonjs/types";
  59619. import { Vector3 } from "babylonjs/Maths/math.vector";
  59620. import { Color3 } from "babylonjs/Maths/math.color";
  59621. import { Node } from "babylonjs/node";
  59622. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59623. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59624. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59625. import "babylonjs/Meshes/Builders/linesBuilder";
  59626. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59627. /**
  59628. * Single plane rotation gizmo
  59629. */
  59630. export class PlaneRotationGizmo extends Gizmo {
  59631. /**
  59632. * Drag behavior responsible for the gizmos dragging interactions
  59633. */
  59634. dragBehavior: PointerDragBehavior;
  59635. private _pointerObserver;
  59636. /**
  59637. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59638. */
  59639. snapDistance: number;
  59640. /**
  59641. * Event that fires each time the gizmo snaps to a new location.
  59642. * * snapDistance is the the change in distance
  59643. */
  59644. onSnapObservable: Observable<{
  59645. snapDistance: number;
  59646. }>;
  59647. private _isEnabled;
  59648. private _parent;
  59649. /**
  59650. * Creates a PlaneRotationGizmo
  59651. * @param gizmoLayer The utility layer the gizmo will be added to
  59652. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59653. * @param color The color of the gizmo
  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(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59659. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59660. /**
  59661. * If the gizmo is enabled
  59662. */
  59663. set isEnabled(value: boolean);
  59664. get isEnabled(): boolean;
  59665. /**
  59666. * Disposes of the gizmo
  59667. */
  59668. dispose(): void;
  59669. }
  59670. }
  59671. declare module "babylonjs/Gizmos/rotationGizmo" {
  59672. import { Observable } from "babylonjs/Misc/observable";
  59673. import { Nullable } from "babylonjs/types";
  59674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59675. import { Mesh } from "babylonjs/Meshes/mesh";
  59676. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59677. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59678. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59679. import { Node } from "babylonjs/node";
  59680. /**
  59681. * Gizmo that enables rotating a mesh along 3 axis
  59682. */
  59683. export class RotationGizmo extends Gizmo {
  59684. /**
  59685. * Internal gizmo used for interactions on the x axis
  59686. */
  59687. xGizmo: PlaneRotationGizmo;
  59688. /**
  59689. * Internal gizmo used for interactions on the y axis
  59690. */
  59691. yGizmo: PlaneRotationGizmo;
  59692. /**
  59693. * Internal gizmo used for interactions on the z axis
  59694. */
  59695. zGizmo: PlaneRotationGizmo;
  59696. /** Fires an event when any of it's sub gizmos are dragged */
  59697. onDragStartObservable: Observable<unknown>;
  59698. /** Fires an event when any of it's sub gizmos are released from dragging */
  59699. onDragEndObservable: Observable<unknown>;
  59700. private _meshAttached;
  59701. private _nodeAttached;
  59702. get attachedMesh(): Nullable<AbstractMesh>;
  59703. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59704. get attachedNode(): Nullable<Node>;
  59705. set attachedNode(node: Nullable<Node>);
  59706. protected _checkBillboardTransform(): void;
  59707. /**
  59708. * True when the mouse pointer is hovering a gizmo mesh
  59709. */
  59710. get isHovered(): boolean;
  59711. /**
  59712. * Creates a RotationGizmo
  59713. * @param gizmoLayer The utility layer the gizmo will be added to
  59714. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59715. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59716. * @param thickness display gizmo axis thickness
  59717. */
  59718. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59719. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59720. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59721. /**
  59722. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59723. */
  59724. set snapDistance(value: number);
  59725. get snapDistance(): number;
  59726. /**
  59727. * Ratio for the scale of the gizmo (Default: 1)
  59728. */
  59729. set scaleRatio(value: number);
  59730. get scaleRatio(): number;
  59731. /**
  59732. * Disposes of the gizmo
  59733. */
  59734. dispose(): void;
  59735. /**
  59736. * CustomMeshes are not supported by this gizmo
  59737. * @param mesh The mesh to replace the default mesh of the gizmo
  59738. */
  59739. setCustomMesh(mesh: Mesh): void;
  59740. }
  59741. }
  59742. declare module "babylonjs/Gizmos/gizmoManager" {
  59743. import { Observable } from "babylonjs/Misc/observable";
  59744. import { Nullable } from "babylonjs/types";
  59745. import { Scene, IDisposable } from "babylonjs/scene";
  59746. import { Node } from "babylonjs/node";
  59747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59748. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59749. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59750. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59751. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59752. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59753. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59754. /**
  59755. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59756. */
  59757. export class GizmoManager implements IDisposable {
  59758. private scene;
  59759. /**
  59760. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59761. */
  59762. gizmos: {
  59763. positionGizmo: Nullable<PositionGizmo>;
  59764. rotationGizmo: Nullable<RotationGizmo>;
  59765. scaleGizmo: Nullable<ScaleGizmo>;
  59766. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59767. };
  59768. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59769. clearGizmoOnEmptyPointerEvent: boolean;
  59770. /** Fires an event when the manager is attached to a mesh */
  59771. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59772. /** Fires an event when the manager is attached to a node */
  59773. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59774. private _gizmosEnabled;
  59775. private _pointerObserver;
  59776. private _attachedMesh;
  59777. private _attachedNode;
  59778. private _boundingBoxColor;
  59779. private _defaultUtilityLayer;
  59780. private _defaultKeepDepthUtilityLayer;
  59781. private _thickness;
  59782. /**
  59783. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59784. */
  59785. boundingBoxDragBehavior: SixDofDragBehavior;
  59786. /**
  59787. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59788. */
  59789. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59790. /**
  59791. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59792. */
  59793. attachableNodes: Nullable<Array<Node>>;
  59794. /**
  59795. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59796. */
  59797. usePointerToAttachGizmos: boolean;
  59798. /**
  59799. * Utility layer that the bounding box gizmo belongs to
  59800. */
  59801. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59802. /**
  59803. * Utility layer that all gizmos besides bounding box belong to
  59804. */
  59805. get utilityLayer(): UtilityLayerRenderer;
  59806. /**
  59807. * True when the mouse pointer is hovering a gizmo mesh
  59808. */
  59809. get isHovered(): boolean;
  59810. /**
  59811. * Instatiates a gizmo manager
  59812. * @param scene the scene to overlay the gizmos on top of
  59813. * @param thickness display gizmo axis thickness
  59814. */
  59815. constructor(scene: Scene, thickness?: number);
  59816. /**
  59817. * Attaches a set of gizmos to the specified mesh
  59818. * @param mesh The mesh the gizmo's should be attached to
  59819. */
  59820. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59821. /**
  59822. * Attaches a set of gizmos to the specified node
  59823. * @param node The node the gizmo's should be attached to
  59824. */
  59825. attachToNode(node: Nullable<Node>): void;
  59826. /**
  59827. * If the position gizmo is enabled
  59828. */
  59829. set positionGizmoEnabled(value: boolean);
  59830. get positionGizmoEnabled(): boolean;
  59831. /**
  59832. * If the rotation gizmo is enabled
  59833. */
  59834. set rotationGizmoEnabled(value: boolean);
  59835. get rotationGizmoEnabled(): boolean;
  59836. /**
  59837. * If the scale gizmo is enabled
  59838. */
  59839. set scaleGizmoEnabled(value: boolean);
  59840. get scaleGizmoEnabled(): boolean;
  59841. /**
  59842. * If the boundingBox gizmo is enabled
  59843. */
  59844. set boundingBoxGizmoEnabled(value: boolean);
  59845. get boundingBoxGizmoEnabled(): boolean;
  59846. /**
  59847. * Disposes of the gizmo manager
  59848. */
  59849. dispose(): void;
  59850. }
  59851. }
  59852. declare module "babylonjs/Lights/directionalLight" {
  59853. import { Camera } from "babylonjs/Cameras/camera";
  59854. import { Scene } from "babylonjs/scene";
  59855. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59857. import { Light } from "babylonjs/Lights/light";
  59858. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59859. import { Effect } from "babylonjs/Materials/effect";
  59860. /**
  59861. * A directional light is defined by a direction (what a surprise!).
  59862. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59863. * 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.
  59864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59865. */
  59866. export class DirectionalLight extends ShadowLight {
  59867. private _shadowFrustumSize;
  59868. /**
  59869. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59870. */
  59871. get shadowFrustumSize(): number;
  59872. /**
  59873. * Specifies a fix frustum size for the shadow generation.
  59874. */
  59875. set shadowFrustumSize(value: number);
  59876. private _shadowOrthoScale;
  59877. /**
  59878. * Gets the shadow projection scale against the optimal computed one.
  59879. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59880. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59881. */
  59882. get shadowOrthoScale(): number;
  59883. /**
  59884. * Sets the shadow projection scale against the optimal computed one.
  59885. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59886. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59887. */
  59888. set shadowOrthoScale(value: number);
  59889. /**
  59890. * Automatically compute the projection matrix to best fit (including all the casters)
  59891. * on each frame.
  59892. */
  59893. autoUpdateExtends: boolean;
  59894. /**
  59895. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59896. * on each frame. autoUpdateExtends must be set to true for this to work
  59897. */
  59898. autoCalcShadowZBounds: boolean;
  59899. private _orthoLeft;
  59900. private _orthoRight;
  59901. private _orthoTop;
  59902. private _orthoBottom;
  59903. /**
  59904. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59905. * The directional light is emitted from everywhere in the given direction.
  59906. * It can cast shadows.
  59907. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59908. * @param name The friendly name of the light
  59909. * @param direction The direction of the light
  59910. * @param scene The scene the light belongs to
  59911. */
  59912. constructor(name: string, direction: Vector3, scene: Scene);
  59913. /**
  59914. * Returns the string "DirectionalLight".
  59915. * @return The class name
  59916. */
  59917. getClassName(): string;
  59918. /**
  59919. * Returns the integer 1.
  59920. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59921. */
  59922. getTypeID(): number;
  59923. /**
  59924. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59925. * Returns the DirectionalLight Shadow projection matrix.
  59926. */
  59927. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59928. /**
  59929. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59930. * Returns the DirectionalLight Shadow projection matrix.
  59931. */
  59932. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59933. /**
  59934. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59935. * Returns the DirectionalLight Shadow projection matrix.
  59936. */
  59937. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59938. protected _buildUniformLayout(): void;
  59939. /**
  59940. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59941. * @param effect The effect to update
  59942. * @param lightIndex The index of the light in the effect to update
  59943. * @returns The directional light
  59944. */
  59945. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59946. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59947. /**
  59948. * Gets the minZ used for shadow according to both the scene and the light.
  59949. *
  59950. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59951. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59952. * @param activeCamera The camera we are returning the min for
  59953. * @returns the depth min z
  59954. */
  59955. getDepthMinZ(activeCamera: Camera): number;
  59956. /**
  59957. * Gets the maxZ used for shadow according to both the scene and the light.
  59958. *
  59959. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59960. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59961. * @param activeCamera The camera we are returning the max for
  59962. * @returns the depth max z
  59963. */
  59964. getDepthMaxZ(activeCamera: Camera): number;
  59965. /**
  59966. * Prepares the list of defines specific to the light type.
  59967. * @param defines the list of defines
  59968. * @param lightIndex defines the index of the light for the effect
  59969. */
  59970. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59971. }
  59972. }
  59973. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59974. import { Mesh } from "babylonjs/Meshes/mesh";
  59975. /**
  59976. * Class containing static functions to help procedurally build meshes
  59977. */
  59978. export class HemisphereBuilder {
  59979. /**
  59980. * Creates a hemisphere mesh
  59981. * @param name defines the name of the mesh
  59982. * @param options defines the options used to create the mesh
  59983. * @param scene defines the hosting scene
  59984. * @returns the hemisphere mesh
  59985. */
  59986. static CreateHemisphere(name: string, options: {
  59987. segments?: number;
  59988. diameter?: number;
  59989. sideOrientation?: number;
  59990. }, scene: any): Mesh;
  59991. }
  59992. }
  59993. declare module "babylonjs/Lights/spotLight" {
  59994. import { Nullable } from "babylonjs/types";
  59995. import { Scene } from "babylonjs/scene";
  59996. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59998. import { Effect } from "babylonjs/Materials/effect";
  59999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60000. import { Light } from "babylonjs/Lights/light";
  60001. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60002. /**
  60003. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60004. * These values define a cone of light starting from the position, emitting toward the direction.
  60005. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60006. * and the exponent defines the speed of the decay of the light with distance (reach).
  60007. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60008. */
  60009. export class SpotLight extends ShadowLight {
  60010. private _angle;
  60011. private _innerAngle;
  60012. private _cosHalfAngle;
  60013. private _lightAngleScale;
  60014. private _lightAngleOffset;
  60015. /**
  60016. * Gets the cone angle of the spot light in Radians.
  60017. */
  60018. get angle(): number;
  60019. /**
  60020. * Sets the cone angle of the spot light in Radians.
  60021. */
  60022. set angle(value: number);
  60023. /**
  60024. * Only used in gltf falloff mode, this defines the angle where
  60025. * the directional falloff will start before cutting at angle which could be seen
  60026. * as outer angle.
  60027. */
  60028. get innerAngle(): number;
  60029. /**
  60030. * Only used in gltf falloff mode, this defines the angle where
  60031. * the directional falloff will start before cutting at angle which could be seen
  60032. * as outer angle.
  60033. */
  60034. set innerAngle(value: number);
  60035. private _shadowAngleScale;
  60036. /**
  60037. * Allows scaling the angle of the light for shadow generation only.
  60038. */
  60039. get shadowAngleScale(): number;
  60040. /**
  60041. * Allows scaling the angle of the light for shadow generation only.
  60042. */
  60043. set shadowAngleScale(value: number);
  60044. /**
  60045. * The light decay speed with the distance from the emission spot.
  60046. */
  60047. exponent: number;
  60048. private _projectionTextureMatrix;
  60049. /**
  60050. * Allows reading the projecton texture
  60051. */
  60052. get projectionTextureMatrix(): Matrix;
  60053. protected _projectionTextureLightNear: number;
  60054. /**
  60055. * Gets the near clip of the Spotlight for texture projection.
  60056. */
  60057. get projectionTextureLightNear(): number;
  60058. /**
  60059. * Sets the near clip of the Spotlight for texture projection.
  60060. */
  60061. set projectionTextureLightNear(value: number);
  60062. protected _projectionTextureLightFar: number;
  60063. /**
  60064. * Gets the far clip of the Spotlight for texture projection.
  60065. */
  60066. get projectionTextureLightFar(): number;
  60067. /**
  60068. * Sets the far clip of the Spotlight for texture projection.
  60069. */
  60070. set projectionTextureLightFar(value: number);
  60071. protected _projectionTextureUpDirection: Vector3;
  60072. /**
  60073. * Gets the Up vector of the Spotlight for texture projection.
  60074. */
  60075. get projectionTextureUpDirection(): Vector3;
  60076. /**
  60077. * Sets the Up vector of the Spotlight for texture projection.
  60078. */
  60079. set projectionTextureUpDirection(value: Vector3);
  60080. private _projectionTexture;
  60081. /**
  60082. * Gets the projection texture of the light.
  60083. */
  60084. get projectionTexture(): Nullable<BaseTexture>;
  60085. /**
  60086. * Sets the projection texture of the light.
  60087. */
  60088. set projectionTexture(value: Nullable<BaseTexture>);
  60089. private static _IsProceduralTexture;
  60090. private static _IsTexture;
  60091. private _projectionTextureViewLightDirty;
  60092. private _projectionTextureProjectionLightDirty;
  60093. private _projectionTextureDirty;
  60094. private _projectionTextureViewTargetVector;
  60095. private _projectionTextureViewLightMatrix;
  60096. private _projectionTextureProjectionLightMatrix;
  60097. private _projectionTextureScalingMatrix;
  60098. /**
  60099. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60100. * It can cast shadows.
  60101. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60102. * @param name The light friendly name
  60103. * @param position The position of the spot light in the scene
  60104. * @param direction The direction of the light in the scene
  60105. * @param angle The cone angle of the light in Radians
  60106. * @param exponent The light decay speed with the distance from the emission spot
  60107. * @param scene The scene the lights belongs to
  60108. */
  60109. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60110. /**
  60111. * Returns the string "SpotLight".
  60112. * @returns the class name
  60113. */
  60114. getClassName(): string;
  60115. /**
  60116. * Returns the integer 2.
  60117. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60118. */
  60119. getTypeID(): number;
  60120. /**
  60121. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60122. */
  60123. protected _setDirection(value: Vector3): void;
  60124. /**
  60125. * Overrides the position setter to recompute the projection texture view light Matrix.
  60126. */
  60127. protected _setPosition(value: Vector3): void;
  60128. /**
  60129. * 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.
  60130. * Returns the SpotLight.
  60131. */
  60132. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60133. protected _computeProjectionTextureViewLightMatrix(): void;
  60134. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60135. /**
  60136. * Main function for light texture projection matrix computing.
  60137. */
  60138. protected _computeProjectionTextureMatrix(): void;
  60139. protected _buildUniformLayout(): void;
  60140. private _computeAngleValues;
  60141. /**
  60142. * Sets the passed Effect "effect" with the Light textures.
  60143. * @param effect The effect to update
  60144. * @param lightIndex The index of the light in the effect to update
  60145. * @returns The light
  60146. */
  60147. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60148. /**
  60149. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60150. * @param effect The effect to update
  60151. * @param lightIndex The index of the light in the effect to update
  60152. * @returns The spot light
  60153. */
  60154. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60155. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60156. /**
  60157. * Disposes the light and the associated resources.
  60158. */
  60159. dispose(): void;
  60160. /**
  60161. * Prepares the list of defines specific to the light type.
  60162. * @param defines the list of defines
  60163. * @param lightIndex defines the index of the light for the effect
  60164. */
  60165. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60166. }
  60167. }
  60168. declare module "babylonjs/Gizmos/lightGizmo" {
  60169. import { Nullable } from "babylonjs/types";
  60170. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60171. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60172. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60173. import { Light } from "babylonjs/Lights/light";
  60174. import { Observable } from "babylonjs/Misc/observable";
  60175. /**
  60176. * Gizmo that enables viewing a light
  60177. */
  60178. export class LightGizmo extends Gizmo {
  60179. private _lightMesh;
  60180. private _material;
  60181. private _cachedPosition;
  60182. private _cachedForward;
  60183. private _attachedMeshParent;
  60184. private _pointerObserver;
  60185. /**
  60186. * Event that fires each time the gizmo is clicked
  60187. */
  60188. onClickedObservable: Observable<Light>;
  60189. /**
  60190. * Creates a LightGizmo
  60191. * @param gizmoLayer The utility layer the gizmo will be added to
  60192. */
  60193. constructor(gizmoLayer?: UtilityLayerRenderer);
  60194. private _light;
  60195. /**
  60196. * The light that the gizmo is attached to
  60197. */
  60198. set light(light: Nullable<Light>);
  60199. get light(): Nullable<Light>;
  60200. /**
  60201. * Gets the material used to render the light gizmo
  60202. */
  60203. get material(): StandardMaterial;
  60204. /**
  60205. * @hidden
  60206. * Updates the gizmo to match the attached mesh's position/rotation
  60207. */
  60208. protected _update(): void;
  60209. private static _Scale;
  60210. /**
  60211. * Creates the lines for a light mesh
  60212. */
  60213. private static _CreateLightLines;
  60214. /**
  60215. * Disposes of the light gizmo
  60216. */
  60217. dispose(): void;
  60218. private static _CreateHemisphericLightMesh;
  60219. private static _CreatePointLightMesh;
  60220. private static _CreateSpotLightMesh;
  60221. private static _CreateDirectionalLightMesh;
  60222. }
  60223. }
  60224. declare module "babylonjs/Gizmos/cameraGizmo" {
  60225. import { Nullable } from "babylonjs/types";
  60226. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60227. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60228. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60229. import { Camera } from "babylonjs/Cameras/camera";
  60230. import { Observable } from "babylonjs/Misc/observable";
  60231. /**
  60232. * Gizmo that enables viewing a camera
  60233. */
  60234. export class CameraGizmo extends Gizmo {
  60235. private _cameraMesh;
  60236. private _cameraLinesMesh;
  60237. private _material;
  60238. private _pointerObserver;
  60239. /**
  60240. * Event that fires each time the gizmo is clicked
  60241. */
  60242. onClickedObservable: Observable<Camera>;
  60243. /**
  60244. * Creates a CameraGizmo
  60245. * @param gizmoLayer The utility layer the gizmo will be added to
  60246. */
  60247. constructor(gizmoLayer?: UtilityLayerRenderer);
  60248. private _camera;
  60249. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60250. get displayFrustum(): boolean;
  60251. set displayFrustum(value: boolean);
  60252. /**
  60253. * The camera that the gizmo is attached to
  60254. */
  60255. set camera(camera: Nullable<Camera>);
  60256. get camera(): Nullable<Camera>;
  60257. /**
  60258. * Gets the material used to render the camera gizmo
  60259. */
  60260. get material(): StandardMaterial;
  60261. /**
  60262. * @hidden
  60263. * Updates the gizmo to match the attached mesh's position/rotation
  60264. */
  60265. protected _update(): void;
  60266. private static _Scale;
  60267. private _invProjection;
  60268. /**
  60269. * Disposes of the camera gizmo
  60270. */
  60271. dispose(): void;
  60272. private static _CreateCameraMesh;
  60273. private static _CreateCameraFrustum;
  60274. }
  60275. }
  60276. declare module "babylonjs/Gizmos/index" {
  60277. export * from "babylonjs/Gizmos/axisDragGizmo";
  60278. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60279. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60280. export * from "babylonjs/Gizmos/gizmo";
  60281. export * from "babylonjs/Gizmos/gizmoManager";
  60282. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60283. export * from "babylonjs/Gizmos/positionGizmo";
  60284. export * from "babylonjs/Gizmos/rotationGizmo";
  60285. export * from "babylonjs/Gizmos/scaleGizmo";
  60286. export * from "babylonjs/Gizmos/lightGizmo";
  60287. export * from "babylonjs/Gizmos/cameraGizmo";
  60288. export * from "babylonjs/Gizmos/planeDragGizmo";
  60289. }
  60290. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60291. /** @hidden */
  60292. export var backgroundFragmentDeclaration: {
  60293. name: string;
  60294. shader: string;
  60295. };
  60296. }
  60297. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60298. /** @hidden */
  60299. export var backgroundUboDeclaration: {
  60300. name: string;
  60301. shader: string;
  60302. };
  60303. }
  60304. declare module "babylonjs/Shaders/background.fragment" {
  60305. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60306. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60307. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60308. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60309. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60310. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60311. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60312. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60313. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60314. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60315. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60316. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60318. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60319. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60320. /** @hidden */
  60321. export var backgroundPixelShader: {
  60322. name: string;
  60323. shader: string;
  60324. };
  60325. }
  60326. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60327. /** @hidden */
  60328. export var backgroundVertexDeclaration: {
  60329. name: string;
  60330. shader: string;
  60331. };
  60332. }
  60333. declare module "babylonjs/Shaders/background.vertex" {
  60334. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60335. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60336. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60337. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60339. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60340. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60341. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60342. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60343. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60344. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60345. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60346. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60347. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60348. /** @hidden */
  60349. export var backgroundVertexShader: {
  60350. name: string;
  60351. shader: string;
  60352. };
  60353. }
  60354. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60355. import { Nullable, int, float } from "babylonjs/types";
  60356. import { Scene } from "babylonjs/scene";
  60357. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60358. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60360. import { Mesh } from "babylonjs/Meshes/mesh";
  60361. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60362. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60363. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60365. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60366. import { Color3 } from "babylonjs/Maths/math.color";
  60367. import "babylonjs/Shaders/background.fragment";
  60368. import "babylonjs/Shaders/background.vertex";
  60369. /**
  60370. * Background material used to create an efficient environement around your scene.
  60371. */
  60372. export class BackgroundMaterial extends PushMaterial {
  60373. /**
  60374. * Standard reflectance value at parallel view angle.
  60375. */
  60376. static StandardReflectance0: number;
  60377. /**
  60378. * Standard reflectance value at grazing angle.
  60379. */
  60380. static StandardReflectance90: number;
  60381. protected _primaryColor: Color3;
  60382. /**
  60383. * Key light Color (multiply against the environement texture)
  60384. */
  60385. primaryColor: Color3;
  60386. protected __perceptualColor: Nullable<Color3>;
  60387. /**
  60388. * Experimental Internal Use Only.
  60389. *
  60390. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60391. * This acts as a helper to set the primary color to a more "human friendly" value.
  60392. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60393. * output color as close as possible from the chosen value.
  60394. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60395. * part of lighting setup.)
  60396. */
  60397. get _perceptualColor(): Nullable<Color3>;
  60398. set _perceptualColor(value: Nullable<Color3>);
  60399. protected _primaryColorShadowLevel: float;
  60400. /**
  60401. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60402. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60403. */
  60404. get primaryColorShadowLevel(): float;
  60405. set primaryColorShadowLevel(value: float);
  60406. protected _primaryColorHighlightLevel: float;
  60407. /**
  60408. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60409. * The primary color is used at the level chosen to define what the white area would look.
  60410. */
  60411. get primaryColorHighlightLevel(): float;
  60412. set primaryColorHighlightLevel(value: float);
  60413. protected _reflectionTexture: Nullable<BaseTexture>;
  60414. /**
  60415. * Reflection Texture used in the material.
  60416. * Should be author in a specific way for the best result (refer to the documentation).
  60417. */
  60418. reflectionTexture: Nullable<BaseTexture>;
  60419. protected _reflectionBlur: float;
  60420. /**
  60421. * Reflection Texture level of blur.
  60422. *
  60423. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60424. * texture twice.
  60425. */
  60426. reflectionBlur: float;
  60427. protected _diffuseTexture: Nullable<BaseTexture>;
  60428. /**
  60429. * Diffuse Texture used in the material.
  60430. * Should be author in a specific way for the best result (refer to the documentation).
  60431. */
  60432. diffuseTexture: Nullable<BaseTexture>;
  60433. protected _shadowLights: Nullable<IShadowLight[]>;
  60434. /**
  60435. * Specify the list of lights casting shadow on the material.
  60436. * All scene shadow lights will be included if null.
  60437. */
  60438. shadowLights: Nullable<IShadowLight[]>;
  60439. protected _shadowLevel: float;
  60440. /**
  60441. * Helps adjusting the shadow to a softer level if required.
  60442. * 0 means black shadows and 1 means no shadows.
  60443. */
  60444. shadowLevel: float;
  60445. protected _sceneCenter: Vector3;
  60446. /**
  60447. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60448. * It is usually zero but might be interesting to modify according to your setup.
  60449. */
  60450. sceneCenter: Vector3;
  60451. protected _opacityFresnel: boolean;
  60452. /**
  60453. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60454. * This helps ensuring a nice transition when the camera goes under the ground.
  60455. */
  60456. opacityFresnel: boolean;
  60457. protected _reflectionFresnel: boolean;
  60458. /**
  60459. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60460. * This helps adding a mirror texture on the ground.
  60461. */
  60462. reflectionFresnel: boolean;
  60463. protected _reflectionFalloffDistance: number;
  60464. /**
  60465. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60466. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60467. */
  60468. reflectionFalloffDistance: number;
  60469. protected _reflectionAmount: number;
  60470. /**
  60471. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60472. */
  60473. reflectionAmount: number;
  60474. protected _reflectionReflectance0: number;
  60475. /**
  60476. * This specifies the weight of the reflection at grazing angle.
  60477. */
  60478. reflectionReflectance0: number;
  60479. protected _reflectionReflectance90: number;
  60480. /**
  60481. * This specifies the weight of the reflection at a perpendicular point of view.
  60482. */
  60483. reflectionReflectance90: number;
  60484. /**
  60485. * Sets the reflection reflectance fresnel values according to the default standard
  60486. * empirically know to work well :-)
  60487. */
  60488. set reflectionStandardFresnelWeight(value: number);
  60489. protected _useRGBColor: boolean;
  60490. /**
  60491. * Helps to directly use the maps channels instead of their level.
  60492. */
  60493. useRGBColor: boolean;
  60494. protected _enableNoise: boolean;
  60495. /**
  60496. * This helps reducing the banding effect that could occur on the background.
  60497. */
  60498. enableNoise: boolean;
  60499. /**
  60500. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60501. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60502. * Recommended to be keep at 1.0 except for special cases.
  60503. */
  60504. get fovMultiplier(): number;
  60505. set fovMultiplier(value: number);
  60506. private _fovMultiplier;
  60507. /**
  60508. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60509. */
  60510. useEquirectangularFOV: boolean;
  60511. private _maxSimultaneousLights;
  60512. /**
  60513. * Number of Simultaneous lights allowed on the material.
  60514. */
  60515. maxSimultaneousLights: int;
  60516. private _shadowOnly;
  60517. /**
  60518. * Make the material only render shadows
  60519. */
  60520. shadowOnly: boolean;
  60521. /**
  60522. * Default configuration related to image processing available in the Background Material.
  60523. */
  60524. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60525. /**
  60526. * Keep track of the image processing observer to allow dispose and replace.
  60527. */
  60528. private _imageProcessingObserver;
  60529. /**
  60530. * Attaches a new image processing configuration to the PBR Material.
  60531. * @param configuration (if null the scene configuration will be use)
  60532. */
  60533. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60534. /**
  60535. * Gets the image processing configuration used either in this material.
  60536. */
  60537. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60538. /**
  60539. * Sets the Default image processing configuration used either in the this material.
  60540. *
  60541. * If sets to null, the scene one is in use.
  60542. */
  60543. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60544. /**
  60545. * Gets wether the color curves effect is enabled.
  60546. */
  60547. get cameraColorCurvesEnabled(): boolean;
  60548. /**
  60549. * Sets wether the color curves effect is enabled.
  60550. */
  60551. set cameraColorCurvesEnabled(value: boolean);
  60552. /**
  60553. * Gets wether the color grading effect is enabled.
  60554. */
  60555. get cameraColorGradingEnabled(): boolean;
  60556. /**
  60557. * Gets wether the color grading effect is enabled.
  60558. */
  60559. set cameraColorGradingEnabled(value: boolean);
  60560. /**
  60561. * Gets wether tonemapping is enabled or not.
  60562. */
  60563. get cameraToneMappingEnabled(): boolean;
  60564. /**
  60565. * Sets wether tonemapping is enabled or not
  60566. */
  60567. set cameraToneMappingEnabled(value: boolean);
  60568. /**
  60569. * The camera exposure used on this material.
  60570. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60571. * This corresponds to a photographic exposure.
  60572. */
  60573. get cameraExposure(): float;
  60574. /**
  60575. * The camera exposure used on this material.
  60576. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60577. * This corresponds to a photographic exposure.
  60578. */
  60579. set cameraExposure(value: float);
  60580. /**
  60581. * Gets The camera contrast used on this material.
  60582. */
  60583. get cameraContrast(): float;
  60584. /**
  60585. * Sets The camera contrast used on this material.
  60586. */
  60587. set cameraContrast(value: float);
  60588. /**
  60589. * Gets the Color Grading 2D Lookup Texture.
  60590. */
  60591. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60592. /**
  60593. * Sets the Color Grading 2D Lookup Texture.
  60594. */
  60595. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60596. /**
  60597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60599. * 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;
  60600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60601. */
  60602. get cameraColorCurves(): Nullable<ColorCurves>;
  60603. /**
  60604. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60605. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60606. * 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;
  60607. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60608. */
  60609. set cameraColorCurves(value: Nullable<ColorCurves>);
  60610. /**
  60611. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60612. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60613. */
  60614. switchToBGR: boolean;
  60615. private _renderTargets;
  60616. private _reflectionControls;
  60617. private _white;
  60618. private _primaryShadowColor;
  60619. private _primaryHighlightColor;
  60620. /**
  60621. * Instantiates a Background Material in the given scene
  60622. * @param name The friendly name of the material
  60623. * @param scene The scene to add the material to
  60624. */
  60625. constructor(name: string, scene: Scene);
  60626. /**
  60627. * Gets a boolean indicating that current material needs to register RTT
  60628. */
  60629. get hasRenderTargetTextures(): boolean;
  60630. /**
  60631. * The entire material has been created in order to prevent overdraw.
  60632. * @returns false
  60633. */
  60634. needAlphaTesting(): boolean;
  60635. /**
  60636. * The entire material has been created in order to prevent overdraw.
  60637. * @returns true if blending is enable
  60638. */
  60639. needAlphaBlending(): boolean;
  60640. /**
  60641. * Checks wether the material is ready to be rendered for a given mesh.
  60642. * @param mesh The mesh to render
  60643. * @param subMesh The submesh to check against
  60644. * @param useInstances Specify wether or not the material is used with instances
  60645. * @returns true if all the dependencies are ready (Textures, Effects...)
  60646. */
  60647. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60648. /**
  60649. * Compute the primary color according to the chosen perceptual color.
  60650. */
  60651. private _computePrimaryColorFromPerceptualColor;
  60652. /**
  60653. * Compute the highlights and shadow colors according to their chosen levels.
  60654. */
  60655. private _computePrimaryColors;
  60656. /**
  60657. * Build the uniform buffer used in the material.
  60658. */
  60659. buildUniformLayout(): void;
  60660. /**
  60661. * Unbind the material.
  60662. */
  60663. unbind(): void;
  60664. /**
  60665. * Bind only the world matrix to the material.
  60666. * @param world The world matrix to bind.
  60667. */
  60668. bindOnlyWorldMatrix(world: Matrix): void;
  60669. /**
  60670. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60671. * @param world The world matrix to bind.
  60672. * @param subMesh The submesh to bind for.
  60673. */
  60674. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60675. /**
  60676. * Checks to see if a texture is used in the material.
  60677. * @param texture - Base texture to use.
  60678. * @returns - Boolean specifying if a texture is used in the material.
  60679. */
  60680. hasTexture(texture: BaseTexture): boolean;
  60681. /**
  60682. * Dispose the material.
  60683. * @param forceDisposeEffect Force disposal of the associated effect.
  60684. * @param forceDisposeTextures Force disposal of the associated textures.
  60685. */
  60686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60687. /**
  60688. * Clones the material.
  60689. * @param name The cloned name.
  60690. * @returns The cloned material.
  60691. */
  60692. clone(name: string): BackgroundMaterial;
  60693. /**
  60694. * Serializes the current material to its JSON representation.
  60695. * @returns The JSON representation.
  60696. */
  60697. serialize(): any;
  60698. /**
  60699. * Gets the class name of the material
  60700. * @returns "BackgroundMaterial"
  60701. */
  60702. getClassName(): string;
  60703. /**
  60704. * Parse a JSON input to create back a background material.
  60705. * @param source The JSON data to parse
  60706. * @param scene The scene to create the parsed material in
  60707. * @param rootUrl The root url of the assets the material depends upon
  60708. * @returns the instantiated BackgroundMaterial.
  60709. */
  60710. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60711. }
  60712. }
  60713. declare module "babylonjs/Helpers/environmentHelper" {
  60714. import { Observable } from "babylonjs/Misc/observable";
  60715. import { Nullable } from "babylonjs/types";
  60716. import { Scene } from "babylonjs/scene";
  60717. import { Vector3 } from "babylonjs/Maths/math.vector";
  60718. import { Color3 } from "babylonjs/Maths/math.color";
  60719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60720. import { Mesh } from "babylonjs/Meshes/mesh";
  60721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60722. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60723. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60724. import "babylonjs/Meshes/Builders/planeBuilder";
  60725. import "babylonjs/Meshes/Builders/boxBuilder";
  60726. /**
  60727. * Represents the different options available during the creation of
  60728. * a Environment helper.
  60729. *
  60730. * This can control the default ground, skybox and image processing setup of your scene.
  60731. */
  60732. export interface IEnvironmentHelperOptions {
  60733. /**
  60734. * Specifies whether or not to create a ground.
  60735. * True by default.
  60736. */
  60737. createGround: boolean;
  60738. /**
  60739. * Specifies the ground size.
  60740. * 15 by default.
  60741. */
  60742. groundSize: number;
  60743. /**
  60744. * The texture used on the ground for the main color.
  60745. * Comes from the BabylonJS CDN by default.
  60746. *
  60747. * Remarks: Can be either a texture or a url.
  60748. */
  60749. groundTexture: string | BaseTexture;
  60750. /**
  60751. * The color mixed in the ground texture by default.
  60752. * BabylonJS clearColor by default.
  60753. */
  60754. groundColor: Color3;
  60755. /**
  60756. * Specifies the ground opacity.
  60757. * 1 by default.
  60758. */
  60759. groundOpacity: number;
  60760. /**
  60761. * Enables the ground to receive shadows.
  60762. * True by default.
  60763. */
  60764. enableGroundShadow: boolean;
  60765. /**
  60766. * Helps preventing the shadow to be fully black on the ground.
  60767. * 0.5 by default.
  60768. */
  60769. groundShadowLevel: number;
  60770. /**
  60771. * Creates a mirror texture attach to the ground.
  60772. * false by default.
  60773. */
  60774. enableGroundMirror: boolean;
  60775. /**
  60776. * Specifies the ground mirror size ratio.
  60777. * 0.3 by default as the default kernel is 64.
  60778. */
  60779. groundMirrorSizeRatio: number;
  60780. /**
  60781. * Specifies the ground mirror blur kernel size.
  60782. * 64 by default.
  60783. */
  60784. groundMirrorBlurKernel: number;
  60785. /**
  60786. * Specifies the ground mirror visibility amount.
  60787. * 1 by default
  60788. */
  60789. groundMirrorAmount: number;
  60790. /**
  60791. * Specifies the ground mirror reflectance weight.
  60792. * This uses the standard weight of the background material to setup the fresnel effect
  60793. * of the mirror.
  60794. * 1 by default.
  60795. */
  60796. groundMirrorFresnelWeight: number;
  60797. /**
  60798. * Specifies the ground mirror Falloff distance.
  60799. * This can helps reducing the size of the reflection.
  60800. * 0 by Default.
  60801. */
  60802. groundMirrorFallOffDistance: number;
  60803. /**
  60804. * Specifies the ground mirror texture type.
  60805. * Unsigned Int by Default.
  60806. */
  60807. groundMirrorTextureType: number;
  60808. /**
  60809. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60810. * the shown objects.
  60811. */
  60812. groundYBias: number;
  60813. /**
  60814. * Specifies whether or not to create a skybox.
  60815. * True by default.
  60816. */
  60817. createSkybox: boolean;
  60818. /**
  60819. * Specifies the skybox size.
  60820. * 20 by default.
  60821. */
  60822. skyboxSize: number;
  60823. /**
  60824. * The texture used on the skybox for the main color.
  60825. * Comes from the BabylonJS CDN by default.
  60826. *
  60827. * Remarks: Can be either a texture or a url.
  60828. */
  60829. skyboxTexture: string | BaseTexture;
  60830. /**
  60831. * The color mixed in the skybox texture by default.
  60832. * BabylonJS clearColor by default.
  60833. */
  60834. skyboxColor: Color3;
  60835. /**
  60836. * The background rotation around the Y axis of the scene.
  60837. * This helps aligning the key lights of your scene with the background.
  60838. * 0 by default.
  60839. */
  60840. backgroundYRotation: number;
  60841. /**
  60842. * Compute automatically the size of the elements to best fit with the scene.
  60843. */
  60844. sizeAuto: boolean;
  60845. /**
  60846. * Default position of the rootMesh if autoSize is not true.
  60847. */
  60848. rootPosition: Vector3;
  60849. /**
  60850. * Sets up the image processing in the scene.
  60851. * true by default.
  60852. */
  60853. setupImageProcessing: boolean;
  60854. /**
  60855. * The texture used as your environment texture in the scene.
  60856. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60857. *
  60858. * Remarks: Can be either a texture or a url.
  60859. */
  60860. environmentTexture: string | BaseTexture;
  60861. /**
  60862. * The value of the exposure to apply to the scene.
  60863. * 0.6 by default if setupImageProcessing is true.
  60864. */
  60865. cameraExposure: number;
  60866. /**
  60867. * The value of the contrast to apply to the scene.
  60868. * 1.6 by default if setupImageProcessing is true.
  60869. */
  60870. cameraContrast: number;
  60871. /**
  60872. * Specifies whether or not tonemapping should be enabled in the scene.
  60873. * true by default if setupImageProcessing is true.
  60874. */
  60875. toneMappingEnabled: boolean;
  60876. }
  60877. /**
  60878. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60879. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60880. * It also helps with the default setup of your imageProcessing configuration.
  60881. */
  60882. export class EnvironmentHelper {
  60883. /**
  60884. * Default ground texture URL.
  60885. */
  60886. private static _groundTextureCDNUrl;
  60887. /**
  60888. * Default skybox texture URL.
  60889. */
  60890. private static _skyboxTextureCDNUrl;
  60891. /**
  60892. * Default environment texture URL.
  60893. */
  60894. private static _environmentTextureCDNUrl;
  60895. /**
  60896. * Creates the default options for the helper.
  60897. */
  60898. private static _getDefaultOptions;
  60899. private _rootMesh;
  60900. /**
  60901. * Gets the root mesh created by the helper.
  60902. */
  60903. get rootMesh(): Mesh;
  60904. private _skybox;
  60905. /**
  60906. * Gets the skybox created by the helper.
  60907. */
  60908. get skybox(): Nullable<Mesh>;
  60909. private _skyboxTexture;
  60910. /**
  60911. * Gets the skybox texture created by the helper.
  60912. */
  60913. get skyboxTexture(): Nullable<BaseTexture>;
  60914. private _skyboxMaterial;
  60915. /**
  60916. * Gets the skybox material created by the helper.
  60917. */
  60918. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60919. private _ground;
  60920. /**
  60921. * Gets the ground mesh created by the helper.
  60922. */
  60923. get ground(): Nullable<Mesh>;
  60924. private _groundTexture;
  60925. /**
  60926. * Gets the ground texture created by the helper.
  60927. */
  60928. get groundTexture(): Nullable<BaseTexture>;
  60929. private _groundMirror;
  60930. /**
  60931. * Gets the ground mirror created by the helper.
  60932. */
  60933. get groundMirror(): Nullable<MirrorTexture>;
  60934. /**
  60935. * Gets the ground mirror render list to helps pushing the meshes
  60936. * you wish in the ground reflection.
  60937. */
  60938. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60939. private _groundMaterial;
  60940. /**
  60941. * Gets the ground material created by the helper.
  60942. */
  60943. get groundMaterial(): Nullable<BackgroundMaterial>;
  60944. /**
  60945. * Stores the creation options.
  60946. */
  60947. private readonly _scene;
  60948. private _options;
  60949. /**
  60950. * This observable will be notified with any error during the creation of the environment,
  60951. * mainly texture creation errors.
  60952. */
  60953. onErrorObservable: Observable<{
  60954. message?: string;
  60955. exception?: any;
  60956. }>;
  60957. /**
  60958. * constructor
  60959. * @param options Defines the options we want to customize the helper
  60960. * @param scene The scene to add the material to
  60961. */
  60962. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60963. /**
  60964. * Updates the background according to the new options
  60965. * @param options
  60966. */
  60967. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60968. /**
  60969. * Sets the primary color of all the available elements.
  60970. * @param color the main color to affect to the ground and the background
  60971. */
  60972. setMainColor(color: Color3): void;
  60973. /**
  60974. * Setup the image processing according to the specified options.
  60975. */
  60976. private _setupImageProcessing;
  60977. /**
  60978. * Setup the environment texture according to the specified options.
  60979. */
  60980. private _setupEnvironmentTexture;
  60981. /**
  60982. * Setup the background according to the specified options.
  60983. */
  60984. private _setupBackground;
  60985. /**
  60986. * Get the scene sizes according to the setup.
  60987. */
  60988. private _getSceneSize;
  60989. /**
  60990. * Setup the ground according to the specified options.
  60991. */
  60992. private _setupGround;
  60993. /**
  60994. * Setup the ground material according to the specified options.
  60995. */
  60996. private _setupGroundMaterial;
  60997. /**
  60998. * Setup the ground diffuse texture according to the specified options.
  60999. */
  61000. private _setupGroundDiffuseTexture;
  61001. /**
  61002. * Setup the ground mirror texture according to the specified options.
  61003. */
  61004. private _setupGroundMirrorTexture;
  61005. /**
  61006. * Setup the ground to receive the mirror texture.
  61007. */
  61008. private _setupMirrorInGroundMaterial;
  61009. /**
  61010. * Setup the skybox according to the specified options.
  61011. */
  61012. private _setupSkybox;
  61013. /**
  61014. * Setup the skybox material according to the specified options.
  61015. */
  61016. private _setupSkyboxMaterial;
  61017. /**
  61018. * Setup the skybox reflection texture according to the specified options.
  61019. */
  61020. private _setupSkyboxReflectionTexture;
  61021. private _errorHandler;
  61022. /**
  61023. * Dispose all the elements created by the Helper.
  61024. */
  61025. dispose(): void;
  61026. }
  61027. }
  61028. declare module "babylonjs/Helpers/textureDome" {
  61029. import { Scene } from "babylonjs/scene";
  61030. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61031. import { Mesh } from "babylonjs/Meshes/mesh";
  61032. import { Texture } from "babylonjs/Materials/Textures/texture";
  61033. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61034. import "babylonjs/Meshes/Builders/sphereBuilder";
  61035. import { Nullable } from "babylonjs/types";
  61036. import { Observable } from "babylonjs/Misc/observable";
  61037. /**
  61038. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61039. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61040. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61041. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61042. */
  61043. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61044. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61045. /**
  61046. * Define the source as a Monoscopic panoramic 360/180.
  61047. */
  61048. static readonly MODE_MONOSCOPIC: number;
  61049. /**
  61050. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61051. */
  61052. static readonly MODE_TOPBOTTOM: number;
  61053. /**
  61054. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61055. */
  61056. static readonly MODE_SIDEBYSIDE: number;
  61057. private _halfDome;
  61058. private _crossEye;
  61059. protected _useDirectMapping: boolean;
  61060. /**
  61061. * The texture being displayed on the sphere
  61062. */
  61063. protected _texture: T;
  61064. /**
  61065. * Gets the texture being displayed on the sphere
  61066. */
  61067. get texture(): T;
  61068. /**
  61069. * Sets the texture being displayed on the sphere
  61070. */
  61071. set texture(newTexture: T);
  61072. /**
  61073. * The skybox material
  61074. */
  61075. protected _material: BackgroundMaterial;
  61076. /**
  61077. * The surface used for the dome
  61078. */
  61079. protected _mesh: Mesh;
  61080. /**
  61081. * Gets the mesh used for the dome.
  61082. */
  61083. get mesh(): Mesh;
  61084. /**
  61085. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61086. */
  61087. private _halfDomeMask;
  61088. /**
  61089. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61090. * Also see the options.resolution property.
  61091. */
  61092. get fovMultiplier(): number;
  61093. set fovMultiplier(value: number);
  61094. protected _textureMode: number;
  61095. /**
  61096. * Gets or set the current texture mode for the texture. It can be:
  61097. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61098. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61099. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61100. */
  61101. get textureMode(): number;
  61102. /**
  61103. * Sets the current texture mode for the texture. It can be:
  61104. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61105. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61106. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61107. */
  61108. set textureMode(value: number);
  61109. /**
  61110. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61111. */
  61112. get halfDome(): boolean;
  61113. /**
  61114. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61115. */
  61116. set halfDome(enabled: boolean);
  61117. /**
  61118. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61119. */
  61120. set crossEye(enabled: boolean);
  61121. /**
  61122. * Is it a cross-eye texture?
  61123. */
  61124. get crossEye(): boolean;
  61125. /**
  61126. * The background material of this dome.
  61127. */
  61128. get material(): BackgroundMaterial;
  61129. /**
  61130. * Oberserver used in Stereoscopic VR Mode.
  61131. */
  61132. private _onBeforeCameraRenderObserver;
  61133. /**
  61134. * Observable raised when an error occured while loading the 360 image
  61135. */
  61136. onLoadErrorObservable: Observable<string>;
  61137. /**
  61138. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61139. * @param name Element's name, child elements will append suffixes for their own names.
  61140. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61141. * @param options An object containing optional or exposed sub element properties
  61142. */
  61143. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61144. resolution?: number;
  61145. clickToPlay?: boolean;
  61146. autoPlay?: boolean;
  61147. loop?: boolean;
  61148. size?: number;
  61149. poster?: string;
  61150. faceForward?: boolean;
  61151. useDirectMapping?: boolean;
  61152. halfDomeMode?: boolean;
  61153. crossEyeMode?: boolean;
  61154. generateMipMaps?: boolean;
  61155. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61156. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61157. protected _changeTextureMode(value: number): void;
  61158. /**
  61159. * Releases resources associated with this node.
  61160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61162. */
  61163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61164. }
  61165. }
  61166. declare module "babylonjs/Helpers/photoDome" {
  61167. import { Scene } from "babylonjs/scene";
  61168. import { Texture } from "babylonjs/Materials/Textures/texture";
  61169. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61170. /**
  61171. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61172. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61173. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61174. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61175. */
  61176. export class PhotoDome extends TextureDome<Texture> {
  61177. /**
  61178. * Define the image as a Monoscopic panoramic 360 image.
  61179. */
  61180. static readonly MODE_MONOSCOPIC: number;
  61181. /**
  61182. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61183. */
  61184. static readonly MODE_TOPBOTTOM: number;
  61185. /**
  61186. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61187. */
  61188. static readonly MODE_SIDEBYSIDE: number;
  61189. /**
  61190. * Gets or sets the texture being displayed on the sphere
  61191. */
  61192. get photoTexture(): Texture;
  61193. /**
  61194. * sets the texture being displayed on the sphere
  61195. */
  61196. set photoTexture(value: Texture);
  61197. /**
  61198. * Gets the current video mode for the video. It can be:
  61199. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61200. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61201. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61202. */
  61203. get imageMode(): number;
  61204. /**
  61205. * Sets the current video mode for the video. It can be:
  61206. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61207. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61208. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61209. */
  61210. set imageMode(value: number);
  61211. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61212. }
  61213. }
  61214. declare module "babylonjs/Misc/dds" {
  61215. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61217. import { Nullable } from "babylonjs/types";
  61218. import { Scene } from "babylonjs/scene";
  61219. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61220. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61221. /**
  61222. * Direct draw surface info
  61223. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61224. */
  61225. export interface DDSInfo {
  61226. /**
  61227. * Width of the texture
  61228. */
  61229. width: number;
  61230. /**
  61231. * Width of the texture
  61232. */
  61233. height: number;
  61234. /**
  61235. * Number of Mipmaps for the texture
  61236. * @see https://en.wikipedia.org/wiki/Mipmap
  61237. */
  61238. mipmapCount: number;
  61239. /**
  61240. * If the textures format is a known fourCC format
  61241. * @see https://www.fourcc.org/
  61242. */
  61243. isFourCC: boolean;
  61244. /**
  61245. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61246. */
  61247. isRGB: boolean;
  61248. /**
  61249. * If the texture is a lumincance format
  61250. */
  61251. isLuminance: boolean;
  61252. /**
  61253. * If this is a cube texture
  61254. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61255. */
  61256. isCube: boolean;
  61257. /**
  61258. * If the texture is a compressed format eg. FOURCC_DXT1
  61259. */
  61260. isCompressed: boolean;
  61261. /**
  61262. * The dxgiFormat of the texture
  61263. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61264. */
  61265. dxgiFormat: number;
  61266. /**
  61267. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61268. */
  61269. textureType: number;
  61270. /**
  61271. * Sphericle polynomial created for the dds texture
  61272. */
  61273. sphericalPolynomial?: SphericalPolynomial;
  61274. }
  61275. /**
  61276. * Class used to provide DDS decompression tools
  61277. */
  61278. export class DDSTools {
  61279. /**
  61280. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61281. */
  61282. static StoreLODInAlphaChannel: boolean;
  61283. /**
  61284. * Gets DDS information from an array buffer
  61285. * @param data defines the array buffer view to read data from
  61286. * @returns the DDS information
  61287. */
  61288. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61289. private static _FloatView;
  61290. private static _Int32View;
  61291. private static _ToHalfFloat;
  61292. private static _FromHalfFloat;
  61293. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61294. private static _GetHalfFloatRGBAArrayBuffer;
  61295. private static _GetFloatRGBAArrayBuffer;
  61296. private static _GetFloatAsUIntRGBAArrayBuffer;
  61297. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61298. private static _GetRGBAArrayBuffer;
  61299. private static _ExtractLongWordOrder;
  61300. private static _GetRGBArrayBuffer;
  61301. private static _GetLuminanceArrayBuffer;
  61302. /**
  61303. * Uploads DDS Levels to a Babylon Texture
  61304. * @hidden
  61305. */
  61306. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61307. }
  61308. module "babylonjs/Engines/thinEngine" {
  61309. interface ThinEngine {
  61310. /**
  61311. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61312. * @param rootUrl defines the url where the file to load is located
  61313. * @param scene defines the current scene
  61314. * @param lodScale defines scale to apply to the mip map selection
  61315. * @param lodOffset defines offset to apply to the mip map selection
  61316. * @param onLoad defines an optional callback raised when the texture is loaded
  61317. * @param onError defines an optional callback raised if there is an issue to load the texture
  61318. * @param format defines the format of the data
  61319. * @param forcedExtension defines the extension to use to pick the right loader
  61320. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61321. * @returns the cube texture as an InternalTexture
  61322. */
  61323. 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;
  61324. }
  61325. }
  61326. }
  61327. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61328. import { Nullable } from "babylonjs/types";
  61329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61330. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61331. /**
  61332. * Implementation of the DDS Texture Loader.
  61333. * @hidden
  61334. */
  61335. export class _DDSTextureLoader implements IInternalTextureLoader {
  61336. /**
  61337. * Defines wether the loader supports cascade loading the different faces.
  61338. */
  61339. readonly supportCascades: boolean;
  61340. /**
  61341. * This returns if the loader support the current file information.
  61342. * @param extension defines the file extension of the file being loaded
  61343. * @returns true if the loader can load the specified file
  61344. */
  61345. canLoad(extension: string): boolean;
  61346. /**
  61347. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61348. * @param data contains the texture data
  61349. * @param texture defines the BabylonJS internal texture
  61350. * @param createPolynomials will be true if polynomials have been requested
  61351. * @param onLoad defines the callback to trigger once the texture is ready
  61352. * @param onError defines the callback to trigger in case of error
  61353. */
  61354. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61355. /**
  61356. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61357. * @param data contains the texture data
  61358. * @param texture defines the BabylonJS internal texture
  61359. * @param callback defines the method to call once ready to upload
  61360. */
  61361. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61362. }
  61363. }
  61364. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61365. import { Nullable } from "babylonjs/types";
  61366. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61367. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61368. /**
  61369. * Implementation of the ENV Texture Loader.
  61370. * @hidden
  61371. */
  61372. export class _ENVTextureLoader implements IInternalTextureLoader {
  61373. /**
  61374. * Defines wether the loader supports cascade loading the different faces.
  61375. */
  61376. readonly supportCascades: boolean;
  61377. /**
  61378. * This returns if the loader support the current file information.
  61379. * @param extension defines the file extension of the file being loaded
  61380. * @returns true if the loader can load the specified file
  61381. */
  61382. canLoad(extension: string): boolean;
  61383. /**
  61384. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61385. * @param data contains the texture data
  61386. * @param texture defines the BabylonJS internal texture
  61387. * @param createPolynomials will be true if polynomials have been requested
  61388. * @param onLoad defines the callback to trigger once the texture is ready
  61389. * @param onError defines the callback to trigger in case of error
  61390. */
  61391. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61392. /**
  61393. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61394. * @param data contains the texture data
  61395. * @param texture defines the BabylonJS internal texture
  61396. * @param callback defines the method to call once ready to upload
  61397. */
  61398. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61399. }
  61400. }
  61401. declare module "babylonjs/Misc/khronosTextureContainer" {
  61402. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61403. /**
  61404. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61405. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61406. */
  61407. export class KhronosTextureContainer {
  61408. /** contents of the KTX container file */
  61409. data: ArrayBufferView;
  61410. private static HEADER_LEN;
  61411. private static COMPRESSED_2D;
  61412. private static COMPRESSED_3D;
  61413. private static TEX_2D;
  61414. private static TEX_3D;
  61415. /**
  61416. * Gets the openGL type
  61417. */
  61418. glType: number;
  61419. /**
  61420. * Gets the openGL type size
  61421. */
  61422. glTypeSize: number;
  61423. /**
  61424. * Gets the openGL format
  61425. */
  61426. glFormat: number;
  61427. /**
  61428. * Gets the openGL internal format
  61429. */
  61430. glInternalFormat: number;
  61431. /**
  61432. * Gets the base internal format
  61433. */
  61434. glBaseInternalFormat: number;
  61435. /**
  61436. * Gets image width in pixel
  61437. */
  61438. pixelWidth: number;
  61439. /**
  61440. * Gets image height in pixel
  61441. */
  61442. pixelHeight: number;
  61443. /**
  61444. * Gets image depth in pixels
  61445. */
  61446. pixelDepth: number;
  61447. /**
  61448. * Gets the number of array elements
  61449. */
  61450. numberOfArrayElements: number;
  61451. /**
  61452. * Gets the number of faces
  61453. */
  61454. numberOfFaces: number;
  61455. /**
  61456. * Gets the number of mipmap levels
  61457. */
  61458. numberOfMipmapLevels: number;
  61459. /**
  61460. * Gets the bytes of key value data
  61461. */
  61462. bytesOfKeyValueData: number;
  61463. /**
  61464. * Gets the load type
  61465. */
  61466. loadType: number;
  61467. /**
  61468. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61469. */
  61470. isInvalid: boolean;
  61471. /**
  61472. * Creates a new KhronosTextureContainer
  61473. * @param data contents of the KTX container file
  61474. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61475. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61476. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61477. */
  61478. constructor(
  61479. /** contents of the KTX container file */
  61480. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61481. /**
  61482. * Uploads KTX content to a Babylon Texture.
  61483. * It is assumed that the texture has already been created & is currently bound
  61484. * @hidden
  61485. */
  61486. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61487. private _upload2DCompressedLevels;
  61488. /**
  61489. * Checks if the given data starts with a KTX file identifier.
  61490. * @param data the data to check
  61491. * @returns true if the data is a KTX file or false otherwise
  61492. */
  61493. static IsValid(data: ArrayBufferView): boolean;
  61494. }
  61495. }
  61496. declare module "babylonjs/Misc/workerPool" {
  61497. import { IDisposable } from "babylonjs/scene";
  61498. /**
  61499. * Helper class to push actions to a pool of workers.
  61500. */
  61501. export class WorkerPool implements IDisposable {
  61502. private _workerInfos;
  61503. private _pendingActions;
  61504. /**
  61505. * Constructor
  61506. * @param workers Array of workers to use for actions
  61507. */
  61508. constructor(workers: Array<Worker>);
  61509. /**
  61510. * Terminates all workers and clears any pending actions.
  61511. */
  61512. dispose(): void;
  61513. /**
  61514. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61515. * pended until a worker has completed its action.
  61516. * @param action The action to perform. Call onComplete when the action is complete.
  61517. */
  61518. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61519. private _execute;
  61520. }
  61521. }
  61522. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61524. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61525. /**
  61526. * Class for loading KTX2 files
  61527. */
  61528. export class KhronosTextureContainer2 {
  61529. private static _WorkerPoolPromise?;
  61530. private static _Initialized;
  61531. private static _Ktx2Decoder;
  61532. /**
  61533. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61534. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61535. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61536. * Urls you can change:
  61537. * URLConfig.jsDecoderModule
  61538. * URLConfig.wasmUASTCToASTC
  61539. * URLConfig.wasmUASTCToBC7
  61540. * URLConfig.wasmUASTCToRGBA_UNORM
  61541. * URLConfig.wasmUASTCToRGBA_SRGB
  61542. * URLConfig.jsMSCTranscoder
  61543. * URLConfig.wasmMSCTranscoder
  61544. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61545. */
  61546. static URLConfig: {
  61547. jsDecoderModule: string;
  61548. wasmUASTCToASTC: null;
  61549. wasmUASTCToBC7: null;
  61550. wasmUASTCToRGBA_UNORM: null;
  61551. wasmUASTCToRGBA_SRGB: null;
  61552. jsMSCTranscoder: null;
  61553. wasmMSCTranscoder: null;
  61554. };
  61555. /**
  61556. * Default number of workers used to handle data decoding
  61557. */
  61558. static DefaultNumWorkers: number;
  61559. private static GetDefaultNumWorkers;
  61560. private _engine;
  61561. private static _CreateWorkerPool;
  61562. /**
  61563. * Constructor
  61564. * @param engine The engine to use
  61565. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61566. */
  61567. constructor(engine: ThinEngine, numWorkers?: number);
  61568. /** @hidden */
  61569. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61570. /**
  61571. * Stop all async operations and release resources.
  61572. */
  61573. dispose(): void;
  61574. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  61575. /**
  61576. * Checks if the given data starts with a KTX2 file identifier.
  61577. * @param data the data to check
  61578. * @returns true if the data is a KTX2 file or false otherwise
  61579. */
  61580. static IsValid(data: ArrayBufferView): boolean;
  61581. }
  61582. }
  61583. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61584. import { Nullable } from "babylonjs/types";
  61585. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61586. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61587. /**
  61588. * Implementation of the KTX Texture Loader.
  61589. * @hidden
  61590. */
  61591. export class _KTXTextureLoader implements IInternalTextureLoader {
  61592. /**
  61593. * Defines wether the loader supports cascade loading the different faces.
  61594. */
  61595. readonly supportCascades: boolean;
  61596. /**
  61597. * This returns if the loader support the current file information.
  61598. * @param extension defines the file extension of the file being loaded
  61599. * @param mimeType defines the optional mime type of the file being loaded
  61600. * @returns true if the loader can load the specified file
  61601. */
  61602. canLoad(extension: string, mimeType?: string): boolean;
  61603. /**
  61604. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61605. * @param data contains the texture data
  61606. * @param texture defines the BabylonJS internal texture
  61607. * @param createPolynomials will be true if polynomials have been requested
  61608. * @param onLoad defines the callback to trigger once the texture is ready
  61609. * @param onError defines the callback to trigger in case of error
  61610. */
  61611. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61612. /**
  61613. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61614. * @param data contains the texture data
  61615. * @param texture defines the BabylonJS internal texture
  61616. * @param callback defines the method to call once ready to upload
  61617. */
  61618. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61619. }
  61620. }
  61621. declare module "babylonjs/Helpers/sceneHelpers" {
  61622. import { Nullable } from "babylonjs/types";
  61623. import { Mesh } from "babylonjs/Meshes/mesh";
  61624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61625. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61626. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61627. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61628. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61629. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61630. import "babylonjs/Meshes/Builders/boxBuilder";
  61631. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61632. /** @hidden */
  61633. export var _forceSceneHelpersToBundle: boolean;
  61634. module "babylonjs/scene" {
  61635. interface Scene {
  61636. /**
  61637. * Creates a default light for the scene.
  61638. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61639. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61640. */
  61641. createDefaultLight(replace?: boolean): void;
  61642. /**
  61643. * Creates a default camera for the scene.
  61644. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61645. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61646. * @param replace has default false, when true replaces the active camera in the scene
  61647. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61648. */
  61649. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61650. /**
  61651. * Creates a default camera and a default light.
  61652. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61653. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61654. * @param replace has the default false, when true replaces the active camera/light in the scene
  61655. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61656. */
  61657. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61658. /**
  61659. * Creates a new sky box
  61660. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61661. * @param environmentTexture defines the texture to use as environment texture
  61662. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61663. * @param scale defines the overall scale of the skybox
  61664. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61665. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61666. * @returns a new mesh holding the sky box
  61667. */
  61668. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61669. /**
  61670. * Creates a new environment
  61671. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61672. * @param options defines the options you can use to configure the environment
  61673. * @returns the new EnvironmentHelper
  61674. */
  61675. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61676. /**
  61677. * Creates a new VREXperienceHelper
  61678. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61679. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61680. * @returns a new VREXperienceHelper
  61681. */
  61682. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61683. /**
  61684. * Creates a new WebXRDefaultExperience
  61685. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61686. * @param options experience options
  61687. * @returns a promise for a new WebXRDefaultExperience
  61688. */
  61689. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61690. }
  61691. }
  61692. }
  61693. declare module "babylonjs/Helpers/videoDome" {
  61694. import { Scene } from "babylonjs/scene";
  61695. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61696. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61697. /**
  61698. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61699. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61700. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61701. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61702. */
  61703. export class VideoDome extends TextureDome<VideoTexture> {
  61704. /**
  61705. * Define the video source as a Monoscopic panoramic 360 video.
  61706. */
  61707. static readonly MODE_MONOSCOPIC: number;
  61708. /**
  61709. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61710. */
  61711. static readonly MODE_TOPBOTTOM: number;
  61712. /**
  61713. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61714. */
  61715. static readonly MODE_SIDEBYSIDE: number;
  61716. /**
  61717. * Get the video texture associated with this video dome
  61718. */
  61719. get videoTexture(): VideoTexture;
  61720. /**
  61721. * Get the video mode of this dome
  61722. */
  61723. get videoMode(): number;
  61724. /**
  61725. * Set the video mode of this dome.
  61726. * @see textureMode
  61727. */
  61728. set videoMode(value: number);
  61729. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61730. }
  61731. }
  61732. declare module "babylonjs/Helpers/index" {
  61733. export * from "babylonjs/Helpers/environmentHelper";
  61734. export * from "babylonjs/Helpers/photoDome";
  61735. export * from "babylonjs/Helpers/sceneHelpers";
  61736. export * from "babylonjs/Helpers/videoDome";
  61737. }
  61738. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61739. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61740. import { IDisposable } from "babylonjs/scene";
  61741. import { Engine } from "babylonjs/Engines/engine";
  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#engineinstrumentation
  61745. */
  61746. export class EngineInstrumentation implements IDisposable {
  61747. /**
  61748. * Define the instrumented engine.
  61749. */
  61750. engine: Engine;
  61751. private _captureGPUFrameTime;
  61752. private _gpuFrameTimeToken;
  61753. private _gpuFrameTime;
  61754. private _captureShaderCompilationTime;
  61755. private _shaderCompilationTime;
  61756. private _onBeginFrameObserver;
  61757. private _onEndFrameObserver;
  61758. private _onBeforeShaderCompilationObserver;
  61759. private _onAfterShaderCompilationObserver;
  61760. /**
  61761. * Gets the perf counter used for GPU frame time
  61762. */
  61763. get gpuFrameTimeCounter(): PerfCounter;
  61764. /**
  61765. * Gets the GPU frame time capture status
  61766. */
  61767. get captureGPUFrameTime(): boolean;
  61768. /**
  61769. * Enable or disable the GPU frame time capture
  61770. */
  61771. set captureGPUFrameTime(value: boolean);
  61772. /**
  61773. * Gets the perf counter used for shader compilation time
  61774. */
  61775. get shaderCompilationTimeCounter(): PerfCounter;
  61776. /**
  61777. * Gets the shader compilation time capture status
  61778. */
  61779. get captureShaderCompilationTime(): boolean;
  61780. /**
  61781. * Enable or disable the shader compilation time capture
  61782. */
  61783. set captureShaderCompilationTime(value: boolean);
  61784. /**
  61785. * Instantiates a new engine instrumentation.
  61786. * This class can be used to get instrumentation data from a Babylon engine
  61787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61788. * @param engine Defines the engine to instrument
  61789. */
  61790. constructor(
  61791. /**
  61792. * Define the instrumented engine.
  61793. */
  61794. engine: Engine);
  61795. /**
  61796. * Dispose and release associated resources.
  61797. */
  61798. dispose(): void;
  61799. }
  61800. }
  61801. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61802. import { Scene, IDisposable } from "babylonjs/scene";
  61803. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61804. /**
  61805. * This class can be used to get instrumentation data from a Babylon engine
  61806. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61807. */
  61808. export class SceneInstrumentation implements IDisposable {
  61809. /**
  61810. * Defines the scene to instrument
  61811. */
  61812. scene: Scene;
  61813. private _captureActiveMeshesEvaluationTime;
  61814. private _activeMeshesEvaluationTime;
  61815. private _captureRenderTargetsRenderTime;
  61816. private _renderTargetsRenderTime;
  61817. private _captureFrameTime;
  61818. private _frameTime;
  61819. private _captureRenderTime;
  61820. private _renderTime;
  61821. private _captureInterFrameTime;
  61822. private _interFrameTime;
  61823. private _captureParticlesRenderTime;
  61824. private _particlesRenderTime;
  61825. private _captureSpritesRenderTime;
  61826. private _spritesRenderTime;
  61827. private _capturePhysicsTime;
  61828. private _physicsTime;
  61829. private _captureAnimationsTime;
  61830. private _animationsTime;
  61831. private _captureCameraRenderTime;
  61832. private _cameraRenderTime;
  61833. private _onBeforeActiveMeshesEvaluationObserver;
  61834. private _onAfterActiveMeshesEvaluationObserver;
  61835. private _onBeforeRenderTargetsRenderObserver;
  61836. private _onAfterRenderTargetsRenderObserver;
  61837. private _onAfterRenderObserver;
  61838. private _onBeforeDrawPhaseObserver;
  61839. private _onAfterDrawPhaseObserver;
  61840. private _onBeforeAnimationsObserver;
  61841. private _onBeforeParticlesRenderingObserver;
  61842. private _onAfterParticlesRenderingObserver;
  61843. private _onBeforeSpritesRenderingObserver;
  61844. private _onAfterSpritesRenderingObserver;
  61845. private _onBeforePhysicsObserver;
  61846. private _onAfterPhysicsObserver;
  61847. private _onAfterAnimationsObserver;
  61848. private _onBeforeCameraRenderObserver;
  61849. private _onAfterCameraRenderObserver;
  61850. /**
  61851. * Gets the perf counter used for active meshes evaluation time
  61852. */
  61853. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61854. /**
  61855. * Gets the active meshes evaluation time capture status
  61856. */
  61857. get captureActiveMeshesEvaluationTime(): boolean;
  61858. /**
  61859. * Enable or disable the active meshes evaluation time capture
  61860. */
  61861. set captureActiveMeshesEvaluationTime(value: boolean);
  61862. /**
  61863. * Gets the perf counter used for render targets render time
  61864. */
  61865. get renderTargetsRenderTimeCounter(): PerfCounter;
  61866. /**
  61867. * Gets the render targets render time capture status
  61868. */
  61869. get captureRenderTargetsRenderTime(): boolean;
  61870. /**
  61871. * Enable or disable the render targets render time capture
  61872. */
  61873. set captureRenderTargetsRenderTime(value: boolean);
  61874. /**
  61875. * Gets the perf counter used for particles render time
  61876. */
  61877. get particlesRenderTimeCounter(): PerfCounter;
  61878. /**
  61879. * Gets the particles render time capture status
  61880. */
  61881. get captureParticlesRenderTime(): boolean;
  61882. /**
  61883. * Enable or disable the particles render time capture
  61884. */
  61885. set captureParticlesRenderTime(value: boolean);
  61886. /**
  61887. * Gets the perf counter used for sprites render time
  61888. */
  61889. get spritesRenderTimeCounter(): PerfCounter;
  61890. /**
  61891. * Gets the sprites render time capture status
  61892. */
  61893. get captureSpritesRenderTime(): boolean;
  61894. /**
  61895. * Enable or disable the sprites render time capture
  61896. */
  61897. set captureSpritesRenderTime(value: boolean);
  61898. /**
  61899. * Gets the perf counter used for physics time
  61900. */
  61901. get physicsTimeCounter(): PerfCounter;
  61902. /**
  61903. * Gets the physics time capture status
  61904. */
  61905. get capturePhysicsTime(): boolean;
  61906. /**
  61907. * Enable or disable the physics time capture
  61908. */
  61909. set capturePhysicsTime(value: boolean);
  61910. /**
  61911. * Gets the perf counter used for animations time
  61912. */
  61913. get animationsTimeCounter(): PerfCounter;
  61914. /**
  61915. * Gets the animations time capture status
  61916. */
  61917. get captureAnimationsTime(): boolean;
  61918. /**
  61919. * Enable or disable the animations time capture
  61920. */
  61921. set captureAnimationsTime(value: boolean);
  61922. /**
  61923. * Gets the perf counter used for frame time capture
  61924. */
  61925. get frameTimeCounter(): PerfCounter;
  61926. /**
  61927. * Gets the frame time capture status
  61928. */
  61929. get captureFrameTime(): boolean;
  61930. /**
  61931. * Enable or disable the frame time capture
  61932. */
  61933. set captureFrameTime(value: boolean);
  61934. /**
  61935. * Gets the perf counter used for inter-frames time capture
  61936. */
  61937. get interFrameTimeCounter(): PerfCounter;
  61938. /**
  61939. * Gets the inter-frames time capture status
  61940. */
  61941. get captureInterFrameTime(): boolean;
  61942. /**
  61943. * Enable or disable the inter-frames time capture
  61944. */
  61945. set captureInterFrameTime(value: boolean);
  61946. /**
  61947. * Gets the perf counter used for render time capture
  61948. */
  61949. get renderTimeCounter(): PerfCounter;
  61950. /**
  61951. * Gets the render time capture status
  61952. */
  61953. get captureRenderTime(): boolean;
  61954. /**
  61955. * Enable or disable the render time capture
  61956. */
  61957. set captureRenderTime(value: boolean);
  61958. /**
  61959. * Gets the perf counter used for camera render time capture
  61960. */
  61961. get cameraRenderTimeCounter(): PerfCounter;
  61962. /**
  61963. * Gets the camera render time capture status
  61964. */
  61965. get captureCameraRenderTime(): boolean;
  61966. /**
  61967. * Enable or disable the camera render time capture
  61968. */
  61969. set captureCameraRenderTime(value: boolean);
  61970. /**
  61971. * Gets the perf counter used for draw calls
  61972. */
  61973. get drawCallsCounter(): PerfCounter;
  61974. /**
  61975. * Instantiates a new scene instrumentation.
  61976. * This class can be used to get instrumentation data from a Babylon engine
  61977. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61978. * @param scene Defines the scene to instrument
  61979. */
  61980. constructor(
  61981. /**
  61982. * Defines the scene to instrument
  61983. */
  61984. scene: Scene);
  61985. /**
  61986. * Dispose and release associated resources.
  61987. */
  61988. dispose(): void;
  61989. }
  61990. }
  61991. declare module "babylonjs/Instrumentation/index" {
  61992. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61993. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61994. export * from "babylonjs/Instrumentation/timeToken";
  61995. }
  61996. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61997. /** @hidden */
  61998. export var glowMapGenerationPixelShader: {
  61999. name: string;
  62000. shader: string;
  62001. };
  62002. }
  62003. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62004. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62005. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62006. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62007. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62009. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62010. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62011. /** @hidden */
  62012. export var glowMapGenerationVertexShader: {
  62013. name: string;
  62014. shader: string;
  62015. };
  62016. }
  62017. declare module "babylonjs/Layers/effectLayer" {
  62018. import { Observable } from "babylonjs/Misc/observable";
  62019. import { Nullable } from "babylonjs/types";
  62020. import { Camera } from "babylonjs/Cameras/camera";
  62021. import { Scene } from "babylonjs/scene";
  62022. import { ISize } from "babylonjs/Maths/math.size";
  62023. import { Color4 } from "babylonjs/Maths/math.color";
  62024. import { Engine } from "babylonjs/Engines/engine";
  62025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62027. import { Mesh } from "babylonjs/Meshes/mesh";
  62028. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62029. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62030. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62031. import { Effect } from "babylonjs/Materials/effect";
  62032. import { Material } from "babylonjs/Materials/material";
  62033. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62034. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62035. /**
  62036. * Effect layer options. This helps customizing the behaviour
  62037. * of the effect layer.
  62038. */
  62039. export interface IEffectLayerOptions {
  62040. /**
  62041. * Multiplication factor apply to the canvas size to compute the render target size
  62042. * used to generated the objects (the smaller the faster).
  62043. */
  62044. mainTextureRatio: number;
  62045. /**
  62046. * Enforces a fixed size texture to ensure effect stability across devices.
  62047. */
  62048. mainTextureFixedSize?: number;
  62049. /**
  62050. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62051. */
  62052. alphaBlendingMode: number;
  62053. /**
  62054. * The camera attached to the layer.
  62055. */
  62056. camera: Nullable<Camera>;
  62057. /**
  62058. * The rendering group to draw the layer in.
  62059. */
  62060. renderingGroupId: number;
  62061. }
  62062. /**
  62063. * The effect layer Helps adding post process effect blended with the main pass.
  62064. *
  62065. * This can be for instance use to generate glow or higlight effects on the scene.
  62066. *
  62067. * The effect layer class can not be used directly and is intented to inherited from to be
  62068. * customized per effects.
  62069. */
  62070. export abstract class EffectLayer {
  62071. private _vertexBuffers;
  62072. private _indexBuffer;
  62073. private _cachedDefines;
  62074. private _effectLayerMapGenerationEffect;
  62075. private _effectLayerOptions;
  62076. private _mergeEffect;
  62077. protected _scene: Scene;
  62078. protected _engine: Engine;
  62079. protected _maxSize: number;
  62080. protected _mainTextureDesiredSize: ISize;
  62081. protected _mainTexture: RenderTargetTexture;
  62082. protected _shouldRender: boolean;
  62083. protected _postProcesses: PostProcess[];
  62084. protected _textures: BaseTexture[];
  62085. protected _emissiveTextureAndColor: {
  62086. texture: Nullable<BaseTexture>;
  62087. color: Color4;
  62088. };
  62089. /**
  62090. * The name of the layer
  62091. */
  62092. name: string;
  62093. /**
  62094. * The clear color of the texture used to generate the glow map.
  62095. */
  62096. neutralColor: Color4;
  62097. /**
  62098. * Specifies whether the highlight layer is enabled or not.
  62099. */
  62100. isEnabled: boolean;
  62101. /**
  62102. * Gets the camera attached to the layer.
  62103. */
  62104. get camera(): Nullable<Camera>;
  62105. /**
  62106. * Gets the rendering group id the layer should render in.
  62107. */
  62108. get renderingGroupId(): number;
  62109. set renderingGroupId(renderingGroupId: number);
  62110. /**
  62111. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62112. */
  62113. disableBoundingBoxesFromEffectLayer: boolean;
  62114. /**
  62115. * An event triggered when the effect layer has been disposed.
  62116. */
  62117. onDisposeObservable: Observable<EffectLayer>;
  62118. /**
  62119. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62120. */
  62121. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62122. /**
  62123. * An event triggered when the generated texture is being merged in the scene.
  62124. */
  62125. onBeforeComposeObservable: Observable<EffectLayer>;
  62126. /**
  62127. * An event triggered when the mesh is rendered into the effect render target.
  62128. */
  62129. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62130. /**
  62131. * An event triggered after the mesh has been rendered into the effect render target.
  62132. */
  62133. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62134. /**
  62135. * An event triggered when the generated texture has been merged in the scene.
  62136. */
  62137. onAfterComposeObservable: Observable<EffectLayer>;
  62138. /**
  62139. * An event triggered when the efffect layer changes its size.
  62140. */
  62141. onSizeChangedObservable: Observable<EffectLayer>;
  62142. /** @hidden */
  62143. static _SceneComponentInitialization: (scene: Scene) => void;
  62144. /**
  62145. * Instantiates a new effect Layer and references it in the scene.
  62146. * @param name The name of the layer
  62147. * @param scene The scene to use the layer in
  62148. */
  62149. constructor(
  62150. /** The Friendly of the effect in the scene */
  62151. name: string, scene: Scene);
  62152. /**
  62153. * Get the effect name of the layer.
  62154. * @return The effect name
  62155. */
  62156. abstract getEffectName(): string;
  62157. /**
  62158. * Checks for the readiness of the element composing the layer.
  62159. * @param subMesh the mesh to check for
  62160. * @param useInstances specify whether or not to use instances to render the mesh
  62161. * @return true if ready otherwise, false
  62162. */
  62163. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62164. /**
  62165. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62166. * @returns true if the effect requires stencil during the main canvas render pass.
  62167. */
  62168. abstract needStencil(): boolean;
  62169. /**
  62170. * Create the merge effect. This is the shader use to blit the information back
  62171. * to the main canvas at the end of the scene rendering.
  62172. * @returns The effect containing the shader used to merge the effect on the main canvas
  62173. */
  62174. protected abstract _createMergeEffect(): Effect;
  62175. /**
  62176. * Creates the render target textures and post processes used in the effect layer.
  62177. */
  62178. protected abstract _createTextureAndPostProcesses(): void;
  62179. /**
  62180. * Implementation specific of rendering the generating effect on the main canvas.
  62181. * @param effect The effect used to render through
  62182. */
  62183. protected abstract _internalRender(effect: Effect): void;
  62184. /**
  62185. * Sets the required values for both the emissive texture and and the main color.
  62186. */
  62187. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62188. /**
  62189. * Free any resources and references associated to a mesh.
  62190. * Internal use
  62191. * @param mesh The mesh to free.
  62192. */
  62193. abstract _disposeMesh(mesh: Mesh): void;
  62194. /**
  62195. * Serializes this layer (Glow or Highlight for example)
  62196. * @returns a serialized layer object
  62197. */
  62198. abstract serialize?(): any;
  62199. /**
  62200. * Initializes the effect layer with the required options.
  62201. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62202. */
  62203. protected _init(options: Partial<IEffectLayerOptions>): void;
  62204. /**
  62205. * Generates the index buffer of the full screen quad blending to the main canvas.
  62206. */
  62207. private _generateIndexBuffer;
  62208. /**
  62209. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62210. */
  62211. private _generateVertexBuffer;
  62212. /**
  62213. * Sets the main texture desired size which is the closest power of two
  62214. * of the engine canvas size.
  62215. */
  62216. private _setMainTextureSize;
  62217. /**
  62218. * Creates the main texture for the effect layer.
  62219. */
  62220. protected _createMainTexture(): void;
  62221. /**
  62222. * Adds specific effects defines.
  62223. * @param defines The defines to add specifics to.
  62224. */
  62225. protected _addCustomEffectDefines(defines: string[]): void;
  62226. /**
  62227. * Checks for the readiness of the element composing the layer.
  62228. * @param subMesh the mesh to check for
  62229. * @param useInstances specify whether or not to use instances to render the mesh
  62230. * @param emissiveTexture the associated emissive texture used to generate the glow
  62231. * @return true if ready otherwise, false
  62232. */
  62233. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62234. /**
  62235. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62236. */
  62237. render(): void;
  62238. /**
  62239. * Determine if a given mesh will be used in the current effect.
  62240. * @param mesh mesh to test
  62241. * @returns true if the mesh will be used
  62242. */
  62243. hasMesh(mesh: AbstractMesh): boolean;
  62244. /**
  62245. * Returns true if the layer contains information to display, otherwise false.
  62246. * @returns true if the glow layer should be rendered
  62247. */
  62248. shouldRender(): boolean;
  62249. /**
  62250. * Returns true if the mesh should render, otherwise false.
  62251. * @param mesh The mesh to render
  62252. * @returns true if it should render otherwise false
  62253. */
  62254. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62255. /**
  62256. * Returns true if the mesh can be rendered, otherwise false.
  62257. * @param mesh The mesh to render
  62258. * @param material The material used on the mesh
  62259. * @returns true if it can be rendered otherwise false
  62260. */
  62261. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62262. /**
  62263. * Returns true if the mesh should render, otherwise false.
  62264. * @param mesh The mesh to render
  62265. * @returns true if it should render otherwise false
  62266. */
  62267. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62268. /**
  62269. * Renders the submesh passed in parameter to the generation map.
  62270. */
  62271. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62272. /**
  62273. * Defines whether the current material of the mesh should be use to render the effect.
  62274. * @param mesh defines the current mesh to render
  62275. */
  62276. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62277. /**
  62278. * Rebuild the required buffers.
  62279. * @hidden Internal use only.
  62280. */
  62281. _rebuild(): void;
  62282. /**
  62283. * Dispose only the render target textures and post process.
  62284. */
  62285. private _disposeTextureAndPostProcesses;
  62286. /**
  62287. * Dispose the highlight layer and free resources.
  62288. */
  62289. dispose(): void;
  62290. /**
  62291. * Gets the class name of the effect layer
  62292. * @returns the string with the class name of the effect layer
  62293. */
  62294. getClassName(): string;
  62295. /**
  62296. * Creates an effect layer from parsed effect layer data
  62297. * @param parsedEffectLayer defines effect layer data
  62298. * @param scene defines the current scene
  62299. * @param rootUrl defines the root URL containing the effect layer information
  62300. * @returns a parsed effect Layer
  62301. */
  62302. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62303. }
  62304. }
  62305. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62306. import { Scene } from "babylonjs/scene";
  62307. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62308. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62309. import { AbstractScene } from "babylonjs/abstractScene";
  62310. module "babylonjs/abstractScene" {
  62311. interface AbstractScene {
  62312. /**
  62313. * The list of effect layers (highlights/glow) added to the scene
  62314. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62315. * @see https://doc.babylonjs.com/how_to/glow_layer
  62316. */
  62317. effectLayers: Array<EffectLayer>;
  62318. /**
  62319. * Removes the given effect layer from this scene.
  62320. * @param toRemove defines the effect layer to remove
  62321. * @returns the index of the removed effect layer
  62322. */
  62323. removeEffectLayer(toRemove: EffectLayer): number;
  62324. /**
  62325. * Adds the given effect layer to this scene
  62326. * @param newEffectLayer defines the effect layer to add
  62327. */
  62328. addEffectLayer(newEffectLayer: EffectLayer): void;
  62329. }
  62330. }
  62331. /**
  62332. * Defines the layer scene component responsible to manage any effect layers
  62333. * in a given scene.
  62334. */
  62335. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62336. /**
  62337. * The component name helpfull to identify the component in the list of scene components.
  62338. */
  62339. readonly name: string;
  62340. /**
  62341. * The scene the component belongs to.
  62342. */
  62343. scene: Scene;
  62344. private _engine;
  62345. private _renderEffects;
  62346. private _needStencil;
  62347. private _previousStencilState;
  62348. /**
  62349. * Creates a new instance of the component for the given scene
  62350. * @param scene Defines the scene to register the component in
  62351. */
  62352. constructor(scene: Scene);
  62353. /**
  62354. * Registers the component in a given scene
  62355. */
  62356. register(): void;
  62357. /**
  62358. * Rebuilds the elements related to this component in case of
  62359. * context lost for instance.
  62360. */
  62361. rebuild(): void;
  62362. /**
  62363. * Serializes the component data to the specified json object
  62364. * @param serializationObject The object to serialize to
  62365. */
  62366. serialize(serializationObject: any): void;
  62367. /**
  62368. * Adds all the elements from the container to the scene
  62369. * @param container the container holding the elements
  62370. */
  62371. addFromContainer(container: AbstractScene): void;
  62372. /**
  62373. * Removes all the elements in the container from the scene
  62374. * @param container contains the elements to remove
  62375. * @param dispose if the removed element should be disposed (default: false)
  62376. */
  62377. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62378. /**
  62379. * Disposes the component and the associated ressources.
  62380. */
  62381. dispose(): void;
  62382. private _isReadyForMesh;
  62383. private _renderMainTexture;
  62384. private _setStencil;
  62385. private _setStencilBack;
  62386. private _draw;
  62387. private _drawCamera;
  62388. private _drawRenderingGroup;
  62389. }
  62390. }
  62391. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62392. /** @hidden */
  62393. export var glowMapMergePixelShader: {
  62394. name: string;
  62395. shader: string;
  62396. };
  62397. }
  62398. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62399. /** @hidden */
  62400. export var glowMapMergeVertexShader: {
  62401. name: string;
  62402. shader: string;
  62403. };
  62404. }
  62405. declare module "babylonjs/Layers/glowLayer" {
  62406. import { Nullable } from "babylonjs/types";
  62407. import { Camera } from "babylonjs/Cameras/camera";
  62408. import { Scene } from "babylonjs/scene";
  62409. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62411. import { Mesh } from "babylonjs/Meshes/mesh";
  62412. import { Texture } from "babylonjs/Materials/Textures/texture";
  62413. import { Effect } from "babylonjs/Materials/effect";
  62414. import { Material } from "babylonjs/Materials/material";
  62415. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62416. import { Color4 } from "babylonjs/Maths/math.color";
  62417. import "babylonjs/Shaders/glowMapMerge.fragment";
  62418. import "babylonjs/Shaders/glowMapMerge.vertex";
  62419. import "babylonjs/Layers/effectLayerSceneComponent";
  62420. module "babylonjs/abstractScene" {
  62421. interface AbstractScene {
  62422. /**
  62423. * Return a the first highlight layer of the scene with a given name.
  62424. * @param name The name of the highlight layer to look for.
  62425. * @return The highlight layer if found otherwise null.
  62426. */
  62427. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62428. }
  62429. }
  62430. /**
  62431. * Glow layer options. This helps customizing the behaviour
  62432. * of the glow layer.
  62433. */
  62434. export interface IGlowLayerOptions {
  62435. /**
  62436. * Multiplication factor apply to the canvas size to compute the render target size
  62437. * used to generated the glowing objects (the smaller the faster).
  62438. */
  62439. mainTextureRatio: number;
  62440. /**
  62441. * Enforces a fixed size texture to ensure resize independant blur.
  62442. */
  62443. mainTextureFixedSize?: number;
  62444. /**
  62445. * How big is the kernel of the blur texture.
  62446. */
  62447. blurKernelSize: number;
  62448. /**
  62449. * The camera attached to the layer.
  62450. */
  62451. camera: Nullable<Camera>;
  62452. /**
  62453. * Enable MSAA by chosing the number of samples.
  62454. */
  62455. mainTextureSamples?: number;
  62456. /**
  62457. * The rendering group to draw the layer in.
  62458. */
  62459. renderingGroupId: number;
  62460. }
  62461. /**
  62462. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62463. *
  62464. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62465. *
  62466. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62467. */
  62468. export class GlowLayer extends EffectLayer {
  62469. /**
  62470. * Effect Name of the layer.
  62471. */
  62472. static readonly EffectName: string;
  62473. /**
  62474. * The default blur kernel size used for the glow.
  62475. */
  62476. static DefaultBlurKernelSize: number;
  62477. /**
  62478. * The default texture size ratio used for the glow.
  62479. */
  62480. static DefaultTextureRatio: number;
  62481. /**
  62482. * Sets the kernel size of the blur.
  62483. */
  62484. set blurKernelSize(value: number);
  62485. /**
  62486. * Gets the kernel size of the blur.
  62487. */
  62488. get blurKernelSize(): number;
  62489. /**
  62490. * Sets the glow intensity.
  62491. */
  62492. set intensity(value: number);
  62493. /**
  62494. * Gets the glow intensity.
  62495. */
  62496. get intensity(): number;
  62497. private _options;
  62498. private _intensity;
  62499. private _horizontalBlurPostprocess1;
  62500. private _verticalBlurPostprocess1;
  62501. private _horizontalBlurPostprocess2;
  62502. private _verticalBlurPostprocess2;
  62503. private _blurTexture1;
  62504. private _blurTexture2;
  62505. private _postProcesses1;
  62506. private _postProcesses2;
  62507. private _includedOnlyMeshes;
  62508. private _excludedMeshes;
  62509. private _meshesUsingTheirOwnMaterials;
  62510. /**
  62511. * Callback used to let the user override the color selection on a per mesh basis
  62512. */
  62513. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62514. /**
  62515. * Callback used to let the user override the texture selection on a per mesh basis
  62516. */
  62517. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62518. /**
  62519. * Instantiates a new glow Layer and references it to the scene.
  62520. * @param name The name of the layer
  62521. * @param scene The scene to use the layer in
  62522. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62523. */
  62524. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62525. /**
  62526. * Get the effect name of the layer.
  62527. * @return The effect name
  62528. */
  62529. getEffectName(): string;
  62530. /**
  62531. * Create the merge effect. This is the shader use to blit the information back
  62532. * to the main canvas at the end of the scene rendering.
  62533. */
  62534. protected _createMergeEffect(): Effect;
  62535. /**
  62536. * Creates the render target textures and post processes used in the glow layer.
  62537. */
  62538. protected _createTextureAndPostProcesses(): void;
  62539. /**
  62540. * Checks for the readiness of the element composing the layer.
  62541. * @param subMesh the mesh to check for
  62542. * @param useInstances specify wether or not to use instances to render the mesh
  62543. * @param emissiveTexture the associated emissive texture used to generate the glow
  62544. * @return true if ready otherwise, false
  62545. */
  62546. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62547. /**
  62548. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62549. */
  62550. needStencil(): boolean;
  62551. /**
  62552. * Returns true if the mesh can be rendered, otherwise false.
  62553. * @param mesh The mesh to render
  62554. * @param material The material used on the mesh
  62555. * @returns true if it can be rendered otherwise false
  62556. */
  62557. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62558. /**
  62559. * Implementation specific of rendering the generating effect on the main canvas.
  62560. * @param effect The effect used to render through
  62561. */
  62562. protected _internalRender(effect: Effect): void;
  62563. /**
  62564. * Sets the required values for both the emissive texture and and the main color.
  62565. */
  62566. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62567. /**
  62568. * Returns true if the mesh should render, otherwise false.
  62569. * @param mesh The mesh to render
  62570. * @returns true if it should render otherwise false
  62571. */
  62572. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62573. /**
  62574. * Adds specific effects defines.
  62575. * @param defines The defines to add specifics to.
  62576. */
  62577. protected _addCustomEffectDefines(defines: string[]): void;
  62578. /**
  62579. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62580. * @param mesh The mesh to exclude from the glow layer
  62581. */
  62582. addExcludedMesh(mesh: Mesh): void;
  62583. /**
  62584. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62585. * @param mesh The mesh to remove
  62586. */
  62587. removeExcludedMesh(mesh: Mesh): void;
  62588. /**
  62589. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62590. * @param mesh The mesh to include in the glow layer
  62591. */
  62592. addIncludedOnlyMesh(mesh: Mesh): void;
  62593. /**
  62594. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62595. * @param mesh The mesh to remove
  62596. */
  62597. removeIncludedOnlyMesh(mesh: Mesh): void;
  62598. /**
  62599. * Determine if a given mesh will be used in the glow layer
  62600. * @param mesh The mesh to test
  62601. * @returns true if the mesh will be highlighted by the current glow layer
  62602. */
  62603. hasMesh(mesh: AbstractMesh): boolean;
  62604. /**
  62605. * Defines whether the current material of the mesh should be use to render the effect.
  62606. * @param mesh defines the current mesh to render
  62607. */
  62608. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62609. /**
  62610. * Add a mesh to be rendered through its own material and not with emissive only.
  62611. * @param mesh The mesh for which we need to use its material
  62612. */
  62613. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62614. /**
  62615. * Remove a mesh from being rendered through its own material and not with emissive only.
  62616. * @param mesh The mesh for which we need to not use its material
  62617. */
  62618. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62619. /**
  62620. * Free any resources and references associated to a mesh.
  62621. * Internal use
  62622. * @param mesh The mesh to free.
  62623. * @hidden
  62624. */
  62625. _disposeMesh(mesh: Mesh): void;
  62626. /**
  62627. * Gets the class name of the effect layer
  62628. * @returns the string with the class name of the effect layer
  62629. */
  62630. getClassName(): string;
  62631. /**
  62632. * Serializes this glow layer
  62633. * @returns a serialized glow layer object
  62634. */
  62635. serialize(): any;
  62636. /**
  62637. * Creates a Glow Layer from parsed glow layer data
  62638. * @param parsedGlowLayer defines glow layer data
  62639. * @param scene defines the current scene
  62640. * @param rootUrl defines the root URL containing the glow layer information
  62641. * @returns a parsed Glow Layer
  62642. */
  62643. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62644. }
  62645. }
  62646. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62647. /** @hidden */
  62648. export var glowBlurPostProcessPixelShader: {
  62649. name: string;
  62650. shader: string;
  62651. };
  62652. }
  62653. declare module "babylonjs/Layers/highlightLayer" {
  62654. import { Observable } from "babylonjs/Misc/observable";
  62655. import { Nullable } from "babylonjs/types";
  62656. import { Camera } from "babylonjs/Cameras/camera";
  62657. import { Scene } from "babylonjs/scene";
  62658. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62660. import { Mesh } from "babylonjs/Meshes/mesh";
  62661. import { Effect } from "babylonjs/Materials/effect";
  62662. import { Material } from "babylonjs/Materials/material";
  62663. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62664. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62665. import "babylonjs/Shaders/glowMapMerge.fragment";
  62666. import "babylonjs/Shaders/glowMapMerge.vertex";
  62667. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62668. module "babylonjs/abstractScene" {
  62669. interface AbstractScene {
  62670. /**
  62671. * Return a the first highlight layer of the scene with a given name.
  62672. * @param name The name of the highlight layer to look for.
  62673. * @return The highlight layer if found otherwise null.
  62674. */
  62675. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62676. }
  62677. }
  62678. /**
  62679. * Highlight layer options. This helps customizing the behaviour
  62680. * of the highlight layer.
  62681. */
  62682. export interface IHighlightLayerOptions {
  62683. /**
  62684. * Multiplication factor apply to the canvas size to compute the render target size
  62685. * used to generated the glowing objects (the smaller the faster).
  62686. */
  62687. mainTextureRatio: number;
  62688. /**
  62689. * Enforces a fixed size texture to ensure resize independant blur.
  62690. */
  62691. mainTextureFixedSize?: number;
  62692. /**
  62693. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62694. * of the picture to blur (the smaller the faster).
  62695. */
  62696. blurTextureSizeRatio: number;
  62697. /**
  62698. * How big in texel of the blur texture is the vertical blur.
  62699. */
  62700. blurVerticalSize: number;
  62701. /**
  62702. * How big in texel of the blur texture is the horizontal blur.
  62703. */
  62704. blurHorizontalSize: number;
  62705. /**
  62706. * Alpha blending mode used to apply the blur. Default is combine.
  62707. */
  62708. alphaBlendingMode: number;
  62709. /**
  62710. * The camera attached to the layer.
  62711. */
  62712. camera: Nullable<Camera>;
  62713. /**
  62714. * Should we display highlight as a solid stroke?
  62715. */
  62716. isStroke?: boolean;
  62717. /**
  62718. * The rendering group to draw the layer in.
  62719. */
  62720. renderingGroupId: number;
  62721. }
  62722. /**
  62723. * The highlight layer Helps adding a glow effect around a mesh.
  62724. *
  62725. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62726. * glowy meshes to your scene.
  62727. *
  62728. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62729. */
  62730. export class HighlightLayer extends EffectLayer {
  62731. name: string;
  62732. /**
  62733. * Effect Name of the highlight layer.
  62734. */
  62735. static readonly EffectName: string;
  62736. /**
  62737. * The neutral color used during the preparation of the glow effect.
  62738. * This is black by default as the blend operation is a blend operation.
  62739. */
  62740. static NeutralColor: Color4;
  62741. /**
  62742. * Stencil value used for glowing meshes.
  62743. */
  62744. static GlowingMeshStencilReference: number;
  62745. /**
  62746. * Stencil value used for the other meshes in the scene.
  62747. */
  62748. static NormalMeshStencilReference: number;
  62749. /**
  62750. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62751. */
  62752. innerGlow: boolean;
  62753. /**
  62754. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62755. */
  62756. outerGlow: boolean;
  62757. /**
  62758. * Specifies the horizontal size of the blur.
  62759. */
  62760. set blurHorizontalSize(value: number);
  62761. /**
  62762. * Specifies the vertical size of the blur.
  62763. */
  62764. set blurVerticalSize(value: number);
  62765. /**
  62766. * Gets the horizontal size of the blur.
  62767. */
  62768. get blurHorizontalSize(): number;
  62769. /**
  62770. * Gets the vertical size of the blur.
  62771. */
  62772. get blurVerticalSize(): number;
  62773. /**
  62774. * An event triggered when the highlight layer is being blurred.
  62775. */
  62776. onBeforeBlurObservable: Observable<HighlightLayer>;
  62777. /**
  62778. * An event triggered when the highlight layer has been blurred.
  62779. */
  62780. onAfterBlurObservable: Observable<HighlightLayer>;
  62781. private _instanceGlowingMeshStencilReference;
  62782. private _options;
  62783. private _downSamplePostprocess;
  62784. private _horizontalBlurPostprocess;
  62785. private _verticalBlurPostprocess;
  62786. private _blurTexture;
  62787. private _meshes;
  62788. private _excludedMeshes;
  62789. /**
  62790. * Instantiates a new highlight Layer and references it to the scene..
  62791. * @param name The name of the layer
  62792. * @param scene The scene to use the layer in
  62793. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62794. */
  62795. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62796. /**
  62797. * Get the effect name of the layer.
  62798. * @return The effect name
  62799. */
  62800. getEffectName(): string;
  62801. /**
  62802. * Create the merge effect. This is the shader use to blit the information back
  62803. * to the main canvas at the end of the scene rendering.
  62804. */
  62805. protected _createMergeEffect(): Effect;
  62806. /**
  62807. * Creates the render target textures and post processes used in the highlight layer.
  62808. */
  62809. protected _createTextureAndPostProcesses(): void;
  62810. /**
  62811. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62812. */
  62813. needStencil(): boolean;
  62814. /**
  62815. * Checks for the readiness of the element composing the layer.
  62816. * @param subMesh the mesh to check for
  62817. * @param useInstances specify wether or not to use instances to render the mesh
  62818. * @param emissiveTexture the associated emissive texture used to generate the glow
  62819. * @return true if ready otherwise, false
  62820. */
  62821. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62822. /**
  62823. * Implementation specific of rendering the generating effect on the main canvas.
  62824. * @param effect The effect used to render through
  62825. */
  62826. protected _internalRender(effect: Effect): void;
  62827. /**
  62828. * Returns true if the layer contains information to display, otherwise false.
  62829. */
  62830. shouldRender(): boolean;
  62831. /**
  62832. * Returns true if the mesh should render, otherwise false.
  62833. * @param mesh The mesh to render
  62834. * @returns true if it should render otherwise false
  62835. */
  62836. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62837. /**
  62838. * Returns true if the mesh can be rendered, otherwise false.
  62839. * @param mesh The mesh to render
  62840. * @param material The material used on the mesh
  62841. * @returns true if it can be rendered otherwise false
  62842. */
  62843. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62844. /**
  62845. * Adds specific effects defines.
  62846. * @param defines The defines to add specifics to.
  62847. */
  62848. protected _addCustomEffectDefines(defines: string[]): void;
  62849. /**
  62850. * Sets the required values for both the emissive texture and and the main color.
  62851. */
  62852. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62853. /**
  62854. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62855. * @param mesh The mesh to exclude from the highlight layer
  62856. */
  62857. addExcludedMesh(mesh: Mesh): void;
  62858. /**
  62859. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62860. * @param mesh The mesh to highlight
  62861. */
  62862. removeExcludedMesh(mesh: Mesh): void;
  62863. /**
  62864. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62865. * @param mesh mesh to test
  62866. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62867. */
  62868. hasMesh(mesh: AbstractMesh): boolean;
  62869. /**
  62870. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62871. * @param mesh The mesh to highlight
  62872. * @param color The color of the highlight
  62873. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62874. */
  62875. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62876. /**
  62877. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62878. * @param mesh The mesh to highlight
  62879. */
  62880. removeMesh(mesh: Mesh): void;
  62881. /**
  62882. * Remove all the meshes currently referenced in the highlight layer
  62883. */
  62884. removeAllMeshes(): void;
  62885. /**
  62886. * Force the stencil to the normal expected value for none glowing parts
  62887. */
  62888. private _defaultStencilReference;
  62889. /**
  62890. * Free any resources and references associated to a mesh.
  62891. * Internal use
  62892. * @param mesh The mesh to free.
  62893. * @hidden
  62894. */
  62895. _disposeMesh(mesh: Mesh): void;
  62896. /**
  62897. * Dispose the highlight layer and free resources.
  62898. */
  62899. dispose(): void;
  62900. /**
  62901. * Gets the class name of the effect layer
  62902. * @returns the string with the class name of the effect layer
  62903. */
  62904. getClassName(): string;
  62905. /**
  62906. * Serializes this Highlight layer
  62907. * @returns a serialized Highlight layer object
  62908. */
  62909. serialize(): any;
  62910. /**
  62911. * Creates a Highlight layer from parsed Highlight layer data
  62912. * @param parsedHightlightLayer defines the Highlight layer data
  62913. * @param scene defines the current scene
  62914. * @param rootUrl defines the root URL containing the Highlight layer information
  62915. * @returns a parsed Highlight layer
  62916. */
  62917. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62918. }
  62919. }
  62920. declare module "babylonjs/Layers/layerSceneComponent" {
  62921. import { Scene } from "babylonjs/scene";
  62922. import { ISceneComponent } from "babylonjs/sceneComponent";
  62923. import { Layer } from "babylonjs/Layers/layer";
  62924. import { AbstractScene } from "babylonjs/abstractScene";
  62925. module "babylonjs/abstractScene" {
  62926. interface AbstractScene {
  62927. /**
  62928. * The list of layers (background and foreground) of the scene
  62929. */
  62930. layers: Array<Layer>;
  62931. }
  62932. }
  62933. /**
  62934. * Defines the layer scene component responsible to manage any layers
  62935. * in a given scene.
  62936. */
  62937. export class LayerSceneComponent implements ISceneComponent {
  62938. /**
  62939. * The component name helpfull to identify the component in the list of scene components.
  62940. */
  62941. readonly name: string;
  62942. /**
  62943. * The scene the component belongs to.
  62944. */
  62945. scene: Scene;
  62946. private _engine;
  62947. /**
  62948. * Creates a new instance of the component for the given scene
  62949. * @param scene Defines the scene to register the component in
  62950. */
  62951. constructor(scene: Scene);
  62952. /**
  62953. * Registers the component in a given scene
  62954. */
  62955. register(): void;
  62956. /**
  62957. * Rebuilds the elements related to this component in case of
  62958. * context lost for instance.
  62959. */
  62960. rebuild(): void;
  62961. /**
  62962. * Disposes the component and the associated ressources.
  62963. */
  62964. dispose(): void;
  62965. private _draw;
  62966. private _drawCameraPredicate;
  62967. private _drawCameraBackground;
  62968. private _drawCameraForeground;
  62969. private _drawRenderTargetPredicate;
  62970. private _drawRenderTargetBackground;
  62971. private _drawRenderTargetForeground;
  62972. /**
  62973. * Adds all the elements from the container to the scene
  62974. * @param container the container holding the elements
  62975. */
  62976. addFromContainer(container: AbstractScene): void;
  62977. /**
  62978. * Removes all the elements in the container from the scene
  62979. * @param container contains the elements to remove
  62980. * @param dispose if the removed element should be disposed (default: false)
  62981. */
  62982. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62983. }
  62984. }
  62985. declare module "babylonjs/Shaders/layer.fragment" {
  62986. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62987. /** @hidden */
  62988. export var layerPixelShader: {
  62989. name: string;
  62990. shader: string;
  62991. };
  62992. }
  62993. declare module "babylonjs/Shaders/layer.vertex" {
  62994. /** @hidden */
  62995. export var layerVertexShader: {
  62996. name: string;
  62997. shader: string;
  62998. };
  62999. }
  63000. declare module "babylonjs/Layers/layer" {
  63001. import { Observable } from "babylonjs/Misc/observable";
  63002. import { Nullable } from "babylonjs/types";
  63003. import { Scene } from "babylonjs/scene";
  63004. import { Vector2 } from "babylonjs/Maths/math.vector";
  63005. import { Color4 } from "babylonjs/Maths/math.color";
  63006. import { Texture } from "babylonjs/Materials/Textures/texture";
  63007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63008. import "babylonjs/Shaders/layer.fragment";
  63009. import "babylonjs/Shaders/layer.vertex";
  63010. /**
  63011. * This represents a full screen 2d layer.
  63012. * This can be useful to display a picture in the background of your scene for instance.
  63013. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63014. */
  63015. export class Layer {
  63016. /**
  63017. * Define the name of the layer.
  63018. */
  63019. name: string;
  63020. /**
  63021. * Define the texture the layer should display.
  63022. */
  63023. texture: Nullable<Texture>;
  63024. /**
  63025. * Is the layer in background or foreground.
  63026. */
  63027. isBackground: boolean;
  63028. /**
  63029. * Define the color of the layer (instead of texture).
  63030. */
  63031. color: Color4;
  63032. /**
  63033. * Define the scale of the layer in order to zoom in out of the texture.
  63034. */
  63035. scale: Vector2;
  63036. /**
  63037. * Define an offset for the layer in order to shift the texture.
  63038. */
  63039. offset: Vector2;
  63040. /**
  63041. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63042. */
  63043. alphaBlendingMode: number;
  63044. /**
  63045. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63046. * Alpha test will not mix with the background color in case of transparency.
  63047. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63048. */
  63049. alphaTest: boolean;
  63050. /**
  63051. * Define a mask to restrict the layer to only some of the scene cameras.
  63052. */
  63053. layerMask: number;
  63054. /**
  63055. * Define the list of render target the layer is visible into.
  63056. */
  63057. renderTargetTextures: RenderTargetTexture[];
  63058. /**
  63059. * Define if the layer is only used in renderTarget or if it also
  63060. * renders in the main frame buffer of the canvas.
  63061. */
  63062. renderOnlyInRenderTargetTextures: boolean;
  63063. private _scene;
  63064. private _vertexBuffers;
  63065. private _indexBuffer;
  63066. private _effect;
  63067. private _previousDefines;
  63068. /**
  63069. * An event triggered when the layer is disposed.
  63070. */
  63071. onDisposeObservable: Observable<Layer>;
  63072. private _onDisposeObserver;
  63073. /**
  63074. * Back compatibility with callback before the onDisposeObservable existed.
  63075. * The set callback will be triggered when the layer has been disposed.
  63076. */
  63077. set onDispose(callback: () => void);
  63078. /**
  63079. * An event triggered before rendering the scene
  63080. */
  63081. onBeforeRenderObservable: Observable<Layer>;
  63082. private _onBeforeRenderObserver;
  63083. /**
  63084. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63085. * The set callback will be triggered just before rendering the layer.
  63086. */
  63087. set onBeforeRender(callback: () => void);
  63088. /**
  63089. * An event triggered after rendering the scene
  63090. */
  63091. onAfterRenderObservable: Observable<Layer>;
  63092. private _onAfterRenderObserver;
  63093. /**
  63094. * Back compatibility with callback before the onAfterRenderObservable existed.
  63095. * The set callback will be triggered just after rendering the layer.
  63096. */
  63097. set onAfterRender(callback: () => void);
  63098. /**
  63099. * Instantiates a new layer.
  63100. * This represents a full screen 2d layer.
  63101. * This can be useful to display a picture in the background of your scene for instance.
  63102. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63103. * @param name Define the name of the layer in the scene
  63104. * @param imgUrl Define the url of the texture to display in the layer
  63105. * @param scene Define the scene the layer belongs to
  63106. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63107. * @param color Defines a color for the layer
  63108. */
  63109. constructor(
  63110. /**
  63111. * Define the name of the layer.
  63112. */
  63113. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63114. private _createIndexBuffer;
  63115. /** @hidden */
  63116. _rebuild(): void;
  63117. /**
  63118. * Renders the layer in the scene.
  63119. */
  63120. render(): void;
  63121. /**
  63122. * Disposes and releases the associated ressources.
  63123. */
  63124. dispose(): void;
  63125. }
  63126. }
  63127. declare module "babylonjs/Layers/index" {
  63128. export * from "babylonjs/Layers/effectLayer";
  63129. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63130. export * from "babylonjs/Layers/glowLayer";
  63131. export * from "babylonjs/Layers/highlightLayer";
  63132. export * from "babylonjs/Layers/layer";
  63133. export * from "babylonjs/Layers/layerSceneComponent";
  63134. }
  63135. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63136. /** @hidden */
  63137. export var lensFlarePixelShader: {
  63138. name: string;
  63139. shader: string;
  63140. };
  63141. }
  63142. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63143. /** @hidden */
  63144. export var lensFlareVertexShader: {
  63145. name: string;
  63146. shader: string;
  63147. };
  63148. }
  63149. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63150. import { Scene } from "babylonjs/scene";
  63151. import { Vector3 } from "babylonjs/Maths/math.vector";
  63152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63153. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63154. import "babylonjs/Shaders/lensFlare.fragment";
  63155. import "babylonjs/Shaders/lensFlare.vertex";
  63156. import { Viewport } from "babylonjs/Maths/math.viewport";
  63157. /**
  63158. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63159. * It is usually composed of several `lensFlare`.
  63160. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63161. */
  63162. export class LensFlareSystem {
  63163. /**
  63164. * Define the name of the lens flare system
  63165. */
  63166. name: string;
  63167. /**
  63168. * List of lens flares used in this system.
  63169. */
  63170. lensFlares: LensFlare[];
  63171. /**
  63172. * Define a limit from the border the lens flare can be visible.
  63173. */
  63174. borderLimit: number;
  63175. /**
  63176. * Define a viewport border we do not want to see the lens flare in.
  63177. */
  63178. viewportBorder: number;
  63179. /**
  63180. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63181. */
  63182. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63183. /**
  63184. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63185. */
  63186. layerMask: number;
  63187. /**
  63188. * Define the id of the lens flare system in the scene.
  63189. * (equal to name by default)
  63190. */
  63191. id: string;
  63192. private _scene;
  63193. private _emitter;
  63194. private _vertexBuffers;
  63195. private _indexBuffer;
  63196. private _effect;
  63197. private _positionX;
  63198. private _positionY;
  63199. private _isEnabled;
  63200. /** @hidden */
  63201. static _SceneComponentInitialization: (scene: Scene) => void;
  63202. /**
  63203. * Instantiates a lens flare system.
  63204. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63205. * It is usually composed of several `lensFlare`.
  63206. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63207. * @param name Define the name of the lens flare system in the scene
  63208. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63209. * @param scene Define the scene the lens flare system belongs to
  63210. */
  63211. constructor(
  63212. /**
  63213. * Define the name of the lens flare system
  63214. */
  63215. name: string, emitter: any, scene: Scene);
  63216. /**
  63217. * Define if the lens flare system is enabled.
  63218. */
  63219. get isEnabled(): boolean;
  63220. set isEnabled(value: boolean);
  63221. /**
  63222. * Get the scene the effects belongs to.
  63223. * @returns the scene holding the lens flare system
  63224. */
  63225. getScene(): Scene;
  63226. /**
  63227. * Get the emitter of the lens flare system.
  63228. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63229. * @returns the emitter of the lens flare system
  63230. */
  63231. getEmitter(): any;
  63232. /**
  63233. * Set the emitter of the lens flare system.
  63234. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63235. * @param newEmitter Define the new emitter of the system
  63236. */
  63237. setEmitter(newEmitter: any): void;
  63238. /**
  63239. * Get the lens flare system emitter position.
  63240. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63241. * @returns the position
  63242. */
  63243. getEmitterPosition(): Vector3;
  63244. /**
  63245. * @hidden
  63246. */
  63247. computeEffectivePosition(globalViewport: Viewport): boolean;
  63248. /** @hidden */
  63249. _isVisible(): boolean;
  63250. /**
  63251. * @hidden
  63252. */
  63253. render(): boolean;
  63254. /**
  63255. * Dispose and release the lens flare with its associated resources.
  63256. */
  63257. dispose(): void;
  63258. /**
  63259. * Parse a lens flare system from a JSON repressentation
  63260. * @param parsedLensFlareSystem Define the JSON to parse
  63261. * @param scene Define the scene the parsed system should be instantiated in
  63262. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63263. * @returns the parsed system
  63264. */
  63265. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63266. /**
  63267. * Serialize the current Lens Flare System into a JSON representation.
  63268. * @returns the serialized JSON
  63269. */
  63270. serialize(): any;
  63271. }
  63272. }
  63273. declare module "babylonjs/LensFlares/lensFlare" {
  63274. import { Nullable } from "babylonjs/types";
  63275. import { Color3 } from "babylonjs/Maths/math.color";
  63276. import { Texture } from "babylonjs/Materials/Textures/texture";
  63277. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63278. /**
  63279. * This represents one of the lens effect in a `lensFlareSystem`.
  63280. * It controls one of the indiviual texture used in the effect.
  63281. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63282. */
  63283. export class LensFlare {
  63284. /**
  63285. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63286. */
  63287. size: number;
  63288. /**
  63289. * 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.
  63290. */
  63291. position: number;
  63292. /**
  63293. * Define the lens color.
  63294. */
  63295. color: Color3;
  63296. /**
  63297. * Define the lens texture.
  63298. */
  63299. texture: Nullable<Texture>;
  63300. /**
  63301. * Define the alpha mode to render this particular lens.
  63302. */
  63303. alphaMode: number;
  63304. private _system;
  63305. /**
  63306. * Creates a new Lens Flare.
  63307. * This represents one of the lens effect in a `lensFlareSystem`.
  63308. * It controls one of the indiviual texture used in the effect.
  63309. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63310. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63311. * @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.
  63312. * @param color Define the lens color
  63313. * @param imgUrl Define the lens texture url
  63314. * @param system Define the `lensFlareSystem` this flare is part of
  63315. * @returns The newly created Lens Flare
  63316. */
  63317. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63318. /**
  63319. * Instantiates a new Lens Flare.
  63320. * This represents one of the lens effect in a `lensFlareSystem`.
  63321. * It controls one of the indiviual texture used in the effect.
  63322. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63323. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63324. * @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.
  63325. * @param color Define the lens color
  63326. * @param imgUrl Define the lens texture url
  63327. * @param system Define the `lensFlareSystem` this flare is part of
  63328. */
  63329. constructor(
  63330. /**
  63331. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63332. */
  63333. size: number,
  63334. /**
  63335. * 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.
  63336. */
  63337. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63338. /**
  63339. * Dispose and release the lens flare with its associated resources.
  63340. */
  63341. dispose(): void;
  63342. }
  63343. }
  63344. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63345. import { Nullable } from "babylonjs/types";
  63346. import { Scene } from "babylonjs/scene";
  63347. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63348. import { AbstractScene } from "babylonjs/abstractScene";
  63349. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63350. module "babylonjs/abstractScene" {
  63351. interface AbstractScene {
  63352. /**
  63353. * The list of lens flare system added to the scene
  63354. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63355. */
  63356. lensFlareSystems: Array<LensFlareSystem>;
  63357. /**
  63358. * Removes the given lens flare system from this scene.
  63359. * @param toRemove The lens flare system to remove
  63360. * @returns The index of the removed lens flare system
  63361. */
  63362. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63363. /**
  63364. * Adds the given lens flare system to this scene
  63365. * @param newLensFlareSystem The lens flare system to add
  63366. */
  63367. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63368. /**
  63369. * Gets a lens flare system using its name
  63370. * @param name defines the name to look for
  63371. * @returns the lens flare system or null if not found
  63372. */
  63373. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63374. /**
  63375. * Gets a lens flare system using its id
  63376. * @param id defines the id to look for
  63377. * @returns the lens flare system or null if not found
  63378. */
  63379. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63380. }
  63381. }
  63382. /**
  63383. * Defines the lens flare scene component responsible to manage any lens flares
  63384. * in a given scene.
  63385. */
  63386. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63387. /**
  63388. * The component name helpfull to identify the component in the list of scene components.
  63389. */
  63390. readonly name: string;
  63391. /**
  63392. * The scene the component belongs to.
  63393. */
  63394. scene: Scene;
  63395. /**
  63396. * Creates a new instance of the component for the given scene
  63397. * @param scene Defines the scene to register the component in
  63398. */
  63399. constructor(scene: Scene);
  63400. /**
  63401. * Registers the component in a given scene
  63402. */
  63403. register(): void;
  63404. /**
  63405. * Rebuilds the elements related to this component in case of
  63406. * context lost for instance.
  63407. */
  63408. rebuild(): void;
  63409. /**
  63410. * Adds all the elements from the container to the scene
  63411. * @param container the container holding the elements
  63412. */
  63413. addFromContainer(container: AbstractScene): void;
  63414. /**
  63415. * Removes all the elements in the container from the scene
  63416. * @param container contains the elements to remove
  63417. * @param dispose if the removed element should be disposed (default: false)
  63418. */
  63419. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63420. /**
  63421. * Serializes the component data to the specified json object
  63422. * @param serializationObject The object to serialize to
  63423. */
  63424. serialize(serializationObject: any): void;
  63425. /**
  63426. * Disposes the component and the associated ressources.
  63427. */
  63428. dispose(): void;
  63429. private _draw;
  63430. }
  63431. }
  63432. declare module "babylonjs/LensFlares/index" {
  63433. export * from "babylonjs/LensFlares/lensFlare";
  63434. export * from "babylonjs/LensFlares/lensFlareSystem";
  63435. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63436. }
  63437. declare module "babylonjs/Shaders/depth.fragment" {
  63438. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63439. /** @hidden */
  63440. export var depthPixelShader: {
  63441. name: string;
  63442. shader: string;
  63443. };
  63444. }
  63445. declare module "babylonjs/Shaders/depth.vertex" {
  63446. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63449. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63450. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63451. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63452. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63453. /** @hidden */
  63454. export var depthVertexShader: {
  63455. name: string;
  63456. shader: string;
  63457. };
  63458. }
  63459. declare module "babylonjs/Rendering/depthRenderer" {
  63460. import { Nullable } from "babylonjs/types";
  63461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63462. import { Scene } from "babylonjs/scene";
  63463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63464. import { Camera } from "babylonjs/Cameras/camera";
  63465. import "babylonjs/Shaders/depth.fragment";
  63466. import "babylonjs/Shaders/depth.vertex";
  63467. /**
  63468. * This represents a depth renderer in Babylon.
  63469. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63470. */
  63471. export class DepthRenderer {
  63472. private _scene;
  63473. private _depthMap;
  63474. private _effect;
  63475. private readonly _storeNonLinearDepth;
  63476. private readonly _clearColor;
  63477. /** Get if the depth renderer is using packed depth or not */
  63478. readonly isPacked: boolean;
  63479. private _cachedDefines;
  63480. private _camera;
  63481. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63482. enabled: boolean;
  63483. /**
  63484. * Specifiess that the depth renderer will only be used within
  63485. * the camera it is created for.
  63486. * This can help forcing its rendering during the camera processing.
  63487. */
  63488. useOnlyInActiveCamera: boolean;
  63489. /** @hidden */
  63490. static _SceneComponentInitialization: (scene: Scene) => void;
  63491. /**
  63492. * Instantiates a depth renderer
  63493. * @param scene The scene the renderer belongs to
  63494. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63495. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63496. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63497. */
  63498. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63499. /**
  63500. * Creates the depth rendering effect and checks if the effect is ready.
  63501. * @param subMesh The submesh to be used to render the depth map of
  63502. * @param useInstances If multiple world instances should be used
  63503. * @returns if the depth renderer is ready to render the depth map
  63504. */
  63505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63506. /**
  63507. * Gets the texture which the depth map will be written to.
  63508. * @returns The depth map texture
  63509. */
  63510. getDepthMap(): RenderTargetTexture;
  63511. /**
  63512. * Disposes of the depth renderer.
  63513. */
  63514. dispose(): void;
  63515. }
  63516. }
  63517. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63518. /** @hidden */
  63519. export var minmaxReduxPixelShader: {
  63520. name: string;
  63521. shader: string;
  63522. };
  63523. }
  63524. declare module "babylonjs/Misc/minMaxReducer" {
  63525. import { Nullable } from "babylonjs/types";
  63526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63527. import { Camera } from "babylonjs/Cameras/camera";
  63528. import { Observer } from "babylonjs/Misc/observable";
  63529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63530. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63531. import { Observable } from "babylonjs/Misc/observable";
  63532. import "babylonjs/Shaders/minmaxRedux.fragment";
  63533. /**
  63534. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63535. * and maximum values from all values of the texture.
  63536. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63537. * The source values are read from the red channel of the texture.
  63538. */
  63539. export class MinMaxReducer {
  63540. /**
  63541. * Observable triggered when the computation has been performed
  63542. */
  63543. onAfterReductionPerformed: Observable<{
  63544. min: number;
  63545. max: number;
  63546. }>;
  63547. protected _camera: Camera;
  63548. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63549. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63550. protected _postProcessManager: PostProcessManager;
  63551. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63552. protected _forceFullscreenViewport: boolean;
  63553. /**
  63554. * Creates a min/max reducer
  63555. * @param camera The camera to use for the post processes
  63556. */
  63557. constructor(camera: Camera);
  63558. /**
  63559. * Gets the texture used to read the values from.
  63560. */
  63561. get sourceTexture(): Nullable<RenderTargetTexture>;
  63562. /**
  63563. * Sets the source texture to read the values from.
  63564. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63565. * because in such textures '1' value must not be taken into account to compute the maximum
  63566. * as this value is used to clear the texture.
  63567. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63568. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63569. * @param depthRedux Indicates if the texture is a depth texture or not
  63570. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63571. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63572. */
  63573. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63574. /**
  63575. * Defines the refresh rate of the computation.
  63576. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63577. */
  63578. get refreshRate(): number;
  63579. set refreshRate(value: number);
  63580. protected _activated: boolean;
  63581. /**
  63582. * Gets the activation status of the reducer
  63583. */
  63584. get activated(): boolean;
  63585. /**
  63586. * Activates the reduction computation.
  63587. * When activated, the observers registered in onAfterReductionPerformed are
  63588. * called after the compuation is performed
  63589. */
  63590. activate(): void;
  63591. /**
  63592. * Deactivates the reduction computation.
  63593. */
  63594. deactivate(): void;
  63595. /**
  63596. * Disposes the min/max reducer
  63597. * @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.
  63598. */
  63599. dispose(disposeAll?: boolean): void;
  63600. }
  63601. }
  63602. declare module "babylonjs/Misc/depthReducer" {
  63603. import { Nullable } from "babylonjs/types";
  63604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63605. import { Camera } from "babylonjs/Cameras/camera";
  63606. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63607. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63608. /**
  63609. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63610. */
  63611. export class DepthReducer extends MinMaxReducer {
  63612. private _depthRenderer;
  63613. private _depthRendererId;
  63614. /**
  63615. * Gets the depth renderer used for the computation.
  63616. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63617. */
  63618. get depthRenderer(): Nullable<DepthRenderer>;
  63619. /**
  63620. * Creates a depth reducer
  63621. * @param camera The camera used to render the depth texture
  63622. */
  63623. constructor(camera: Camera);
  63624. /**
  63625. * Sets the depth renderer to use to generate the depth map
  63626. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63627. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63628. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63629. */
  63630. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63631. /** @hidden */
  63632. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63633. /**
  63634. * Activates the reduction computation.
  63635. * When activated, the observers registered in onAfterReductionPerformed are
  63636. * called after the compuation is performed
  63637. */
  63638. activate(): void;
  63639. /**
  63640. * Deactivates the reduction computation.
  63641. */
  63642. deactivate(): void;
  63643. /**
  63644. * Disposes the depth reducer
  63645. * @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.
  63646. */
  63647. dispose(disposeAll?: boolean): void;
  63648. }
  63649. }
  63650. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63651. import { Nullable } from "babylonjs/types";
  63652. import { Scene } from "babylonjs/scene";
  63653. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63654. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63656. import { Effect } from "babylonjs/Materials/effect";
  63657. import "babylonjs/Shaders/shadowMap.fragment";
  63658. import "babylonjs/Shaders/shadowMap.vertex";
  63659. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63660. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63661. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63662. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63663. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63664. /**
  63665. * A CSM implementation allowing casting shadows on large scenes.
  63666. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63667. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63668. */
  63669. export class CascadedShadowGenerator extends ShadowGenerator {
  63670. private static readonly frustumCornersNDCSpace;
  63671. /**
  63672. * Name of the CSM class
  63673. */
  63674. static CLASSNAME: string;
  63675. /**
  63676. * Defines the default number of cascades used by the CSM.
  63677. */
  63678. static readonly DEFAULT_CASCADES_COUNT: number;
  63679. /**
  63680. * Defines the minimum number of cascades used by the CSM.
  63681. */
  63682. static readonly MIN_CASCADES_COUNT: number;
  63683. /**
  63684. * Defines the maximum number of cascades used by the CSM.
  63685. */
  63686. static readonly MAX_CASCADES_COUNT: number;
  63687. protected _validateFilter(filter: number): number;
  63688. /**
  63689. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63690. */
  63691. penumbraDarkness: number;
  63692. private _numCascades;
  63693. /**
  63694. * Gets or set the number of cascades used by the CSM.
  63695. */
  63696. get numCascades(): number;
  63697. set numCascades(value: number);
  63698. /**
  63699. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63700. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63701. */
  63702. stabilizeCascades: boolean;
  63703. private _freezeShadowCastersBoundingInfo;
  63704. private _freezeShadowCastersBoundingInfoObservable;
  63705. /**
  63706. * Enables or disables the shadow casters bounding info computation.
  63707. * If your shadow casters don't move, you can disable this feature.
  63708. * If it is enabled, the bounding box computation is done every frame.
  63709. */
  63710. get freezeShadowCastersBoundingInfo(): boolean;
  63711. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63712. private _scbiMin;
  63713. private _scbiMax;
  63714. protected _computeShadowCastersBoundingInfo(): void;
  63715. protected _shadowCastersBoundingInfo: BoundingInfo;
  63716. /**
  63717. * Gets or sets the shadow casters bounding info.
  63718. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63719. * so that the system won't overwrite the bounds you provide
  63720. */
  63721. get shadowCastersBoundingInfo(): BoundingInfo;
  63722. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63723. protected _breaksAreDirty: boolean;
  63724. protected _minDistance: number;
  63725. protected _maxDistance: number;
  63726. /**
  63727. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63728. *
  63729. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63730. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63731. * @param min minimal distance for the breaks (default to 0.)
  63732. * @param max maximal distance for the breaks (default to 1.)
  63733. */
  63734. setMinMaxDistance(min: number, max: number): void;
  63735. /** Gets the minimal distance used in the cascade break computation */
  63736. get minDistance(): number;
  63737. /** Gets the maximal distance used in the cascade break computation */
  63738. get maxDistance(): number;
  63739. /**
  63740. * Gets the class name of that object
  63741. * @returns "CascadedShadowGenerator"
  63742. */
  63743. getClassName(): string;
  63744. private _cascadeMinExtents;
  63745. private _cascadeMaxExtents;
  63746. /**
  63747. * Gets a cascade minimum extents
  63748. * @param cascadeIndex index of the cascade
  63749. * @returns the minimum cascade extents
  63750. */
  63751. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63752. /**
  63753. * Gets a cascade maximum extents
  63754. * @param cascadeIndex index of the cascade
  63755. * @returns the maximum cascade extents
  63756. */
  63757. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63758. private _cascades;
  63759. private _currentLayer;
  63760. private _viewSpaceFrustumsZ;
  63761. private _viewMatrices;
  63762. private _projectionMatrices;
  63763. private _transformMatrices;
  63764. private _transformMatricesAsArray;
  63765. private _frustumLengths;
  63766. private _lightSizeUVCorrection;
  63767. private _depthCorrection;
  63768. private _frustumCornersWorldSpace;
  63769. private _frustumCenter;
  63770. private _shadowCameraPos;
  63771. private _shadowMaxZ;
  63772. /**
  63773. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63774. * It defaults to camera.maxZ
  63775. */
  63776. get shadowMaxZ(): number;
  63777. /**
  63778. * Sets the shadow max z distance.
  63779. */
  63780. set shadowMaxZ(value: number);
  63781. protected _debug: boolean;
  63782. /**
  63783. * Gets or sets the debug flag.
  63784. * When enabled, the cascades are materialized by different colors on the screen.
  63785. */
  63786. get debug(): boolean;
  63787. set debug(dbg: boolean);
  63788. private _depthClamp;
  63789. /**
  63790. * Gets or sets the depth clamping value.
  63791. *
  63792. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63793. * to account for the shadow casters far away.
  63794. *
  63795. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63796. */
  63797. get depthClamp(): boolean;
  63798. set depthClamp(value: boolean);
  63799. private _cascadeBlendPercentage;
  63800. /**
  63801. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63802. * It defaults to 0.1 (10% blending).
  63803. */
  63804. get cascadeBlendPercentage(): number;
  63805. set cascadeBlendPercentage(value: number);
  63806. private _lambda;
  63807. /**
  63808. * Gets or set the lambda parameter.
  63809. * This parameter is used to split the camera frustum and create the cascades.
  63810. * 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.
  63811. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63812. */
  63813. get lambda(): number;
  63814. set lambda(value: number);
  63815. /**
  63816. * Gets the view matrix corresponding to a given cascade
  63817. * @param cascadeNum cascade to retrieve the view matrix from
  63818. * @returns the cascade view matrix
  63819. */
  63820. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63821. /**
  63822. * Gets the projection matrix corresponding to a given cascade
  63823. * @param cascadeNum cascade to retrieve the projection matrix from
  63824. * @returns the cascade projection matrix
  63825. */
  63826. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63827. /**
  63828. * Gets the transformation matrix corresponding to a given cascade
  63829. * @param cascadeNum cascade to retrieve the transformation matrix from
  63830. * @returns the cascade transformation matrix
  63831. */
  63832. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63833. private _depthRenderer;
  63834. /**
  63835. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63836. *
  63837. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63838. *
  63839. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63840. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63841. * @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
  63842. */
  63843. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63844. private _depthReducer;
  63845. private _autoCalcDepthBounds;
  63846. /**
  63847. * Gets or sets the autoCalcDepthBounds property.
  63848. *
  63849. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63850. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63851. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63852. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63853. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63854. */
  63855. get autoCalcDepthBounds(): boolean;
  63856. set autoCalcDepthBounds(value: boolean);
  63857. /**
  63858. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63859. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63860. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63861. * for setting the refresh rate on the renderer yourself!
  63862. */
  63863. get autoCalcDepthBoundsRefreshRate(): number;
  63864. set autoCalcDepthBoundsRefreshRate(value: number);
  63865. /**
  63866. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63867. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63868. * you change the camera near/far planes!
  63869. */
  63870. splitFrustum(): void;
  63871. private _splitFrustum;
  63872. private _computeMatrices;
  63873. private _computeFrustumInWorldSpace;
  63874. private _computeCascadeFrustum;
  63875. /**
  63876. * Support test.
  63877. */
  63878. static get IsSupported(): boolean;
  63879. /** @hidden */
  63880. static _SceneComponentInitialization: (scene: Scene) => void;
  63881. /**
  63882. * Creates a Cascaded Shadow Generator object.
  63883. * A ShadowGenerator is the required tool to use the shadows.
  63884. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63885. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63886. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63887. * @param light The directional light object generating the shadows.
  63888. * @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.
  63889. */
  63890. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63891. protected _initializeGenerator(): void;
  63892. protected _createTargetRenderTexture(): void;
  63893. protected _initializeShadowMap(): void;
  63894. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63895. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63896. /**
  63897. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63898. * @param defines Defines of the material we want to update
  63899. * @param lightIndex Index of the light in the enabled light list of the material
  63900. */
  63901. prepareDefines(defines: any, lightIndex: number): void;
  63902. /**
  63903. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63904. * defined in the generator but impacting the effect).
  63905. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63906. * @param effect The effect we are binfing the information for
  63907. */
  63908. bindShadowLight(lightIndex: string, effect: Effect): void;
  63909. /**
  63910. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63911. * (eq to view projection * shadow projection matrices)
  63912. * @returns The transform matrix used to create the shadow map
  63913. */
  63914. getTransformMatrix(): Matrix;
  63915. /**
  63916. * Disposes the ShadowGenerator.
  63917. * Returns nothing.
  63918. */
  63919. dispose(): void;
  63920. /**
  63921. * Serializes the shadow generator setup to a json object.
  63922. * @returns The serialized JSON object
  63923. */
  63924. serialize(): any;
  63925. /**
  63926. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63927. * @param parsedShadowGenerator The JSON object to parse
  63928. * @param scene The scene to create the shadow map for
  63929. * @returns The parsed shadow generator
  63930. */
  63931. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63932. }
  63933. }
  63934. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63935. import { Scene } from "babylonjs/scene";
  63936. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63937. import { AbstractScene } from "babylonjs/abstractScene";
  63938. /**
  63939. * Defines the shadow generator component responsible to manage any shadow generators
  63940. * in a given scene.
  63941. */
  63942. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63943. /**
  63944. * The component name helpfull to identify the component in the list of scene components.
  63945. */
  63946. readonly name: string;
  63947. /**
  63948. * The scene the component belongs to.
  63949. */
  63950. scene: Scene;
  63951. /**
  63952. * Creates a new instance of the component for the given scene
  63953. * @param scene Defines the scene to register the component in
  63954. */
  63955. constructor(scene: Scene);
  63956. /**
  63957. * Registers the component in a given scene
  63958. */
  63959. register(): void;
  63960. /**
  63961. * Rebuilds the elements related to this component in case of
  63962. * context lost for instance.
  63963. */
  63964. rebuild(): void;
  63965. /**
  63966. * Serializes the component data to the specified json object
  63967. * @param serializationObject The object to serialize to
  63968. */
  63969. serialize(serializationObject: any): void;
  63970. /**
  63971. * Adds all the elements from the container to the scene
  63972. * @param container the container holding the elements
  63973. */
  63974. addFromContainer(container: AbstractScene): void;
  63975. /**
  63976. * Removes all the elements in the container from the scene
  63977. * @param container contains the elements to remove
  63978. * @param dispose if the removed element should be disposed (default: false)
  63979. */
  63980. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63981. /**
  63982. * Rebuilds the elements related to this component in case of
  63983. * context lost for instance.
  63984. */
  63985. dispose(): void;
  63986. private _gatherRenderTargets;
  63987. }
  63988. }
  63989. declare module "babylonjs/Lights/Shadows/index" {
  63990. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63991. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63992. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63993. }
  63994. declare module "babylonjs/Lights/pointLight" {
  63995. import { Scene } from "babylonjs/scene";
  63996. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63998. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63999. import { Effect } from "babylonjs/Materials/effect";
  64000. /**
  64001. * A point light is a light defined by an unique point in world space.
  64002. * The light is emitted in every direction from this point.
  64003. * A good example of a point light is a standard light bulb.
  64004. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64005. */
  64006. export class PointLight extends ShadowLight {
  64007. private _shadowAngle;
  64008. /**
  64009. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64010. * This specifies what angle the shadow will use to be created.
  64011. *
  64012. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64013. */
  64014. get shadowAngle(): number;
  64015. /**
  64016. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64017. * This specifies what angle the shadow will use to be created.
  64018. *
  64019. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64020. */
  64021. set shadowAngle(value: number);
  64022. /**
  64023. * Gets the direction if it has been set.
  64024. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64025. */
  64026. get direction(): Vector3;
  64027. /**
  64028. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64029. */
  64030. set direction(value: Vector3);
  64031. /**
  64032. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64033. * A PointLight emits the light in every direction.
  64034. * It can cast shadows.
  64035. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64036. * ```javascript
  64037. * var pointLight = new PointLight("pl", camera.position, scene);
  64038. * ```
  64039. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64040. * @param name The light friendly name
  64041. * @param position The position of the point light in the scene
  64042. * @param scene The scene the lights belongs to
  64043. */
  64044. constructor(name: string, position: Vector3, scene: Scene);
  64045. /**
  64046. * Returns the string "PointLight"
  64047. * @returns the class name
  64048. */
  64049. getClassName(): string;
  64050. /**
  64051. * Returns the integer 0.
  64052. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64053. */
  64054. getTypeID(): number;
  64055. /**
  64056. * Specifies wether or not the shadowmap should be a cube texture.
  64057. * @returns true if the shadowmap needs to be a cube texture.
  64058. */
  64059. needCube(): boolean;
  64060. /**
  64061. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64062. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64063. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64064. */
  64065. getShadowDirection(faceIndex?: number): Vector3;
  64066. /**
  64067. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64068. * - fov = PI / 2
  64069. * - aspect ratio : 1.0
  64070. * - z-near and far equal to the active camera minZ and maxZ.
  64071. * Returns the PointLight.
  64072. */
  64073. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64074. protected _buildUniformLayout(): void;
  64075. /**
  64076. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64077. * @param effect The effect to update
  64078. * @param lightIndex The index of the light in the effect to update
  64079. * @returns The point light
  64080. */
  64081. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64082. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64083. /**
  64084. * Prepares the list of defines specific to the light type.
  64085. * @param defines the list of defines
  64086. * @param lightIndex defines the index of the light for the effect
  64087. */
  64088. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64089. }
  64090. }
  64091. declare module "babylonjs/Lights/index" {
  64092. export * from "babylonjs/Lights/light";
  64093. export * from "babylonjs/Lights/shadowLight";
  64094. export * from "babylonjs/Lights/Shadows/index";
  64095. export * from "babylonjs/Lights/directionalLight";
  64096. export * from "babylonjs/Lights/hemisphericLight";
  64097. export * from "babylonjs/Lights/pointLight";
  64098. export * from "babylonjs/Lights/spotLight";
  64099. }
  64100. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64101. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64102. /**
  64103. * Header information of HDR texture files.
  64104. */
  64105. export interface HDRInfo {
  64106. /**
  64107. * The height of the texture in pixels.
  64108. */
  64109. height: number;
  64110. /**
  64111. * The width of the texture in pixels.
  64112. */
  64113. width: number;
  64114. /**
  64115. * The index of the beginning of the data in the binary file.
  64116. */
  64117. dataPosition: number;
  64118. }
  64119. /**
  64120. * This groups tools to convert HDR texture to native colors array.
  64121. */
  64122. export class HDRTools {
  64123. private static Ldexp;
  64124. private static Rgbe2float;
  64125. private static readStringLine;
  64126. /**
  64127. * Reads header information from an RGBE texture stored in a native array.
  64128. * More information on this format are available here:
  64129. * https://en.wikipedia.org/wiki/RGBE_image_format
  64130. *
  64131. * @param uint8array The binary file stored in native array.
  64132. * @return The header information.
  64133. */
  64134. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64135. /**
  64136. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64137. * This RGBE texture needs to store the information as a panorama.
  64138. *
  64139. * More information on this format are available here:
  64140. * https://en.wikipedia.org/wiki/RGBE_image_format
  64141. *
  64142. * @param buffer The binary file stored in an array buffer.
  64143. * @param size The expected size of the extracted cubemap.
  64144. * @return The Cube Map information.
  64145. */
  64146. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64147. /**
  64148. * Returns the pixels data extracted from an RGBE texture.
  64149. * This pixels will be stored left to right up to down in the R G B order in one array.
  64150. *
  64151. * More information on this format are available here:
  64152. * https://en.wikipedia.org/wiki/RGBE_image_format
  64153. *
  64154. * @param uint8array The binary file stored in an array buffer.
  64155. * @param hdrInfo The header information of the file.
  64156. * @return The pixels data in RGB right to left up to down order.
  64157. */
  64158. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64159. private static RGBE_ReadPixels_RLE;
  64160. private static RGBE_ReadPixels_NOT_RLE;
  64161. }
  64162. }
  64163. declare module "babylonjs/Materials/effectRenderer" {
  64164. import { Nullable } from "babylonjs/types";
  64165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64167. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64168. import { Viewport } from "babylonjs/Maths/math.viewport";
  64169. import { Observable } from "babylonjs/Misc/observable";
  64170. import { Effect } from "babylonjs/Materials/effect";
  64171. import "babylonjs/Shaders/postprocess.vertex";
  64172. /**
  64173. * Effect Render Options
  64174. */
  64175. export interface IEffectRendererOptions {
  64176. /**
  64177. * Defines the vertices positions.
  64178. */
  64179. positions?: number[];
  64180. /**
  64181. * Defines the indices.
  64182. */
  64183. indices?: number[];
  64184. }
  64185. /**
  64186. * Helper class to render one or more effects.
  64187. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64188. */
  64189. export class EffectRenderer {
  64190. private engine;
  64191. private static _DefaultOptions;
  64192. private _vertexBuffers;
  64193. private _indexBuffer;
  64194. private _fullscreenViewport;
  64195. /**
  64196. * Creates an effect renderer
  64197. * @param engine the engine to use for rendering
  64198. * @param options defines the options of the effect renderer
  64199. */
  64200. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64201. /**
  64202. * Sets the current viewport in normalized coordinates 0-1
  64203. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64204. */
  64205. setViewport(viewport?: Viewport): void;
  64206. /**
  64207. * Binds the embedded attributes buffer to the effect.
  64208. * @param effect Defines the effect to bind the attributes for
  64209. */
  64210. bindBuffers(effect: Effect): void;
  64211. /**
  64212. * Sets the current effect wrapper to use during draw.
  64213. * The effect needs to be ready before calling this api.
  64214. * This also sets the default full screen position attribute.
  64215. * @param effectWrapper Defines the effect to draw with
  64216. */
  64217. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64218. /**
  64219. * Restores engine states
  64220. */
  64221. restoreStates(): void;
  64222. /**
  64223. * Draws a full screen quad.
  64224. */
  64225. draw(): void;
  64226. private isRenderTargetTexture;
  64227. /**
  64228. * renders one or more effects to a specified texture
  64229. * @param effectWrapper the effect to renderer
  64230. * @param outputTexture texture to draw to, if null it will render to the screen.
  64231. */
  64232. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64233. /**
  64234. * Disposes of the effect renderer
  64235. */
  64236. dispose(): void;
  64237. }
  64238. /**
  64239. * Options to create an EffectWrapper
  64240. */
  64241. interface EffectWrapperCreationOptions {
  64242. /**
  64243. * Engine to use to create the effect
  64244. */
  64245. engine: ThinEngine;
  64246. /**
  64247. * Fragment shader for the effect
  64248. */
  64249. fragmentShader: string;
  64250. /**
  64251. * Use the shader store instead of direct source code
  64252. */
  64253. useShaderStore?: boolean;
  64254. /**
  64255. * Vertex shader for the effect
  64256. */
  64257. vertexShader?: string;
  64258. /**
  64259. * Attributes to use in the shader
  64260. */
  64261. attributeNames?: Array<string>;
  64262. /**
  64263. * Uniforms to use in the shader
  64264. */
  64265. uniformNames?: Array<string>;
  64266. /**
  64267. * Texture sampler names to use in the shader
  64268. */
  64269. samplerNames?: Array<string>;
  64270. /**
  64271. * Defines to use in the shader
  64272. */
  64273. defines?: Array<string>;
  64274. /**
  64275. * Callback when effect is compiled
  64276. */
  64277. onCompiled?: Nullable<(effect: Effect) => void>;
  64278. /**
  64279. * The friendly name of the effect displayed in Spector.
  64280. */
  64281. name?: string;
  64282. }
  64283. /**
  64284. * Wraps an effect to be used for rendering
  64285. */
  64286. export class EffectWrapper {
  64287. /**
  64288. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64289. */
  64290. onApplyObservable: Observable<{}>;
  64291. /**
  64292. * The underlying effect
  64293. */
  64294. effect: Effect;
  64295. /**
  64296. * Creates an effect to be renderer
  64297. * @param creationOptions options to create the effect
  64298. */
  64299. constructor(creationOptions: EffectWrapperCreationOptions);
  64300. /**
  64301. * Disposes of the effect wrapper
  64302. */
  64303. dispose(): void;
  64304. }
  64305. }
  64306. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64307. /** @hidden */
  64308. export var hdrFilteringVertexShader: {
  64309. name: string;
  64310. shader: string;
  64311. };
  64312. }
  64313. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64314. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64315. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64316. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64317. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64318. /** @hidden */
  64319. export var hdrFilteringPixelShader: {
  64320. name: string;
  64321. shader: string;
  64322. };
  64323. }
  64324. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64326. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64327. import { Nullable } from "babylonjs/types";
  64328. import "babylonjs/Shaders/hdrFiltering.vertex";
  64329. import "babylonjs/Shaders/hdrFiltering.fragment";
  64330. /**
  64331. * Options for texture filtering
  64332. */
  64333. interface IHDRFilteringOptions {
  64334. /**
  64335. * Scales pixel intensity for the input HDR map.
  64336. */
  64337. hdrScale?: number;
  64338. /**
  64339. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64340. */
  64341. quality?: number;
  64342. }
  64343. /**
  64344. * Filters HDR maps to get correct renderings of PBR reflections
  64345. */
  64346. export class HDRFiltering {
  64347. private _engine;
  64348. private _effectRenderer;
  64349. private _effectWrapper;
  64350. private _lodGenerationOffset;
  64351. private _lodGenerationScale;
  64352. /**
  64353. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64354. * you care about baking speed.
  64355. */
  64356. quality: number;
  64357. /**
  64358. * Scales pixel intensity for the input HDR map.
  64359. */
  64360. hdrScale: number;
  64361. /**
  64362. * Instantiates HDR filter for reflection maps
  64363. *
  64364. * @param engine Thin engine
  64365. * @param options Options
  64366. */
  64367. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64368. private _createRenderTarget;
  64369. private _prefilterInternal;
  64370. private _createEffect;
  64371. /**
  64372. * Get a value indicating if the filter is ready to be used
  64373. * @param texture Texture to filter
  64374. * @returns true if the filter is ready
  64375. */
  64376. isReady(texture: BaseTexture): boolean;
  64377. /**
  64378. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64379. * Prefiltering will be invoked at the end of next rendering pass.
  64380. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64381. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64382. * @param texture Texture to filter
  64383. * @param onFinished Callback when filtering is done
  64384. * @return Promise called when prefiltering is done
  64385. */
  64386. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64387. }
  64388. }
  64389. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64390. import { Nullable } from "babylonjs/types";
  64391. import { Scene } from "babylonjs/scene";
  64392. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64394. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64395. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64396. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64397. /**
  64398. * This represents a texture coming from an HDR input.
  64399. *
  64400. * The only supported format is currently panorama picture stored in RGBE format.
  64401. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64402. */
  64403. export class HDRCubeTexture extends BaseTexture {
  64404. private static _facesMapping;
  64405. private _generateHarmonics;
  64406. private _noMipmap;
  64407. private _prefilterOnLoad;
  64408. private _textureMatrix;
  64409. private _size;
  64410. private _onLoad;
  64411. private _onError;
  64412. /**
  64413. * The texture URL.
  64414. */
  64415. url: string;
  64416. protected _isBlocking: boolean;
  64417. /**
  64418. * Sets wether or not the texture is blocking during loading.
  64419. */
  64420. set isBlocking(value: boolean);
  64421. /**
  64422. * Gets wether or not the texture is blocking during loading.
  64423. */
  64424. get isBlocking(): boolean;
  64425. protected _rotationY: number;
  64426. /**
  64427. * Sets texture matrix rotation angle around Y axis in radians.
  64428. */
  64429. set rotationY(value: number);
  64430. /**
  64431. * Gets texture matrix rotation angle around Y axis radians.
  64432. */
  64433. get rotationY(): number;
  64434. /**
  64435. * Gets or sets the center of the bounding box associated with the cube texture
  64436. * It must define where the camera used to render the texture was set
  64437. */
  64438. boundingBoxPosition: Vector3;
  64439. private _boundingBoxSize;
  64440. /**
  64441. * Gets or sets the size of the bounding box associated with the cube texture
  64442. * When defined, the cubemap will switch to local mode
  64443. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64444. * @example https://www.babylonjs-playground.com/#RNASML
  64445. */
  64446. set boundingBoxSize(value: Vector3);
  64447. get boundingBoxSize(): Vector3;
  64448. /**
  64449. * Instantiates an HDRTexture from the following parameters.
  64450. *
  64451. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64452. * @param sceneOrEngine The scene or engine the texture will be used in
  64453. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64454. * @param noMipmap Forces to not generate the mipmap if true
  64455. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64456. * @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)
  64457. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64458. */
  64459. 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>);
  64460. /**
  64461. * Get the current class name of the texture useful for serialization or dynamic coding.
  64462. * @returns "HDRCubeTexture"
  64463. */
  64464. getClassName(): string;
  64465. /**
  64466. * Occurs when the file is raw .hdr file.
  64467. */
  64468. private loadTexture;
  64469. clone(): HDRCubeTexture;
  64470. delayLoad(): void;
  64471. /**
  64472. * Get the texture reflection matrix used to rotate/transform the reflection.
  64473. * @returns the reflection matrix
  64474. */
  64475. getReflectionTextureMatrix(): Matrix;
  64476. /**
  64477. * Set the texture reflection matrix used to rotate/transform the reflection.
  64478. * @param value Define the reflection matrix to set
  64479. */
  64480. setReflectionTextureMatrix(value: Matrix): void;
  64481. /**
  64482. * Parses a JSON representation of an HDR Texture in order to create the texture
  64483. * @param parsedTexture Define the JSON representation
  64484. * @param scene Define the scene the texture should be created in
  64485. * @param rootUrl Define the root url in case we need to load relative dependencies
  64486. * @returns the newly created texture after parsing
  64487. */
  64488. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64489. serialize(): any;
  64490. }
  64491. }
  64492. declare module "babylonjs/Physics/physicsEngine" {
  64493. import { Nullable } from "babylonjs/types";
  64494. import { Vector3 } from "babylonjs/Maths/math.vector";
  64495. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64496. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64497. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64498. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64499. /**
  64500. * Class used to control physics engine
  64501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64502. */
  64503. export class PhysicsEngine implements IPhysicsEngine {
  64504. private _physicsPlugin;
  64505. /**
  64506. * Global value used to control the smallest number supported by the simulation
  64507. */
  64508. static Epsilon: number;
  64509. private _impostors;
  64510. private _joints;
  64511. private _subTimeStep;
  64512. /**
  64513. * Gets the gravity vector used by the simulation
  64514. */
  64515. gravity: Vector3;
  64516. /**
  64517. * Factory used to create the default physics plugin.
  64518. * @returns The default physics plugin
  64519. */
  64520. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64521. /**
  64522. * Creates a new Physics Engine
  64523. * @param gravity defines the gravity vector used by the simulation
  64524. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64525. */
  64526. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64527. /**
  64528. * Sets the gravity vector used by the simulation
  64529. * @param gravity defines the gravity vector to use
  64530. */
  64531. setGravity(gravity: Vector3): void;
  64532. /**
  64533. * Set the time step of the physics engine.
  64534. * Default is 1/60.
  64535. * To slow it down, enter 1/600 for example.
  64536. * To speed it up, 1/30
  64537. * @param newTimeStep defines the new timestep to apply to this world.
  64538. */
  64539. setTimeStep(newTimeStep?: number): void;
  64540. /**
  64541. * Get the time step of the physics engine.
  64542. * @returns the current time step
  64543. */
  64544. getTimeStep(): number;
  64545. /**
  64546. * Set the sub time step of the physics engine.
  64547. * Default is 0 meaning there is no sub steps
  64548. * To increase physics resolution precision, set a small value (like 1 ms)
  64549. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64550. */
  64551. setSubTimeStep(subTimeStep?: number): void;
  64552. /**
  64553. * Get the sub time step of the physics engine.
  64554. * @returns the current sub time step
  64555. */
  64556. getSubTimeStep(): number;
  64557. /**
  64558. * Release all resources
  64559. */
  64560. dispose(): void;
  64561. /**
  64562. * Gets the name of the current physics plugin
  64563. * @returns the name of the plugin
  64564. */
  64565. getPhysicsPluginName(): string;
  64566. /**
  64567. * Adding a new impostor for the impostor tracking.
  64568. * This will be done by the impostor itself.
  64569. * @param impostor the impostor to add
  64570. */
  64571. addImpostor(impostor: PhysicsImpostor): void;
  64572. /**
  64573. * Remove an impostor from the engine.
  64574. * This impostor and its mesh will not longer be updated by the physics engine.
  64575. * @param impostor the impostor to remove
  64576. */
  64577. removeImpostor(impostor: PhysicsImpostor): void;
  64578. /**
  64579. * Add a joint to the physics engine
  64580. * @param mainImpostor defines the main impostor to which the joint is added.
  64581. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64582. * @param joint defines the joint that will connect both impostors.
  64583. */
  64584. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64585. /**
  64586. * Removes a joint from the simulation
  64587. * @param mainImpostor defines the impostor used with the joint
  64588. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64589. * @param joint defines the joint to remove
  64590. */
  64591. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64592. /**
  64593. * Called by the scene. No need to call it.
  64594. * @param delta defines the timespam between frames
  64595. */
  64596. _step(delta: number): void;
  64597. /**
  64598. * Gets the current plugin used to run the simulation
  64599. * @returns current plugin
  64600. */
  64601. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64602. /**
  64603. * Gets the list of physic impostors
  64604. * @returns an array of PhysicsImpostor
  64605. */
  64606. getImpostors(): Array<PhysicsImpostor>;
  64607. /**
  64608. * Gets the impostor for a physics enabled object
  64609. * @param object defines the object impersonated by the impostor
  64610. * @returns the PhysicsImpostor or null if not found
  64611. */
  64612. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64613. /**
  64614. * Gets the impostor for a physics body object
  64615. * @param body defines physics body used by the impostor
  64616. * @returns the PhysicsImpostor or null if not found
  64617. */
  64618. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64619. /**
  64620. * Does a raycast in the physics world
  64621. * @param from when should the ray start?
  64622. * @param to when should the ray end?
  64623. * @returns PhysicsRaycastResult
  64624. */
  64625. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64626. }
  64627. }
  64628. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64629. import { Nullable } from "babylonjs/types";
  64630. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64632. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64633. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64634. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64635. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64636. /** @hidden */
  64637. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64638. private _useDeltaForWorldStep;
  64639. world: any;
  64640. name: string;
  64641. private _physicsMaterials;
  64642. private _fixedTimeStep;
  64643. private _cannonRaycastResult;
  64644. private _raycastResult;
  64645. private _physicsBodysToRemoveAfterStep;
  64646. private _firstFrame;
  64647. BJSCANNON: any;
  64648. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64649. setGravity(gravity: Vector3): void;
  64650. setTimeStep(timeStep: number): void;
  64651. getTimeStep(): number;
  64652. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64653. private _removeMarkedPhysicsBodiesFromWorld;
  64654. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64655. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64656. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64657. private _processChildMeshes;
  64658. removePhysicsBody(impostor: PhysicsImpostor): void;
  64659. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64660. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64661. private _addMaterial;
  64662. private _checkWithEpsilon;
  64663. private _createShape;
  64664. private _createHeightmap;
  64665. private _minus90X;
  64666. private _plus90X;
  64667. private _tmpPosition;
  64668. private _tmpDeltaPosition;
  64669. private _tmpUnityRotation;
  64670. private _updatePhysicsBodyTransformation;
  64671. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64672. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64673. isSupported(): boolean;
  64674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64675. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64676. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64677. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64678. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64679. getBodyMass(impostor: PhysicsImpostor): number;
  64680. getBodyFriction(impostor: PhysicsImpostor): number;
  64681. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64682. getBodyRestitution(impostor: PhysicsImpostor): number;
  64683. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64684. sleepBody(impostor: PhysicsImpostor): void;
  64685. wakeUpBody(impostor: PhysicsImpostor): void;
  64686. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64687. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64688. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64689. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64690. getRadius(impostor: PhysicsImpostor): number;
  64691. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64692. dispose(): void;
  64693. private _extendNamespace;
  64694. /**
  64695. * Does a raycast in the physics world
  64696. * @param from when should the ray start?
  64697. * @param to when should the ray end?
  64698. * @returns PhysicsRaycastResult
  64699. */
  64700. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64701. }
  64702. }
  64703. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64704. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64705. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64706. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64708. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64709. import { Nullable } from "babylonjs/types";
  64710. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64711. /** @hidden */
  64712. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64713. private _useDeltaForWorldStep;
  64714. world: any;
  64715. name: string;
  64716. BJSOIMO: any;
  64717. private _raycastResult;
  64718. private _fixedTimeStep;
  64719. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64720. setGravity(gravity: Vector3): void;
  64721. setTimeStep(timeStep: number): void;
  64722. getTimeStep(): number;
  64723. private _tmpImpostorsArray;
  64724. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64725. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64726. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64727. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64728. private _tmpPositionVector;
  64729. removePhysicsBody(impostor: PhysicsImpostor): void;
  64730. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64731. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64732. isSupported(): boolean;
  64733. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64734. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64735. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64736. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64737. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64738. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64739. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64740. getBodyMass(impostor: PhysicsImpostor): number;
  64741. getBodyFriction(impostor: PhysicsImpostor): number;
  64742. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64743. getBodyRestitution(impostor: PhysicsImpostor): number;
  64744. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64745. sleepBody(impostor: PhysicsImpostor): void;
  64746. wakeUpBody(impostor: PhysicsImpostor): void;
  64747. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64748. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64749. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64750. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64751. getRadius(impostor: PhysicsImpostor): number;
  64752. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64753. dispose(): void;
  64754. /**
  64755. * Does a raycast in the physics world
  64756. * @param from when should the ray start?
  64757. * @param to when should the ray end?
  64758. * @returns PhysicsRaycastResult
  64759. */
  64760. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64761. }
  64762. }
  64763. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64764. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64765. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64766. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64767. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64768. import { Nullable } from "babylonjs/types";
  64769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64770. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64771. /**
  64772. * AmmoJS Physics plugin
  64773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64774. * @see https://github.com/kripken/ammo.js/
  64775. */
  64776. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64777. private _useDeltaForWorldStep;
  64778. /**
  64779. * Reference to the Ammo library
  64780. */
  64781. bjsAMMO: any;
  64782. /**
  64783. * Created ammoJS world which physics bodies are added to
  64784. */
  64785. world: any;
  64786. /**
  64787. * Name of the plugin
  64788. */
  64789. name: string;
  64790. private _timeStep;
  64791. private _fixedTimeStep;
  64792. private _maxSteps;
  64793. private _tmpQuaternion;
  64794. private _tmpAmmoTransform;
  64795. private _tmpAmmoQuaternion;
  64796. private _tmpAmmoConcreteContactResultCallback;
  64797. private _collisionConfiguration;
  64798. private _dispatcher;
  64799. private _overlappingPairCache;
  64800. private _solver;
  64801. private _softBodySolver;
  64802. private _tmpAmmoVectorA;
  64803. private _tmpAmmoVectorB;
  64804. private _tmpAmmoVectorC;
  64805. private _tmpAmmoVectorD;
  64806. private _tmpContactCallbackResult;
  64807. private _tmpAmmoVectorRCA;
  64808. private _tmpAmmoVectorRCB;
  64809. private _raycastResult;
  64810. private _tmpContactPoint;
  64811. private static readonly DISABLE_COLLISION_FLAG;
  64812. private static readonly KINEMATIC_FLAG;
  64813. private static readonly DISABLE_DEACTIVATION_FLAG;
  64814. /**
  64815. * Initializes the ammoJS plugin
  64816. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64817. * @param ammoInjection can be used to inject your own ammo reference
  64818. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64819. */
  64820. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64821. /**
  64822. * Sets the gravity of the physics world (m/(s^2))
  64823. * @param gravity Gravity to set
  64824. */
  64825. setGravity(gravity: Vector3): void;
  64826. /**
  64827. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64828. * @param timeStep timestep to use in seconds
  64829. */
  64830. setTimeStep(timeStep: number): void;
  64831. /**
  64832. * 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)
  64833. * @param fixedTimeStep fixedTimeStep to use in seconds
  64834. */
  64835. setFixedTimeStep(fixedTimeStep: number): void;
  64836. /**
  64837. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64838. * @param maxSteps the maximum number of steps by the physics engine per frame
  64839. */
  64840. setMaxSteps(maxSteps: number): void;
  64841. /**
  64842. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64843. * @returns the current timestep in seconds
  64844. */
  64845. getTimeStep(): number;
  64846. /**
  64847. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64848. */
  64849. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64850. private _isImpostorInContact;
  64851. private _isImpostorPairInContact;
  64852. private _stepSimulation;
  64853. /**
  64854. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64855. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64856. * After the step the babylon meshes are set to the position of the physics imposters
  64857. * @param delta amount of time to step forward
  64858. * @param impostors array of imposters to update before/after the step
  64859. */
  64860. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64861. /**
  64862. * Update babylon mesh to match physics world object
  64863. * @param impostor imposter to match
  64864. */
  64865. private _afterSoftStep;
  64866. /**
  64867. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64868. * @param impostor imposter to match
  64869. */
  64870. private _ropeStep;
  64871. /**
  64872. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64873. * @param impostor imposter to match
  64874. */
  64875. private _softbodyOrClothStep;
  64876. private _tmpMatrix;
  64877. /**
  64878. * Applies an impulse on the imposter
  64879. * @param impostor imposter to apply impulse to
  64880. * @param force amount of force to be applied to the imposter
  64881. * @param contactPoint the location to apply the impulse on the imposter
  64882. */
  64883. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64884. /**
  64885. * Applies a force on the imposter
  64886. * @param impostor imposter to apply force
  64887. * @param force amount of force to be applied to the imposter
  64888. * @param contactPoint the location to apply the force on the imposter
  64889. */
  64890. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64891. /**
  64892. * Creates a physics body using the plugin
  64893. * @param impostor the imposter to create the physics body on
  64894. */
  64895. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64896. /**
  64897. * Removes the physics body from the imposter and disposes of the body's memory
  64898. * @param impostor imposter to remove the physics body from
  64899. */
  64900. removePhysicsBody(impostor: PhysicsImpostor): void;
  64901. /**
  64902. * Generates a joint
  64903. * @param impostorJoint the imposter joint to create the joint with
  64904. */
  64905. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64906. /**
  64907. * Removes a joint
  64908. * @param impostorJoint the imposter joint to remove the joint from
  64909. */
  64910. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64911. private _addMeshVerts;
  64912. /**
  64913. * Initialise the soft body vertices to match its object's (mesh) vertices
  64914. * Softbody vertices (nodes) are in world space and to match this
  64915. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64916. * @param impostor to create the softbody for
  64917. */
  64918. private _softVertexData;
  64919. /**
  64920. * Create an impostor's soft body
  64921. * @param impostor to create the softbody for
  64922. */
  64923. private _createSoftbody;
  64924. /**
  64925. * Create cloth for an impostor
  64926. * @param impostor to create the softbody for
  64927. */
  64928. private _createCloth;
  64929. /**
  64930. * Create rope for an impostor
  64931. * @param impostor to create the softbody for
  64932. */
  64933. private _createRope;
  64934. /**
  64935. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64936. * @param impostor to create the custom physics shape for
  64937. */
  64938. private _createCustom;
  64939. private _addHullVerts;
  64940. private _createShape;
  64941. /**
  64942. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64943. * @param impostor imposter containing the physics body and babylon object
  64944. */
  64945. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64946. /**
  64947. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64948. * @param impostor imposter containing the physics body and babylon object
  64949. * @param newPosition new position
  64950. * @param newRotation new rotation
  64951. */
  64952. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64953. /**
  64954. * If this plugin is supported
  64955. * @returns true if its supported
  64956. */
  64957. isSupported(): boolean;
  64958. /**
  64959. * Sets the linear velocity of the physics body
  64960. * @param impostor imposter to set the velocity on
  64961. * @param velocity velocity to set
  64962. */
  64963. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64964. /**
  64965. * Sets the angular velocity of the physics body
  64966. * @param impostor imposter to set the velocity on
  64967. * @param velocity velocity to set
  64968. */
  64969. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64970. /**
  64971. * gets the linear velocity
  64972. * @param impostor imposter to get linear velocity from
  64973. * @returns linear velocity
  64974. */
  64975. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64976. /**
  64977. * gets the angular velocity
  64978. * @param impostor imposter to get angular velocity from
  64979. * @returns angular velocity
  64980. */
  64981. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64982. /**
  64983. * Sets the mass of physics body
  64984. * @param impostor imposter to set the mass on
  64985. * @param mass mass to set
  64986. */
  64987. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64988. /**
  64989. * Gets the mass of the physics body
  64990. * @param impostor imposter to get the mass from
  64991. * @returns mass
  64992. */
  64993. getBodyMass(impostor: PhysicsImpostor): number;
  64994. /**
  64995. * Gets friction of the impostor
  64996. * @param impostor impostor to get friction from
  64997. * @returns friction value
  64998. */
  64999. getBodyFriction(impostor: PhysicsImpostor): number;
  65000. /**
  65001. * Sets friction of the impostor
  65002. * @param impostor impostor to set friction on
  65003. * @param friction friction value
  65004. */
  65005. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65006. /**
  65007. * Gets restitution of the impostor
  65008. * @param impostor impostor to get restitution from
  65009. * @returns restitution value
  65010. */
  65011. getBodyRestitution(impostor: PhysicsImpostor): number;
  65012. /**
  65013. * Sets resitution of the impostor
  65014. * @param impostor impostor to set resitution on
  65015. * @param restitution resitution value
  65016. */
  65017. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65018. /**
  65019. * Gets pressure inside the impostor
  65020. * @param impostor impostor to get pressure from
  65021. * @returns pressure value
  65022. */
  65023. getBodyPressure(impostor: PhysicsImpostor): number;
  65024. /**
  65025. * Sets pressure inside a soft body impostor
  65026. * Cloth and rope must remain 0 pressure
  65027. * @param impostor impostor to set pressure on
  65028. * @param pressure pressure value
  65029. */
  65030. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65031. /**
  65032. * Gets stiffness of the impostor
  65033. * @param impostor impostor to get stiffness from
  65034. * @returns pressure value
  65035. */
  65036. getBodyStiffness(impostor: PhysicsImpostor): number;
  65037. /**
  65038. * Sets stiffness of the impostor
  65039. * @param impostor impostor to set stiffness on
  65040. * @param stiffness stiffness value from 0 to 1
  65041. */
  65042. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65043. /**
  65044. * Gets velocityIterations of the impostor
  65045. * @param impostor impostor to get velocity iterations from
  65046. * @returns velocityIterations value
  65047. */
  65048. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65049. /**
  65050. * Sets velocityIterations of the impostor
  65051. * @param impostor impostor to set velocity iterations on
  65052. * @param velocityIterations velocityIterations value
  65053. */
  65054. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65055. /**
  65056. * Gets positionIterations of the impostor
  65057. * @param impostor impostor to get position iterations from
  65058. * @returns positionIterations value
  65059. */
  65060. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65061. /**
  65062. * Sets positionIterations of the impostor
  65063. * @param impostor impostor to set position on
  65064. * @param positionIterations positionIterations value
  65065. */
  65066. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65067. /**
  65068. * Append an anchor to a cloth object
  65069. * @param impostor is the cloth impostor to add anchor to
  65070. * @param otherImpostor is the rigid impostor to anchor to
  65071. * @param width ratio across width from 0 to 1
  65072. * @param height ratio up height from 0 to 1
  65073. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65074. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65075. */
  65076. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65077. /**
  65078. * Append an hook to a rope object
  65079. * @param impostor is the rope impostor to add hook to
  65080. * @param otherImpostor is the rigid impostor to hook to
  65081. * @param length ratio along the rope from 0 to 1
  65082. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65083. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65084. */
  65085. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65086. /**
  65087. * Sleeps the physics body and stops it from being active
  65088. * @param impostor impostor to sleep
  65089. */
  65090. sleepBody(impostor: PhysicsImpostor): void;
  65091. /**
  65092. * Activates the physics body
  65093. * @param impostor impostor to activate
  65094. */
  65095. wakeUpBody(impostor: PhysicsImpostor): void;
  65096. /**
  65097. * Updates the distance parameters of the joint
  65098. * @param joint joint to update
  65099. * @param maxDistance maximum distance of the joint
  65100. * @param minDistance minimum distance of the joint
  65101. */
  65102. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65103. /**
  65104. * Sets a motor on the joint
  65105. * @param joint joint to set motor on
  65106. * @param speed speed of the motor
  65107. * @param maxForce maximum force of the motor
  65108. * @param motorIndex index of the motor
  65109. */
  65110. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65111. /**
  65112. * Sets the motors limit
  65113. * @param joint joint to set limit on
  65114. * @param upperLimit upper limit
  65115. * @param lowerLimit lower limit
  65116. */
  65117. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65118. /**
  65119. * Syncs the position and rotation of a mesh with the impostor
  65120. * @param mesh mesh to sync
  65121. * @param impostor impostor to update the mesh with
  65122. */
  65123. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65124. /**
  65125. * Gets the radius of the impostor
  65126. * @param impostor impostor to get radius from
  65127. * @returns the radius
  65128. */
  65129. getRadius(impostor: PhysicsImpostor): number;
  65130. /**
  65131. * Gets the box size of the impostor
  65132. * @param impostor impostor to get box size from
  65133. * @param result the resulting box size
  65134. */
  65135. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65136. /**
  65137. * Disposes of the impostor
  65138. */
  65139. dispose(): void;
  65140. /**
  65141. * Does a raycast in the physics world
  65142. * @param from when should the ray start?
  65143. * @param to when should the ray end?
  65144. * @returns PhysicsRaycastResult
  65145. */
  65146. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65147. }
  65148. }
  65149. declare module "babylonjs/Probes/reflectionProbe" {
  65150. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65151. import { Vector3 } from "babylonjs/Maths/math.vector";
  65152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65153. import { Nullable } from "babylonjs/types";
  65154. import { Scene } from "babylonjs/scene";
  65155. module "babylonjs/abstractScene" {
  65156. interface AbstractScene {
  65157. /**
  65158. * The list of reflection probes added to the scene
  65159. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65160. */
  65161. reflectionProbes: Array<ReflectionProbe>;
  65162. /**
  65163. * Removes the given reflection probe from this scene.
  65164. * @param toRemove The reflection probe to remove
  65165. * @returns The index of the removed reflection probe
  65166. */
  65167. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65168. /**
  65169. * Adds the given reflection probe to this scene.
  65170. * @param newReflectionProbe The reflection probe to add
  65171. */
  65172. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65173. }
  65174. }
  65175. /**
  65176. * Class used to generate realtime reflection / refraction cube textures
  65177. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65178. */
  65179. export class ReflectionProbe {
  65180. /** defines the name of the probe */
  65181. name: string;
  65182. private _scene;
  65183. private _renderTargetTexture;
  65184. private _projectionMatrix;
  65185. private _viewMatrix;
  65186. private _target;
  65187. private _add;
  65188. private _attachedMesh;
  65189. private _invertYAxis;
  65190. /** Gets or sets probe position (center of the cube map) */
  65191. position: Vector3;
  65192. /**
  65193. * Creates a new reflection probe
  65194. * @param name defines the name of the probe
  65195. * @param size defines the texture resolution (for each face)
  65196. * @param scene defines the hosting scene
  65197. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65198. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65199. */
  65200. constructor(
  65201. /** defines the name of the probe */
  65202. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65203. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65204. get samples(): number;
  65205. set samples(value: number);
  65206. /** Gets or sets the refresh rate to use (on every frame by default) */
  65207. get refreshRate(): number;
  65208. set refreshRate(value: number);
  65209. /**
  65210. * Gets the hosting scene
  65211. * @returns a Scene
  65212. */
  65213. getScene(): Scene;
  65214. /** Gets the internal CubeTexture used to render to */
  65215. get cubeTexture(): RenderTargetTexture;
  65216. /** Gets the list of meshes to render */
  65217. get renderList(): Nullable<AbstractMesh[]>;
  65218. /**
  65219. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65220. * @param mesh defines the mesh to attach to
  65221. */
  65222. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65223. /**
  65224. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65225. * @param renderingGroupId The rendering group id corresponding to its index
  65226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65227. */
  65228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65229. /**
  65230. * Clean all associated resources
  65231. */
  65232. dispose(): void;
  65233. /**
  65234. * Converts the reflection probe information to a readable string for debug purpose.
  65235. * @param fullDetails Supports for multiple levels of logging within scene loading
  65236. * @returns the human readable reflection probe info
  65237. */
  65238. toString(fullDetails?: boolean): string;
  65239. /**
  65240. * Get the class name of the relfection probe.
  65241. * @returns "ReflectionProbe"
  65242. */
  65243. getClassName(): string;
  65244. /**
  65245. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65246. * @returns The JSON representation of the texture
  65247. */
  65248. serialize(): any;
  65249. /**
  65250. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65251. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65252. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65253. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65254. * @returns The parsed reflection probe if successful
  65255. */
  65256. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65257. }
  65258. }
  65259. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65260. /** @hidden */
  65261. export var _BabylonLoaderRegistered: boolean;
  65262. /**
  65263. * Helps setting up some configuration for the babylon file loader.
  65264. */
  65265. export class BabylonFileLoaderConfiguration {
  65266. /**
  65267. * The loader does not allow injecting custom physix engine into the plugins.
  65268. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65269. * So you could set this variable to your engine import to make it work.
  65270. */
  65271. static LoaderInjectedPhysicsEngine: any;
  65272. }
  65273. }
  65274. declare module "babylonjs/Loading/Plugins/index" {
  65275. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65276. }
  65277. declare module "babylonjs/Loading/index" {
  65278. export * from "babylonjs/Loading/loadingScreen";
  65279. export * from "babylonjs/Loading/Plugins/index";
  65280. export * from "babylonjs/Loading/sceneLoader";
  65281. export * from "babylonjs/Loading/sceneLoaderFlags";
  65282. }
  65283. declare module "babylonjs/Materials/Background/index" {
  65284. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65285. }
  65286. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65287. import { Scene } from "babylonjs/scene";
  65288. import { Color3 } from "babylonjs/Maths/math.color";
  65289. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65291. /**
  65292. * The Physically based simple base material of BJS.
  65293. *
  65294. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65295. * It is used as the base class for both the specGloss and metalRough conventions.
  65296. */
  65297. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65298. /**
  65299. * Number of Simultaneous lights allowed on the material.
  65300. */
  65301. maxSimultaneousLights: number;
  65302. /**
  65303. * If sets to true, disables all the lights affecting the material.
  65304. */
  65305. disableLighting: boolean;
  65306. /**
  65307. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65308. */
  65309. environmentTexture: BaseTexture;
  65310. /**
  65311. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65312. */
  65313. invertNormalMapX: boolean;
  65314. /**
  65315. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65316. */
  65317. invertNormalMapY: boolean;
  65318. /**
  65319. * Normal map used in the model.
  65320. */
  65321. normalTexture: BaseTexture;
  65322. /**
  65323. * Emissivie color used to self-illuminate the model.
  65324. */
  65325. emissiveColor: Color3;
  65326. /**
  65327. * Emissivie texture used to self-illuminate the model.
  65328. */
  65329. emissiveTexture: BaseTexture;
  65330. /**
  65331. * Occlusion Channel Strenght.
  65332. */
  65333. occlusionStrength: number;
  65334. /**
  65335. * Occlusion Texture of the material (adding extra occlusion effects).
  65336. */
  65337. occlusionTexture: BaseTexture;
  65338. /**
  65339. * Defines the alpha limits in alpha test mode.
  65340. */
  65341. alphaCutOff: number;
  65342. /**
  65343. * Gets the current double sided mode.
  65344. */
  65345. get doubleSided(): boolean;
  65346. /**
  65347. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65348. */
  65349. set doubleSided(value: boolean);
  65350. /**
  65351. * Stores the pre-calculated light information of a mesh in a texture.
  65352. */
  65353. lightmapTexture: BaseTexture;
  65354. /**
  65355. * If true, the light map contains occlusion information instead of lighting info.
  65356. */
  65357. useLightmapAsShadowmap: boolean;
  65358. /**
  65359. * Instantiates a new PBRMaterial instance.
  65360. *
  65361. * @param name The material name
  65362. * @param scene The scene the material will be use in.
  65363. */
  65364. constructor(name: string, scene: Scene);
  65365. getClassName(): string;
  65366. }
  65367. }
  65368. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65369. import { Scene } from "babylonjs/scene";
  65370. import { Color3 } from "babylonjs/Maths/math.color";
  65371. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65372. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65373. /**
  65374. * The PBR material of BJS following the metal roughness convention.
  65375. *
  65376. * This fits to the PBR convention in the GLTF definition:
  65377. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65378. */
  65379. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65380. /**
  65381. * The base color has two different interpretations depending on the value of metalness.
  65382. * When the material is a metal, the base color is the specific measured reflectance value
  65383. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65384. * of the material.
  65385. */
  65386. baseColor: Color3;
  65387. /**
  65388. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65389. * well as opacity information in the alpha channel.
  65390. */
  65391. baseTexture: BaseTexture;
  65392. /**
  65393. * Specifies the metallic scalar value of the material.
  65394. * Can also be used to scale the metalness values of the metallic texture.
  65395. */
  65396. metallic: number;
  65397. /**
  65398. * Specifies the roughness scalar value of the material.
  65399. * Can also be used to scale the roughness values of the metallic texture.
  65400. */
  65401. roughness: number;
  65402. /**
  65403. * Texture containing both the metallic value in the B channel and the
  65404. * roughness value in the G channel to keep better precision.
  65405. */
  65406. metallicRoughnessTexture: BaseTexture;
  65407. /**
  65408. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65409. *
  65410. * @param name The material name
  65411. * @param scene The scene the material will be use in.
  65412. */
  65413. constructor(name: string, scene: Scene);
  65414. /**
  65415. * Return the currrent class name of the material.
  65416. */
  65417. getClassName(): string;
  65418. /**
  65419. * Makes a duplicate of the current material.
  65420. * @param name - name to use for the new material.
  65421. */
  65422. clone(name: string): PBRMetallicRoughnessMaterial;
  65423. /**
  65424. * Serialize the material to a parsable JSON object.
  65425. */
  65426. serialize(): any;
  65427. /**
  65428. * Parses a JSON object correponding to the serialize function.
  65429. */
  65430. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65431. }
  65432. }
  65433. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65434. import { Scene } from "babylonjs/scene";
  65435. import { Color3 } from "babylonjs/Maths/math.color";
  65436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65437. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65438. /**
  65439. * The PBR material of BJS following the specular glossiness convention.
  65440. *
  65441. * This fits to the PBR convention in the GLTF definition:
  65442. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65443. */
  65444. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65445. /**
  65446. * Specifies the diffuse color of the material.
  65447. */
  65448. diffuseColor: Color3;
  65449. /**
  65450. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65451. * channel.
  65452. */
  65453. diffuseTexture: BaseTexture;
  65454. /**
  65455. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65456. */
  65457. specularColor: Color3;
  65458. /**
  65459. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65460. */
  65461. glossiness: number;
  65462. /**
  65463. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65464. */
  65465. specularGlossinessTexture: BaseTexture;
  65466. /**
  65467. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65468. *
  65469. * @param name The material name
  65470. * @param scene The scene the material will be use in.
  65471. */
  65472. constructor(name: string, scene: Scene);
  65473. /**
  65474. * Return the currrent class name of the material.
  65475. */
  65476. getClassName(): string;
  65477. /**
  65478. * Makes a duplicate of the current material.
  65479. * @param name - name to use for the new material.
  65480. */
  65481. clone(name: string): PBRSpecularGlossinessMaterial;
  65482. /**
  65483. * Serialize the material to a parsable JSON object.
  65484. */
  65485. serialize(): any;
  65486. /**
  65487. * Parses a JSON object correponding to the serialize function.
  65488. */
  65489. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65490. }
  65491. }
  65492. declare module "babylonjs/Materials/PBR/index" {
  65493. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65494. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65495. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65496. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65497. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65498. }
  65499. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65500. import { Nullable } from "babylonjs/types";
  65501. import { Scene } from "babylonjs/scene";
  65502. import { Matrix } from "babylonjs/Maths/math.vector";
  65503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65504. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65505. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65506. /**
  65507. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65508. * It can help converting any input color in a desired output one. This can then be used to create effects
  65509. * from sepia, black and white to sixties or futuristic rendering...
  65510. *
  65511. * The only supported format is currently 3dl.
  65512. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65513. */
  65514. export class ColorGradingTexture extends BaseTexture {
  65515. /**
  65516. * The texture URL.
  65517. */
  65518. url: string;
  65519. /**
  65520. * Empty line regex stored for GC.
  65521. */
  65522. private static _noneEmptyLineRegex;
  65523. private _textureMatrix;
  65524. private _onLoad;
  65525. /**
  65526. * Instantiates a ColorGradingTexture from the following parameters.
  65527. *
  65528. * @param url The location of the color gradind data (currently only supporting 3dl)
  65529. * @param sceneOrEngine The scene or engine the texture will be used in
  65530. * @param onLoad defines a callback triggered when the texture has been loaded
  65531. */
  65532. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65533. /**
  65534. * Fires the onload event from the constructor if requested.
  65535. */
  65536. private _triggerOnLoad;
  65537. /**
  65538. * Returns the texture matrix used in most of the material.
  65539. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65540. */
  65541. getTextureMatrix(): Matrix;
  65542. /**
  65543. * Occurs when the file being loaded is a .3dl LUT file.
  65544. */
  65545. private load3dlTexture;
  65546. /**
  65547. * Starts the loading process of the texture.
  65548. */
  65549. private loadTexture;
  65550. /**
  65551. * Clones the color gradind texture.
  65552. */
  65553. clone(): ColorGradingTexture;
  65554. /**
  65555. * Called during delayed load for textures.
  65556. */
  65557. delayLoad(): void;
  65558. /**
  65559. * Parses a color grading texture serialized by Babylon.
  65560. * @param parsedTexture The texture information being parsedTexture
  65561. * @param scene The scene to load the texture in
  65562. * @param rootUrl The root url of the data assets to load
  65563. * @return A color gradind texture
  65564. */
  65565. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65566. /**
  65567. * Serializes the LUT texture to json format.
  65568. */
  65569. serialize(): any;
  65570. }
  65571. }
  65572. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65574. import { Scene } from "babylonjs/scene";
  65575. import { Nullable } from "babylonjs/types";
  65576. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65577. /**
  65578. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65579. */
  65580. export class EquiRectangularCubeTexture extends BaseTexture {
  65581. /** The six faces of the cube. */
  65582. private static _FacesMapping;
  65583. private _noMipmap;
  65584. private _onLoad;
  65585. private _onError;
  65586. /** The size of the cubemap. */
  65587. private _size;
  65588. /** The buffer of the image. */
  65589. private _buffer;
  65590. /** The width of the input image. */
  65591. private _width;
  65592. /** The height of the input image. */
  65593. private _height;
  65594. /** The URL to the image. */
  65595. url: string;
  65596. /**
  65597. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65598. * @param url The location of the image
  65599. * @param scene The scene the texture will be used in
  65600. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65601. * @param noMipmap Forces to not generate the mipmap if true
  65602. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65603. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65604. * @param onLoad — defines a callback called when texture is loaded
  65605. * @param onError — defines a callback called if there is an error
  65606. */
  65607. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65608. /**
  65609. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65610. */
  65611. private loadImage;
  65612. /**
  65613. * Convert the image buffer into a cubemap and create a CubeTexture.
  65614. */
  65615. private loadTexture;
  65616. /**
  65617. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65618. * @param buffer The ArrayBuffer that should be converted.
  65619. * @returns The buffer as Float32Array.
  65620. */
  65621. private getFloat32ArrayFromArrayBuffer;
  65622. /**
  65623. * Get the current class name of the texture useful for serialization or dynamic coding.
  65624. * @returns "EquiRectangularCubeTexture"
  65625. */
  65626. getClassName(): string;
  65627. /**
  65628. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65629. * @returns A clone of the current EquiRectangularCubeTexture.
  65630. */
  65631. clone(): EquiRectangularCubeTexture;
  65632. }
  65633. }
  65634. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65635. import { Nullable } from "babylonjs/types";
  65636. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65637. import { Matrix } from "babylonjs/Maths/math.vector";
  65638. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65639. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65640. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65641. import { Scene } from "babylonjs/scene";
  65642. /**
  65643. * Defines the options related to the creation of an HtmlElementTexture
  65644. */
  65645. export interface IHtmlElementTextureOptions {
  65646. /**
  65647. * Defines wether mip maps should be created or not.
  65648. */
  65649. generateMipMaps?: boolean;
  65650. /**
  65651. * Defines the sampling mode of the texture.
  65652. */
  65653. samplingMode?: number;
  65654. /**
  65655. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65656. */
  65657. engine: Nullable<ThinEngine>;
  65658. /**
  65659. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65660. */
  65661. scene: Nullable<Scene>;
  65662. }
  65663. /**
  65664. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65665. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65666. * is automatically managed.
  65667. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65668. * in your application.
  65669. *
  65670. * As the update is not automatic, you need to call them manually.
  65671. */
  65672. export class HtmlElementTexture extends BaseTexture {
  65673. /**
  65674. * The texture URL.
  65675. */
  65676. element: HTMLVideoElement | HTMLCanvasElement;
  65677. private static readonly DefaultOptions;
  65678. private _textureMatrix;
  65679. private _isVideo;
  65680. private _generateMipMaps;
  65681. private _samplingMode;
  65682. /**
  65683. * Instantiates a HtmlElementTexture from the following parameters.
  65684. *
  65685. * @param name Defines the name of the texture
  65686. * @param element Defines the video or canvas the texture is filled with
  65687. * @param options Defines the other none mandatory texture creation options
  65688. */
  65689. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65690. private _createInternalTexture;
  65691. /**
  65692. * Returns the texture matrix used in most of the material.
  65693. */
  65694. getTextureMatrix(): Matrix;
  65695. /**
  65696. * Updates the content of the texture.
  65697. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65698. */
  65699. update(invertY?: Nullable<boolean>): void;
  65700. }
  65701. }
  65702. declare module "babylonjs/Misc/tga" {
  65703. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65704. /**
  65705. * Based on jsTGALoader - Javascript loader for TGA file
  65706. * By Vincent Thibault
  65707. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65708. */
  65709. export class TGATools {
  65710. private static _TYPE_INDEXED;
  65711. private static _TYPE_RGB;
  65712. private static _TYPE_GREY;
  65713. private static _TYPE_RLE_INDEXED;
  65714. private static _TYPE_RLE_RGB;
  65715. private static _TYPE_RLE_GREY;
  65716. private static _ORIGIN_MASK;
  65717. private static _ORIGIN_SHIFT;
  65718. private static _ORIGIN_BL;
  65719. private static _ORIGIN_BR;
  65720. private static _ORIGIN_UL;
  65721. private static _ORIGIN_UR;
  65722. /**
  65723. * Gets the header of a TGA file
  65724. * @param data defines the TGA data
  65725. * @returns the header
  65726. */
  65727. static GetTGAHeader(data: Uint8Array): any;
  65728. /**
  65729. * Uploads TGA content to a Babylon Texture
  65730. * @hidden
  65731. */
  65732. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65733. /** @hidden */
  65734. 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;
  65735. /** @hidden */
  65736. 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;
  65737. /** @hidden */
  65738. 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;
  65739. /** @hidden */
  65740. 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;
  65741. /** @hidden */
  65742. 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;
  65743. /** @hidden */
  65744. 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;
  65745. }
  65746. }
  65747. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65748. import { Nullable } from "babylonjs/types";
  65749. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65750. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65751. /**
  65752. * Implementation of the TGA Texture Loader.
  65753. * @hidden
  65754. */
  65755. export class _TGATextureLoader implements IInternalTextureLoader {
  65756. /**
  65757. * Defines wether the loader supports cascade loading the different faces.
  65758. */
  65759. readonly supportCascades: boolean;
  65760. /**
  65761. * This returns if the loader support the current file information.
  65762. * @param extension defines the file extension of the file being loaded
  65763. * @returns true if the loader can load the specified file
  65764. */
  65765. canLoad(extension: string): boolean;
  65766. /**
  65767. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65768. * @param data contains the texture data
  65769. * @param texture defines the BabylonJS internal texture
  65770. * @param createPolynomials will be true if polynomials have been requested
  65771. * @param onLoad defines the callback to trigger once the texture is ready
  65772. * @param onError defines the callback to trigger in case of error
  65773. */
  65774. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65775. /**
  65776. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65777. * @param data contains the texture data
  65778. * @param texture defines the BabylonJS internal texture
  65779. * @param callback defines the method to call once ready to upload
  65780. */
  65781. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65782. }
  65783. }
  65784. declare module "babylonjs/Misc/basis" {
  65785. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65786. /**
  65787. * Info about the .basis files
  65788. */
  65789. class BasisFileInfo {
  65790. /**
  65791. * If the file has alpha
  65792. */
  65793. hasAlpha: boolean;
  65794. /**
  65795. * Info about each image of the basis file
  65796. */
  65797. images: Array<{
  65798. levels: Array<{
  65799. width: number;
  65800. height: number;
  65801. transcodedPixels: ArrayBufferView;
  65802. }>;
  65803. }>;
  65804. }
  65805. /**
  65806. * Result of transcoding a basis file
  65807. */
  65808. class TranscodeResult {
  65809. /**
  65810. * Info about the .basis file
  65811. */
  65812. fileInfo: BasisFileInfo;
  65813. /**
  65814. * Format to use when loading the file
  65815. */
  65816. format: number;
  65817. }
  65818. /**
  65819. * Configuration options for the Basis transcoder
  65820. */
  65821. export class BasisTranscodeConfiguration {
  65822. /**
  65823. * Supported compression formats used to determine the supported output format of the transcoder
  65824. */
  65825. supportedCompressionFormats?: {
  65826. /**
  65827. * etc1 compression format
  65828. */
  65829. etc1?: boolean;
  65830. /**
  65831. * s3tc compression format
  65832. */
  65833. s3tc?: boolean;
  65834. /**
  65835. * pvrtc compression format
  65836. */
  65837. pvrtc?: boolean;
  65838. /**
  65839. * etc2 compression format
  65840. */
  65841. etc2?: boolean;
  65842. };
  65843. /**
  65844. * If mipmap levels should be loaded for transcoded images (Default: true)
  65845. */
  65846. loadMipmapLevels?: boolean;
  65847. /**
  65848. * Index of a single image to load (Default: all images)
  65849. */
  65850. loadSingleImage?: number;
  65851. }
  65852. /**
  65853. * Used to load .Basis files
  65854. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65855. */
  65856. export class BasisTools {
  65857. private static _IgnoreSupportedFormats;
  65858. /**
  65859. * URL to use when loading the basis transcoder
  65860. */
  65861. static JSModuleURL: string;
  65862. /**
  65863. * URL to use when loading the wasm module for the transcoder
  65864. */
  65865. static WasmModuleURL: string;
  65866. /**
  65867. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65868. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65869. * @returns internal format corresponding to the Basis format
  65870. */
  65871. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65872. private static _WorkerPromise;
  65873. private static _Worker;
  65874. private static _actionId;
  65875. private static _CreateWorkerAsync;
  65876. /**
  65877. * Transcodes a loaded image file to compressed pixel data
  65878. * @param data image data to transcode
  65879. * @param config configuration options for the transcoding
  65880. * @returns a promise resulting in the transcoded image
  65881. */
  65882. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65883. /**
  65884. * Loads a texture from the transcode result
  65885. * @param texture texture load to
  65886. * @param transcodeResult the result of transcoding the basis file to load from
  65887. */
  65888. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65889. }
  65890. }
  65891. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65892. import { Nullable } from "babylonjs/types";
  65893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65894. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65895. /**
  65896. * Loader for .basis file format
  65897. */
  65898. export class _BasisTextureLoader implements IInternalTextureLoader {
  65899. /**
  65900. * Defines whether the loader supports cascade loading the different faces.
  65901. */
  65902. readonly supportCascades: boolean;
  65903. /**
  65904. * This returns if the loader support the current file information.
  65905. * @param extension defines the file extension of the file being loaded
  65906. * @returns true if the loader can load the specified file
  65907. */
  65908. canLoad(extension: string): boolean;
  65909. /**
  65910. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65911. * @param data contains the texture data
  65912. * @param texture defines the BabylonJS internal texture
  65913. * @param createPolynomials will be true if polynomials have been requested
  65914. * @param onLoad defines the callback to trigger once the texture is ready
  65915. * @param onError defines the callback to trigger in case of error
  65916. */
  65917. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65918. /**
  65919. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65920. * @param data contains the texture data
  65921. * @param texture defines the BabylonJS internal texture
  65922. * @param callback defines the method to call once ready to upload
  65923. */
  65924. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65925. }
  65926. }
  65927. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65928. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65929. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65930. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65931. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65932. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65933. }
  65934. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65935. import { Vector2 } from "babylonjs/Maths/math.vector";
  65936. /**
  65937. * Defines the basic options interface of a TexturePacker Frame
  65938. */
  65939. export interface ITexturePackerFrame {
  65940. /**
  65941. * The frame ID
  65942. */
  65943. id: number;
  65944. /**
  65945. * The frames Scale
  65946. */
  65947. scale: Vector2;
  65948. /**
  65949. * The Frames offset
  65950. */
  65951. offset: Vector2;
  65952. }
  65953. /**
  65954. * This is a support class for frame Data on texture packer sets.
  65955. */
  65956. export class TexturePackerFrame implements ITexturePackerFrame {
  65957. /**
  65958. * The frame ID
  65959. */
  65960. id: number;
  65961. /**
  65962. * The frames Scale
  65963. */
  65964. scale: Vector2;
  65965. /**
  65966. * The Frames offset
  65967. */
  65968. offset: Vector2;
  65969. /**
  65970. * Initializes a texture package frame.
  65971. * @param id The numerical frame identifier
  65972. * @param scale Scalar Vector2 for UV frame
  65973. * @param offset Vector2 for the frame position in UV units.
  65974. * @returns TexturePackerFrame
  65975. */
  65976. constructor(id: number, scale: Vector2, offset: Vector2);
  65977. }
  65978. }
  65979. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65981. import { Scene } from "babylonjs/scene";
  65982. import { Nullable } from "babylonjs/types";
  65983. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65984. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65985. /**
  65986. * Defines the basic options interface of a TexturePacker
  65987. */
  65988. export interface ITexturePackerOptions {
  65989. /**
  65990. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65991. */
  65992. map?: string[];
  65993. /**
  65994. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65995. */
  65996. uvsIn?: string;
  65997. /**
  65998. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65999. */
  66000. uvsOut?: string;
  66001. /**
  66002. * number representing the layout style. Defaults to LAYOUT_STRIP
  66003. */
  66004. layout?: number;
  66005. /**
  66006. * number of columns if using custom column count layout(2). This defaults to 4.
  66007. */
  66008. colnum?: number;
  66009. /**
  66010. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66011. */
  66012. updateInputMeshes?: boolean;
  66013. /**
  66014. * boolean flag to dispose all the source textures. Defaults to true.
  66015. */
  66016. disposeSources?: boolean;
  66017. /**
  66018. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66019. */
  66020. fillBlanks?: boolean;
  66021. /**
  66022. * string value representing the context fill style color. Defaults to 'black'.
  66023. */
  66024. customFillColor?: string;
  66025. /**
  66026. * Width and Height Value of each Frame in the TexturePacker Sets
  66027. */
  66028. frameSize?: number;
  66029. /**
  66030. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66031. */
  66032. paddingRatio?: number;
  66033. /**
  66034. * Number that declares the fill method for the padding gutter.
  66035. */
  66036. paddingMode?: number;
  66037. /**
  66038. * If in SUBUV_COLOR padding mode what color to use.
  66039. */
  66040. paddingColor?: Color3 | Color4;
  66041. }
  66042. /**
  66043. * Defines the basic interface of a TexturePacker JSON File
  66044. */
  66045. export interface ITexturePackerJSON {
  66046. /**
  66047. * The frame ID
  66048. */
  66049. name: string;
  66050. /**
  66051. * The base64 channel data
  66052. */
  66053. sets: any;
  66054. /**
  66055. * The options of the Packer
  66056. */
  66057. options: ITexturePackerOptions;
  66058. /**
  66059. * The frame data of the Packer
  66060. */
  66061. frames: Array<number>;
  66062. }
  66063. /**
  66064. * This is a support class that generates a series of packed texture sets.
  66065. * @see https://doc.babylonjs.com/babylon101/materials
  66066. */
  66067. export class TexturePacker {
  66068. /** Packer Layout Constant 0 */
  66069. static readonly LAYOUT_STRIP: number;
  66070. /** Packer Layout Constant 1 */
  66071. static readonly LAYOUT_POWER2: number;
  66072. /** Packer Layout Constant 2 */
  66073. static readonly LAYOUT_COLNUM: number;
  66074. /** Packer Layout Constant 0 */
  66075. static readonly SUBUV_WRAP: number;
  66076. /** Packer Layout Constant 1 */
  66077. static readonly SUBUV_EXTEND: number;
  66078. /** Packer Layout Constant 2 */
  66079. static readonly SUBUV_COLOR: number;
  66080. /** The Name of the Texture Package */
  66081. name: string;
  66082. /** The scene scope of the TexturePacker */
  66083. scene: Scene;
  66084. /** The Meshes to target */
  66085. meshes: AbstractMesh[];
  66086. /** Arguments passed with the Constructor */
  66087. options: ITexturePackerOptions;
  66088. /** The promise that is started upon initialization */
  66089. promise: Nullable<Promise<TexturePacker | string>>;
  66090. /** The Container object for the channel sets that are generated */
  66091. sets: object;
  66092. /** The Container array for the frames that are generated */
  66093. frames: TexturePackerFrame[];
  66094. /** The expected number of textures the system is parsing. */
  66095. private _expecting;
  66096. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66097. private _paddingValue;
  66098. /**
  66099. * Initializes a texture package series from an array of meshes or a single mesh.
  66100. * @param name The name of the package
  66101. * @param meshes The target meshes to compose the package from
  66102. * @param options The arguments that texture packer should follow while building.
  66103. * @param scene The scene which the textures are scoped to.
  66104. * @returns TexturePacker
  66105. */
  66106. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66107. /**
  66108. * Starts the package process
  66109. * @param resolve The promises resolution function
  66110. * @returns TexturePacker
  66111. */
  66112. private _createFrames;
  66113. /**
  66114. * Calculates the Size of the Channel Sets
  66115. * @returns Vector2
  66116. */
  66117. private _calculateSize;
  66118. /**
  66119. * Calculates the UV data for the frames.
  66120. * @param baseSize the base frameSize
  66121. * @param padding the base frame padding
  66122. * @param dtSize size of the Dynamic Texture for that channel
  66123. * @param dtUnits is 1/dtSize
  66124. * @param update flag to update the input meshes
  66125. */
  66126. private _calculateMeshUVFrames;
  66127. /**
  66128. * Calculates the frames Offset.
  66129. * @param index of the frame
  66130. * @returns Vector2
  66131. */
  66132. private _getFrameOffset;
  66133. /**
  66134. * Updates a Mesh to the frame data
  66135. * @param mesh that is the target
  66136. * @param frameID or the frame index
  66137. */
  66138. private _updateMeshUV;
  66139. /**
  66140. * Updates a Meshes materials to use the texture packer channels
  66141. * @param m is the mesh to target
  66142. * @param force all channels on the packer to be set.
  66143. */
  66144. private _updateTextureReferences;
  66145. /**
  66146. * Public method to set a Mesh to a frame
  66147. * @param m that is the target
  66148. * @param frameID or the frame index
  66149. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66150. */
  66151. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66152. /**
  66153. * Starts the async promise to compile the texture packer.
  66154. * @returns Promise<void>
  66155. */
  66156. processAsync(): Promise<void>;
  66157. /**
  66158. * Disposes all textures associated with this packer
  66159. */
  66160. dispose(): void;
  66161. /**
  66162. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66163. * @param imageType is the image type to use.
  66164. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66165. */
  66166. download(imageType?: string, quality?: number): void;
  66167. /**
  66168. * Public method to load a texturePacker JSON file.
  66169. * @param data of the JSON file in string format.
  66170. */
  66171. updateFromJSON(data: string): void;
  66172. }
  66173. }
  66174. declare module "babylonjs/Materials/Textures/Packer/index" {
  66175. export * from "babylonjs/Materials/Textures/Packer/packer";
  66176. export * from "babylonjs/Materials/Textures/Packer/frame";
  66177. }
  66178. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66179. import { Scene } from "babylonjs/scene";
  66180. import { Texture } from "babylonjs/Materials/Textures/texture";
  66181. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66182. /**
  66183. * 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.
  66184. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66185. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66186. */
  66187. export class CustomProceduralTexture extends ProceduralTexture {
  66188. private _animate;
  66189. private _time;
  66190. private _config;
  66191. private _texturePath;
  66192. /**
  66193. * Instantiates a new Custom Procedural Texture.
  66194. * 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.
  66195. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66196. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66197. * @param name Define the name of the texture
  66198. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66199. * @param size Define the size of the texture to create
  66200. * @param scene Define the scene the texture belongs to
  66201. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66202. * @param generateMipMaps Define if the texture should creates mip maps or not
  66203. */
  66204. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66205. private _loadJson;
  66206. /**
  66207. * Is the texture ready to be used ? (rendered at least once)
  66208. * @returns true if ready, otherwise, false.
  66209. */
  66210. isReady(): boolean;
  66211. /**
  66212. * Render the texture to its associated render target.
  66213. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66214. */
  66215. render(useCameraPostProcess?: boolean): void;
  66216. /**
  66217. * Update the list of dependant textures samplers in the shader.
  66218. */
  66219. updateTextures(): void;
  66220. /**
  66221. * Update the uniform values of the procedural texture in the shader.
  66222. */
  66223. updateShaderUniforms(): void;
  66224. /**
  66225. * Define if the texture animates or not.
  66226. */
  66227. get animate(): boolean;
  66228. set animate(value: boolean);
  66229. }
  66230. }
  66231. declare module "babylonjs/Shaders/noise.fragment" {
  66232. /** @hidden */
  66233. export var noisePixelShader: {
  66234. name: string;
  66235. shader: string;
  66236. };
  66237. }
  66238. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66239. import { Nullable } from "babylonjs/types";
  66240. import { Scene } from "babylonjs/scene";
  66241. import { Texture } from "babylonjs/Materials/Textures/texture";
  66242. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66243. import "babylonjs/Shaders/noise.fragment";
  66244. /**
  66245. * Class used to generate noise procedural textures
  66246. */
  66247. export class NoiseProceduralTexture extends ProceduralTexture {
  66248. /** Gets or sets the start time (default is 0) */
  66249. time: number;
  66250. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66251. brightness: number;
  66252. /** Defines the number of octaves to process */
  66253. octaves: number;
  66254. /** Defines the level of persistence (0.8 by default) */
  66255. persistence: number;
  66256. /** Gets or sets animation speed factor (default is 1) */
  66257. animationSpeedFactor: number;
  66258. /**
  66259. * Creates a new NoiseProceduralTexture
  66260. * @param name defines the name fo the texture
  66261. * @param size defines the size of the texture (default is 256)
  66262. * @param scene defines the hosting scene
  66263. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66264. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66265. */
  66266. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66267. private _updateShaderUniforms;
  66268. protected _getDefines(): string;
  66269. /** Generate the current state of the procedural texture */
  66270. render(useCameraPostProcess?: boolean): void;
  66271. /**
  66272. * Serializes this noise procedural texture
  66273. * @returns a serialized noise procedural texture object
  66274. */
  66275. serialize(): any;
  66276. /**
  66277. * Clone the texture.
  66278. * @returns the cloned texture
  66279. */
  66280. clone(): NoiseProceduralTexture;
  66281. /**
  66282. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66283. * @param parsedTexture defines parsed texture data
  66284. * @param scene defines the current scene
  66285. * @param rootUrl defines the root URL containing noise procedural texture information
  66286. * @returns a parsed NoiseProceduralTexture
  66287. */
  66288. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66289. }
  66290. }
  66291. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66292. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66293. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66294. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66295. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66296. }
  66297. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66298. import { Nullable } from "babylonjs/types";
  66299. import { Scene } from "babylonjs/scene";
  66300. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66301. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66302. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66303. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66304. /**
  66305. * Raw cube texture where the raw buffers are passed in
  66306. */
  66307. export class RawCubeTexture extends CubeTexture {
  66308. /**
  66309. * Creates a cube texture where the raw buffers are passed in.
  66310. * @param scene defines the scene the texture is attached to
  66311. * @param data defines the array of data to use to create each face
  66312. * @param size defines the size of the textures
  66313. * @param format defines the format of the data
  66314. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66315. * @param generateMipMaps defines if the engine should generate the mip levels
  66316. * @param invertY defines if data must be stored with Y axis inverted
  66317. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66318. * @param compression defines the compression used (null by default)
  66319. */
  66320. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66321. /**
  66322. * Updates the raw cube texture.
  66323. * @param data defines the data to store
  66324. * @param format defines the data format
  66325. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66326. * @param invertY defines if data must be stored with Y axis inverted
  66327. * @param compression defines the compression used (null by default)
  66328. * @param level defines which level of the texture to update
  66329. */
  66330. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66331. /**
  66332. * Updates a raw cube texture with RGBD encoded data.
  66333. * @param data defines the array of data [mipmap][face] to use to create each face
  66334. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66335. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66336. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66337. * @returns a promsie that resolves when the operation is complete
  66338. */
  66339. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66340. /**
  66341. * Clones the raw cube texture.
  66342. * @return a new cube texture
  66343. */
  66344. clone(): CubeTexture;
  66345. /** @hidden */
  66346. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66347. }
  66348. }
  66349. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66350. import { Scene } from "babylonjs/scene";
  66351. import { Texture } from "babylonjs/Materials/Textures/texture";
  66352. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66353. /**
  66354. * Class used to store 2D array textures containing user data
  66355. */
  66356. export class RawTexture2DArray extends Texture {
  66357. /** Gets or sets the texture format to use */
  66358. format: number;
  66359. /**
  66360. * Create a new RawTexture2DArray
  66361. * @param data defines the data of the texture
  66362. * @param width defines the width of the texture
  66363. * @param height defines the height of the texture
  66364. * @param depth defines the number of layers of the texture
  66365. * @param format defines the texture format to use
  66366. * @param scene defines the hosting scene
  66367. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66368. * @param invertY defines if texture must be stored with Y axis inverted
  66369. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66370. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66371. */
  66372. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66373. /** Gets or sets the texture format to use */
  66374. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66375. /**
  66376. * Update the texture with new data
  66377. * @param data defines the data to store in the texture
  66378. */
  66379. update(data: ArrayBufferView): void;
  66380. }
  66381. }
  66382. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66383. import { Scene } from "babylonjs/scene";
  66384. import { Texture } from "babylonjs/Materials/Textures/texture";
  66385. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66386. /**
  66387. * Class used to store 3D textures containing user data
  66388. */
  66389. export class RawTexture3D extends Texture {
  66390. /** Gets or sets the texture format to use */
  66391. format: number;
  66392. /**
  66393. * Create a new RawTexture3D
  66394. * @param data defines the data of the texture
  66395. * @param width defines the width of the texture
  66396. * @param height defines the height of the texture
  66397. * @param depth defines the depth of the texture
  66398. * @param format defines the texture format to use
  66399. * @param scene defines the hosting scene
  66400. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66401. * @param invertY defines if texture must be stored with Y axis inverted
  66402. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66403. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66404. */
  66405. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66406. /** Gets or sets the texture format to use */
  66407. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66408. /**
  66409. * Update the texture with new data
  66410. * @param data defines the data to store in the texture
  66411. */
  66412. update(data: ArrayBufferView): void;
  66413. }
  66414. }
  66415. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66416. import { Scene } from "babylonjs/scene";
  66417. import { Plane } from "babylonjs/Maths/math.plane";
  66418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66419. /**
  66420. * Creates a refraction texture used by refraction channel of the standard material.
  66421. * It is like a mirror but to see through a material.
  66422. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66423. */
  66424. export class RefractionTexture extends RenderTargetTexture {
  66425. /**
  66426. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66427. * 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.
  66428. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66429. */
  66430. refractionPlane: Plane;
  66431. /**
  66432. * Define how deep under the surface we should see.
  66433. */
  66434. depth: number;
  66435. /**
  66436. * Creates a refraction texture used by refraction channel of the standard material.
  66437. * It is like a mirror but to see through a material.
  66438. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66439. * @param name Define the texture name
  66440. * @param size Define the size of the underlying texture
  66441. * @param scene Define the scene the refraction belongs to
  66442. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66443. */
  66444. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66445. /**
  66446. * Clone the refraction texture.
  66447. * @returns the cloned texture
  66448. */
  66449. clone(): RefractionTexture;
  66450. /**
  66451. * Serialize the texture to a JSON representation you could use in Parse later on
  66452. * @returns the serialized JSON representation
  66453. */
  66454. serialize(): any;
  66455. }
  66456. }
  66457. declare module "babylonjs/Materials/Textures/index" {
  66458. export * from "babylonjs/Materials/Textures/baseTexture";
  66459. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66460. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66461. export * from "babylonjs/Materials/Textures/cubeTexture";
  66462. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66463. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66464. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66465. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66466. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66467. export * from "babylonjs/Materials/Textures/internalTexture";
  66468. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66469. export * from "babylonjs/Materials/Textures/Loaders/index";
  66470. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66471. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66472. export * from "babylonjs/Materials/Textures/Packer/index";
  66473. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66474. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66475. export * from "babylonjs/Materials/Textures/rawTexture";
  66476. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66477. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66478. export * from "babylonjs/Materials/Textures/refractionTexture";
  66479. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66480. export * from "babylonjs/Materials/Textures/texture";
  66481. export * from "babylonjs/Materials/Textures/videoTexture";
  66482. }
  66483. declare module "babylonjs/Materials/Node/Enums/index" {
  66484. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66485. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66486. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66487. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66488. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66489. }
  66490. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66494. import { Mesh } from "babylonjs/Meshes/mesh";
  66495. import { Effect } from "babylonjs/Materials/effect";
  66496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66497. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66498. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66499. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66500. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66501. /**
  66502. * Block used to add support for vertex skinning (bones)
  66503. */
  66504. export class BonesBlock extends NodeMaterialBlock {
  66505. /**
  66506. * Creates a new BonesBlock
  66507. * @param name defines the block name
  66508. */
  66509. constructor(name: string);
  66510. /**
  66511. * Initialize the block and prepare the context for build
  66512. * @param state defines the state that will be used for the build
  66513. */
  66514. initialize(state: NodeMaterialBuildState): void;
  66515. /**
  66516. * Gets the current class name
  66517. * @returns the class name
  66518. */
  66519. getClassName(): string;
  66520. /**
  66521. * Gets the matrix indices input component
  66522. */
  66523. get matricesIndices(): NodeMaterialConnectionPoint;
  66524. /**
  66525. * Gets the matrix weights input component
  66526. */
  66527. get matricesWeights(): NodeMaterialConnectionPoint;
  66528. /**
  66529. * Gets the extra matrix indices input component
  66530. */
  66531. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66532. /**
  66533. * Gets the extra matrix weights input component
  66534. */
  66535. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66536. /**
  66537. * Gets the world input component
  66538. */
  66539. get world(): NodeMaterialConnectionPoint;
  66540. /**
  66541. * Gets the output component
  66542. */
  66543. get output(): NodeMaterialConnectionPoint;
  66544. autoConfigure(material: NodeMaterial): void;
  66545. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66548. protected _buildBlock(state: NodeMaterialBuildState): this;
  66549. }
  66550. }
  66551. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66558. /**
  66559. * Block used to add support for instances
  66560. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66561. */
  66562. export class InstancesBlock extends NodeMaterialBlock {
  66563. /**
  66564. * Creates a new InstancesBlock
  66565. * @param name defines the block name
  66566. */
  66567. constructor(name: string);
  66568. /**
  66569. * Gets the current class name
  66570. * @returns the class name
  66571. */
  66572. getClassName(): string;
  66573. /**
  66574. * Gets the first world row input component
  66575. */
  66576. get world0(): NodeMaterialConnectionPoint;
  66577. /**
  66578. * Gets the second world row input component
  66579. */
  66580. get world1(): NodeMaterialConnectionPoint;
  66581. /**
  66582. * Gets the third world row input component
  66583. */
  66584. get world2(): NodeMaterialConnectionPoint;
  66585. /**
  66586. * Gets the forth world row input component
  66587. */
  66588. get world3(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the world input component
  66591. */
  66592. get world(): NodeMaterialConnectionPoint;
  66593. /**
  66594. * Gets the output component
  66595. */
  66596. get output(): NodeMaterialConnectionPoint;
  66597. /**
  66598. * Gets the isntanceID component
  66599. */
  66600. get instanceID(): NodeMaterialConnectionPoint;
  66601. autoConfigure(material: NodeMaterial): void;
  66602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66603. protected _buildBlock(state: NodeMaterialBuildState): this;
  66604. }
  66605. }
  66606. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66611. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66612. import { Effect } from "babylonjs/Materials/effect";
  66613. import { Mesh } from "babylonjs/Meshes/mesh";
  66614. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66615. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66616. /**
  66617. * Block used to add morph targets support to vertex shader
  66618. */
  66619. export class MorphTargetsBlock extends NodeMaterialBlock {
  66620. private _repeatableContentAnchor;
  66621. /**
  66622. * Create a new MorphTargetsBlock
  66623. * @param name defines the block name
  66624. */
  66625. constructor(name: string);
  66626. /**
  66627. * Gets the current class name
  66628. * @returns the class name
  66629. */
  66630. getClassName(): string;
  66631. /**
  66632. * Gets the position input component
  66633. */
  66634. get position(): NodeMaterialConnectionPoint;
  66635. /**
  66636. * Gets the normal input component
  66637. */
  66638. get normal(): NodeMaterialConnectionPoint;
  66639. /**
  66640. * Gets the tangent input component
  66641. */
  66642. get tangent(): NodeMaterialConnectionPoint;
  66643. /**
  66644. * Gets the tangent input component
  66645. */
  66646. get uv(): NodeMaterialConnectionPoint;
  66647. /**
  66648. * Gets the position output component
  66649. */
  66650. get positionOutput(): NodeMaterialConnectionPoint;
  66651. /**
  66652. * Gets the normal output component
  66653. */
  66654. get normalOutput(): NodeMaterialConnectionPoint;
  66655. /**
  66656. * Gets the tangent output component
  66657. */
  66658. get tangentOutput(): NodeMaterialConnectionPoint;
  66659. /**
  66660. * Gets the tangent output component
  66661. */
  66662. get uvOutput(): NodeMaterialConnectionPoint;
  66663. initialize(state: NodeMaterialBuildState): void;
  66664. autoConfigure(material: NodeMaterial): void;
  66665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66667. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66668. protected _buildBlock(state: NodeMaterialBuildState): this;
  66669. }
  66670. }
  66671. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  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 { Nullable } from "babylonjs/types";
  66676. import { Scene } from "babylonjs/scene";
  66677. import { Effect } from "babylonjs/Materials/effect";
  66678. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66679. import { Mesh } from "babylonjs/Meshes/mesh";
  66680. import { Light } from "babylonjs/Lights/light";
  66681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66682. /**
  66683. * Block used to get data information from a light
  66684. */
  66685. export class LightInformationBlock extends NodeMaterialBlock {
  66686. private _lightDataUniformName;
  66687. private _lightColorUniformName;
  66688. private _lightTypeDefineName;
  66689. /**
  66690. * Gets or sets the light associated with this block
  66691. */
  66692. light: Nullable<Light>;
  66693. /**
  66694. * Creates a new LightInformationBlock
  66695. * @param name defines the block name
  66696. */
  66697. constructor(name: string);
  66698. /**
  66699. * Gets the current class name
  66700. * @returns the class name
  66701. */
  66702. getClassName(): string;
  66703. /**
  66704. * Gets the world position input component
  66705. */
  66706. get worldPosition(): NodeMaterialConnectionPoint;
  66707. /**
  66708. * Gets the direction output component
  66709. */
  66710. get direction(): NodeMaterialConnectionPoint;
  66711. /**
  66712. * Gets the direction output component
  66713. */
  66714. get color(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the direction output component
  66717. */
  66718. get intensity(): NodeMaterialConnectionPoint;
  66719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66721. protected _buildBlock(state: NodeMaterialBuildState): this;
  66722. serialize(): any;
  66723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66724. }
  66725. }
  66726. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66727. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66728. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66729. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66730. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66731. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66732. }
  66733. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66738. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66739. import { Effect } from "babylonjs/Materials/effect";
  66740. import { Mesh } from "babylonjs/Meshes/mesh";
  66741. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66742. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66743. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66744. /**
  66745. * Block used to add image processing support to fragment shader
  66746. */
  66747. export class ImageProcessingBlock extends NodeMaterialBlock {
  66748. /**
  66749. * Create a new ImageProcessingBlock
  66750. * @param name defines the block name
  66751. */
  66752. constructor(name: string);
  66753. /**
  66754. * Gets the current class name
  66755. * @returns the class name
  66756. */
  66757. getClassName(): string;
  66758. /**
  66759. * Gets the color input component
  66760. */
  66761. get color(): NodeMaterialConnectionPoint;
  66762. /**
  66763. * Gets the output component
  66764. */
  66765. get output(): NodeMaterialConnectionPoint;
  66766. /**
  66767. * Initialize the block and prepare the context for build
  66768. * @param state defines the state that will be used for the build
  66769. */
  66770. initialize(state: NodeMaterialBuildState): void;
  66771. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66773. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66774. protected _buildBlock(state: NodeMaterialBuildState): this;
  66775. }
  66776. }
  66777. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66781. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66783. import { Effect } from "babylonjs/Materials/effect";
  66784. import { Mesh } from "babylonjs/Meshes/mesh";
  66785. import { Scene } from "babylonjs/scene";
  66786. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66787. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66788. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66789. /**
  66790. * Block used to pertub normals based on a normal map
  66791. */
  66792. export class PerturbNormalBlock extends NodeMaterialBlock {
  66793. private _tangentSpaceParameterName;
  66794. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66795. invertX: boolean;
  66796. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66797. invertY: boolean;
  66798. /**
  66799. * Create a new PerturbNormalBlock
  66800. * @param name defines the block name
  66801. */
  66802. constructor(name: string);
  66803. /**
  66804. * Gets the current class name
  66805. * @returns the class name
  66806. */
  66807. getClassName(): string;
  66808. /**
  66809. * Gets the world position input component
  66810. */
  66811. get worldPosition(): NodeMaterialConnectionPoint;
  66812. /**
  66813. * Gets the world normal input component
  66814. */
  66815. get worldNormal(): NodeMaterialConnectionPoint;
  66816. /**
  66817. * Gets the world tangent input component
  66818. */
  66819. get worldTangent(): NodeMaterialConnectionPoint;
  66820. /**
  66821. * Gets the uv input component
  66822. */
  66823. get uv(): NodeMaterialConnectionPoint;
  66824. /**
  66825. * Gets the normal map color input component
  66826. */
  66827. get normalMapColor(): NodeMaterialConnectionPoint;
  66828. /**
  66829. * Gets the strength input component
  66830. */
  66831. get strength(): NodeMaterialConnectionPoint;
  66832. /**
  66833. * Gets the output component
  66834. */
  66835. get output(): NodeMaterialConnectionPoint;
  66836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66838. autoConfigure(material: NodeMaterial): void;
  66839. protected _buildBlock(state: NodeMaterialBuildState): this;
  66840. protected _dumpPropertiesCode(): string;
  66841. serialize(): any;
  66842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66843. }
  66844. }
  66845. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66849. /**
  66850. * Block used to discard a pixel if a value is smaller than a cutoff
  66851. */
  66852. export class DiscardBlock extends NodeMaterialBlock {
  66853. /**
  66854. * Create a new DiscardBlock
  66855. * @param name defines the block name
  66856. */
  66857. constructor(name: string);
  66858. /**
  66859. * Gets the current class name
  66860. * @returns the class name
  66861. */
  66862. getClassName(): string;
  66863. /**
  66864. * Gets the color input component
  66865. */
  66866. get value(): NodeMaterialConnectionPoint;
  66867. /**
  66868. * Gets the cutoff input component
  66869. */
  66870. get cutoff(): NodeMaterialConnectionPoint;
  66871. protected _buildBlock(state: NodeMaterialBuildState): this;
  66872. }
  66873. }
  66874. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66878. /**
  66879. * Block used to test if the fragment shader is front facing
  66880. */
  66881. export class FrontFacingBlock extends NodeMaterialBlock {
  66882. /**
  66883. * Creates a new FrontFacingBlock
  66884. * @param name defines the block name
  66885. */
  66886. constructor(name: string);
  66887. /**
  66888. * Gets the current class name
  66889. * @returns the class name
  66890. */
  66891. getClassName(): string;
  66892. /**
  66893. * Gets the output component
  66894. */
  66895. get output(): NodeMaterialConnectionPoint;
  66896. protected _buildBlock(state: NodeMaterialBuildState): this;
  66897. }
  66898. }
  66899. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66903. /**
  66904. * Block used to get the derivative value on x and y of a given input
  66905. */
  66906. export class DerivativeBlock extends NodeMaterialBlock {
  66907. /**
  66908. * Create a new DerivativeBlock
  66909. * @param name defines the block name
  66910. */
  66911. constructor(name: string);
  66912. /**
  66913. * Gets the current class name
  66914. * @returns the class name
  66915. */
  66916. getClassName(): string;
  66917. /**
  66918. * Gets the input component
  66919. */
  66920. get input(): NodeMaterialConnectionPoint;
  66921. /**
  66922. * Gets the derivative output on x
  66923. */
  66924. get dx(): NodeMaterialConnectionPoint;
  66925. /**
  66926. * Gets the derivative output on y
  66927. */
  66928. get dy(): NodeMaterialConnectionPoint;
  66929. protected _buildBlock(state: NodeMaterialBuildState): this;
  66930. }
  66931. }
  66932. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66936. /**
  66937. * Block used to make gl_FragCoord available
  66938. */
  66939. export class FragCoordBlock extends NodeMaterialBlock {
  66940. /**
  66941. * Creates a new FragCoordBlock
  66942. * @param name defines the block name
  66943. */
  66944. constructor(name: string);
  66945. /**
  66946. * Gets the current class name
  66947. * @returns the class name
  66948. */
  66949. getClassName(): string;
  66950. /**
  66951. * Gets the xy component
  66952. */
  66953. get xy(): NodeMaterialConnectionPoint;
  66954. /**
  66955. * Gets the xyz component
  66956. */
  66957. get xyz(): NodeMaterialConnectionPoint;
  66958. /**
  66959. * Gets the xyzw component
  66960. */
  66961. get xyzw(): NodeMaterialConnectionPoint;
  66962. /**
  66963. * Gets the x component
  66964. */
  66965. get x(): NodeMaterialConnectionPoint;
  66966. /**
  66967. * Gets the y component
  66968. */
  66969. get y(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the z component
  66972. */
  66973. get z(): NodeMaterialConnectionPoint;
  66974. /**
  66975. * Gets the w component
  66976. */
  66977. get output(): NodeMaterialConnectionPoint;
  66978. protected writeOutputs(state: NodeMaterialBuildState): string;
  66979. protected _buildBlock(state: NodeMaterialBuildState): this;
  66980. }
  66981. }
  66982. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66986. import { Effect } from "babylonjs/Materials/effect";
  66987. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66988. import { Mesh } from "babylonjs/Meshes/mesh";
  66989. /**
  66990. * Block used to get the screen sizes
  66991. */
  66992. export class ScreenSizeBlock extends NodeMaterialBlock {
  66993. private _varName;
  66994. private _scene;
  66995. /**
  66996. * Creates a new ScreenSizeBlock
  66997. * @param name defines the block name
  66998. */
  66999. constructor(name: string);
  67000. /**
  67001. * Gets the current class name
  67002. * @returns the class name
  67003. */
  67004. getClassName(): string;
  67005. /**
  67006. * Gets the xy component
  67007. */
  67008. get xy(): NodeMaterialConnectionPoint;
  67009. /**
  67010. * Gets the x component
  67011. */
  67012. get x(): NodeMaterialConnectionPoint;
  67013. /**
  67014. * Gets the y component
  67015. */
  67016. get y(): NodeMaterialConnectionPoint;
  67017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67018. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67019. protected _buildBlock(state: NodeMaterialBuildState): this;
  67020. }
  67021. }
  67022. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67023. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67024. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67025. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67026. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67027. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67028. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67029. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67030. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67031. }
  67032. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67035. import { Mesh } from "babylonjs/Meshes/mesh";
  67036. import { Effect } from "babylonjs/Materials/effect";
  67037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67039. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67040. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67041. /**
  67042. * Block used to add support for scene fog
  67043. */
  67044. export class FogBlock extends NodeMaterialBlock {
  67045. private _fogDistanceName;
  67046. private _fogParameters;
  67047. /**
  67048. * Create a new FogBlock
  67049. * @param name defines the block name
  67050. */
  67051. constructor(name: string);
  67052. /**
  67053. * Gets the current class name
  67054. * @returns the class name
  67055. */
  67056. getClassName(): string;
  67057. /**
  67058. * Gets the world position input component
  67059. */
  67060. get worldPosition(): NodeMaterialConnectionPoint;
  67061. /**
  67062. * Gets the view input component
  67063. */
  67064. get view(): NodeMaterialConnectionPoint;
  67065. /**
  67066. * Gets the color input component
  67067. */
  67068. get input(): NodeMaterialConnectionPoint;
  67069. /**
  67070. * Gets the fog color input component
  67071. */
  67072. get fogColor(): NodeMaterialConnectionPoint;
  67073. /**
  67074. * Gets the output component
  67075. */
  67076. get output(): NodeMaterialConnectionPoint;
  67077. autoConfigure(material: NodeMaterial): void;
  67078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67079. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67080. protected _buildBlock(state: NodeMaterialBuildState): this;
  67081. }
  67082. }
  67083. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67088. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67089. import { Effect } from "babylonjs/Materials/effect";
  67090. import { Mesh } from "babylonjs/Meshes/mesh";
  67091. import { Light } from "babylonjs/Lights/light";
  67092. import { Nullable } from "babylonjs/types";
  67093. import { Scene } from "babylonjs/scene";
  67094. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67095. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67096. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67098. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67099. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67100. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67101. /**
  67102. * Block used to add light in the fragment shader
  67103. */
  67104. export class LightBlock extends NodeMaterialBlock {
  67105. private _lightId;
  67106. /**
  67107. * Gets or sets the light associated with this block
  67108. */
  67109. light: Nullable<Light>;
  67110. /**
  67111. * Create a new LightBlock
  67112. * @param name defines the block name
  67113. */
  67114. constructor(name: string);
  67115. /**
  67116. * Gets the current class name
  67117. * @returns the class name
  67118. */
  67119. getClassName(): string;
  67120. /**
  67121. * Gets the world position input component
  67122. */
  67123. get worldPosition(): NodeMaterialConnectionPoint;
  67124. /**
  67125. * Gets the world normal input component
  67126. */
  67127. get worldNormal(): NodeMaterialConnectionPoint;
  67128. /**
  67129. * Gets the camera (or eye) position component
  67130. */
  67131. get cameraPosition(): NodeMaterialConnectionPoint;
  67132. /**
  67133. * Gets the glossiness component
  67134. */
  67135. get glossiness(): NodeMaterialConnectionPoint;
  67136. /**
  67137. * Gets the glossinness power component
  67138. */
  67139. get glossPower(): NodeMaterialConnectionPoint;
  67140. /**
  67141. * Gets the diffuse color component
  67142. */
  67143. get diffuseColor(): NodeMaterialConnectionPoint;
  67144. /**
  67145. * Gets the specular color component
  67146. */
  67147. get specularColor(): NodeMaterialConnectionPoint;
  67148. /**
  67149. * Gets the view matrix component
  67150. */
  67151. get view(): NodeMaterialConnectionPoint;
  67152. /**
  67153. * Gets the diffuse output component
  67154. */
  67155. get diffuseOutput(): NodeMaterialConnectionPoint;
  67156. /**
  67157. * Gets the specular output component
  67158. */
  67159. get specularOutput(): NodeMaterialConnectionPoint;
  67160. /**
  67161. * Gets the shadow output component
  67162. */
  67163. get shadow(): NodeMaterialConnectionPoint;
  67164. autoConfigure(material: NodeMaterial): void;
  67165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67166. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67167. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67168. private _injectVertexCode;
  67169. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67170. serialize(): any;
  67171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67172. }
  67173. }
  67174. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67177. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67178. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67179. /**
  67180. * Block used to read a reflection texture from a sampler
  67181. */
  67182. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67183. /**
  67184. * Create a new ReflectionTextureBlock
  67185. * @param name defines the block name
  67186. */
  67187. constructor(name: string);
  67188. /**
  67189. * Gets the current class name
  67190. * @returns the class name
  67191. */
  67192. getClassName(): string;
  67193. /**
  67194. * Gets the world position input component
  67195. */
  67196. get position(): NodeMaterialConnectionPoint;
  67197. /**
  67198. * Gets the world position input component
  67199. */
  67200. get worldPosition(): NodeMaterialConnectionPoint;
  67201. /**
  67202. * Gets the world normal input component
  67203. */
  67204. get worldNormal(): NodeMaterialConnectionPoint;
  67205. /**
  67206. * Gets the world input component
  67207. */
  67208. get world(): NodeMaterialConnectionPoint;
  67209. /**
  67210. * Gets the camera (or eye) position component
  67211. */
  67212. get cameraPosition(): NodeMaterialConnectionPoint;
  67213. /**
  67214. * Gets the view input component
  67215. */
  67216. get view(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the rgb output component
  67219. */
  67220. get rgb(): NodeMaterialConnectionPoint;
  67221. /**
  67222. * Gets the rgba output component
  67223. */
  67224. get rgba(): NodeMaterialConnectionPoint;
  67225. /**
  67226. * Gets the r output component
  67227. */
  67228. get r(): NodeMaterialConnectionPoint;
  67229. /**
  67230. * Gets the g output component
  67231. */
  67232. get g(): NodeMaterialConnectionPoint;
  67233. /**
  67234. * Gets the b output component
  67235. */
  67236. get b(): NodeMaterialConnectionPoint;
  67237. /**
  67238. * Gets the a output component
  67239. */
  67240. get a(): NodeMaterialConnectionPoint;
  67241. autoConfigure(material: NodeMaterial): void;
  67242. protected _buildBlock(state: NodeMaterialBuildState): this;
  67243. }
  67244. }
  67245. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67246. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67247. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67248. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67249. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67250. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67251. }
  67252. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67253. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67254. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67255. }
  67256. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67260. /**
  67261. * Block used to add 2 vectors
  67262. */
  67263. export class AddBlock extends NodeMaterialBlock {
  67264. /**
  67265. * Creates a new AddBlock
  67266. * @param name defines the block name
  67267. */
  67268. constructor(name: string);
  67269. /**
  67270. * Gets the current class name
  67271. * @returns the class name
  67272. */
  67273. getClassName(): string;
  67274. /**
  67275. * Gets the left operand input component
  67276. */
  67277. get left(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the right operand input component
  67280. */
  67281. get right(): NodeMaterialConnectionPoint;
  67282. /**
  67283. * Gets the output component
  67284. */
  67285. get output(): NodeMaterialConnectionPoint;
  67286. protected _buildBlock(state: NodeMaterialBuildState): this;
  67287. }
  67288. }
  67289. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67293. /**
  67294. * Block used to scale a vector by a float
  67295. */
  67296. export class ScaleBlock extends NodeMaterialBlock {
  67297. /**
  67298. * Creates a new ScaleBlock
  67299. * @param name defines the block name
  67300. */
  67301. constructor(name: string);
  67302. /**
  67303. * Gets the current class name
  67304. * @returns the class name
  67305. */
  67306. getClassName(): string;
  67307. /**
  67308. * Gets the input component
  67309. */
  67310. get input(): NodeMaterialConnectionPoint;
  67311. /**
  67312. * Gets the factor input component
  67313. */
  67314. get factor(): NodeMaterialConnectionPoint;
  67315. /**
  67316. * Gets the output component
  67317. */
  67318. get output(): NodeMaterialConnectionPoint;
  67319. protected _buildBlock(state: NodeMaterialBuildState): this;
  67320. }
  67321. }
  67322. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67326. import { Scene } from "babylonjs/scene";
  67327. /**
  67328. * Block used to clamp a float
  67329. */
  67330. export class ClampBlock extends NodeMaterialBlock {
  67331. /** Gets or sets the minimum range */
  67332. minimum: number;
  67333. /** Gets or sets the maximum range */
  67334. maximum: number;
  67335. /**
  67336. * Creates a new ClampBlock
  67337. * @param name defines the block name
  67338. */
  67339. constructor(name: string);
  67340. /**
  67341. * Gets the current class name
  67342. * @returns the class name
  67343. */
  67344. getClassName(): string;
  67345. /**
  67346. * Gets the value input component
  67347. */
  67348. get value(): NodeMaterialConnectionPoint;
  67349. /**
  67350. * Gets the output component
  67351. */
  67352. get output(): NodeMaterialConnectionPoint;
  67353. protected _buildBlock(state: NodeMaterialBuildState): this;
  67354. protected _dumpPropertiesCode(): string;
  67355. serialize(): any;
  67356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67357. }
  67358. }
  67359. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67363. /**
  67364. * Block used to apply a cross product between 2 vectors
  67365. */
  67366. export class CrossBlock extends NodeMaterialBlock {
  67367. /**
  67368. * Creates a new CrossBlock
  67369. * @param name defines the block name
  67370. */
  67371. constructor(name: string);
  67372. /**
  67373. * Gets the current class name
  67374. * @returns the class name
  67375. */
  67376. getClassName(): string;
  67377. /**
  67378. * Gets the left operand input component
  67379. */
  67380. get left(): NodeMaterialConnectionPoint;
  67381. /**
  67382. * Gets the right operand input component
  67383. */
  67384. get right(): 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/dotBlock" {
  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 apply a dot product between 2 vectors
  67398. */
  67399. export class DotBlock extends NodeMaterialBlock {
  67400. /**
  67401. * Creates a new DotBlock
  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 left operand input component
  67412. */
  67413. get left(): NodeMaterialConnectionPoint;
  67414. /**
  67415. * Gets the right operand input component
  67416. */
  67417. get right(): NodeMaterialConnectionPoint;
  67418. /**
  67419. * Gets the output component
  67420. */
  67421. get output(): NodeMaterialConnectionPoint;
  67422. protected _buildBlock(state: NodeMaterialBuildState): this;
  67423. }
  67424. }
  67425. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67429. /**
  67430. * Block used to normalize a vector
  67431. */
  67432. export class NormalizeBlock extends NodeMaterialBlock {
  67433. /**
  67434. * Creates a new NormalizeBlock
  67435. * @param name defines the block name
  67436. */
  67437. constructor(name: string);
  67438. /**
  67439. * Gets the current class name
  67440. * @returns the class name
  67441. */
  67442. getClassName(): string;
  67443. /**
  67444. * Gets the input component
  67445. */
  67446. get input(): NodeMaterialConnectionPoint;
  67447. /**
  67448. * Gets the output component
  67449. */
  67450. get output(): NodeMaterialConnectionPoint;
  67451. protected _buildBlock(state: NodeMaterialBuildState): this;
  67452. }
  67453. }
  67454. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67458. /**
  67459. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67460. */
  67461. export class ColorMergerBlock extends NodeMaterialBlock {
  67462. /**
  67463. * Create a new ColorMergerBlock
  67464. * @param name defines the block name
  67465. */
  67466. constructor(name: string);
  67467. /**
  67468. * Gets the current class name
  67469. * @returns the class name
  67470. */
  67471. getClassName(): string;
  67472. /**
  67473. * Gets the rgb component (input)
  67474. */
  67475. get rgbIn(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the r component (input)
  67478. */
  67479. get r(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the g component (input)
  67482. */
  67483. get g(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the b component (input)
  67486. */
  67487. get b(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the a component (input)
  67490. */
  67491. get a(): NodeMaterialConnectionPoint;
  67492. /**
  67493. * Gets the rgba component (output)
  67494. */
  67495. get rgba(): NodeMaterialConnectionPoint;
  67496. /**
  67497. * Gets the rgb component (output)
  67498. */
  67499. get rgbOut(): NodeMaterialConnectionPoint;
  67500. /**
  67501. * Gets the rgb component (output)
  67502. * @deprecated Please use rgbOut instead.
  67503. */
  67504. get rgb(): NodeMaterialConnectionPoint;
  67505. protected _buildBlock(state: NodeMaterialBuildState): this;
  67506. }
  67507. }
  67508. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67512. /**
  67513. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67514. */
  67515. export class VectorSplitterBlock extends NodeMaterialBlock {
  67516. /**
  67517. * Create a new VectorSplitterBlock
  67518. * @param name defines the block name
  67519. */
  67520. constructor(name: string);
  67521. /**
  67522. * Gets the current class name
  67523. * @returns the class name
  67524. */
  67525. getClassName(): string;
  67526. /**
  67527. * Gets the xyzw component (input)
  67528. */
  67529. get xyzw(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the xyz component (input)
  67532. */
  67533. get xyzIn(): NodeMaterialConnectionPoint;
  67534. /**
  67535. * Gets the xy component (input)
  67536. */
  67537. get xyIn(): NodeMaterialConnectionPoint;
  67538. /**
  67539. * Gets the xyz component (output)
  67540. */
  67541. get xyzOut(): NodeMaterialConnectionPoint;
  67542. /**
  67543. * Gets the xy component (output)
  67544. */
  67545. get xyOut(): NodeMaterialConnectionPoint;
  67546. /**
  67547. * Gets the x component (output)
  67548. */
  67549. get x(): NodeMaterialConnectionPoint;
  67550. /**
  67551. * Gets the y component (output)
  67552. */
  67553. get y(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the z component (output)
  67556. */
  67557. get z(): NodeMaterialConnectionPoint;
  67558. /**
  67559. * Gets the w component (output)
  67560. */
  67561. get w(): NodeMaterialConnectionPoint;
  67562. protected _inputRename(name: string): string;
  67563. protected _outputRename(name: string): string;
  67564. protected _buildBlock(state: NodeMaterialBuildState): this;
  67565. }
  67566. }
  67567. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67571. /**
  67572. * Block used to lerp between 2 values
  67573. */
  67574. export class LerpBlock extends NodeMaterialBlock {
  67575. /**
  67576. * Creates a new LerpBlock
  67577. * @param name defines the block name
  67578. */
  67579. constructor(name: string);
  67580. /**
  67581. * Gets the current class name
  67582. * @returns the class name
  67583. */
  67584. getClassName(): string;
  67585. /**
  67586. * Gets the left operand input component
  67587. */
  67588. get left(): NodeMaterialConnectionPoint;
  67589. /**
  67590. * Gets the right operand input component
  67591. */
  67592. get right(): NodeMaterialConnectionPoint;
  67593. /**
  67594. * Gets the gradient operand input component
  67595. */
  67596. get gradient(): NodeMaterialConnectionPoint;
  67597. /**
  67598. * Gets the output component
  67599. */
  67600. get output(): NodeMaterialConnectionPoint;
  67601. protected _buildBlock(state: NodeMaterialBuildState): this;
  67602. }
  67603. }
  67604. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67606. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67607. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67608. /**
  67609. * Block used to divide 2 vectors
  67610. */
  67611. export class DivideBlock extends NodeMaterialBlock {
  67612. /**
  67613. * Creates a new DivideBlock
  67614. * @param name defines the block name
  67615. */
  67616. constructor(name: string);
  67617. /**
  67618. * Gets the current class name
  67619. * @returns the class name
  67620. */
  67621. getClassName(): string;
  67622. /**
  67623. * Gets the left operand input component
  67624. */
  67625. get left(): NodeMaterialConnectionPoint;
  67626. /**
  67627. * Gets the right operand input component
  67628. */
  67629. get right(): NodeMaterialConnectionPoint;
  67630. /**
  67631. * Gets the output component
  67632. */
  67633. get output(): NodeMaterialConnectionPoint;
  67634. protected _buildBlock(state: NodeMaterialBuildState): this;
  67635. }
  67636. }
  67637. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67641. /**
  67642. * Block used to subtract 2 vectors
  67643. */
  67644. export class SubtractBlock extends NodeMaterialBlock {
  67645. /**
  67646. * Creates a new SubtractBlock
  67647. * @param name defines the block name
  67648. */
  67649. constructor(name: string);
  67650. /**
  67651. * Gets the current class name
  67652. * @returns the class name
  67653. */
  67654. getClassName(): string;
  67655. /**
  67656. * Gets the left operand input component
  67657. */
  67658. get left(): NodeMaterialConnectionPoint;
  67659. /**
  67660. * Gets the right operand input component
  67661. */
  67662. get right(): 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/stepBlock" {
  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. /**
  67675. * Block used to step a value
  67676. */
  67677. export class StepBlock extends NodeMaterialBlock {
  67678. /**
  67679. * Creates a new StepBlock
  67680. * @param name defines the block name
  67681. */
  67682. constructor(name: string);
  67683. /**
  67684. * Gets the current class name
  67685. * @returns the class name
  67686. */
  67687. getClassName(): string;
  67688. /**
  67689. * Gets the value operand input component
  67690. */
  67691. get value(): NodeMaterialConnectionPoint;
  67692. /**
  67693. * Gets the edge operand input component
  67694. */
  67695. get edge(): NodeMaterialConnectionPoint;
  67696. /**
  67697. * Gets the output component
  67698. */
  67699. get output(): NodeMaterialConnectionPoint;
  67700. protected _buildBlock(state: NodeMaterialBuildState): this;
  67701. }
  67702. }
  67703. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67707. /**
  67708. * Block used to get the opposite (1 - x) of a value
  67709. */
  67710. export class OneMinusBlock extends NodeMaterialBlock {
  67711. /**
  67712. * Creates a new OneMinusBlock
  67713. * @param name defines the block name
  67714. */
  67715. constructor(name: string);
  67716. /**
  67717. * Gets the current class name
  67718. * @returns the class name
  67719. */
  67720. getClassName(): string;
  67721. /**
  67722. * Gets the input component
  67723. */
  67724. get input(): NodeMaterialConnectionPoint;
  67725. /**
  67726. * Gets the output component
  67727. */
  67728. get output(): NodeMaterialConnectionPoint;
  67729. protected _buildBlock(state: NodeMaterialBuildState): this;
  67730. }
  67731. }
  67732. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67733. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67736. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67737. /**
  67738. * Block used to get the view direction
  67739. */
  67740. export class ViewDirectionBlock extends NodeMaterialBlock {
  67741. /**
  67742. * Creates a new ViewDirectionBlock
  67743. * @param name defines the block name
  67744. */
  67745. constructor(name: string);
  67746. /**
  67747. * Gets the current class name
  67748. * @returns the class name
  67749. */
  67750. getClassName(): string;
  67751. /**
  67752. * Gets the world position component
  67753. */
  67754. get worldPosition(): NodeMaterialConnectionPoint;
  67755. /**
  67756. * Gets the camera position component
  67757. */
  67758. get cameraPosition(): NodeMaterialConnectionPoint;
  67759. /**
  67760. * Gets the output component
  67761. */
  67762. get output(): NodeMaterialConnectionPoint;
  67763. autoConfigure(material: NodeMaterial): void;
  67764. protected _buildBlock(state: NodeMaterialBuildState): this;
  67765. }
  67766. }
  67767. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67770. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67771. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67772. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67773. /**
  67774. * Block used to compute fresnel value
  67775. */
  67776. export class FresnelBlock extends NodeMaterialBlock {
  67777. /**
  67778. * Create a new FresnelBlock
  67779. * @param name defines the block name
  67780. */
  67781. constructor(name: string);
  67782. /**
  67783. * Gets the current class name
  67784. * @returns the class name
  67785. */
  67786. getClassName(): string;
  67787. /**
  67788. * Gets the world normal input component
  67789. */
  67790. get worldNormal(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the view direction input component
  67793. */
  67794. get viewDirection(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the bias input component
  67797. */
  67798. get bias(): NodeMaterialConnectionPoint;
  67799. /**
  67800. * Gets the camera (or eye) position component
  67801. */
  67802. get power(): NodeMaterialConnectionPoint;
  67803. /**
  67804. * Gets the fresnel output component
  67805. */
  67806. get fresnel(): NodeMaterialConnectionPoint;
  67807. autoConfigure(material: NodeMaterial): void;
  67808. protected _buildBlock(state: NodeMaterialBuildState): this;
  67809. }
  67810. }
  67811. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67815. /**
  67816. * Block used to get the max of 2 values
  67817. */
  67818. export class MaxBlock extends NodeMaterialBlock {
  67819. /**
  67820. * Creates a new MaxBlock
  67821. * @param name defines the block name
  67822. */
  67823. constructor(name: string);
  67824. /**
  67825. * Gets the current class name
  67826. * @returns the class name
  67827. */
  67828. getClassName(): string;
  67829. /**
  67830. * Gets the left operand input component
  67831. */
  67832. get left(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the right operand input component
  67835. */
  67836. get right(): NodeMaterialConnectionPoint;
  67837. /**
  67838. * Gets the output component
  67839. */
  67840. get output(): NodeMaterialConnectionPoint;
  67841. protected _buildBlock(state: NodeMaterialBuildState): this;
  67842. }
  67843. }
  67844. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67848. /**
  67849. * Block used to get the min of 2 values
  67850. */
  67851. export class MinBlock extends NodeMaterialBlock {
  67852. /**
  67853. * Creates a new MinBlock
  67854. * @param name defines the block name
  67855. */
  67856. constructor(name: string);
  67857. /**
  67858. * Gets the current class name
  67859. * @returns the class name
  67860. */
  67861. getClassName(): string;
  67862. /**
  67863. * Gets the left operand input component
  67864. */
  67865. get left(): NodeMaterialConnectionPoint;
  67866. /**
  67867. * Gets the right operand input component
  67868. */
  67869. get right(): 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/distanceBlock" {
  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 the distance between 2 values
  67883. */
  67884. export class DistanceBlock extends NodeMaterialBlock {
  67885. /**
  67886. * Creates a new DistanceBlock
  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 left operand input component
  67897. */
  67898. get left(): NodeMaterialConnectionPoint;
  67899. /**
  67900. * Gets the right operand input component
  67901. */
  67902. get right(): NodeMaterialConnectionPoint;
  67903. /**
  67904. * Gets the output component
  67905. */
  67906. get output(): NodeMaterialConnectionPoint;
  67907. protected _buildBlock(state: NodeMaterialBuildState): this;
  67908. }
  67909. }
  67910. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67914. /**
  67915. * Block used to get the length of a vector
  67916. */
  67917. export class LengthBlock extends NodeMaterialBlock {
  67918. /**
  67919. * Creates a new LengthBlock
  67920. * @param name defines the block name
  67921. */
  67922. constructor(name: string);
  67923. /**
  67924. * Gets the current class name
  67925. * @returns the class name
  67926. */
  67927. getClassName(): string;
  67928. /**
  67929. * Gets the value input component
  67930. */
  67931. get value(): 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/negateBlock" {
  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. /**
  67944. * Block used to get negative version of a value (i.e. x * -1)
  67945. */
  67946. export class NegateBlock extends NodeMaterialBlock {
  67947. /**
  67948. * Creates a new NegateBlock
  67949. * @param name defines the block name
  67950. */
  67951. constructor(name: string);
  67952. /**
  67953. * Gets the current class name
  67954. * @returns the class name
  67955. */
  67956. getClassName(): string;
  67957. /**
  67958. * Gets the value input component
  67959. */
  67960. get value(): NodeMaterialConnectionPoint;
  67961. /**
  67962. * Gets the output component
  67963. */
  67964. get output(): NodeMaterialConnectionPoint;
  67965. protected _buildBlock(state: NodeMaterialBuildState): this;
  67966. }
  67967. }
  67968. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67972. /**
  67973. * Block used to get the value of the first parameter raised to the power of the second
  67974. */
  67975. export class PowBlock extends NodeMaterialBlock {
  67976. /**
  67977. * Creates a new PowBlock
  67978. * @param name defines the block name
  67979. */
  67980. constructor(name: string);
  67981. /**
  67982. * Gets the current class name
  67983. * @returns the class name
  67984. */
  67985. getClassName(): string;
  67986. /**
  67987. * Gets the value operand input component
  67988. */
  67989. get value(): NodeMaterialConnectionPoint;
  67990. /**
  67991. * Gets the power operand input component
  67992. */
  67993. get power(): NodeMaterialConnectionPoint;
  67994. /**
  67995. * Gets the output component
  67996. */
  67997. get output(): NodeMaterialConnectionPoint;
  67998. protected _buildBlock(state: NodeMaterialBuildState): this;
  67999. }
  68000. }
  68001. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  68002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68005. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68006. /**
  68007. * Block used to get a random number
  68008. */
  68009. export class RandomNumberBlock extends NodeMaterialBlock {
  68010. /**
  68011. * Creates a new RandomNumberBlock
  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 seed input component
  68022. */
  68023. get seed(): NodeMaterialConnectionPoint;
  68024. /**
  68025. * Gets the output component
  68026. */
  68027. get output(): NodeMaterialConnectionPoint;
  68028. protected _buildBlock(state: NodeMaterialBuildState): this;
  68029. }
  68030. }
  68031. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68035. /**
  68036. * Block used to compute arc tangent of 2 values
  68037. */
  68038. export class ArcTan2Block extends NodeMaterialBlock {
  68039. /**
  68040. * Creates a new ArcTan2Block
  68041. * @param name defines the block name
  68042. */
  68043. constructor(name: string);
  68044. /**
  68045. * Gets the current class name
  68046. * @returns the class name
  68047. */
  68048. getClassName(): string;
  68049. /**
  68050. * Gets the x operand input component
  68051. */
  68052. get x(): NodeMaterialConnectionPoint;
  68053. /**
  68054. * Gets the y operand input component
  68055. */
  68056. get y(): NodeMaterialConnectionPoint;
  68057. /**
  68058. * Gets the output component
  68059. */
  68060. get output(): NodeMaterialConnectionPoint;
  68061. protected _buildBlock(state: NodeMaterialBuildState): this;
  68062. }
  68063. }
  68064. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68068. /**
  68069. * Block used to smooth step a value
  68070. */
  68071. export class SmoothStepBlock extends NodeMaterialBlock {
  68072. /**
  68073. * Creates a new SmoothStepBlock
  68074. * @param name defines the block name
  68075. */
  68076. constructor(name: string);
  68077. /**
  68078. * Gets the current class name
  68079. * @returns the class name
  68080. */
  68081. getClassName(): string;
  68082. /**
  68083. * Gets the value operand input component
  68084. */
  68085. get value(): NodeMaterialConnectionPoint;
  68086. /**
  68087. * Gets the first edge operand input component
  68088. */
  68089. get edge0(): NodeMaterialConnectionPoint;
  68090. /**
  68091. * Gets the second edge operand input component
  68092. */
  68093. get edge1(): NodeMaterialConnectionPoint;
  68094. /**
  68095. * Gets the output component
  68096. */
  68097. get output(): NodeMaterialConnectionPoint;
  68098. protected _buildBlock(state: NodeMaterialBuildState): this;
  68099. }
  68100. }
  68101. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68103. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68104. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68105. /**
  68106. * Block used to get the reciprocal (1 / x) of a value
  68107. */
  68108. export class ReciprocalBlock extends NodeMaterialBlock {
  68109. /**
  68110. * Creates a new ReciprocalBlock
  68111. * @param name defines the block name
  68112. */
  68113. constructor(name: string);
  68114. /**
  68115. * Gets the current class name
  68116. * @returns the class name
  68117. */
  68118. getClassName(): string;
  68119. /**
  68120. * Gets the input component
  68121. */
  68122. get input(): NodeMaterialConnectionPoint;
  68123. /**
  68124. * Gets the output component
  68125. */
  68126. get output(): NodeMaterialConnectionPoint;
  68127. protected _buildBlock(state: NodeMaterialBuildState): this;
  68128. }
  68129. }
  68130. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68134. /**
  68135. * Block used to replace a color by another one
  68136. */
  68137. export class ReplaceColorBlock extends NodeMaterialBlock {
  68138. /**
  68139. * Creates a new ReplaceColorBlock
  68140. * @param name defines the block name
  68141. */
  68142. constructor(name: string);
  68143. /**
  68144. * Gets the current class name
  68145. * @returns the class name
  68146. */
  68147. getClassName(): string;
  68148. /**
  68149. * Gets the value input component
  68150. */
  68151. get value(): NodeMaterialConnectionPoint;
  68152. /**
  68153. * Gets the reference input component
  68154. */
  68155. get reference(): NodeMaterialConnectionPoint;
  68156. /**
  68157. * Gets the distance input component
  68158. */
  68159. get distance(): NodeMaterialConnectionPoint;
  68160. /**
  68161. * Gets the replacement input component
  68162. */
  68163. get replacement(): NodeMaterialConnectionPoint;
  68164. /**
  68165. * Gets the output component
  68166. */
  68167. get output(): NodeMaterialConnectionPoint;
  68168. protected _buildBlock(state: NodeMaterialBuildState): this;
  68169. }
  68170. }
  68171. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68175. /**
  68176. * Block used to posterize a value
  68177. * @see https://en.wikipedia.org/wiki/Posterization
  68178. */
  68179. export class PosterizeBlock extends NodeMaterialBlock {
  68180. /**
  68181. * Creates a new PosterizeBlock
  68182. * @param name defines the block name
  68183. */
  68184. constructor(name: string);
  68185. /**
  68186. * Gets the current class name
  68187. * @returns the class name
  68188. */
  68189. getClassName(): string;
  68190. /**
  68191. * Gets the value input component
  68192. */
  68193. get value(): NodeMaterialConnectionPoint;
  68194. /**
  68195. * Gets the steps input component
  68196. */
  68197. get steps(): NodeMaterialConnectionPoint;
  68198. /**
  68199. * Gets the output component
  68200. */
  68201. get output(): NodeMaterialConnectionPoint;
  68202. protected _buildBlock(state: NodeMaterialBuildState): this;
  68203. }
  68204. }
  68205. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68209. import { Scene } from "babylonjs/scene";
  68210. /**
  68211. * Operations supported by the Wave block
  68212. */
  68213. export enum WaveBlockKind {
  68214. /** SawTooth */
  68215. SawTooth = 0,
  68216. /** Square */
  68217. Square = 1,
  68218. /** Triangle */
  68219. Triangle = 2
  68220. }
  68221. /**
  68222. * Block used to apply wave operation to floats
  68223. */
  68224. export class WaveBlock extends NodeMaterialBlock {
  68225. /**
  68226. * Gets or sets the kibnd of wave to be applied by the block
  68227. */
  68228. kind: WaveBlockKind;
  68229. /**
  68230. * Creates a new WaveBlock
  68231. * @param name defines the block name
  68232. */
  68233. constructor(name: string);
  68234. /**
  68235. * Gets the current class name
  68236. * @returns the class name
  68237. */
  68238. getClassName(): string;
  68239. /**
  68240. * Gets the input component
  68241. */
  68242. get input(): NodeMaterialConnectionPoint;
  68243. /**
  68244. * Gets the output component
  68245. */
  68246. get output(): NodeMaterialConnectionPoint;
  68247. protected _buildBlock(state: NodeMaterialBuildState): this;
  68248. serialize(): any;
  68249. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68250. }
  68251. }
  68252. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68253. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68255. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68256. import { Color3 } from "babylonjs/Maths/math.color";
  68257. import { Scene } from "babylonjs/scene";
  68258. import { Observable } from "babylonjs/Misc/observable";
  68259. /**
  68260. * Class used to store a color step for the GradientBlock
  68261. */
  68262. export class GradientBlockColorStep {
  68263. private _step;
  68264. /**
  68265. * Gets value indicating which step this color is associated with (between 0 and 1)
  68266. */
  68267. get step(): number;
  68268. /**
  68269. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68270. */
  68271. set step(val: number);
  68272. private _color;
  68273. /**
  68274. * Gets the color associated with this step
  68275. */
  68276. get color(): Color3;
  68277. /**
  68278. * Sets the color associated with this step
  68279. */
  68280. set color(val: Color3);
  68281. /**
  68282. * Creates a new GradientBlockColorStep
  68283. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68284. * @param color defines the color associated with this step
  68285. */
  68286. constructor(step: number, color: Color3);
  68287. }
  68288. /**
  68289. * Block used to return a color from a gradient based on an input value between 0 and 1
  68290. */
  68291. export class GradientBlock extends NodeMaterialBlock {
  68292. /**
  68293. * Gets or sets the list of color steps
  68294. */
  68295. colorSteps: GradientBlockColorStep[];
  68296. /** Gets an observable raised when the value is changed */
  68297. onValueChangedObservable: Observable<GradientBlock>;
  68298. /** calls observable when the value is changed*/
  68299. colorStepsUpdated(): void;
  68300. /**
  68301. * Creates a new GradientBlock
  68302. * @param name defines the block name
  68303. */
  68304. constructor(name: string);
  68305. /**
  68306. * Gets the current class name
  68307. * @returns the class name
  68308. */
  68309. getClassName(): string;
  68310. /**
  68311. * Gets the gradient input component
  68312. */
  68313. get gradient(): NodeMaterialConnectionPoint;
  68314. /**
  68315. * Gets the output component
  68316. */
  68317. get output(): NodeMaterialConnectionPoint;
  68318. private _writeColorConstant;
  68319. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68320. serialize(): any;
  68321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68322. protected _dumpPropertiesCode(): string;
  68323. }
  68324. }
  68325. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68329. /**
  68330. * Block used to normalize lerp between 2 values
  68331. */
  68332. export class NLerpBlock extends NodeMaterialBlock {
  68333. /**
  68334. * Creates a new NLerpBlock
  68335. * @param name defines the block name
  68336. */
  68337. constructor(name: string);
  68338. /**
  68339. * Gets the current class name
  68340. * @returns the class name
  68341. */
  68342. getClassName(): string;
  68343. /**
  68344. * Gets the left operand input component
  68345. */
  68346. get left(): NodeMaterialConnectionPoint;
  68347. /**
  68348. * Gets the right operand input component
  68349. */
  68350. get right(): NodeMaterialConnectionPoint;
  68351. /**
  68352. * Gets the gradient operand input component
  68353. */
  68354. get gradient(): NodeMaterialConnectionPoint;
  68355. /**
  68356. * Gets the output component
  68357. */
  68358. get output(): NodeMaterialConnectionPoint;
  68359. protected _buildBlock(state: NodeMaterialBuildState): this;
  68360. }
  68361. }
  68362. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68366. import { Scene } from "babylonjs/scene";
  68367. /**
  68368. * block used to Generate a Worley Noise 3D Noise Pattern
  68369. */
  68370. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68371. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68372. manhattanDistance: boolean;
  68373. /**
  68374. * Creates a new WorleyNoise3DBlock
  68375. * @param name defines the block name
  68376. */
  68377. constructor(name: string);
  68378. /**
  68379. * Gets the current class name
  68380. * @returns the class name
  68381. */
  68382. getClassName(): string;
  68383. /**
  68384. * Gets the seed input component
  68385. */
  68386. get seed(): NodeMaterialConnectionPoint;
  68387. /**
  68388. * Gets the jitter input component
  68389. */
  68390. get jitter(): NodeMaterialConnectionPoint;
  68391. /**
  68392. * Gets the output component
  68393. */
  68394. get output(): NodeMaterialConnectionPoint;
  68395. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68396. /**
  68397. * Exposes the properties to the UI?
  68398. */
  68399. protected _dumpPropertiesCode(): string;
  68400. /**
  68401. * Exposes the properties to the Seralize?
  68402. */
  68403. serialize(): any;
  68404. /**
  68405. * Exposes the properties to the deseralize?
  68406. */
  68407. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68408. }
  68409. }
  68410. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  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. /**
  68415. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68416. */
  68417. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68418. /**
  68419. * Creates a new SimplexPerlin3DBlock
  68420. * @param name defines the block name
  68421. */
  68422. constructor(name: string);
  68423. /**
  68424. * Gets the current class name
  68425. * @returns the class name
  68426. */
  68427. getClassName(): string;
  68428. /**
  68429. * Gets the seed operand input component
  68430. */
  68431. get seed(): NodeMaterialConnectionPoint;
  68432. /**
  68433. * Gets the output component
  68434. */
  68435. get output(): NodeMaterialConnectionPoint;
  68436. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68437. }
  68438. }
  68439. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68443. /**
  68444. * Block used to blend normals
  68445. */
  68446. export class NormalBlendBlock extends NodeMaterialBlock {
  68447. /**
  68448. * Creates a new NormalBlendBlock
  68449. * @param name defines the block name
  68450. */
  68451. constructor(name: string);
  68452. /**
  68453. * Gets the current class name
  68454. * @returns the class name
  68455. */
  68456. getClassName(): string;
  68457. /**
  68458. * Gets the first input component
  68459. */
  68460. get normalMap0(): NodeMaterialConnectionPoint;
  68461. /**
  68462. * Gets the second input component
  68463. */
  68464. get normalMap1(): NodeMaterialConnectionPoint;
  68465. /**
  68466. * Gets the output component
  68467. */
  68468. get output(): NodeMaterialConnectionPoint;
  68469. protected _buildBlock(state: NodeMaterialBuildState): this;
  68470. }
  68471. }
  68472. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68476. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68477. /**
  68478. * Block used to rotate a 2d vector by a given angle
  68479. */
  68480. export class Rotate2dBlock extends NodeMaterialBlock {
  68481. /**
  68482. * Creates a new Rotate2dBlock
  68483. * @param name defines the block name
  68484. */
  68485. constructor(name: string);
  68486. /**
  68487. * Gets the current class name
  68488. * @returns the class name
  68489. */
  68490. getClassName(): string;
  68491. /**
  68492. * Gets the input vector
  68493. */
  68494. get input(): NodeMaterialConnectionPoint;
  68495. /**
  68496. * Gets the input angle
  68497. */
  68498. get angle(): NodeMaterialConnectionPoint;
  68499. /**
  68500. * Gets the output component
  68501. */
  68502. get output(): NodeMaterialConnectionPoint;
  68503. autoConfigure(material: NodeMaterial): void;
  68504. protected _buildBlock(state: NodeMaterialBuildState): this;
  68505. }
  68506. }
  68507. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68511. /**
  68512. * Block used to get the reflected vector from a direction and a normal
  68513. */
  68514. export class ReflectBlock extends NodeMaterialBlock {
  68515. /**
  68516. * Creates a new ReflectBlock
  68517. * @param name defines the block name
  68518. */
  68519. constructor(name: string);
  68520. /**
  68521. * Gets the current class name
  68522. * @returns the class name
  68523. */
  68524. getClassName(): string;
  68525. /**
  68526. * Gets the incident component
  68527. */
  68528. get incident(): NodeMaterialConnectionPoint;
  68529. /**
  68530. * Gets the normal component
  68531. */
  68532. get normal(): NodeMaterialConnectionPoint;
  68533. /**
  68534. * Gets the output component
  68535. */
  68536. get output(): NodeMaterialConnectionPoint;
  68537. protected _buildBlock(state: NodeMaterialBuildState): this;
  68538. }
  68539. }
  68540. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68544. /**
  68545. * Block used to get the refracted vector from a direction and a normal
  68546. */
  68547. export class RefractBlock extends NodeMaterialBlock {
  68548. /**
  68549. * Creates a new RefractBlock
  68550. * @param name defines the block name
  68551. */
  68552. constructor(name: string);
  68553. /**
  68554. * Gets the current class name
  68555. * @returns the class name
  68556. */
  68557. getClassName(): string;
  68558. /**
  68559. * Gets the incident component
  68560. */
  68561. get incident(): NodeMaterialConnectionPoint;
  68562. /**
  68563. * Gets the normal component
  68564. */
  68565. get normal(): NodeMaterialConnectionPoint;
  68566. /**
  68567. * Gets the index of refraction component
  68568. */
  68569. get ior(): NodeMaterialConnectionPoint;
  68570. /**
  68571. * Gets the output component
  68572. */
  68573. get output(): NodeMaterialConnectionPoint;
  68574. protected _buildBlock(state: NodeMaterialBuildState): this;
  68575. }
  68576. }
  68577. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68581. /**
  68582. * Block used to desaturate a color
  68583. */
  68584. export class DesaturateBlock extends NodeMaterialBlock {
  68585. /**
  68586. * Creates a new DesaturateBlock
  68587. * @param name defines the block name
  68588. */
  68589. constructor(name: string);
  68590. /**
  68591. * Gets the current class name
  68592. * @returns the class name
  68593. */
  68594. getClassName(): string;
  68595. /**
  68596. * Gets the color operand input component
  68597. */
  68598. get color(): NodeMaterialConnectionPoint;
  68599. /**
  68600. * Gets the level operand input component
  68601. */
  68602. get level(): NodeMaterialConnectionPoint;
  68603. /**
  68604. * Gets the output component
  68605. */
  68606. get output(): NodeMaterialConnectionPoint;
  68607. protected _buildBlock(state: NodeMaterialBuildState): this;
  68608. }
  68609. }
  68610. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68614. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68615. import { Nullable } from "babylonjs/types";
  68616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68617. import { Scene } from "babylonjs/scene";
  68618. /**
  68619. * Block used to implement the ambient occlusion module of the PBR material
  68620. */
  68621. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68622. /**
  68623. * Create a new AmbientOcclusionBlock
  68624. * @param name defines the block name
  68625. */
  68626. constructor(name: string);
  68627. /**
  68628. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68629. */
  68630. useAmbientInGrayScale: boolean;
  68631. /**
  68632. * Initialize the block and prepare the context for build
  68633. * @param state defines the state that will be used for the build
  68634. */
  68635. initialize(state: NodeMaterialBuildState): void;
  68636. /**
  68637. * Gets the current class name
  68638. * @returns the class name
  68639. */
  68640. getClassName(): string;
  68641. /**
  68642. * Gets the texture input component
  68643. */
  68644. get texture(): NodeMaterialConnectionPoint;
  68645. /**
  68646. * Gets the texture intensity component
  68647. */
  68648. get intensity(): NodeMaterialConnectionPoint;
  68649. /**
  68650. * Gets the direct light intensity input component
  68651. */
  68652. get directLightIntensity(): NodeMaterialConnectionPoint;
  68653. /**
  68654. * Gets the ambient occlusion object output component
  68655. */
  68656. get ambientOcc(): NodeMaterialConnectionPoint;
  68657. /**
  68658. * Gets the main code of the block (fragment side)
  68659. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68660. * @returns the shader code
  68661. */
  68662. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68664. protected _buildBlock(state: NodeMaterialBuildState): this;
  68665. protected _dumpPropertiesCode(): string;
  68666. serialize(): any;
  68667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68668. }
  68669. }
  68670. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68673. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68674. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68676. import { Nullable } from "babylonjs/types";
  68677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68678. import { Mesh } from "babylonjs/Meshes/mesh";
  68679. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68680. import { Effect } from "babylonjs/Materials/effect";
  68681. import { Scene } from "babylonjs/scene";
  68682. /**
  68683. * Block used to implement the reflection module of the PBR material
  68684. */
  68685. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68686. /** @hidden */
  68687. _defineLODReflectionAlpha: string;
  68688. /** @hidden */
  68689. _defineLinearSpecularReflection: string;
  68690. private _vEnvironmentIrradianceName;
  68691. /** @hidden */
  68692. _vReflectionMicrosurfaceInfosName: string;
  68693. /** @hidden */
  68694. _vReflectionInfosName: string;
  68695. /** @hidden */
  68696. _vReflectionFilteringInfoName: string;
  68697. private _scene;
  68698. /**
  68699. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68700. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68701. * It's less burden on the user side in the editor part.
  68702. */
  68703. /** @hidden */
  68704. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68705. /** @hidden */
  68706. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68707. /** @hidden */
  68708. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68709. /**
  68710. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68711. * diffuse part of the IBL.
  68712. */
  68713. useSphericalHarmonics: boolean;
  68714. /**
  68715. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68716. */
  68717. forceIrradianceInFragment: boolean;
  68718. /**
  68719. * Create a new ReflectionBlock
  68720. * @param name defines the block name
  68721. */
  68722. constructor(name: string);
  68723. /**
  68724. * Gets the current class name
  68725. * @returns the class name
  68726. */
  68727. getClassName(): string;
  68728. /**
  68729. * Gets the position input component
  68730. */
  68731. get position(): NodeMaterialConnectionPoint;
  68732. /**
  68733. * Gets the world position input component
  68734. */
  68735. get worldPosition(): NodeMaterialConnectionPoint;
  68736. /**
  68737. * Gets the world normal input component
  68738. */
  68739. get worldNormal(): NodeMaterialConnectionPoint;
  68740. /**
  68741. * Gets the world input component
  68742. */
  68743. get world(): NodeMaterialConnectionPoint;
  68744. /**
  68745. * Gets the camera (or eye) position component
  68746. */
  68747. get cameraPosition(): NodeMaterialConnectionPoint;
  68748. /**
  68749. * Gets the view input component
  68750. */
  68751. get view(): NodeMaterialConnectionPoint;
  68752. /**
  68753. * Gets the color input component
  68754. */
  68755. get color(): NodeMaterialConnectionPoint;
  68756. /**
  68757. * Gets the reflection object output component
  68758. */
  68759. get reflection(): NodeMaterialConnectionPoint;
  68760. /**
  68761. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68762. */
  68763. get hasTexture(): boolean;
  68764. /**
  68765. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68766. */
  68767. get reflectionColor(): string;
  68768. protected _getTexture(): Nullable<BaseTexture>;
  68769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68770. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68771. /**
  68772. * Gets the code to inject in the vertex shader
  68773. * @param state current state of the node material building
  68774. * @returns the shader code
  68775. */
  68776. handleVertexSide(state: NodeMaterialBuildState): string;
  68777. /**
  68778. * Gets the main code of the block (fragment side)
  68779. * @param state current state of the node material building
  68780. * @param normalVarName name of the existing variable corresponding to the normal
  68781. * @returns the shader code
  68782. */
  68783. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68784. protected _buildBlock(state: NodeMaterialBuildState): this;
  68785. protected _dumpPropertiesCode(): string;
  68786. serialize(): any;
  68787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68788. }
  68789. }
  68790. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68794. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68796. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68797. import { Scene } from "babylonjs/scene";
  68798. import { Nullable } from "babylonjs/types";
  68799. /**
  68800. * Block used to implement the sheen module of the PBR material
  68801. */
  68802. export class SheenBlock extends NodeMaterialBlock {
  68803. /**
  68804. * Create a new SheenBlock
  68805. * @param name defines the block name
  68806. */
  68807. constructor(name: string);
  68808. /**
  68809. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68810. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68811. * making it easier to setup and tweak the effect
  68812. */
  68813. albedoScaling: boolean;
  68814. /**
  68815. * Defines if the sheen is linked to the sheen color.
  68816. */
  68817. linkSheenWithAlbedo: boolean;
  68818. /**
  68819. * Initialize the block and prepare the context for build
  68820. * @param state defines the state that will be used for the build
  68821. */
  68822. initialize(state: NodeMaterialBuildState): void;
  68823. /**
  68824. * Gets the current class name
  68825. * @returns the class name
  68826. */
  68827. getClassName(): string;
  68828. /**
  68829. * Gets the intensity input component
  68830. */
  68831. get intensity(): NodeMaterialConnectionPoint;
  68832. /**
  68833. * Gets the color input component
  68834. */
  68835. get color(): NodeMaterialConnectionPoint;
  68836. /**
  68837. * Gets the roughness input component
  68838. */
  68839. get roughness(): NodeMaterialConnectionPoint;
  68840. /**
  68841. * Gets the sheen object output component
  68842. */
  68843. get sheen(): NodeMaterialConnectionPoint;
  68844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68845. /**
  68846. * Gets the main code of the block (fragment side)
  68847. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68848. * @returns the shader code
  68849. */
  68850. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68851. protected _buildBlock(state: NodeMaterialBuildState): this;
  68852. protected _dumpPropertiesCode(): string;
  68853. serialize(): any;
  68854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68855. }
  68856. }
  68857. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68858. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68863. import { Scene } from "babylonjs/scene";
  68864. import { Nullable } from "babylonjs/types";
  68865. import { Mesh } from "babylonjs/Meshes/mesh";
  68866. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68867. import { Effect } from "babylonjs/Materials/effect";
  68868. /**
  68869. * Block used to implement the reflectivity module of the PBR material
  68870. */
  68871. export class ReflectivityBlock extends NodeMaterialBlock {
  68872. private _metallicReflectanceColor;
  68873. private _metallicF0Factor;
  68874. /** @hidden */
  68875. _vMetallicReflectanceFactorsName: string;
  68876. /**
  68877. * The property below is set by the main PBR block prior to calling methods of this class.
  68878. */
  68879. /** @hidden */
  68880. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68881. /**
  68882. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68883. */
  68884. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68885. /**
  68886. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68887. */
  68888. useMetallnessFromMetallicTextureBlue: boolean;
  68889. /**
  68890. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68891. */
  68892. useRoughnessFromMetallicTextureAlpha: boolean;
  68893. /**
  68894. * Specifies if the metallic texture contains the roughness information in its green channel.
  68895. */
  68896. useRoughnessFromMetallicTextureGreen: boolean;
  68897. /**
  68898. * Create a new ReflectivityBlock
  68899. * @param name defines the block name
  68900. */
  68901. constructor(name: string);
  68902. /**
  68903. * Initialize the block and prepare the context for build
  68904. * @param state defines the state that will be used for the build
  68905. */
  68906. initialize(state: NodeMaterialBuildState): void;
  68907. /**
  68908. * Gets the current class name
  68909. * @returns the class name
  68910. */
  68911. getClassName(): string;
  68912. /**
  68913. * Gets the metallic input component
  68914. */
  68915. get metallic(): NodeMaterialConnectionPoint;
  68916. /**
  68917. * Gets the roughness input component
  68918. */
  68919. get roughness(): NodeMaterialConnectionPoint;
  68920. /**
  68921. * Gets the texture input component
  68922. */
  68923. get texture(): NodeMaterialConnectionPoint;
  68924. /**
  68925. * Gets the reflectivity object output component
  68926. */
  68927. get reflectivity(): NodeMaterialConnectionPoint;
  68928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68929. /**
  68930. * Gets the main code of the block (fragment side)
  68931. * @param state current state of the node material building
  68932. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68933. * @returns the shader code
  68934. */
  68935. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68937. protected _buildBlock(state: NodeMaterialBuildState): this;
  68938. protected _dumpPropertiesCode(): string;
  68939. serialize(): any;
  68940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68941. }
  68942. }
  68943. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68944. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68949. /**
  68950. * Block used to implement the anisotropy module of the PBR material
  68951. */
  68952. export class AnisotropyBlock extends NodeMaterialBlock {
  68953. /**
  68954. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68955. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68956. * It's less burden on the user side in the editor part.
  68957. */
  68958. /** @hidden */
  68959. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68960. /** @hidden */
  68961. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68962. /**
  68963. * Create a new AnisotropyBlock
  68964. * @param name defines the block name
  68965. */
  68966. constructor(name: string);
  68967. /**
  68968. * Initialize the block and prepare the context for build
  68969. * @param state defines the state that will be used for the build
  68970. */
  68971. initialize(state: NodeMaterialBuildState): void;
  68972. /**
  68973. * Gets the current class name
  68974. * @returns the class name
  68975. */
  68976. getClassName(): string;
  68977. /**
  68978. * Gets the intensity input component
  68979. */
  68980. get intensity(): NodeMaterialConnectionPoint;
  68981. /**
  68982. * Gets the direction input component
  68983. */
  68984. get direction(): NodeMaterialConnectionPoint;
  68985. /**
  68986. * Gets the texture input component
  68987. */
  68988. get texture(): NodeMaterialConnectionPoint;
  68989. /**
  68990. * Gets the uv input component
  68991. */
  68992. get uv(): NodeMaterialConnectionPoint;
  68993. /**
  68994. * Gets the worldTangent input component
  68995. */
  68996. get worldTangent(): NodeMaterialConnectionPoint;
  68997. /**
  68998. * Gets the anisotropy object output component
  68999. */
  69000. get anisotropy(): NodeMaterialConnectionPoint;
  69001. private _generateTBNSpace;
  69002. /**
  69003. * Gets the main code of the block (fragment side)
  69004. * @param state current state of the node material building
  69005. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69006. * @returns the shader code
  69007. */
  69008. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69010. protected _buildBlock(state: NodeMaterialBuildState): this;
  69011. }
  69012. }
  69013. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69017. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69019. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69020. import { Nullable } from "babylonjs/types";
  69021. import { Mesh } from "babylonjs/Meshes/mesh";
  69022. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69023. import { Effect } from "babylonjs/Materials/effect";
  69024. /**
  69025. * Block used to implement the clear coat module of the PBR material
  69026. */
  69027. export class ClearCoatBlock extends NodeMaterialBlock {
  69028. private _scene;
  69029. /**
  69030. * Create a new ClearCoatBlock
  69031. * @param name defines the block name
  69032. */
  69033. constructor(name: string);
  69034. /**
  69035. * Initialize the block and prepare the context for build
  69036. * @param state defines the state that will be used for the build
  69037. */
  69038. initialize(state: NodeMaterialBuildState): void;
  69039. /**
  69040. * Gets the current class name
  69041. * @returns the class name
  69042. */
  69043. getClassName(): string;
  69044. /**
  69045. * Gets the intensity input component
  69046. */
  69047. get intensity(): NodeMaterialConnectionPoint;
  69048. /**
  69049. * Gets the roughness input component
  69050. */
  69051. get roughness(): NodeMaterialConnectionPoint;
  69052. /**
  69053. * Gets the ior input component
  69054. */
  69055. get ior(): NodeMaterialConnectionPoint;
  69056. /**
  69057. * Gets the texture input component
  69058. */
  69059. get texture(): NodeMaterialConnectionPoint;
  69060. /**
  69061. * Gets the bump texture input component
  69062. */
  69063. get bumpTexture(): NodeMaterialConnectionPoint;
  69064. /**
  69065. * Gets the uv input component
  69066. */
  69067. get uv(): NodeMaterialConnectionPoint;
  69068. /**
  69069. * Gets the tint color input component
  69070. */
  69071. get tintColor(): NodeMaterialConnectionPoint;
  69072. /**
  69073. * Gets the tint "at distance" input component
  69074. */
  69075. get tintAtDistance(): NodeMaterialConnectionPoint;
  69076. /**
  69077. * Gets the tint thickness input component
  69078. */
  69079. get tintThickness(): NodeMaterialConnectionPoint;
  69080. /**
  69081. * Gets the world tangent input component
  69082. */
  69083. get worldTangent(): NodeMaterialConnectionPoint;
  69084. /**
  69085. * Gets the clear coat object output component
  69086. */
  69087. get clearcoat(): NodeMaterialConnectionPoint;
  69088. autoConfigure(material: NodeMaterial): void;
  69089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69091. private _generateTBNSpace;
  69092. /**
  69093. * Gets the main code of the block (fragment side)
  69094. * @param state current state of the node material building
  69095. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69096. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69097. * @param worldPosVarName name of the variable holding the world position
  69098. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69099. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69100. * @param worldNormalVarName name of the variable holding the world normal
  69101. * @returns the shader code
  69102. */
  69103. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69104. protected _buildBlock(state: NodeMaterialBuildState): this;
  69105. }
  69106. }
  69107. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69111. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69113. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69114. import { Nullable } from "babylonjs/types";
  69115. /**
  69116. * Block used to implement the sub surface module of the PBR material
  69117. */
  69118. export class SubSurfaceBlock extends NodeMaterialBlock {
  69119. /**
  69120. * Create a new SubSurfaceBlock
  69121. * @param name defines the block name
  69122. */
  69123. constructor(name: string);
  69124. /**
  69125. * Stores the intensity of the different subsurface effects in the thickness texture.
  69126. * * the green channel is the translucency intensity.
  69127. * * the blue channel is the scattering intensity.
  69128. * * the alpha channel is the refraction intensity.
  69129. */
  69130. useMaskFromThicknessTexture: boolean;
  69131. /**
  69132. * Initialize the block and prepare the context for build
  69133. * @param state defines the state that will be used for the build
  69134. */
  69135. initialize(state: NodeMaterialBuildState): void;
  69136. /**
  69137. * Gets the current class name
  69138. * @returns the class name
  69139. */
  69140. getClassName(): string;
  69141. /**
  69142. * Gets the min thickness input component
  69143. */
  69144. get minThickness(): NodeMaterialConnectionPoint;
  69145. /**
  69146. * Gets the max thickness input component
  69147. */
  69148. get maxThickness(): NodeMaterialConnectionPoint;
  69149. /**
  69150. * Gets the thickness texture component
  69151. */
  69152. get thicknessTexture(): NodeMaterialConnectionPoint;
  69153. /**
  69154. * Gets the tint color input component
  69155. */
  69156. get tintColor(): NodeMaterialConnectionPoint;
  69157. /**
  69158. * Gets the translucency intensity input component
  69159. */
  69160. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69161. /**
  69162. * Gets the translucency diffusion distance input component
  69163. */
  69164. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  69165. /**
  69166. * Gets the refraction object parameters
  69167. */
  69168. get refraction(): NodeMaterialConnectionPoint;
  69169. /**
  69170. * Gets the sub surface object output component
  69171. */
  69172. get subsurface(): NodeMaterialConnectionPoint;
  69173. autoConfigure(material: NodeMaterial): void;
  69174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69175. /**
  69176. * Gets the main code of the block (fragment side)
  69177. * @param state current state of the node material building
  69178. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69179. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69180. * @param worldPosVarName name of the variable holding the world position
  69181. * @returns the shader code
  69182. */
  69183. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69184. protected _buildBlock(state: NodeMaterialBuildState): this;
  69185. }
  69186. }
  69187. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69191. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69192. import { Light } from "babylonjs/Lights/light";
  69193. import { Nullable } from "babylonjs/types";
  69194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69195. import { Effect } from "babylonjs/Materials/effect";
  69196. import { Mesh } from "babylonjs/Meshes/mesh";
  69197. import { Scene } from "babylonjs/scene";
  69198. /**
  69199. * Block used to implement the PBR metallic/roughness model
  69200. */
  69201. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69202. /**
  69203. * Gets or sets the light associated with this block
  69204. */
  69205. light: Nullable<Light>;
  69206. private _lightId;
  69207. private _scene;
  69208. private _environmentBRDFTexture;
  69209. private _environmentBrdfSamplerName;
  69210. private _vNormalWName;
  69211. private _invertNormalName;
  69212. /**
  69213. * Create a new ReflectionBlock
  69214. * @param name defines the block name
  69215. */
  69216. constructor(name: string);
  69217. /**
  69218. * Intensity of the direct lights e.g. the four lights available in your scene.
  69219. * This impacts both the direct diffuse and specular highlights.
  69220. */
  69221. directIntensity: number;
  69222. /**
  69223. * Intensity of the environment e.g. how much the environment will light the object
  69224. * either through harmonics for rough material or through the refelction for shiny ones.
  69225. */
  69226. environmentIntensity: number;
  69227. /**
  69228. * This is a special control allowing the reduction of the specular highlights coming from the
  69229. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69230. */
  69231. specularIntensity: number;
  69232. /**
  69233. * Defines the falloff type used in this material.
  69234. * It by default is Physical.
  69235. */
  69236. lightFalloff: number;
  69237. /**
  69238. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  69239. */
  69240. useAlphaFromAlbedoTexture: boolean;
  69241. /**
  69242. * Specifies that alpha test should be used
  69243. */
  69244. useAlphaTest: boolean;
  69245. /**
  69246. * Defines the alpha limits in alpha test mode.
  69247. */
  69248. alphaTestCutoff: number;
  69249. /**
  69250. * Specifies that alpha blending should be used
  69251. */
  69252. useAlphaBlending: boolean;
  69253. /**
  69254. * Defines if the alpha value should be determined via the rgb values.
  69255. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  69256. */
  69257. opacityRGB: boolean;
  69258. /**
  69259. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69260. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69261. */
  69262. useRadianceOverAlpha: boolean;
  69263. /**
  69264. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69265. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69266. */
  69267. useSpecularOverAlpha: boolean;
  69268. /**
  69269. * Enables specular anti aliasing in the PBR shader.
  69270. * It will both interacts on the Geometry for analytical and IBL lighting.
  69271. * It also prefilter the roughness map based on the bump values.
  69272. */
  69273. enableSpecularAntiAliasing: boolean;
  69274. /**
  69275. * Enables realtime filtering on the texture.
  69276. */
  69277. realTimeFiltering: boolean;
  69278. /**
  69279. * Quality switch for realtime filtering
  69280. */
  69281. realTimeFilteringQuality: number;
  69282. /**
  69283. * Defines if the material uses energy conservation.
  69284. */
  69285. useEnergyConservation: boolean;
  69286. /**
  69287. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69288. * too much the area relying on ambient texture to define their ambient occlusion.
  69289. */
  69290. useRadianceOcclusion: boolean;
  69291. /**
  69292. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69293. * makes the reflect vector face the model (under horizon).
  69294. */
  69295. useHorizonOcclusion: boolean;
  69296. /**
  69297. * If set to true, no lighting calculations will be applied.
  69298. */
  69299. unlit: boolean;
  69300. /**
  69301. * Force normal to face away from face.
  69302. */
  69303. forceNormalForward: boolean;
  69304. /**
  69305. * Defines the material debug mode.
  69306. * It helps seeing only some components of the material while troubleshooting.
  69307. */
  69308. debugMode: number;
  69309. /**
  69310. * Specify from where on screen the debug mode should start.
  69311. * The value goes from -1 (full screen) to 1 (not visible)
  69312. * It helps with side by side comparison against the final render
  69313. * This defaults to 0
  69314. */
  69315. debugLimit: number;
  69316. /**
  69317. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69318. * You can use the factor to better multiply the final value.
  69319. */
  69320. debugFactor: number;
  69321. /**
  69322. * Initialize the block and prepare the context for build
  69323. * @param state defines the state that will be used for the build
  69324. */
  69325. initialize(state: NodeMaterialBuildState): void;
  69326. /**
  69327. * Gets the current class name
  69328. * @returns the class name
  69329. */
  69330. getClassName(): string;
  69331. /**
  69332. * Gets the world position input component
  69333. */
  69334. get worldPosition(): NodeMaterialConnectionPoint;
  69335. /**
  69336. * Gets the world normal input component
  69337. */
  69338. get worldNormal(): NodeMaterialConnectionPoint;
  69339. /**
  69340. * Gets the perturbed normal input component
  69341. */
  69342. get perturbedNormal(): NodeMaterialConnectionPoint;
  69343. /**
  69344. * Gets the camera position input component
  69345. */
  69346. get cameraPosition(): NodeMaterialConnectionPoint;
  69347. /**
  69348. * Gets the base color input component
  69349. */
  69350. get baseColor(): NodeMaterialConnectionPoint;
  69351. /**
  69352. * Gets the opacity texture input component
  69353. */
  69354. get opacityTexture(): NodeMaterialConnectionPoint;
  69355. /**
  69356. * Gets the ambient color input component
  69357. */
  69358. get ambientColor(): NodeMaterialConnectionPoint;
  69359. /**
  69360. * Gets the reflectivity object parameters
  69361. */
  69362. get reflectivity(): NodeMaterialConnectionPoint;
  69363. /**
  69364. * Gets the ambient occlusion object parameters
  69365. */
  69366. get ambientOcc(): NodeMaterialConnectionPoint;
  69367. /**
  69368. * Gets the reflection object parameters
  69369. */
  69370. get reflection(): NodeMaterialConnectionPoint;
  69371. /**
  69372. * Gets the sheen object parameters
  69373. */
  69374. get sheen(): NodeMaterialConnectionPoint;
  69375. /**
  69376. * Gets the clear coat object parameters
  69377. */
  69378. get clearcoat(): NodeMaterialConnectionPoint;
  69379. /**
  69380. * Gets the sub surface object parameters
  69381. */
  69382. get subsurface(): NodeMaterialConnectionPoint;
  69383. /**
  69384. * Gets the anisotropy object parameters
  69385. */
  69386. get anisotropy(): NodeMaterialConnectionPoint;
  69387. /**
  69388. * Gets the view matrix parameter
  69389. */
  69390. get view(): NodeMaterialConnectionPoint;
  69391. /**
  69392. * Gets the ambient output component
  69393. */
  69394. get ambient(): NodeMaterialConnectionPoint;
  69395. /**
  69396. * Gets the diffuse output component
  69397. */
  69398. get diffuse(): NodeMaterialConnectionPoint;
  69399. /**
  69400. * Gets the specular output component
  69401. */
  69402. get specular(): NodeMaterialConnectionPoint;
  69403. /**
  69404. * Gets the sheen output component
  69405. */
  69406. get sheenDir(): NodeMaterialConnectionPoint;
  69407. /**
  69408. * Gets the clear coat output component
  69409. */
  69410. get clearcoatDir(): NodeMaterialConnectionPoint;
  69411. /**
  69412. * Gets the indirect diffuse output component
  69413. */
  69414. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69415. /**
  69416. * Gets the indirect specular output component
  69417. */
  69418. get specularIndirect(): NodeMaterialConnectionPoint;
  69419. /**
  69420. * Gets the indirect sheen output component
  69421. */
  69422. get sheenIndirect(): NodeMaterialConnectionPoint;
  69423. /**
  69424. * Gets the indirect clear coat output component
  69425. */
  69426. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69427. /**
  69428. * Gets the refraction output component
  69429. */
  69430. get refraction(): NodeMaterialConnectionPoint;
  69431. /**
  69432. * Gets the global lighting output component
  69433. */
  69434. get lighting(): NodeMaterialConnectionPoint;
  69435. /**
  69436. * Gets the shadow output component
  69437. */
  69438. get shadow(): NodeMaterialConnectionPoint;
  69439. /**
  69440. * Gets the alpha output component
  69441. */
  69442. get alpha(): NodeMaterialConnectionPoint;
  69443. autoConfigure(material: NodeMaterial): void;
  69444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69445. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69447. private _injectVertexCode;
  69448. /**
  69449. * Gets the code corresponding to the albedo/opacity module
  69450. * @returns the shader code
  69451. */
  69452. getAlbedoOpacityCode(): string;
  69453. protected _buildBlock(state: NodeMaterialBuildState): this;
  69454. protected _dumpPropertiesCode(): string;
  69455. serialize(): any;
  69456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69457. }
  69458. }
  69459. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69460. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69461. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69462. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69463. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69464. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69465. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69466. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69467. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69468. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69469. }
  69470. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69471. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69472. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69473. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69474. }
  69475. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69479. /**
  69480. * Block used to compute value of one parameter modulo another
  69481. */
  69482. export class ModBlock extends NodeMaterialBlock {
  69483. /**
  69484. * Creates a new ModBlock
  69485. * @param name defines the block name
  69486. */
  69487. constructor(name: string);
  69488. /**
  69489. * Gets the current class name
  69490. * @returns the class name
  69491. */
  69492. getClassName(): string;
  69493. /**
  69494. * Gets the left operand input component
  69495. */
  69496. get left(): NodeMaterialConnectionPoint;
  69497. /**
  69498. * Gets the right operand input component
  69499. */
  69500. get right(): NodeMaterialConnectionPoint;
  69501. /**
  69502. * Gets the output component
  69503. */
  69504. get output(): NodeMaterialConnectionPoint;
  69505. protected _buildBlock(state: NodeMaterialBuildState): this;
  69506. }
  69507. }
  69508. declare module "babylonjs/Materials/Node/Blocks/index" {
  69509. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69510. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69511. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69512. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69513. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69514. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69515. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69516. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69517. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69518. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69519. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69520. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69521. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69522. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69523. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69524. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69525. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69526. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69527. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69528. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69529. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69530. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69531. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69532. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69533. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69534. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69535. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69536. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69537. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69538. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69539. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69540. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69541. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69542. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69543. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69544. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69545. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69546. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69547. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69548. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69549. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69550. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69551. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69552. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69553. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69554. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69555. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69556. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69557. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69558. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69559. }
  69560. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69561. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69562. }
  69563. declare module "babylonjs/Materials/Node/index" {
  69564. export * from "babylonjs/Materials/Node/Enums/index";
  69565. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69566. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69567. export * from "babylonjs/Materials/Node/nodeMaterial";
  69568. export * from "babylonjs/Materials/Node/Blocks/index";
  69569. export * from "babylonjs/Materials/Node/Optimizers/index";
  69570. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69571. }
  69572. declare module "babylonjs/Materials/index" {
  69573. export * from "babylonjs/Materials/Background/index";
  69574. export * from "babylonjs/Materials/colorCurves";
  69575. export * from "babylonjs/Materials/iEffectFallbacks";
  69576. export * from "babylonjs/Materials/effectFallbacks";
  69577. export * from "babylonjs/Materials/effect";
  69578. export * from "babylonjs/Materials/fresnelParameters";
  69579. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69580. export * from "babylonjs/Materials/material";
  69581. export * from "babylonjs/Materials/materialDefines";
  69582. export * from "babylonjs/Materials/thinMaterialHelper";
  69583. export * from "babylonjs/Materials/materialHelper";
  69584. export * from "babylonjs/Materials/multiMaterial";
  69585. export * from "babylonjs/Materials/PBR/index";
  69586. export * from "babylonjs/Materials/pushMaterial";
  69587. export * from "babylonjs/Materials/shaderMaterial";
  69588. export * from "babylonjs/Materials/standardMaterial";
  69589. export * from "babylonjs/Materials/Textures/index";
  69590. export * from "babylonjs/Materials/uniformBuffer";
  69591. export * from "babylonjs/Materials/materialFlags";
  69592. export * from "babylonjs/Materials/Node/index";
  69593. export * from "babylonjs/Materials/effectRenderer";
  69594. export * from "babylonjs/Materials/shadowDepthWrapper";
  69595. }
  69596. declare module "babylonjs/Maths/index" {
  69597. export * from "babylonjs/Maths/math.scalar";
  69598. export * from "babylonjs/Maths/math";
  69599. export * from "babylonjs/Maths/sphericalPolynomial";
  69600. }
  69601. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69602. import { IDisposable } from "babylonjs/scene";
  69603. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69604. /**
  69605. * Configuration for Draco compression
  69606. */
  69607. export interface IDracoCompressionConfiguration {
  69608. /**
  69609. * Configuration for the decoder.
  69610. */
  69611. decoder: {
  69612. /**
  69613. * The url to the WebAssembly module.
  69614. */
  69615. wasmUrl?: string;
  69616. /**
  69617. * The url to the WebAssembly binary.
  69618. */
  69619. wasmBinaryUrl?: string;
  69620. /**
  69621. * The url to the fallback JavaScript module.
  69622. */
  69623. fallbackUrl?: string;
  69624. };
  69625. }
  69626. /**
  69627. * Draco compression (https://google.github.io/draco/)
  69628. *
  69629. * This class wraps the Draco module.
  69630. *
  69631. * **Encoder**
  69632. *
  69633. * The encoder is not currently implemented.
  69634. *
  69635. * **Decoder**
  69636. *
  69637. * 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.
  69638. *
  69639. * To update the configuration, use the following code:
  69640. * ```javascript
  69641. * DracoCompression.Configuration = {
  69642. * decoder: {
  69643. * wasmUrl: "<url to the WebAssembly library>",
  69644. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69645. * fallbackUrl: "<url to the fallback JavaScript library>",
  69646. * }
  69647. * };
  69648. * ```
  69649. *
  69650. * 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.
  69651. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69652. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69653. *
  69654. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69655. * ```javascript
  69656. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69657. * ```
  69658. *
  69659. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69660. */
  69661. export class DracoCompression implements IDisposable {
  69662. private _workerPoolPromise?;
  69663. private _decoderModulePromise?;
  69664. /**
  69665. * The configuration. Defaults to the following urls:
  69666. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69667. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69668. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69669. */
  69670. static Configuration: IDracoCompressionConfiguration;
  69671. /**
  69672. * Returns true if the decoder configuration is available.
  69673. */
  69674. static get DecoderAvailable(): boolean;
  69675. /**
  69676. * Default number of workers to create when creating the draco compression object.
  69677. */
  69678. static DefaultNumWorkers: number;
  69679. private static GetDefaultNumWorkers;
  69680. private static _Default;
  69681. /**
  69682. * Default instance for the draco compression object.
  69683. */
  69684. static get Default(): DracoCompression;
  69685. /**
  69686. * Constructor
  69687. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69688. */
  69689. constructor(numWorkers?: number);
  69690. /**
  69691. * Stop all async operations and release resources.
  69692. */
  69693. dispose(): void;
  69694. /**
  69695. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69696. * @returns a promise that resolves when ready
  69697. */
  69698. whenReadyAsync(): Promise<void>;
  69699. /**
  69700. * Decode Draco compressed mesh data to vertex data.
  69701. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69702. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69703. * @returns A promise that resolves with the decoded vertex data
  69704. */
  69705. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69706. [kind: string]: number;
  69707. }): Promise<VertexData>;
  69708. }
  69709. }
  69710. declare module "babylonjs/Meshes/Compression/index" {
  69711. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69712. }
  69713. declare module "babylonjs/Meshes/csg" {
  69714. import { Nullable } from "babylonjs/types";
  69715. import { Scene } from "babylonjs/scene";
  69716. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69717. import { Mesh } from "babylonjs/Meshes/mesh";
  69718. import { Material } from "babylonjs/Materials/material";
  69719. /**
  69720. * Class for building Constructive Solid Geometry
  69721. */
  69722. export class CSG {
  69723. private polygons;
  69724. /**
  69725. * The world matrix
  69726. */
  69727. matrix: Matrix;
  69728. /**
  69729. * Stores the position
  69730. */
  69731. position: Vector3;
  69732. /**
  69733. * Stores the rotation
  69734. */
  69735. rotation: Vector3;
  69736. /**
  69737. * Stores the rotation quaternion
  69738. */
  69739. rotationQuaternion: Nullable<Quaternion>;
  69740. /**
  69741. * Stores the scaling vector
  69742. */
  69743. scaling: Vector3;
  69744. /**
  69745. * Convert the Mesh to CSG
  69746. * @param mesh The Mesh to convert to CSG
  69747. * @returns A new CSG from the Mesh
  69748. */
  69749. static FromMesh(mesh: Mesh): CSG;
  69750. /**
  69751. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69752. * @param polygons Polygons used to construct a CSG solid
  69753. */
  69754. private static FromPolygons;
  69755. /**
  69756. * Clones, or makes a deep copy, of the CSG
  69757. * @returns A new CSG
  69758. */
  69759. clone(): CSG;
  69760. /**
  69761. * Unions this CSG with another CSG
  69762. * @param csg The CSG to union against this CSG
  69763. * @returns The unioned CSG
  69764. */
  69765. union(csg: CSG): CSG;
  69766. /**
  69767. * Unions this CSG with another CSG in place
  69768. * @param csg The CSG to union against this CSG
  69769. */
  69770. unionInPlace(csg: CSG): void;
  69771. /**
  69772. * Subtracts this CSG with another CSG
  69773. * @param csg The CSG to subtract against this CSG
  69774. * @returns A new CSG
  69775. */
  69776. subtract(csg: CSG): CSG;
  69777. /**
  69778. * Subtracts this CSG with another CSG in place
  69779. * @param csg The CSG to subtact against this CSG
  69780. */
  69781. subtractInPlace(csg: CSG): void;
  69782. /**
  69783. * Intersect this CSG with another CSG
  69784. * @param csg The CSG to intersect against this CSG
  69785. * @returns A new CSG
  69786. */
  69787. intersect(csg: CSG): CSG;
  69788. /**
  69789. * Intersects this CSG with another CSG in place
  69790. * @param csg The CSG to intersect against this CSG
  69791. */
  69792. intersectInPlace(csg: CSG): void;
  69793. /**
  69794. * Return a new CSG solid with solid and empty space switched. This solid is
  69795. * not modified.
  69796. * @returns A new CSG solid with solid and empty space switched
  69797. */
  69798. inverse(): CSG;
  69799. /**
  69800. * Inverses the CSG in place
  69801. */
  69802. inverseInPlace(): void;
  69803. /**
  69804. * This is used to keep meshes transformations so they can be restored
  69805. * when we build back a Babylon Mesh
  69806. * NB : All CSG operations are performed in world coordinates
  69807. * @param csg The CSG to copy the transform attributes from
  69808. * @returns This CSG
  69809. */
  69810. copyTransformAttributes(csg: CSG): CSG;
  69811. /**
  69812. * Build Raw mesh from CSG
  69813. * Coordinates here are in world space
  69814. * @param name The name of the mesh geometry
  69815. * @param scene The Scene
  69816. * @param keepSubMeshes Specifies if the submeshes should be kept
  69817. * @returns A new Mesh
  69818. */
  69819. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69820. /**
  69821. * Build Mesh from CSG taking material and transforms into account
  69822. * @param name The name of the Mesh
  69823. * @param material The material of the Mesh
  69824. * @param scene The Scene
  69825. * @param keepSubMeshes Specifies if submeshes should be kept
  69826. * @returns The new Mesh
  69827. */
  69828. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69829. }
  69830. }
  69831. declare module "babylonjs/Meshes/trailMesh" {
  69832. import { Mesh } from "babylonjs/Meshes/mesh";
  69833. import { Scene } from "babylonjs/scene";
  69834. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69835. /**
  69836. * Class used to create a trail following a mesh
  69837. */
  69838. export class TrailMesh extends Mesh {
  69839. private _generator;
  69840. private _autoStart;
  69841. private _running;
  69842. private _diameter;
  69843. private _length;
  69844. private _sectionPolygonPointsCount;
  69845. private _sectionVectors;
  69846. private _sectionNormalVectors;
  69847. private _beforeRenderObserver;
  69848. /**
  69849. * @constructor
  69850. * @param name The value used by scene.getMeshByName() to do a lookup.
  69851. * @param generator The mesh or transform node to generate a trail.
  69852. * @param scene The scene to add this mesh to.
  69853. * @param diameter Diameter of trailing mesh. Default is 1.
  69854. * @param length Length of trailing mesh. Default is 60.
  69855. * @param autoStart Automatically start trailing mesh. Default true.
  69856. */
  69857. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69858. /**
  69859. * "TrailMesh"
  69860. * @returns "TrailMesh"
  69861. */
  69862. getClassName(): string;
  69863. private _createMesh;
  69864. /**
  69865. * Start trailing mesh.
  69866. */
  69867. start(): void;
  69868. /**
  69869. * Stop trailing mesh.
  69870. */
  69871. stop(): void;
  69872. /**
  69873. * Update trailing mesh geometry.
  69874. */
  69875. update(): void;
  69876. /**
  69877. * Returns a new TrailMesh object.
  69878. * @param name is a string, the name given to the new mesh
  69879. * @param newGenerator use new generator object for cloned trail mesh
  69880. * @returns a new mesh
  69881. */
  69882. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69883. /**
  69884. * Serializes this trail mesh
  69885. * @param serializationObject object to write serialization to
  69886. */
  69887. serialize(serializationObject: any): void;
  69888. /**
  69889. * Parses a serialized trail mesh
  69890. * @param parsedMesh the serialized mesh
  69891. * @param scene the scene to create the trail mesh in
  69892. * @returns the created trail mesh
  69893. */
  69894. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69895. }
  69896. }
  69897. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69898. import { Nullable } from "babylonjs/types";
  69899. import { Scene } from "babylonjs/scene";
  69900. import { Vector4 } from "babylonjs/Maths/math.vector";
  69901. import { Color4 } from "babylonjs/Maths/math.color";
  69902. import { Mesh } from "babylonjs/Meshes/mesh";
  69903. /**
  69904. * Class containing static functions to help procedurally build meshes
  69905. */
  69906. export class TiledBoxBuilder {
  69907. /**
  69908. * Creates a box mesh
  69909. * 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)
  69910. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69914. * @param name defines the name of the mesh
  69915. * @param options defines the options used to create the mesh
  69916. * @param scene defines the hosting scene
  69917. * @returns the box mesh
  69918. */
  69919. static CreateTiledBox(name: string, options: {
  69920. pattern?: number;
  69921. width?: number;
  69922. height?: number;
  69923. depth?: number;
  69924. tileSize?: number;
  69925. tileWidth?: number;
  69926. tileHeight?: number;
  69927. alignHorizontal?: number;
  69928. alignVertical?: number;
  69929. faceUV?: Vector4[];
  69930. faceColors?: Color4[];
  69931. sideOrientation?: number;
  69932. updatable?: boolean;
  69933. }, scene?: Nullable<Scene>): Mesh;
  69934. }
  69935. }
  69936. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69937. import { Vector4 } from "babylonjs/Maths/math.vector";
  69938. import { Mesh } from "babylonjs/Meshes/mesh";
  69939. /**
  69940. * Class containing static functions to help procedurally build meshes
  69941. */
  69942. export class TorusKnotBuilder {
  69943. /**
  69944. * Creates a torus knot mesh
  69945. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69946. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69947. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69948. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69952. * @param name defines the name of the mesh
  69953. * @param options defines the options used to create the mesh
  69954. * @param scene defines the hosting scene
  69955. * @returns the torus knot mesh
  69956. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69957. */
  69958. static CreateTorusKnot(name: string, options: {
  69959. radius?: number;
  69960. tube?: number;
  69961. radialSegments?: number;
  69962. tubularSegments?: number;
  69963. p?: number;
  69964. q?: number;
  69965. updatable?: boolean;
  69966. sideOrientation?: number;
  69967. frontUVs?: Vector4;
  69968. backUVs?: Vector4;
  69969. }, scene: any): Mesh;
  69970. }
  69971. }
  69972. declare module "babylonjs/Meshes/polygonMesh" {
  69973. import { Scene } from "babylonjs/scene";
  69974. import { Vector2 } from "babylonjs/Maths/math.vector";
  69975. import { Mesh } from "babylonjs/Meshes/mesh";
  69976. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69977. import { Path2 } from "babylonjs/Maths/math.path";
  69978. /**
  69979. * Polygon
  69980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69981. */
  69982. export class Polygon {
  69983. /**
  69984. * Creates a rectangle
  69985. * @param xmin bottom X coord
  69986. * @param ymin bottom Y coord
  69987. * @param xmax top X coord
  69988. * @param ymax top Y coord
  69989. * @returns points that make the resulting rectation
  69990. */
  69991. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69992. /**
  69993. * Creates a circle
  69994. * @param radius radius of circle
  69995. * @param cx scale in x
  69996. * @param cy scale in y
  69997. * @param numberOfSides number of sides that make up the circle
  69998. * @returns points that make the resulting circle
  69999. */
  70000. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70001. /**
  70002. * Creates a polygon from input string
  70003. * @param input Input polygon data
  70004. * @returns the parsed points
  70005. */
  70006. static Parse(input: string): Vector2[];
  70007. /**
  70008. * Starts building a polygon from x and y coordinates
  70009. * @param x x coordinate
  70010. * @param y y coordinate
  70011. * @returns the started path2
  70012. */
  70013. static StartingAt(x: number, y: number): Path2;
  70014. }
  70015. /**
  70016. * Builds a polygon
  70017. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70018. */
  70019. export class PolygonMeshBuilder {
  70020. private _points;
  70021. private _outlinepoints;
  70022. private _holes;
  70023. private _name;
  70024. private _scene;
  70025. private _epoints;
  70026. private _eholes;
  70027. private _addToepoint;
  70028. /**
  70029. * Babylon reference to the earcut plugin.
  70030. */
  70031. bjsEarcut: any;
  70032. /**
  70033. * Creates a PolygonMeshBuilder
  70034. * @param name name of the builder
  70035. * @param contours Path of the polygon
  70036. * @param scene scene to add to when creating the mesh
  70037. * @param earcutInjection can be used to inject your own earcut reference
  70038. */
  70039. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70040. /**
  70041. * Adds a whole within the polygon
  70042. * @param hole Array of points defining the hole
  70043. * @returns this
  70044. */
  70045. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70046. /**
  70047. * Creates the polygon
  70048. * @param updatable If the mesh should be updatable
  70049. * @param depth The depth of the mesh created
  70050. * @returns the created mesh
  70051. */
  70052. build(updatable?: boolean, depth?: number): Mesh;
  70053. /**
  70054. * Creates the polygon
  70055. * @param depth The depth of the mesh created
  70056. * @returns the created VertexData
  70057. */
  70058. buildVertexData(depth?: number): VertexData;
  70059. /**
  70060. * Adds a side to the polygon
  70061. * @param positions points that make the polygon
  70062. * @param normals normals of the polygon
  70063. * @param uvs uvs of the polygon
  70064. * @param indices indices of the polygon
  70065. * @param bounds bounds of the polygon
  70066. * @param points points of the polygon
  70067. * @param depth depth of the polygon
  70068. * @param flip flip of the polygon
  70069. */
  70070. private addSide;
  70071. }
  70072. }
  70073. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70074. import { Scene } from "babylonjs/scene";
  70075. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70076. import { Color4 } from "babylonjs/Maths/math.color";
  70077. import { Mesh } from "babylonjs/Meshes/mesh";
  70078. import { Nullable } from "babylonjs/types";
  70079. /**
  70080. * Class containing static functions to help procedurally build meshes
  70081. */
  70082. export class PolygonBuilder {
  70083. /**
  70084. * Creates a polygon mesh
  70085. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70086. * * 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
  70087. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70090. * * Remember you can only change the shape positions, not their number when updating a polygon
  70091. * @param name defines the name of the mesh
  70092. * @param options defines the options used to create the mesh
  70093. * @param scene defines the hosting scene
  70094. * @param earcutInjection can be used to inject your own earcut reference
  70095. * @returns the polygon mesh
  70096. */
  70097. static CreatePolygon(name: string, options: {
  70098. shape: Vector3[];
  70099. holes?: Vector3[][];
  70100. depth?: number;
  70101. faceUV?: Vector4[];
  70102. faceColors?: Color4[];
  70103. updatable?: boolean;
  70104. sideOrientation?: number;
  70105. frontUVs?: Vector4;
  70106. backUVs?: Vector4;
  70107. wrap?: boolean;
  70108. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70109. /**
  70110. * Creates an extruded polygon mesh, with depth in the Y direction.
  70111. * * 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)
  70112. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70113. * @param name defines the name of the mesh
  70114. * @param options defines the options used to create the mesh
  70115. * @param scene defines the hosting scene
  70116. * @param earcutInjection can be used to inject your own earcut reference
  70117. * @returns the polygon mesh
  70118. */
  70119. static ExtrudePolygon(name: string, options: {
  70120. shape: Vector3[];
  70121. holes?: Vector3[][];
  70122. depth?: number;
  70123. faceUV?: Vector4[];
  70124. faceColors?: Color4[];
  70125. updatable?: boolean;
  70126. sideOrientation?: number;
  70127. frontUVs?: Vector4;
  70128. backUVs?: Vector4;
  70129. wrap?: boolean;
  70130. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70131. }
  70132. }
  70133. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70134. import { Scene } from "babylonjs/scene";
  70135. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70136. import { Mesh } from "babylonjs/Meshes/mesh";
  70137. import { Nullable } from "babylonjs/types";
  70138. /**
  70139. * Class containing static functions to help procedurally build meshes
  70140. */
  70141. export class LatheBuilder {
  70142. /**
  70143. * Creates lathe mesh.
  70144. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70145. * * 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
  70146. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70147. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70148. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70149. * * 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
  70150. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70151. * * 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
  70152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70154. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70156. * @param name defines the name of the mesh
  70157. * @param options defines the options used to create the mesh
  70158. * @param scene defines the hosting scene
  70159. * @returns the lathe mesh
  70160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70161. */
  70162. static CreateLathe(name: string, options: {
  70163. shape: Vector3[];
  70164. radius?: number;
  70165. tessellation?: number;
  70166. clip?: number;
  70167. arc?: number;
  70168. closed?: boolean;
  70169. updatable?: boolean;
  70170. sideOrientation?: number;
  70171. frontUVs?: Vector4;
  70172. backUVs?: Vector4;
  70173. cap?: number;
  70174. invertUV?: boolean;
  70175. }, scene?: Nullable<Scene>): Mesh;
  70176. }
  70177. }
  70178. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70179. import { Nullable } from "babylonjs/types";
  70180. import { Scene } from "babylonjs/scene";
  70181. import { Vector4 } from "babylonjs/Maths/math.vector";
  70182. import { Mesh } from "babylonjs/Meshes/mesh";
  70183. /**
  70184. * Class containing static functions to help procedurally build meshes
  70185. */
  70186. export class TiledPlaneBuilder {
  70187. /**
  70188. * Creates a tiled plane mesh
  70189. * * The parameter `pattern` will, depending on value, do nothing or
  70190. * * * flip (reflect about central vertical) alternate tiles across and up
  70191. * * * flip every tile on alternate rows
  70192. * * * rotate (180 degs) alternate tiles across and up
  70193. * * * rotate every tile on alternate rows
  70194. * * * flip and rotate alternate tiles across and up
  70195. * * * flip and rotate every tile on alternate rows
  70196. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70197. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70200. * * 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)
  70201. * * 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)
  70202. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70203. * @param name defines the name of the mesh
  70204. * @param options defines the options used to create the mesh
  70205. * @param scene defines the hosting scene
  70206. * @returns the box mesh
  70207. */
  70208. static CreateTiledPlane(name: string, options: {
  70209. pattern?: number;
  70210. tileSize?: number;
  70211. tileWidth?: number;
  70212. tileHeight?: number;
  70213. size?: number;
  70214. width?: number;
  70215. height?: number;
  70216. alignHorizontal?: number;
  70217. alignVertical?: number;
  70218. sideOrientation?: number;
  70219. frontUVs?: Vector4;
  70220. backUVs?: Vector4;
  70221. updatable?: boolean;
  70222. }, scene?: Nullable<Scene>): Mesh;
  70223. }
  70224. }
  70225. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70226. import { Nullable } from "babylonjs/types";
  70227. import { Scene } from "babylonjs/scene";
  70228. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70229. import { Mesh } from "babylonjs/Meshes/mesh";
  70230. /**
  70231. * Class containing static functions to help procedurally build meshes
  70232. */
  70233. export class TubeBuilder {
  70234. /**
  70235. * Creates a tube mesh.
  70236. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70237. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70238. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70239. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70240. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70241. * * 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)
  70242. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70243. * * 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
  70244. * * 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
  70245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70249. * @param name defines the name of the mesh
  70250. * @param options defines the options used to create the mesh
  70251. * @param scene defines the hosting scene
  70252. * @returns the tube mesh
  70253. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70254. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70255. */
  70256. static CreateTube(name: string, options: {
  70257. path: Vector3[];
  70258. radius?: number;
  70259. tessellation?: number;
  70260. radiusFunction?: {
  70261. (i: number, distance: number): number;
  70262. };
  70263. cap?: number;
  70264. arc?: number;
  70265. updatable?: boolean;
  70266. sideOrientation?: number;
  70267. frontUVs?: Vector4;
  70268. backUVs?: Vector4;
  70269. instance?: Mesh;
  70270. invertUV?: boolean;
  70271. }, scene?: Nullable<Scene>): Mesh;
  70272. }
  70273. }
  70274. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70275. import { Scene } from "babylonjs/scene";
  70276. import { Vector4 } from "babylonjs/Maths/math.vector";
  70277. import { Mesh } from "babylonjs/Meshes/mesh";
  70278. import { Nullable } from "babylonjs/types";
  70279. /**
  70280. * Class containing static functions to help procedurally build meshes
  70281. */
  70282. export class IcoSphereBuilder {
  70283. /**
  70284. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70285. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70286. * * 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`)
  70287. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70288. * * 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
  70289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70292. * @param name defines the name of the mesh
  70293. * @param options defines the options used to create the mesh
  70294. * @param scene defines the hosting scene
  70295. * @returns the icosahedron mesh
  70296. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70297. */
  70298. static CreateIcoSphere(name: string, options: {
  70299. radius?: number;
  70300. radiusX?: number;
  70301. radiusY?: number;
  70302. radiusZ?: number;
  70303. flat?: boolean;
  70304. subdivisions?: number;
  70305. sideOrientation?: number;
  70306. frontUVs?: Vector4;
  70307. backUVs?: Vector4;
  70308. updatable?: boolean;
  70309. }, scene?: Nullable<Scene>): Mesh;
  70310. }
  70311. }
  70312. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70313. import { Vector3 } from "babylonjs/Maths/math.vector";
  70314. import { Mesh } from "babylonjs/Meshes/mesh";
  70315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70316. /**
  70317. * Class containing static functions to help procedurally build meshes
  70318. */
  70319. export class DecalBuilder {
  70320. /**
  70321. * Creates a decal mesh.
  70322. * 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
  70323. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70324. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70325. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70326. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70327. * @param name defines the name of the mesh
  70328. * @param sourceMesh defines the mesh where the decal must be applied
  70329. * @param options defines the options used to create the mesh
  70330. * @param scene defines the hosting scene
  70331. * @returns the decal mesh
  70332. * @see https://doc.babylonjs.com/how_to/decals
  70333. */
  70334. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70335. position?: Vector3;
  70336. normal?: Vector3;
  70337. size?: Vector3;
  70338. angle?: number;
  70339. }): Mesh;
  70340. }
  70341. }
  70342. declare module "babylonjs/Meshes/meshBuilder" {
  70343. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70344. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70345. import { Nullable } from "babylonjs/types";
  70346. import { Scene } from "babylonjs/scene";
  70347. import { Mesh } from "babylonjs/Meshes/mesh";
  70348. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70349. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70351. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70352. import { Plane } from "babylonjs/Maths/math.plane";
  70353. /**
  70354. * Class containing static functions to help procedurally build meshes
  70355. */
  70356. export class MeshBuilder {
  70357. /**
  70358. * Creates a box mesh
  70359. * * The parameter `size` sets the size (float) of each box side (default 1)
  70360. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70361. * * 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)
  70362. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70366. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70367. * @param name defines the name of the mesh
  70368. * @param options defines the options used to create the mesh
  70369. * @param scene defines the hosting scene
  70370. * @returns the box mesh
  70371. */
  70372. static CreateBox(name: string, options: {
  70373. size?: number;
  70374. width?: number;
  70375. height?: number;
  70376. depth?: number;
  70377. faceUV?: Vector4[];
  70378. faceColors?: Color4[];
  70379. sideOrientation?: number;
  70380. frontUVs?: Vector4;
  70381. backUVs?: Vector4;
  70382. wrap?: boolean;
  70383. topBaseAt?: number;
  70384. bottomBaseAt?: number;
  70385. updatable?: boolean;
  70386. }, scene?: Nullable<Scene>): Mesh;
  70387. /**
  70388. * Creates a tiled box mesh
  70389. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70391. * @param name defines the name of the mesh
  70392. * @param options defines the options used to create the mesh
  70393. * @param scene defines the hosting scene
  70394. * @returns the tiled box mesh
  70395. */
  70396. static CreateTiledBox(name: string, options: {
  70397. pattern?: number;
  70398. size?: number;
  70399. width?: number;
  70400. height?: number;
  70401. depth: number;
  70402. tileSize?: number;
  70403. tileWidth?: number;
  70404. tileHeight?: number;
  70405. faceUV?: Vector4[];
  70406. faceColors?: Color4[];
  70407. alignHorizontal?: number;
  70408. alignVertical?: number;
  70409. sideOrientation?: number;
  70410. updatable?: boolean;
  70411. }, scene?: Nullable<Scene>): Mesh;
  70412. /**
  70413. * Creates a sphere mesh
  70414. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70415. * * 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`)
  70416. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70417. * * 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
  70418. * * 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)
  70419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70422. * @param name defines the name of the mesh
  70423. * @param options defines the options used to create the mesh
  70424. * @param scene defines the hosting scene
  70425. * @returns the sphere mesh
  70426. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70427. */
  70428. static CreateSphere(name: string, options: {
  70429. segments?: number;
  70430. diameter?: number;
  70431. diameterX?: number;
  70432. diameterY?: number;
  70433. diameterZ?: number;
  70434. arc?: number;
  70435. slice?: number;
  70436. sideOrientation?: number;
  70437. frontUVs?: Vector4;
  70438. backUVs?: Vector4;
  70439. updatable?: boolean;
  70440. }, scene?: Nullable<Scene>): Mesh;
  70441. /**
  70442. * Creates a plane polygonal mesh. By default, this is a disc
  70443. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70444. * * 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
  70445. * * 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
  70446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70449. * @param name defines the name of the mesh
  70450. * @param options defines the options used to create the mesh
  70451. * @param scene defines the hosting scene
  70452. * @returns the plane polygonal mesh
  70453. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70454. */
  70455. static CreateDisc(name: string, options: {
  70456. radius?: number;
  70457. tessellation?: number;
  70458. arc?: number;
  70459. updatable?: boolean;
  70460. sideOrientation?: number;
  70461. frontUVs?: Vector4;
  70462. backUVs?: Vector4;
  70463. }, scene?: Nullable<Scene>): Mesh;
  70464. /**
  70465. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70466. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70467. * * 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`)
  70468. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70469. * * 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
  70470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70473. * @param name defines the name of the mesh
  70474. * @param options defines the options used to create the mesh
  70475. * @param scene defines the hosting scene
  70476. * @returns the icosahedron mesh
  70477. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70478. */
  70479. static CreateIcoSphere(name: string, options: {
  70480. radius?: number;
  70481. radiusX?: number;
  70482. radiusY?: number;
  70483. radiusZ?: number;
  70484. flat?: boolean;
  70485. subdivisions?: number;
  70486. sideOrientation?: number;
  70487. frontUVs?: Vector4;
  70488. backUVs?: Vector4;
  70489. updatable?: boolean;
  70490. }, scene?: Nullable<Scene>): Mesh;
  70491. /**
  70492. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70493. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70494. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70495. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70496. * * 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
  70497. * * 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
  70498. * * 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
  70499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70502. * * 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
  70503. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70504. * * 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
  70505. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70507. * @param name defines the name of the mesh
  70508. * @param options defines the options used to create the mesh
  70509. * @param scene defines the hosting scene
  70510. * @returns the ribbon mesh
  70511. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70512. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70513. */
  70514. static CreateRibbon(name: string, options: {
  70515. pathArray: Vector3[][];
  70516. closeArray?: boolean;
  70517. closePath?: boolean;
  70518. offset?: number;
  70519. updatable?: boolean;
  70520. sideOrientation?: number;
  70521. frontUVs?: Vector4;
  70522. backUVs?: Vector4;
  70523. instance?: Mesh;
  70524. invertUV?: boolean;
  70525. uvs?: Vector2[];
  70526. colors?: Color4[];
  70527. }, scene?: Nullable<Scene>): Mesh;
  70528. /**
  70529. * Creates a cylinder or a cone mesh
  70530. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70531. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70532. * * 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.
  70533. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70534. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70535. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70536. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70537. * * 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).
  70538. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70539. * * 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).
  70540. * * 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
  70541. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70542. * * 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
  70543. * * 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.
  70544. * * If `enclose` is false, a ring surface is one element.
  70545. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70546. * * 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
  70547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70550. * @param name defines the name of the mesh
  70551. * @param options defines the options used to create the mesh
  70552. * @param scene defines the hosting scene
  70553. * @returns the cylinder mesh
  70554. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70555. */
  70556. static CreateCylinder(name: string, options: {
  70557. height?: number;
  70558. diameterTop?: number;
  70559. diameterBottom?: number;
  70560. diameter?: number;
  70561. tessellation?: number;
  70562. subdivisions?: number;
  70563. arc?: number;
  70564. faceColors?: Color4[];
  70565. faceUV?: Vector4[];
  70566. updatable?: boolean;
  70567. hasRings?: boolean;
  70568. enclose?: boolean;
  70569. cap?: number;
  70570. sideOrientation?: number;
  70571. frontUVs?: Vector4;
  70572. backUVs?: Vector4;
  70573. }, scene?: Nullable<Scene>): Mesh;
  70574. /**
  70575. * Creates a torus mesh
  70576. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70577. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70578. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70582. * @param name defines the name of the mesh
  70583. * @param options defines the options used to create the mesh
  70584. * @param scene defines the hosting scene
  70585. * @returns the torus mesh
  70586. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70587. */
  70588. static CreateTorus(name: string, options: {
  70589. diameter?: number;
  70590. thickness?: number;
  70591. tessellation?: number;
  70592. updatable?: boolean;
  70593. sideOrientation?: number;
  70594. frontUVs?: Vector4;
  70595. backUVs?: Vector4;
  70596. }, scene?: Nullable<Scene>): Mesh;
  70597. /**
  70598. * Creates a torus knot mesh
  70599. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70600. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70601. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70602. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70606. * @param name defines the name of the mesh
  70607. * @param options defines the options used to create the mesh
  70608. * @param scene defines the hosting scene
  70609. * @returns the torus knot mesh
  70610. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70611. */
  70612. static CreateTorusKnot(name: string, options: {
  70613. radius?: number;
  70614. tube?: number;
  70615. radialSegments?: number;
  70616. tubularSegments?: number;
  70617. p?: number;
  70618. q?: number;
  70619. updatable?: boolean;
  70620. sideOrientation?: number;
  70621. frontUVs?: Vector4;
  70622. backUVs?: Vector4;
  70623. }, scene?: Nullable<Scene>): Mesh;
  70624. /**
  70625. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70626. * * 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
  70627. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70628. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70629. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70630. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70631. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70632. * * 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
  70633. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70636. * @param name defines the name of the new line system
  70637. * @param options defines the options used to create the line system
  70638. * @param scene defines the hosting scene
  70639. * @returns a new line system mesh
  70640. */
  70641. static CreateLineSystem(name: string, options: {
  70642. lines: Vector3[][];
  70643. updatable?: boolean;
  70644. instance?: Nullable<LinesMesh>;
  70645. colors?: Nullable<Color4[][]>;
  70646. useVertexAlpha?: boolean;
  70647. }, scene: Nullable<Scene>): LinesMesh;
  70648. /**
  70649. * Creates a line mesh
  70650. * 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
  70651. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70652. * * The parameter `points` is an array successive Vector3
  70653. * * 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
  70654. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70655. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70656. * * When updating an instance, remember that only point positions can change, not the number of points
  70657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70659. * @param name defines the name of the new line system
  70660. * @param options defines the options used to create the line system
  70661. * @param scene defines the hosting scene
  70662. * @returns a new line mesh
  70663. */
  70664. static CreateLines(name: string, options: {
  70665. points: Vector3[];
  70666. updatable?: boolean;
  70667. instance?: Nullable<LinesMesh>;
  70668. colors?: Color4[];
  70669. useVertexAlpha?: boolean;
  70670. }, scene?: Nullable<Scene>): LinesMesh;
  70671. /**
  70672. * Creates a dashed line mesh
  70673. * * 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
  70674. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70675. * * The parameter `points` is an array successive Vector3
  70676. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70677. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70678. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70679. * * 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
  70680. * * When updating an instance, remember that only point positions can change, not the number of points
  70681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70682. * @param name defines the name of the mesh
  70683. * @param options defines the options used to create the mesh
  70684. * @param scene defines the hosting scene
  70685. * @returns the dashed line mesh
  70686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70687. */
  70688. static CreateDashedLines(name: string, options: {
  70689. points: Vector3[];
  70690. dashSize?: number;
  70691. gapSize?: number;
  70692. dashNb?: number;
  70693. updatable?: boolean;
  70694. instance?: LinesMesh;
  70695. }, scene?: Nullable<Scene>): LinesMesh;
  70696. /**
  70697. * 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.
  70698. * * 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.
  70699. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70700. * * 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.
  70701. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70702. * * 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
  70703. * * 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
  70704. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70709. * @param name defines the name of the mesh
  70710. * @param options defines the options used to create the mesh
  70711. * @param scene defines the hosting scene
  70712. * @returns the extruded shape mesh
  70713. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70715. */
  70716. static ExtrudeShape(name: string, options: {
  70717. shape: Vector3[];
  70718. path: Vector3[];
  70719. scale?: number;
  70720. rotation?: number;
  70721. cap?: number;
  70722. updatable?: boolean;
  70723. sideOrientation?: number;
  70724. frontUVs?: Vector4;
  70725. backUVs?: Vector4;
  70726. instance?: Mesh;
  70727. invertUV?: boolean;
  70728. }, scene?: Nullable<Scene>): Mesh;
  70729. /**
  70730. * Creates an custom extruded shape mesh.
  70731. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70732. * * 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.
  70733. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70734. * * 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
  70735. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70736. * * 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
  70737. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70738. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70739. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70740. * * 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
  70741. * * 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
  70742. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70745. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70747. * @param name defines the name of the mesh
  70748. * @param options defines the options used to create the mesh
  70749. * @param scene defines the hosting scene
  70750. * @returns the custom extruded shape mesh
  70751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70754. */
  70755. static ExtrudeShapeCustom(name: string, options: {
  70756. shape: Vector3[];
  70757. path: Vector3[];
  70758. scaleFunction?: any;
  70759. rotationFunction?: any;
  70760. ribbonCloseArray?: boolean;
  70761. ribbonClosePath?: boolean;
  70762. cap?: number;
  70763. updatable?: boolean;
  70764. sideOrientation?: number;
  70765. frontUVs?: Vector4;
  70766. backUVs?: Vector4;
  70767. instance?: Mesh;
  70768. invertUV?: boolean;
  70769. }, scene?: Nullable<Scene>): Mesh;
  70770. /**
  70771. * Creates lathe mesh.
  70772. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70773. * * 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
  70774. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70775. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70776. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70777. * * 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
  70778. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70779. * * 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
  70780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70784. * @param name defines the name of the mesh
  70785. * @param options defines the options used to create the mesh
  70786. * @param scene defines the hosting scene
  70787. * @returns the lathe mesh
  70788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70789. */
  70790. static CreateLathe(name: string, options: {
  70791. shape: Vector3[];
  70792. radius?: number;
  70793. tessellation?: number;
  70794. clip?: number;
  70795. arc?: number;
  70796. closed?: boolean;
  70797. updatable?: boolean;
  70798. sideOrientation?: number;
  70799. frontUVs?: Vector4;
  70800. backUVs?: Vector4;
  70801. cap?: number;
  70802. invertUV?: boolean;
  70803. }, scene?: Nullable<Scene>): Mesh;
  70804. /**
  70805. * Creates a tiled plane mesh
  70806. * * You can set a limited pattern arrangement with the tiles
  70807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70810. * @param name defines the name of the mesh
  70811. * @param options defines the options used to create the mesh
  70812. * @param scene defines the hosting scene
  70813. * @returns the plane mesh
  70814. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70815. */
  70816. static CreateTiledPlane(name: string, options: {
  70817. pattern?: number;
  70818. tileSize?: number;
  70819. tileWidth?: number;
  70820. tileHeight?: number;
  70821. size?: number;
  70822. width?: number;
  70823. height?: number;
  70824. alignHorizontal?: number;
  70825. alignVertical?: number;
  70826. sideOrientation?: number;
  70827. frontUVs?: Vector4;
  70828. backUVs?: Vector4;
  70829. updatable?: boolean;
  70830. }, scene?: Nullable<Scene>): Mesh;
  70831. /**
  70832. * Creates a plane mesh
  70833. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70834. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70835. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70839. * @param name defines the name of the mesh
  70840. * @param options defines the options used to create the mesh
  70841. * @param scene defines the hosting scene
  70842. * @returns the plane mesh
  70843. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70844. */
  70845. static CreatePlane(name: string, options: {
  70846. size?: number;
  70847. width?: number;
  70848. height?: number;
  70849. sideOrientation?: number;
  70850. frontUVs?: Vector4;
  70851. backUVs?: Vector4;
  70852. updatable?: boolean;
  70853. sourcePlane?: Plane;
  70854. }, scene?: Nullable<Scene>): Mesh;
  70855. /**
  70856. * Creates a ground mesh
  70857. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70858. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70860. * @param name defines the name of the mesh
  70861. * @param options defines the options used to create the mesh
  70862. * @param scene defines the hosting scene
  70863. * @returns the ground mesh
  70864. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70865. */
  70866. static CreateGround(name: string, options: {
  70867. width?: number;
  70868. height?: number;
  70869. subdivisions?: number;
  70870. subdivisionsX?: number;
  70871. subdivisionsY?: number;
  70872. updatable?: boolean;
  70873. }, scene?: Nullable<Scene>): Mesh;
  70874. /**
  70875. * Creates a tiled ground mesh
  70876. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70877. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70878. * * 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
  70879. * * 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
  70880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70881. * @param name defines the name of the mesh
  70882. * @param options defines the options used to create the mesh
  70883. * @param scene defines the hosting scene
  70884. * @returns the tiled ground mesh
  70885. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70886. */
  70887. static CreateTiledGround(name: string, options: {
  70888. xmin: number;
  70889. zmin: number;
  70890. xmax: number;
  70891. zmax: number;
  70892. subdivisions?: {
  70893. w: number;
  70894. h: number;
  70895. };
  70896. precision?: {
  70897. w: number;
  70898. h: number;
  70899. };
  70900. updatable?: boolean;
  70901. }, scene?: Nullable<Scene>): Mesh;
  70902. /**
  70903. * Creates a ground mesh from a height map
  70904. * * The parameter `url` sets the URL of the height map image resource.
  70905. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70906. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70907. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70908. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70909. * * 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.
  70910. * * 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).
  70911. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70913. * @param name defines the name of the mesh
  70914. * @param url defines the url to the height map
  70915. * @param options defines the options used to create the mesh
  70916. * @param scene defines the hosting scene
  70917. * @returns the ground mesh
  70918. * @see https://doc.babylonjs.com/babylon101/height_map
  70919. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70920. */
  70921. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70922. width?: number;
  70923. height?: number;
  70924. subdivisions?: number;
  70925. minHeight?: number;
  70926. maxHeight?: number;
  70927. colorFilter?: Color3;
  70928. alphaFilter?: number;
  70929. updatable?: boolean;
  70930. onReady?: (mesh: GroundMesh) => void;
  70931. }, scene?: Nullable<Scene>): GroundMesh;
  70932. /**
  70933. * Creates a polygon mesh
  70934. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70935. * * 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
  70936. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70939. * * Remember you can only change the shape positions, not their number when updating a polygon
  70940. * @param name defines the name of the mesh
  70941. * @param options defines the options used to create the mesh
  70942. * @param scene defines the hosting scene
  70943. * @param earcutInjection can be used to inject your own earcut reference
  70944. * @returns the polygon mesh
  70945. */
  70946. static CreatePolygon(name: string, options: {
  70947. shape: Vector3[];
  70948. holes?: Vector3[][];
  70949. depth?: number;
  70950. faceUV?: Vector4[];
  70951. faceColors?: Color4[];
  70952. updatable?: boolean;
  70953. sideOrientation?: number;
  70954. frontUVs?: Vector4;
  70955. backUVs?: Vector4;
  70956. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70957. /**
  70958. * Creates an extruded polygon mesh, with depth in the Y direction.
  70959. * * 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)
  70960. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70961. * @param name defines the name of the mesh
  70962. * @param options defines the options used to create the mesh
  70963. * @param scene defines the hosting scene
  70964. * @param earcutInjection can be used to inject your own earcut reference
  70965. * @returns the polygon mesh
  70966. */
  70967. static ExtrudePolygon(name: string, options: {
  70968. shape: Vector3[];
  70969. holes?: Vector3[][];
  70970. depth?: number;
  70971. faceUV?: Vector4[];
  70972. faceColors?: Color4[];
  70973. updatable?: boolean;
  70974. sideOrientation?: number;
  70975. frontUVs?: Vector4;
  70976. backUVs?: Vector4;
  70977. wrap?: boolean;
  70978. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70979. /**
  70980. * Creates a tube mesh.
  70981. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70982. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70983. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70984. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70985. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70986. * * 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)
  70987. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70988. * * 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
  70989. * * 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
  70990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70994. * @param name defines the name of the mesh
  70995. * @param options defines the options used to create the mesh
  70996. * @param scene defines the hosting scene
  70997. * @returns the tube mesh
  70998. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70999. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71000. */
  71001. static CreateTube(name: string, options: {
  71002. path: Vector3[];
  71003. radius?: number;
  71004. tessellation?: number;
  71005. radiusFunction?: {
  71006. (i: number, distance: number): number;
  71007. };
  71008. cap?: number;
  71009. arc?: number;
  71010. updatable?: boolean;
  71011. sideOrientation?: number;
  71012. frontUVs?: Vector4;
  71013. backUVs?: Vector4;
  71014. instance?: Mesh;
  71015. invertUV?: boolean;
  71016. }, scene?: Nullable<Scene>): Mesh;
  71017. /**
  71018. * Creates a polyhedron mesh
  71019. * * 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
  71020. * * The parameter `size` (positive float, default 1) sets the polygon size
  71021. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71022. * * 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`
  71023. * * 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
  71024. * * 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)`)
  71025. * * 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
  71026. * * 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
  71027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71028. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71030. * @param name defines the name of the mesh
  71031. * @param options defines the options used to create the mesh
  71032. * @param scene defines the hosting scene
  71033. * @returns the polyhedron mesh
  71034. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71035. */
  71036. static CreatePolyhedron(name: string, options: {
  71037. type?: number;
  71038. size?: number;
  71039. sizeX?: number;
  71040. sizeY?: number;
  71041. sizeZ?: number;
  71042. custom?: any;
  71043. faceUV?: Vector4[];
  71044. faceColors?: Color4[];
  71045. flat?: boolean;
  71046. updatable?: boolean;
  71047. sideOrientation?: number;
  71048. frontUVs?: Vector4;
  71049. backUVs?: Vector4;
  71050. }, scene?: Nullable<Scene>): Mesh;
  71051. /**
  71052. * Creates a decal mesh.
  71053. * 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
  71054. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71055. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71056. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71057. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71058. * @param name defines the name of the mesh
  71059. * @param sourceMesh defines the mesh where the decal must be applied
  71060. * @param options defines the options used to create the mesh
  71061. * @param scene defines the hosting scene
  71062. * @returns the decal mesh
  71063. * @see https://doc.babylonjs.com/how_to/decals
  71064. */
  71065. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71066. position?: Vector3;
  71067. normal?: Vector3;
  71068. size?: Vector3;
  71069. angle?: number;
  71070. }): Mesh;
  71071. /**
  71072. * Creates a Capsule Mesh
  71073. * @param name defines the name of the mesh.
  71074. * @param options the constructors options used to shape the mesh.
  71075. * @param scene defines the scene the mesh is scoped to.
  71076. * @returns the capsule mesh
  71077. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71078. */
  71079. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71080. }
  71081. }
  71082. declare module "babylonjs/Meshes/meshSimplification" {
  71083. import { Mesh } from "babylonjs/Meshes/mesh";
  71084. /**
  71085. * A simplifier interface for future simplification implementations
  71086. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71087. */
  71088. export interface ISimplifier {
  71089. /**
  71090. * Simplification of a given mesh according to the given settings.
  71091. * Since this requires computation, it is assumed that the function runs async.
  71092. * @param settings The settings of the simplification, including quality and distance
  71093. * @param successCallback A callback that will be called after the mesh was simplified.
  71094. * @param errorCallback in case of an error, this callback will be called. optional.
  71095. */
  71096. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71097. }
  71098. /**
  71099. * Expected simplification settings.
  71100. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71101. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71102. */
  71103. export interface ISimplificationSettings {
  71104. /**
  71105. * Gets or sets the expected quality
  71106. */
  71107. quality: number;
  71108. /**
  71109. * Gets or sets the distance when this optimized version should be used
  71110. */
  71111. distance: number;
  71112. /**
  71113. * Gets an already optimized mesh
  71114. */
  71115. optimizeMesh?: boolean;
  71116. }
  71117. /**
  71118. * Class used to specify simplification options
  71119. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71120. */
  71121. export class SimplificationSettings implements ISimplificationSettings {
  71122. /** expected quality */
  71123. quality: number;
  71124. /** distance when this optimized version should be used */
  71125. distance: number;
  71126. /** already optimized mesh */
  71127. optimizeMesh?: boolean | undefined;
  71128. /**
  71129. * Creates a SimplificationSettings
  71130. * @param quality expected quality
  71131. * @param distance distance when this optimized version should be used
  71132. * @param optimizeMesh already optimized mesh
  71133. */
  71134. constructor(
  71135. /** expected quality */
  71136. quality: number,
  71137. /** distance when this optimized version should be used */
  71138. distance: number,
  71139. /** already optimized mesh */
  71140. optimizeMesh?: boolean | undefined);
  71141. }
  71142. /**
  71143. * Interface used to define a simplification task
  71144. */
  71145. export interface ISimplificationTask {
  71146. /**
  71147. * Array of settings
  71148. */
  71149. settings: Array<ISimplificationSettings>;
  71150. /**
  71151. * Simplification type
  71152. */
  71153. simplificationType: SimplificationType;
  71154. /**
  71155. * Mesh to simplify
  71156. */
  71157. mesh: Mesh;
  71158. /**
  71159. * Callback called on success
  71160. */
  71161. successCallback?: () => void;
  71162. /**
  71163. * Defines if parallel processing can be used
  71164. */
  71165. parallelProcessing: boolean;
  71166. }
  71167. /**
  71168. * Queue used to order the simplification tasks
  71169. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71170. */
  71171. export class SimplificationQueue {
  71172. private _simplificationArray;
  71173. /**
  71174. * Gets a boolean indicating that the process is still running
  71175. */
  71176. running: boolean;
  71177. /**
  71178. * Creates a new queue
  71179. */
  71180. constructor();
  71181. /**
  71182. * Adds a new simplification task
  71183. * @param task defines a task to add
  71184. */
  71185. addTask(task: ISimplificationTask): void;
  71186. /**
  71187. * Execute next task
  71188. */
  71189. executeNext(): void;
  71190. /**
  71191. * Execute a simplification task
  71192. * @param task defines the task to run
  71193. */
  71194. runSimplification(task: ISimplificationTask): void;
  71195. private getSimplifier;
  71196. }
  71197. /**
  71198. * The implemented types of simplification
  71199. * At the moment only Quadratic Error Decimation is implemented
  71200. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71201. */
  71202. export enum SimplificationType {
  71203. /** Quadratic error decimation */
  71204. QUADRATIC = 0
  71205. }
  71206. /**
  71207. * An implementation of the Quadratic Error simplification algorithm.
  71208. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71209. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71210. * @author RaananW
  71211. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71212. */
  71213. export class QuadraticErrorSimplification implements ISimplifier {
  71214. private _mesh;
  71215. private triangles;
  71216. private vertices;
  71217. private references;
  71218. private _reconstructedMesh;
  71219. /** Gets or sets the number pf sync interations */
  71220. syncIterations: number;
  71221. /** Gets or sets the aggressiveness of the simplifier */
  71222. aggressiveness: number;
  71223. /** Gets or sets the number of allowed iterations for decimation */
  71224. decimationIterations: number;
  71225. /** Gets or sets the espilon to use for bounding box computation */
  71226. boundingBoxEpsilon: number;
  71227. /**
  71228. * Creates a new QuadraticErrorSimplification
  71229. * @param _mesh defines the target mesh
  71230. */
  71231. constructor(_mesh: Mesh);
  71232. /**
  71233. * Simplification of a given mesh according to the given settings.
  71234. * Since this requires computation, it is assumed that the function runs async.
  71235. * @param settings The settings of the simplification, including quality and distance
  71236. * @param successCallback A callback that will be called after the mesh was simplified.
  71237. */
  71238. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71239. private runDecimation;
  71240. private initWithMesh;
  71241. private init;
  71242. private reconstructMesh;
  71243. private initDecimatedMesh;
  71244. private isFlipped;
  71245. private updateTriangles;
  71246. private identifyBorder;
  71247. private updateMesh;
  71248. private vertexError;
  71249. private calculateError;
  71250. }
  71251. }
  71252. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71253. import { Scene } from "babylonjs/scene";
  71254. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71255. import { ISceneComponent } from "babylonjs/sceneComponent";
  71256. module "babylonjs/scene" {
  71257. interface Scene {
  71258. /** @hidden (Backing field) */
  71259. _simplificationQueue: SimplificationQueue;
  71260. /**
  71261. * Gets or sets the simplification queue attached to the scene
  71262. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71263. */
  71264. simplificationQueue: SimplificationQueue;
  71265. }
  71266. }
  71267. module "babylonjs/Meshes/mesh" {
  71268. interface Mesh {
  71269. /**
  71270. * Simplify the mesh according to the given array of settings.
  71271. * Function will return immediately and will simplify async
  71272. * @param settings a collection of simplification settings
  71273. * @param parallelProcessing should all levels calculate parallel or one after the other
  71274. * @param simplificationType the type of simplification to run
  71275. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71276. * @returns the current mesh
  71277. */
  71278. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71279. }
  71280. }
  71281. /**
  71282. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71283. * created in a scene
  71284. */
  71285. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71286. /**
  71287. * The component name helpfull to identify the component in the list of scene components.
  71288. */
  71289. readonly name: string;
  71290. /**
  71291. * The scene the component belongs to.
  71292. */
  71293. scene: Scene;
  71294. /**
  71295. * Creates a new instance of the component for the given scene
  71296. * @param scene Defines the scene to register the component in
  71297. */
  71298. constructor(scene: Scene);
  71299. /**
  71300. * Registers the component in a given scene
  71301. */
  71302. register(): void;
  71303. /**
  71304. * Rebuilds the elements related to this component in case of
  71305. * context lost for instance.
  71306. */
  71307. rebuild(): void;
  71308. /**
  71309. * Disposes the component and the associated ressources
  71310. */
  71311. dispose(): void;
  71312. private _beforeCameraUpdate;
  71313. }
  71314. }
  71315. declare module "babylonjs/Meshes/Builders/index" {
  71316. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71317. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71318. export * from "babylonjs/Meshes/Builders/discBuilder";
  71319. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71320. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71321. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71322. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71323. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71324. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71325. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71326. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71327. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71328. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71329. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71330. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71331. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71332. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71333. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71334. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71335. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71336. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71337. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71338. }
  71339. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71340. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71341. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71342. import { Matrix } from "babylonjs/Maths/math.vector";
  71343. module "babylonjs/Meshes/mesh" {
  71344. interface Mesh {
  71345. /**
  71346. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71347. */
  71348. thinInstanceEnablePicking: boolean;
  71349. /**
  71350. * Creates a new thin instance
  71351. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71352. * @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
  71353. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71354. */
  71355. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71356. /**
  71357. * Adds the transformation (matrix) of the current mesh as a thin instance
  71358. * @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
  71359. * @returns the thin instance index number
  71360. */
  71361. thinInstanceAddSelf(refresh: boolean): number;
  71362. /**
  71363. * Registers a custom attribute to be used with thin instances
  71364. * @param kind name of the attribute
  71365. * @param stride size in floats of the attribute
  71366. */
  71367. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71368. /**
  71369. * Sets the matrix of a thin instance
  71370. * @param index index of the thin instance
  71371. * @param matrix matrix to set
  71372. * @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
  71373. */
  71374. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71375. /**
  71376. * Sets the value of a custom attribute for a thin instance
  71377. * @param kind name of the attribute
  71378. * @param index index of the thin instance
  71379. * @param value value to set
  71380. * @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
  71381. */
  71382. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71383. /**
  71384. * 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.
  71385. */
  71386. thinInstanceCount: number;
  71387. /**
  71388. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71389. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71390. * @param buffer buffer to set
  71391. * @param stride size in floats of each value of the buffer
  71392. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71393. */
  71394. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71395. /**
  71396. * Gets the list of world matrices
  71397. * @return an array containing all the world matrices from the thin instances
  71398. */
  71399. thinInstanceGetWorldMatrices(): Matrix[];
  71400. /**
  71401. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71402. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71403. */
  71404. thinInstanceBufferUpdated(kind: string): void;
  71405. /**
  71406. * Applies a partial update to a buffer directly on the GPU
  71407. * 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
  71408. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71409. * @param data the data to set in the GPU buffer
  71410. * @param offset the offset in the GPU buffer where to update the data
  71411. */
  71412. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71413. /**
  71414. * Refreshes the bounding info, taking into account all the thin instances defined
  71415. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71416. */
  71417. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71418. /** @hidden */
  71419. _thinInstanceInitializeUserStorage(): void;
  71420. /** @hidden */
  71421. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71422. /** @hidden */
  71423. _userThinInstanceBuffersStorage: {
  71424. data: {
  71425. [key: string]: Float32Array;
  71426. };
  71427. sizes: {
  71428. [key: string]: number;
  71429. };
  71430. vertexBuffers: {
  71431. [key: string]: Nullable<VertexBuffer>;
  71432. };
  71433. strides: {
  71434. [key: string]: number;
  71435. };
  71436. };
  71437. }
  71438. }
  71439. }
  71440. declare module "babylonjs/Meshes/index" {
  71441. export * from "babylonjs/Meshes/abstractMesh";
  71442. export * from "babylonjs/Meshes/buffer";
  71443. export * from "babylonjs/Meshes/Compression/index";
  71444. export * from "babylonjs/Meshes/csg";
  71445. export * from "babylonjs/Meshes/geometry";
  71446. export * from "babylonjs/Meshes/groundMesh";
  71447. export * from "babylonjs/Meshes/trailMesh";
  71448. export * from "babylonjs/Meshes/instancedMesh";
  71449. export * from "babylonjs/Meshes/linesMesh";
  71450. export * from "babylonjs/Meshes/mesh";
  71451. export * from "babylonjs/Meshes/mesh.vertexData";
  71452. export * from "babylonjs/Meshes/meshBuilder";
  71453. export * from "babylonjs/Meshes/meshSimplification";
  71454. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71455. export * from "babylonjs/Meshes/polygonMesh";
  71456. export * from "babylonjs/Meshes/subMesh";
  71457. export * from "babylonjs/Meshes/meshLODLevel";
  71458. export * from "babylonjs/Meshes/transformNode";
  71459. export * from "babylonjs/Meshes/Builders/index";
  71460. export * from "babylonjs/Meshes/dataBuffer";
  71461. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71462. import "babylonjs/Meshes/thinInstanceMesh";
  71463. export * from "babylonjs/Meshes/thinInstanceMesh";
  71464. }
  71465. declare module "babylonjs/Morph/index" {
  71466. export * from "babylonjs/Morph/morphTarget";
  71467. export * from "babylonjs/Morph/morphTargetManager";
  71468. }
  71469. declare module "babylonjs/Navigation/INavigationEngine" {
  71470. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71471. import { Vector3 } from "babylonjs/Maths/math";
  71472. import { Mesh } from "babylonjs/Meshes/mesh";
  71473. import { Scene } from "babylonjs/scene";
  71474. /**
  71475. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71476. */
  71477. export interface INavigationEnginePlugin {
  71478. /**
  71479. * plugin name
  71480. */
  71481. name: string;
  71482. /**
  71483. * Creates a navigation mesh
  71484. * @param meshes array of all the geometry used to compute the navigatio mesh
  71485. * @param parameters bunch of parameters used to filter geometry
  71486. */
  71487. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71488. /**
  71489. * Create a navigation mesh debug mesh
  71490. * @param scene is where the mesh will be added
  71491. * @returns debug display mesh
  71492. */
  71493. createDebugNavMesh(scene: Scene): Mesh;
  71494. /**
  71495. * Get a navigation mesh constrained position, closest to the parameter position
  71496. * @param position world position
  71497. * @returns the closest point to position constrained by the navigation mesh
  71498. */
  71499. getClosestPoint(position: Vector3): Vector3;
  71500. /**
  71501. * Get a navigation mesh constrained position, closest to the parameter position
  71502. * @param position world position
  71503. * @param result output the closest point to position constrained by the navigation mesh
  71504. */
  71505. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71506. /**
  71507. * Get a navigation mesh constrained position, within a particular radius
  71508. * @param position world position
  71509. * @param maxRadius the maximum distance to the constrained world position
  71510. * @returns the closest point to position constrained by the navigation mesh
  71511. */
  71512. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71513. /**
  71514. * Get a navigation mesh constrained position, within a particular radius
  71515. * @param position world position
  71516. * @param maxRadius the maximum distance to the constrained world position
  71517. * @param result output the closest point to position constrained by the navigation mesh
  71518. */
  71519. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71520. /**
  71521. * Compute the final position from a segment made of destination-position
  71522. * @param position world position
  71523. * @param destination world position
  71524. * @returns the resulting point along the navmesh
  71525. */
  71526. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71527. /**
  71528. * Compute the final position from a segment made of destination-position
  71529. * @param position world position
  71530. * @param destination world position
  71531. * @param result output the resulting point along the navmesh
  71532. */
  71533. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71534. /**
  71535. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71536. * @param start world position
  71537. * @param end world position
  71538. * @returns array containing world position composing the path
  71539. */
  71540. computePath(start: Vector3, end: Vector3): Vector3[];
  71541. /**
  71542. * If this plugin is supported
  71543. * @returns true if plugin is supported
  71544. */
  71545. isSupported(): boolean;
  71546. /**
  71547. * Create a new Crowd so you can add agents
  71548. * @param maxAgents the maximum agent count in the crowd
  71549. * @param maxAgentRadius the maximum radius an agent can have
  71550. * @param scene to attach the crowd to
  71551. * @returns the crowd you can add agents to
  71552. */
  71553. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71554. /**
  71555. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71556. * The queries will try to find a solution within those bounds
  71557. * default is (1,1,1)
  71558. * @param extent x,y,z value that define the extent around the queries point of reference
  71559. */
  71560. setDefaultQueryExtent(extent: Vector3): void;
  71561. /**
  71562. * Get the Bounding box extent specified by setDefaultQueryExtent
  71563. * @returns the box extent values
  71564. */
  71565. getDefaultQueryExtent(): Vector3;
  71566. /**
  71567. * build the navmesh from a previously saved state using getNavmeshData
  71568. * @param data the Uint8Array returned by getNavmeshData
  71569. */
  71570. buildFromNavmeshData(data: Uint8Array): void;
  71571. /**
  71572. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71573. * @returns data the Uint8Array that can be saved and reused
  71574. */
  71575. getNavmeshData(): Uint8Array;
  71576. /**
  71577. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71578. * @param result output the box extent values
  71579. */
  71580. getDefaultQueryExtentToRef(result: Vector3): void;
  71581. /**
  71582. * Release all resources
  71583. */
  71584. dispose(): void;
  71585. }
  71586. /**
  71587. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71588. */
  71589. export interface ICrowd {
  71590. /**
  71591. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71592. * You can attach anything to that node. The node position is updated in the scene update tick.
  71593. * @param pos world position that will be constrained by the navigation mesh
  71594. * @param parameters agent parameters
  71595. * @param transform hooked to the agent that will be update by the scene
  71596. * @returns agent index
  71597. */
  71598. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71599. /**
  71600. * Returns the agent position in world space
  71601. * @param index agent index returned by addAgent
  71602. * @returns world space position
  71603. */
  71604. getAgentPosition(index: number): Vector3;
  71605. /**
  71606. * Gets the agent position result in world space
  71607. * @param index agent index returned by addAgent
  71608. * @param result output world space position
  71609. */
  71610. getAgentPositionToRef(index: number, result: Vector3): void;
  71611. /**
  71612. * Gets the agent velocity in world space
  71613. * @param index agent index returned by addAgent
  71614. * @returns world space velocity
  71615. */
  71616. getAgentVelocity(index: number): Vector3;
  71617. /**
  71618. * Gets the agent velocity result in world space
  71619. * @param index agent index returned by addAgent
  71620. * @param result output world space velocity
  71621. */
  71622. getAgentVelocityToRef(index: number, result: Vector3): void;
  71623. /**
  71624. * Gets the agent next target point on the path
  71625. * @param index agent index returned by addAgent
  71626. * @returns world space position
  71627. */
  71628. getAgentNextTargetPath(index: number): Vector3;
  71629. /**
  71630. * Gets the agent state
  71631. * @param index agent index returned by addAgent
  71632. * @returns agent state
  71633. */
  71634. getAgentState(index: number): number;
  71635. /**
  71636. * returns true if the agent in over an off mesh link connection
  71637. * @param index agent index returned by addAgent
  71638. * @returns true if over an off mesh link connection
  71639. */
  71640. overOffmeshConnection(index: number): boolean;
  71641. /**
  71642. * Gets the agent next target point on the path
  71643. * @param index agent index returned by addAgent
  71644. * @param result output world space position
  71645. */
  71646. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71647. /**
  71648. * remove a particular agent previously created
  71649. * @param index agent index returned by addAgent
  71650. */
  71651. removeAgent(index: number): void;
  71652. /**
  71653. * get the list of all agents attached to this crowd
  71654. * @returns list of agent indices
  71655. */
  71656. getAgents(): number[];
  71657. /**
  71658. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71659. * @param deltaTime in seconds
  71660. */
  71661. update(deltaTime: number): void;
  71662. /**
  71663. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71664. * @param index agent index returned by addAgent
  71665. * @param destination targeted world position
  71666. */
  71667. agentGoto(index: number, destination: Vector3): void;
  71668. /**
  71669. * Teleport the agent to a new position
  71670. * @param index agent index returned by addAgent
  71671. * @param destination targeted world position
  71672. */
  71673. agentTeleport(index: number, destination: Vector3): void;
  71674. /**
  71675. * Update agent parameters
  71676. * @param index agent index returned by addAgent
  71677. * @param parameters agent parameters
  71678. */
  71679. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71680. /**
  71681. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71682. * The queries will try to find a solution within those bounds
  71683. * default is (1,1,1)
  71684. * @param extent x,y,z value that define the extent around the queries point of reference
  71685. */
  71686. setDefaultQueryExtent(extent: Vector3): void;
  71687. /**
  71688. * Get the Bounding box extent specified by setDefaultQueryExtent
  71689. * @returns the box extent values
  71690. */
  71691. getDefaultQueryExtent(): Vector3;
  71692. /**
  71693. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71694. * @param result output the box extent values
  71695. */
  71696. getDefaultQueryExtentToRef(result: Vector3): void;
  71697. /**
  71698. * Release all resources
  71699. */
  71700. dispose(): void;
  71701. }
  71702. /**
  71703. * Configures an agent
  71704. */
  71705. export interface IAgentParameters {
  71706. /**
  71707. * Agent radius. [Limit: >= 0]
  71708. */
  71709. radius: number;
  71710. /**
  71711. * Agent height. [Limit: > 0]
  71712. */
  71713. height: number;
  71714. /**
  71715. * Maximum allowed acceleration. [Limit: >= 0]
  71716. */
  71717. maxAcceleration: number;
  71718. /**
  71719. * Maximum allowed speed. [Limit: >= 0]
  71720. */
  71721. maxSpeed: number;
  71722. /**
  71723. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71724. */
  71725. collisionQueryRange: number;
  71726. /**
  71727. * The path visibility optimization range. [Limit: > 0]
  71728. */
  71729. pathOptimizationRange: number;
  71730. /**
  71731. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71732. */
  71733. separationWeight: number;
  71734. }
  71735. /**
  71736. * Configures the navigation mesh creation
  71737. */
  71738. export interface INavMeshParameters {
  71739. /**
  71740. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71741. */
  71742. cs: number;
  71743. /**
  71744. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71745. */
  71746. ch: number;
  71747. /**
  71748. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71749. */
  71750. walkableSlopeAngle: number;
  71751. /**
  71752. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71753. * be considered walkable. [Limit: >= 3] [Units: vx]
  71754. */
  71755. walkableHeight: number;
  71756. /**
  71757. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71758. */
  71759. walkableClimb: number;
  71760. /**
  71761. * The distance to erode/shrink the walkable area of the heightfield away from
  71762. * obstructions. [Limit: >=0] [Units: vx]
  71763. */
  71764. walkableRadius: number;
  71765. /**
  71766. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71767. */
  71768. maxEdgeLen: number;
  71769. /**
  71770. * The maximum distance a simplfied contour's border edges should deviate
  71771. * the original raw contour. [Limit: >=0] [Units: vx]
  71772. */
  71773. maxSimplificationError: number;
  71774. /**
  71775. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71776. */
  71777. minRegionArea: number;
  71778. /**
  71779. * Any regions with a span count smaller than this value will, if possible,
  71780. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71781. */
  71782. mergeRegionArea: number;
  71783. /**
  71784. * The maximum number of vertices allowed for polygons generated during the
  71785. * contour to polygon conversion process. [Limit: >= 3]
  71786. */
  71787. maxVertsPerPoly: number;
  71788. /**
  71789. * Sets the sampling distance to use when generating the detail mesh.
  71790. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71791. */
  71792. detailSampleDist: number;
  71793. /**
  71794. * The maximum distance the detail mesh surface should deviate from heightfield
  71795. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71796. */
  71797. detailSampleMaxError: number;
  71798. }
  71799. }
  71800. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71801. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71802. import { Mesh } from "babylonjs/Meshes/mesh";
  71803. import { Scene } from "babylonjs/scene";
  71804. import { Vector3 } from "babylonjs/Maths/math";
  71805. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71806. /**
  71807. * RecastJS navigation plugin
  71808. */
  71809. export class RecastJSPlugin implements INavigationEnginePlugin {
  71810. /**
  71811. * Reference to the Recast library
  71812. */
  71813. bjsRECAST: any;
  71814. /**
  71815. * plugin name
  71816. */
  71817. name: string;
  71818. /**
  71819. * the first navmesh created. We might extend this to support multiple navmeshes
  71820. */
  71821. navMesh: any;
  71822. /**
  71823. * Initializes the recastJS plugin
  71824. * @param recastInjection can be used to inject your own recast reference
  71825. */
  71826. constructor(recastInjection?: any);
  71827. /**
  71828. * Creates a navigation mesh
  71829. * @param meshes array of all the geometry used to compute the navigatio mesh
  71830. * @param parameters bunch of parameters used to filter geometry
  71831. */
  71832. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71833. /**
  71834. * Create a navigation mesh debug mesh
  71835. * @param scene is where the mesh will be added
  71836. * @returns debug display mesh
  71837. */
  71838. createDebugNavMesh(scene: Scene): Mesh;
  71839. /**
  71840. * Get a navigation mesh constrained position, closest to the parameter position
  71841. * @param position world position
  71842. * @returns the closest point to position constrained by the navigation mesh
  71843. */
  71844. getClosestPoint(position: Vector3): Vector3;
  71845. /**
  71846. * Get a navigation mesh constrained position, closest to the parameter position
  71847. * @param position world position
  71848. * @param result output the closest point to position constrained by the navigation mesh
  71849. */
  71850. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71851. /**
  71852. * Get a navigation mesh constrained position, within a particular radius
  71853. * @param position world position
  71854. * @param maxRadius the maximum distance to the constrained world position
  71855. * @returns the closest point to position constrained by the navigation mesh
  71856. */
  71857. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71858. /**
  71859. * Get a navigation mesh constrained position, within a particular radius
  71860. * @param position world position
  71861. * @param maxRadius the maximum distance to the constrained world position
  71862. * @param result output the closest point to position constrained by the navigation mesh
  71863. */
  71864. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71865. /**
  71866. * Compute the final position from a segment made of destination-position
  71867. * @param position world position
  71868. * @param destination world position
  71869. * @returns the resulting point along the navmesh
  71870. */
  71871. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71872. /**
  71873. * Compute the final position from a segment made of destination-position
  71874. * @param position world position
  71875. * @param destination world position
  71876. * @param result output the resulting point along the navmesh
  71877. */
  71878. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71879. /**
  71880. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71881. * @param start world position
  71882. * @param end world position
  71883. * @returns array containing world position composing the path
  71884. */
  71885. computePath(start: Vector3, end: Vector3): Vector3[];
  71886. /**
  71887. * Create a new Crowd so you can add agents
  71888. * @param maxAgents the maximum agent count in the crowd
  71889. * @param maxAgentRadius the maximum radius an agent can have
  71890. * @param scene to attach the crowd to
  71891. * @returns the crowd you can add agents to
  71892. */
  71893. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71894. /**
  71895. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71896. * The queries will try to find a solution within those bounds
  71897. * default is (1,1,1)
  71898. * @param extent x,y,z value that define the extent around the queries point of reference
  71899. */
  71900. setDefaultQueryExtent(extent: Vector3): void;
  71901. /**
  71902. * Get the Bounding box extent specified by setDefaultQueryExtent
  71903. * @returns the box extent values
  71904. */
  71905. getDefaultQueryExtent(): Vector3;
  71906. /**
  71907. * build the navmesh from a previously saved state using getNavmeshData
  71908. * @param data the Uint8Array returned by getNavmeshData
  71909. */
  71910. buildFromNavmeshData(data: Uint8Array): void;
  71911. /**
  71912. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71913. * @returns data the Uint8Array that can be saved and reused
  71914. */
  71915. getNavmeshData(): Uint8Array;
  71916. /**
  71917. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71918. * @param result output the box extent values
  71919. */
  71920. getDefaultQueryExtentToRef(result: Vector3): void;
  71921. /**
  71922. * Disposes
  71923. */
  71924. dispose(): void;
  71925. /**
  71926. * If this plugin is supported
  71927. * @returns true if plugin is supported
  71928. */
  71929. isSupported(): boolean;
  71930. }
  71931. /**
  71932. * Recast detour crowd implementation
  71933. */
  71934. export class RecastJSCrowd implements ICrowd {
  71935. /**
  71936. * Recast/detour plugin
  71937. */
  71938. bjsRECASTPlugin: RecastJSPlugin;
  71939. /**
  71940. * Link to the detour crowd
  71941. */
  71942. recastCrowd: any;
  71943. /**
  71944. * One transform per agent
  71945. */
  71946. transforms: TransformNode[];
  71947. /**
  71948. * All agents created
  71949. */
  71950. agents: number[];
  71951. /**
  71952. * Link to the scene is kept to unregister the crowd from the scene
  71953. */
  71954. private _scene;
  71955. /**
  71956. * Observer for crowd updates
  71957. */
  71958. private _onBeforeAnimationsObserver;
  71959. /**
  71960. * Constructor
  71961. * @param plugin recastJS plugin
  71962. * @param maxAgents the maximum agent count in the crowd
  71963. * @param maxAgentRadius the maximum radius an agent can have
  71964. * @param scene to attach the crowd to
  71965. * @returns the crowd you can add agents to
  71966. */
  71967. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71968. /**
  71969. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71970. * You can attach anything to that node. The node position is updated in the scene update tick.
  71971. * @param pos world position that will be constrained by the navigation mesh
  71972. * @param parameters agent parameters
  71973. * @param transform hooked to the agent that will be update by the scene
  71974. * @returns agent index
  71975. */
  71976. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71977. /**
  71978. * Returns the agent position in world space
  71979. * @param index agent index returned by addAgent
  71980. * @returns world space position
  71981. */
  71982. getAgentPosition(index: number): Vector3;
  71983. /**
  71984. * Returns the agent position result in world space
  71985. * @param index agent index returned by addAgent
  71986. * @param result output world space position
  71987. */
  71988. getAgentPositionToRef(index: number, result: Vector3): void;
  71989. /**
  71990. * Returns the agent velocity in world space
  71991. * @param index agent index returned by addAgent
  71992. * @returns world space velocity
  71993. */
  71994. getAgentVelocity(index: number): Vector3;
  71995. /**
  71996. * Returns the agent velocity result in world space
  71997. * @param index agent index returned by addAgent
  71998. * @param result output world space velocity
  71999. */
  72000. getAgentVelocityToRef(index: number, result: Vector3): void;
  72001. /**
  72002. * Returns the agent next target point on the path
  72003. * @param index agent index returned by addAgent
  72004. * @returns world space position
  72005. */
  72006. getAgentNextTargetPath(index: number): Vector3;
  72007. /**
  72008. * Returns the agent next target point on the path
  72009. * @param index agent index returned by addAgent
  72010. * @param result output world space position
  72011. */
  72012. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72013. /**
  72014. * Gets the agent state
  72015. * @param index agent index returned by addAgent
  72016. * @returns agent state
  72017. */
  72018. getAgentState(index: number): number;
  72019. /**
  72020. * returns true if the agent in over an off mesh link connection
  72021. * @param index agent index returned by addAgent
  72022. * @returns true if over an off mesh link connection
  72023. */
  72024. overOffmeshConnection(index: number): boolean;
  72025. /**
  72026. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72027. * @param index agent index returned by addAgent
  72028. * @param destination targeted world position
  72029. */
  72030. agentGoto(index: number, destination: Vector3): void;
  72031. /**
  72032. * Teleport the agent to a new position
  72033. * @param index agent index returned by addAgent
  72034. * @param destination targeted world position
  72035. */
  72036. agentTeleport(index: number, destination: Vector3): void;
  72037. /**
  72038. * Update agent parameters
  72039. * @param index agent index returned by addAgent
  72040. * @param parameters agent parameters
  72041. */
  72042. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72043. /**
  72044. * remove a particular agent previously created
  72045. * @param index agent index returned by addAgent
  72046. */
  72047. removeAgent(index: number): void;
  72048. /**
  72049. * get the list of all agents attached to this crowd
  72050. * @returns list of agent indices
  72051. */
  72052. getAgents(): number[];
  72053. /**
  72054. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72055. * @param deltaTime in seconds
  72056. */
  72057. update(deltaTime: number): void;
  72058. /**
  72059. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72060. * The queries will try to find a solution within those bounds
  72061. * default is (1,1,1)
  72062. * @param extent x,y,z value that define the extent around the queries point of reference
  72063. */
  72064. setDefaultQueryExtent(extent: Vector3): void;
  72065. /**
  72066. * Get the Bounding box extent specified by setDefaultQueryExtent
  72067. * @returns the box extent values
  72068. */
  72069. getDefaultQueryExtent(): Vector3;
  72070. /**
  72071. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72072. * @param result output the box extent values
  72073. */
  72074. getDefaultQueryExtentToRef(result: Vector3): void;
  72075. /**
  72076. * Release all resources
  72077. */
  72078. dispose(): void;
  72079. }
  72080. }
  72081. declare module "babylonjs/Navigation/Plugins/index" {
  72082. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72083. }
  72084. declare module "babylonjs/Navigation/index" {
  72085. export * from "babylonjs/Navigation/INavigationEngine";
  72086. export * from "babylonjs/Navigation/Plugins/index";
  72087. }
  72088. declare module "babylonjs/Offline/database" {
  72089. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72090. /**
  72091. * Class used to enable access to IndexedDB
  72092. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72093. */
  72094. export class Database implements IOfflineProvider {
  72095. private _callbackManifestChecked;
  72096. private _currentSceneUrl;
  72097. private _db;
  72098. private _enableSceneOffline;
  72099. private _enableTexturesOffline;
  72100. private _manifestVersionFound;
  72101. private _mustUpdateRessources;
  72102. private _hasReachedQuota;
  72103. private _isSupported;
  72104. private _idbFactory;
  72105. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72106. private static IsUASupportingBlobStorage;
  72107. /**
  72108. * Gets a boolean indicating if Database storate is enabled (off by default)
  72109. */
  72110. static IDBStorageEnabled: boolean;
  72111. /**
  72112. * Gets a boolean indicating if scene must be saved in the database
  72113. */
  72114. get enableSceneOffline(): boolean;
  72115. /**
  72116. * Gets a boolean indicating if textures must be saved in the database
  72117. */
  72118. get enableTexturesOffline(): boolean;
  72119. /**
  72120. * Creates a new Database
  72121. * @param urlToScene defines the url to load the scene
  72122. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72123. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72124. */
  72125. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72126. private static _ParseURL;
  72127. private static _ReturnFullUrlLocation;
  72128. private _checkManifestFile;
  72129. /**
  72130. * Open the database and make it available
  72131. * @param successCallback defines the callback to call on success
  72132. * @param errorCallback defines the callback to call on error
  72133. */
  72134. open(successCallback: () => void, errorCallback: () => void): void;
  72135. /**
  72136. * Loads an image from the database
  72137. * @param url defines the url to load from
  72138. * @param image defines the target DOM image
  72139. */
  72140. loadImage(url: string, image: HTMLImageElement): void;
  72141. private _loadImageFromDBAsync;
  72142. private _saveImageIntoDBAsync;
  72143. private _checkVersionFromDB;
  72144. private _loadVersionFromDBAsync;
  72145. private _saveVersionIntoDBAsync;
  72146. /**
  72147. * Loads a file from database
  72148. * @param url defines the URL to load from
  72149. * @param sceneLoaded defines a callback to call on success
  72150. * @param progressCallBack defines a callback to call when progress changed
  72151. * @param errorCallback defines a callback to call on error
  72152. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72153. */
  72154. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72155. private _loadFileAsync;
  72156. private _saveFileAsync;
  72157. /**
  72158. * Validates if xhr data is correct
  72159. * @param xhr defines the request to validate
  72160. * @param dataType defines the expected data type
  72161. * @returns true if data is correct
  72162. */
  72163. private static _ValidateXHRData;
  72164. }
  72165. }
  72166. declare module "babylonjs/Offline/index" {
  72167. export * from "babylonjs/Offline/database";
  72168. export * from "babylonjs/Offline/IOfflineProvider";
  72169. }
  72170. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72171. /** @hidden */
  72172. export var gpuUpdateParticlesPixelShader: {
  72173. name: string;
  72174. shader: string;
  72175. };
  72176. }
  72177. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72178. /** @hidden */
  72179. export var gpuUpdateParticlesVertexShader: {
  72180. name: string;
  72181. shader: string;
  72182. };
  72183. }
  72184. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72185. /** @hidden */
  72186. export var clipPlaneFragmentDeclaration2: {
  72187. name: string;
  72188. shader: string;
  72189. };
  72190. }
  72191. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72192. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72193. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72194. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72195. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72196. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72197. /** @hidden */
  72198. export var gpuRenderParticlesPixelShader: {
  72199. name: string;
  72200. shader: string;
  72201. };
  72202. }
  72203. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72204. /** @hidden */
  72205. export var clipPlaneVertexDeclaration2: {
  72206. name: string;
  72207. shader: string;
  72208. };
  72209. }
  72210. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72211. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72212. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72213. /** @hidden */
  72214. export var gpuRenderParticlesVertexShader: {
  72215. name: string;
  72216. shader: string;
  72217. };
  72218. }
  72219. declare module "babylonjs/Particles/gpuParticleSystem" {
  72220. import { Nullable } from "babylonjs/types";
  72221. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72222. import { Observable } from "babylonjs/Misc/observable";
  72223. import { Matrix } from "babylonjs/Maths/math.vector";
  72224. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72225. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72226. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72227. import { IDisposable } from "babylonjs/scene";
  72228. import { Effect } from "babylonjs/Materials/effect";
  72229. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72230. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72231. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72232. import { Scene } from "babylonjs/scene";
  72233. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72234. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72235. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72236. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72237. /**
  72238. * This represents a GPU particle system in Babylon
  72239. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72240. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72241. */
  72242. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72243. /**
  72244. * The layer mask we are rendering the particles through.
  72245. */
  72246. layerMask: number;
  72247. private _capacity;
  72248. private _activeCount;
  72249. private _currentActiveCount;
  72250. private _accumulatedCount;
  72251. private _renderEffect;
  72252. private _updateEffect;
  72253. private _buffer0;
  72254. private _buffer1;
  72255. private _spriteBuffer;
  72256. private _updateVAO;
  72257. private _renderVAO;
  72258. private _targetIndex;
  72259. private _sourceBuffer;
  72260. private _targetBuffer;
  72261. private _currentRenderId;
  72262. private _started;
  72263. private _stopped;
  72264. private _timeDelta;
  72265. private _randomTexture;
  72266. private _randomTexture2;
  72267. private _attributesStrideSize;
  72268. private _updateEffectOptions;
  72269. private _randomTextureSize;
  72270. private _actualFrame;
  72271. private _customEffect;
  72272. private readonly _rawTextureWidth;
  72273. /**
  72274. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72275. */
  72276. static get IsSupported(): boolean;
  72277. /**
  72278. * An event triggered when the system is disposed.
  72279. */
  72280. onDisposeObservable: Observable<IParticleSystem>;
  72281. /**
  72282. * An event triggered when the system is stopped
  72283. */
  72284. onStoppedObservable: Observable<IParticleSystem>;
  72285. /**
  72286. * Gets the maximum number of particles active at the same time.
  72287. * @returns The max number of active particles.
  72288. */
  72289. getCapacity(): number;
  72290. /**
  72291. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72292. * to override the particles.
  72293. */
  72294. forceDepthWrite: boolean;
  72295. /**
  72296. * Gets or set the number of active particles
  72297. */
  72298. get activeParticleCount(): number;
  72299. set activeParticleCount(value: number);
  72300. private _preWarmDone;
  72301. /**
  72302. * Specifies if the particles are updated in emitter local space or world space.
  72303. */
  72304. isLocal: boolean;
  72305. /** Gets or sets a matrix to use to compute projection */
  72306. defaultProjectionMatrix: Matrix;
  72307. /**
  72308. * Is this system ready to be used/rendered
  72309. * @return true if the system is ready
  72310. */
  72311. isReady(): boolean;
  72312. /**
  72313. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72314. * @returns True if it has been started, otherwise false.
  72315. */
  72316. isStarted(): boolean;
  72317. /**
  72318. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72319. * @returns True if it has been stopped, otherwise false.
  72320. */
  72321. isStopped(): boolean;
  72322. /**
  72323. * Gets a boolean indicating that the system is stopping
  72324. * @returns true if the system is currently stopping
  72325. */
  72326. isStopping(): boolean;
  72327. /**
  72328. * Gets the number of particles active at the same time.
  72329. * @returns The number of active particles.
  72330. */
  72331. getActiveCount(): number;
  72332. /**
  72333. * Starts the particle system and begins to emit
  72334. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72335. */
  72336. start(delay?: number): void;
  72337. /**
  72338. * Stops the particle system.
  72339. */
  72340. stop(): void;
  72341. /**
  72342. * Remove all active particles
  72343. */
  72344. reset(): void;
  72345. /**
  72346. * Returns the string "GPUParticleSystem"
  72347. * @returns a string containing the class name
  72348. */
  72349. getClassName(): string;
  72350. /**
  72351. * Gets the custom effect used to render the particles
  72352. * @param blendMode Blend mode for which the effect should be retrieved
  72353. * @returns The effect
  72354. */
  72355. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72356. /**
  72357. * Sets the custom effect used to render the particles
  72358. * @param effect The effect to set
  72359. * @param blendMode Blend mode for which the effect should be set
  72360. */
  72361. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72362. /** @hidden */
  72363. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72364. /**
  72365. * Observable that will be called just before the particles are drawn
  72366. */
  72367. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72368. /**
  72369. * Gets the name of the particle vertex shader
  72370. */
  72371. get vertexShaderName(): string;
  72372. private _colorGradientsTexture;
  72373. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72374. /**
  72375. * Adds a new color gradient
  72376. * @param gradient defines the gradient to use (between 0 and 1)
  72377. * @param color1 defines the color to affect to the specified gradient
  72378. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72379. * @returns the current particle system
  72380. */
  72381. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72382. private _refreshColorGradient;
  72383. /** Force the system to rebuild all gradients that need to be resync */
  72384. forceRefreshGradients(): void;
  72385. /**
  72386. * Remove a specific color gradient
  72387. * @param gradient defines the gradient to remove
  72388. * @returns the current particle system
  72389. */
  72390. removeColorGradient(gradient: number): GPUParticleSystem;
  72391. private _angularSpeedGradientsTexture;
  72392. private _sizeGradientsTexture;
  72393. private _velocityGradientsTexture;
  72394. private _limitVelocityGradientsTexture;
  72395. private _dragGradientsTexture;
  72396. private _addFactorGradient;
  72397. /**
  72398. * Adds a new size gradient
  72399. * @param gradient defines the gradient to use (between 0 and 1)
  72400. * @param factor defines the size factor to affect to the specified gradient
  72401. * @returns the current particle system
  72402. */
  72403. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72404. /**
  72405. * Remove a specific size gradient
  72406. * @param gradient defines the gradient to remove
  72407. * @returns the current particle system
  72408. */
  72409. removeSizeGradient(gradient: number): GPUParticleSystem;
  72410. private _refreshFactorGradient;
  72411. /**
  72412. * Adds a new angular speed gradient
  72413. * @param gradient defines the gradient to use (between 0 and 1)
  72414. * @param factor defines the angular speed to affect to the specified gradient
  72415. * @returns the current particle system
  72416. */
  72417. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72418. /**
  72419. * Remove a specific angular speed gradient
  72420. * @param gradient defines the gradient to remove
  72421. * @returns the current particle system
  72422. */
  72423. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72424. /**
  72425. * Adds a new velocity gradient
  72426. * @param gradient defines the gradient to use (between 0 and 1)
  72427. * @param factor defines the velocity to affect to the specified gradient
  72428. * @returns the current particle system
  72429. */
  72430. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72431. /**
  72432. * Remove a specific velocity gradient
  72433. * @param gradient defines the gradient to remove
  72434. * @returns the current particle system
  72435. */
  72436. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72437. /**
  72438. * Adds a new limit velocity gradient
  72439. * @param gradient defines the gradient to use (between 0 and 1)
  72440. * @param factor defines the limit velocity value to affect to the specified gradient
  72441. * @returns the current particle system
  72442. */
  72443. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72444. /**
  72445. * Remove a specific limit velocity gradient
  72446. * @param gradient defines the gradient to remove
  72447. * @returns the current particle system
  72448. */
  72449. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72450. /**
  72451. * Adds a new drag gradient
  72452. * @param gradient defines the gradient to use (between 0 and 1)
  72453. * @param factor defines the drag value to affect to the specified gradient
  72454. * @returns the current particle system
  72455. */
  72456. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72457. /**
  72458. * Remove a specific drag gradient
  72459. * @param gradient defines the gradient to remove
  72460. * @returns the current particle system
  72461. */
  72462. removeDragGradient(gradient: number): GPUParticleSystem;
  72463. /**
  72464. * Not supported by GPUParticleSystem
  72465. * @param gradient defines the gradient to use (between 0 and 1)
  72466. * @param factor defines the emit rate value to affect to the specified gradient
  72467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72468. * @returns the current particle system
  72469. */
  72470. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72471. /**
  72472. * Not supported by GPUParticleSystem
  72473. * @param gradient defines the gradient to remove
  72474. * @returns the current particle system
  72475. */
  72476. removeEmitRateGradient(gradient: number): IParticleSystem;
  72477. /**
  72478. * Not supported by GPUParticleSystem
  72479. * @param gradient defines the gradient to use (between 0 and 1)
  72480. * @param factor defines the start size value to affect to the specified gradient
  72481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72482. * @returns the current particle system
  72483. */
  72484. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72485. /**
  72486. * Not supported by GPUParticleSystem
  72487. * @param gradient defines the gradient to remove
  72488. * @returns the current particle system
  72489. */
  72490. removeStartSizeGradient(gradient: number): IParticleSystem;
  72491. /**
  72492. * Not supported by GPUParticleSystem
  72493. * @param gradient defines the gradient to use (between 0 and 1)
  72494. * @param min defines the color remap minimal range
  72495. * @param max defines the color remap maximal range
  72496. * @returns the current particle system
  72497. */
  72498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72499. /**
  72500. * Not supported by GPUParticleSystem
  72501. * @param gradient defines the gradient to remove
  72502. * @returns the current particle system
  72503. */
  72504. removeColorRemapGradient(): IParticleSystem;
  72505. /**
  72506. * Not supported by GPUParticleSystem
  72507. * @param gradient defines the gradient to use (between 0 and 1)
  72508. * @param min defines the alpha remap minimal range
  72509. * @param max defines the alpha remap maximal range
  72510. * @returns the current particle system
  72511. */
  72512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72513. /**
  72514. * Not supported by GPUParticleSystem
  72515. * @param gradient defines the gradient to remove
  72516. * @returns the current particle system
  72517. */
  72518. removeAlphaRemapGradient(): IParticleSystem;
  72519. /**
  72520. * Not supported by GPUParticleSystem
  72521. * @param gradient defines the gradient to use (between 0 and 1)
  72522. * @param color defines the color to affect to the specified gradient
  72523. * @returns the current particle system
  72524. */
  72525. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72526. /**
  72527. * Not supported by GPUParticleSystem
  72528. * @param gradient defines the gradient to remove
  72529. * @returns the current particle system
  72530. */
  72531. removeRampGradient(): IParticleSystem;
  72532. /**
  72533. * Not supported by GPUParticleSystem
  72534. * @returns the list of ramp gradients
  72535. */
  72536. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72537. /**
  72538. * Not supported by GPUParticleSystem
  72539. * Gets or sets a boolean indicating that ramp gradients must be used
  72540. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72541. */
  72542. get useRampGradients(): boolean;
  72543. set useRampGradients(value: boolean);
  72544. /**
  72545. * Not supported by GPUParticleSystem
  72546. * @param gradient defines the gradient to use (between 0 and 1)
  72547. * @param factor defines the life time factor to affect to the specified gradient
  72548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72549. * @returns the current particle system
  72550. */
  72551. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72552. /**
  72553. * Not supported by GPUParticleSystem
  72554. * @param gradient defines the gradient to remove
  72555. * @returns the current particle system
  72556. */
  72557. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72558. /**
  72559. * Instantiates a GPU particle system.
  72560. * 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.
  72561. * @param name The name of the particle system
  72562. * @param options The options used to create the system
  72563. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72564. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72565. * @param customEffect a custom effect used to change the way particles are rendered by default
  72566. */
  72567. constructor(name: string, options: Partial<{
  72568. capacity: number;
  72569. randomTextureSize: number;
  72570. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72571. protected _reset(): void;
  72572. private _createUpdateVAO;
  72573. private _createRenderVAO;
  72574. private _initialize;
  72575. /** @hidden */
  72576. _recreateUpdateEffect(): void;
  72577. private _getEffect;
  72578. /**
  72579. * Fill the defines array according to the current settings of the particle system
  72580. * @param defines Array to be updated
  72581. * @param blendMode blend mode to take into account when updating the array
  72582. */
  72583. fillDefines(defines: Array<string>, blendMode?: number): void;
  72584. /**
  72585. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72586. * @param uniforms Uniforms array to fill
  72587. * @param attributes Attributes array to fill
  72588. * @param samplers Samplers array to fill
  72589. */
  72590. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72591. /** @hidden */
  72592. _recreateRenderEffect(): Effect;
  72593. /**
  72594. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72595. * @param preWarm defines if we are in the pre-warmimg phase
  72596. */
  72597. animate(preWarm?: boolean): void;
  72598. private _createFactorGradientTexture;
  72599. private _createSizeGradientTexture;
  72600. private _createAngularSpeedGradientTexture;
  72601. private _createVelocityGradientTexture;
  72602. private _createLimitVelocityGradientTexture;
  72603. private _createDragGradientTexture;
  72604. private _createColorGradientTexture;
  72605. /**
  72606. * Renders the particle system in its current state
  72607. * @param preWarm defines if the system should only update the particles but not render them
  72608. * @returns the current number of particles
  72609. */
  72610. render(preWarm?: boolean): number;
  72611. /**
  72612. * Rebuilds the particle system
  72613. */
  72614. rebuild(): void;
  72615. private _releaseBuffers;
  72616. private _releaseVAOs;
  72617. /**
  72618. * Disposes the particle system and free the associated resources
  72619. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72620. */
  72621. dispose(disposeTexture?: boolean): void;
  72622. /**
  72623. * Clones the particle system.
  72624. * @param name The name of the cloned object
  72625. * @param newEmitter The new emitter to use
  72626. * @returns the cloned particle system
  72627. */
  72628. clone(name: string, newEmitter: any): GPUParticleSystem;
  72629. /**
  72630. * Serializes the particle system to a JSON object
  72631. * @param serializeTexture defines if the texture must be serialized as well
  72632. * @returns the JSON object
  72633. */
  72634. serialize(serializeTexture?: boolean): any;
  72635. /**
  72636. * Parses a JSON object to create a GPU particle system.
  72637. * @param parsedParticleSystem The JSON object to parse
  72638. * @param sceneOrEngine The scene or the engine to create the particle system in
  72639. * @param rootUrl The root url to use to load external dependencies like texture
  72640. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72641. * @returns the parsed GPU particle system
  72642. */
  72643. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72644. }
  72645. }
  72646. declare module "babylonjs/Particles/particleSystemSet" {
  72647. import { Nullable } from "babylonjs/types";
  72648. import { Color3 } from "babylonjs/Maths/math.color";
  72649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72652. import { Scene, IDisposable } from "babylonjs/scene";
  72653. /**
  72654. * Represents a set of particle systems working together to create a specific effect
  72655. */
  72656. export class ParticleSystemSet implements IDisposable {
  72657. /**
  72658. * Gets or sets base Assets URL
  72659. */
  72660. static BaseAssetsUrl: string;
  72661. private _emitterCreationOptions;
  72662. private _emitterNode;
  72663. /**
  72664. * Gets the particle system list
  72665. */
  72666. systems: IParticleSystem[];
  72667. /**
  72668. * Gets the emitter node used with this set
  72669. */
  72670. get emitterNode(): Nullable<TransformNode>;
  72671. /**
  72672. * Creates a new emitter mesh as a sphere
  72673. * @param options defines the options used to create the sphere
  72674. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72675. * @param scene defines the hosting scene
  72676. */
  72677. setEmitterAsSphere(options: {
  72678. diameter: number;
  72679. segments: number;
  72680. color: Color3;
  72681. }, renderingGroupId: number, scene: Scene): void;
  72682. /**
  72683. * Starts all particle systems of the set
  72684. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72685. */
  72686. start(emitter?: AbstractMesh): void;
  72687. /**
  72688. * Release all associated resources
  72689. */
  72690. dispose(): void;
  72691. /**
  72692. * Serialize the set into a JSON compatible object
  72693. * @param serializeTexture defines if the texture must be serialized as well
  72694. * @returns a JSON compatible representation of the set
  72695. */
  72696. serialize(serializeTexture?: boolean): any;
  72697. /**
  72698. * Parse a new ParticleSystemSet from a serialized source
  72699. * @param data defines a JSON compatible representation of the set
  72700. * @param scene defines the hosting scene
  72701. * @param gpu defines if we want GPU particles or CPU particles
  72702. * @returns a new ParticleSystemSet
  72703. */
  72704. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72705. }
  72706. }
  72707. declare module "babylonjs/Particles/particleHelper" {
  72708. import { Nullable } from "babylonjs/types";
  72709. import { Scene } from "babylonjs/scene";
  72710. import { Vector3 } from "babylonjs/Maths/math.vector";
  72711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72712. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72713. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72714. /**
  72715. * This class is made for on one-liner static method to help creating particle system set.
  72716. */
  72717. export class ParticleHelper {
  72718. /**
  72719. * Gets or sets base Assets URL
  72720. */
  72721. static BaseAssetsUrl: string;
  72722. /** Define the Url to load snippets */
  72723. static SnippetUrl: string;
  72724. /**
  72725. * Create a default particle system that you can tweak
  72726. * @param emitter defines the emitter to use
  72727. * @param capacity defines the system capacity (default is 500 particles)
  72728. * @param scene defines the hosting scene
  72729. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72730. * @returns the new Particle system
  72731. */
  72732. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72733. /**
  72734. * This is the main static method (one-liner) of this helper to create different particle systems
  72735. * @param type This string represents the type to the particle system to create
  72736. * @param scene The scene where the particle system should live
  72737. * @param gpu If the system will use gpu
  72738. * @returns the ParticleSystemSet created
  72739. */
  72740. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72741. /**
  72742. * Static function used to export a particle system to a ParticleSystemSet variable.
  72743. * Please note that the emitter shape is not exported
  72744. * @param systems defines the particle systems to export
  72745. * @returns the created particle system set
  72746. */
  72747. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72748. /**
  72749. * Creates a particle system from a snippet saved in a remote file
  72750. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72751. * @param url defines the url to load from
  72752. * @param scene defines the hosting scene
  72753. * @param gpu If the system will use gpu
  72754. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72755. * @returns a promise that will resolve to the new particle system
  72756. */
  72757. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72758. /**
  72759. * Creates a particle system from a snippet saved by the particle system editor
  72760. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72761. * @param scene defines the hosting scene
  72762. * @param gpu If the system will use gpu
  72763. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72764. * @returns a promise that will resolve to the new particle system
  72765. */
  72766. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72767. }
  72768. }
  72769. declare module "babylonjs/Particles/particleSystemComponent" {
  72770. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72771. import { Effect } from "babylonjs/Materials/effect";
  72772. import "babylonjs/Shaders/particles.vertex";
  72773. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72774. module "babylonjs/Engines/engine" {
  72775. interface Engine {
  72776. /**
  72777. * Create an effect to use with particle systems.
  72778. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72779. * the particle system for which you want to create a custom effect in the last parameter
  72780. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72781. * @param uniformsNames defines a list of attribute names
  72782. * @param samplers defines an array of string used to represent textures
  72783. * @param defines defines the string containing the defines to use to compile the shaders
  72784. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72785. * @param onCompiled defines a function to call when the effect creation is successful
  72786. * @param onError defines a function to call when the effect creation has failed
  72787. * @param particleSystem the particle system you want to create the effect for
  72788. * @returns the new Effect
  72789. */
  72790. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72791. }
  72792. }
  72793. module "babylonjs/Meshes/mesh" {
  72794. interface Mesh {
  72795. /**
  72796. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72797. * @returns an array of IParticleSystem
  72798. */
  72799. getEmittedParticleSystems(): IParticleSystem[];
  72800. /**
  72801. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72802. * @returns an array of IParticleSystem
  72803. */
  72804. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72805. }
  72806. }
  72807. }
  72808. declare module "babylonjs/Particles/pointsCloudSystem" {
  72809. import { Color4 } from "babylonjs/Maths/math";
  72810. import { Mesh } from "babylonjs/Meshes/mesh";
  72811. import { Scene, IDisposable } from "babylonjs/scene";
  72812. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72813. /** Defines the 4 color options */
  72814. export enum PointColor {
  72815. /** color value */
  72816. Color = 2,
  72817. /** uv value */
  72818. UV = 1,
  72819. /** random value */
  72820. Random = 0,
  72821. /** stated value */
  72822. Stated = 3
  72823. }
  72824. /**
  72825. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72826. * 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.
  72827. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72828. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72829. *
  72830. * Full documentation here : TO BE ENTERED
  72831. */
  72832. export class PointsCloudSystem implements IDisposable {
  72833. /**
  72834. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72835. * Example : var p = SPS.particles[i];
  72836. */
  72837. particles: CloudPoint[];
  72838. /**
  72839. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72840. */
  72841. nbParticles: number;
  72842. /**
  72843. * This a counter for your own usage. It's not set by any SPS functions.
  72844. */
  72845. counter: number;
  72846. /**
  72847. * The PCS name. This name is also given to the underlying mesh.
  72848. */
  72849. name: string;
  72850. /**
  72851. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72852. */
  72853. mesh: Mesh;
  72854. /**
  72855. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72856. * Please read :
  72857. */
  72858. vars: any;
  72859. /**
  72860. * @hidden
  72861. */
  72862. _size: number;
  72863. private _scene;
  72864. private _promises;
  72865. private _positions;
  72866. private _indices;
  72867. private _normals;
  72868. private _colors;
  72869. private _uvs;
  72870. private _indices32;
  72871. private _positions32;
  72872. private _colors32;
  72873. private _uvs32;
  72874. private _updatable;
  72875. private _isVisibilityBoxLocked;
  72876. private _alwaysVisible;
  72877. private _groups;
  72878. private _groupCounter;
  72879. private _computeParticleColor;
  72880. private _computeParticleTexture;
  72881. private _computeParticleRotation;
  72882. private _computeBoundingBox;
  72883. private _isReady;
  72884. /**
  72885. * Creates a PCS (Points Cloud System) object
  72886. * @param name (String) is the PCS name, this will be the underlying mesh name
  72887. * @param pointSize (number) is the size for each point
  72888. * @param scene (Scene) is the scene in which the PCS is added
  72889. * @param options defines the options of the PCS e.g.
  72890. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72891. */
  72892. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72893. updatable?: boolean;
  72894. });
  72895. /**
  72896. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72897. * If no points were added to the PCS, the returned mesh is just a single point.
  72898. * @returns a promise for the created mesh
  72899. */
  72900. buildMeshAsync(): Promise<Mesh>;
  72901. /**
  72902. * @hidden
  72903. */
  72904. private _buildMesh;
  72905. private _addParticle;
  72906. private _randomUnitVector;
  72907. private _getColorIndicesForCoord;
  72908. private _setPointsColorOrUV;
  72909. private _colorFromTexture;
  72910. private _calculateDensity;
  72911. /**
  72912. * Adds points to the PCS in random positions within a unit sphere
  72913. * @param nb (positive integer) the number of particles to be created from this model
  72914. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72915. * @returns the number of groups in the system
  72916. */
  72917. addPoints(nb: number, pointFunction?: any): number;
  72918. /**
  72919. * Adds points to the PCS from the surface of the model shape
  72920. * @param mesh is any Mesh object that will be used as a surface model for the points
  72921. * @param nb (positive integer) the number of particles to be created from this model
  72922. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72923. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72924. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72925. * @returns the number of groups in the system
  72926. */
  72927. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72928. /**
  72929. * Adds points to the PCS inside the model shape
  72930. * @param mesh is any Mesh object that will be used as a surface model for the points
  72931. * @param nb (positive integer) the number of particles to be created from this model
  72932. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72933. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72934. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72935. * @returns the number of groups in the system
  72936. */
  72937. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72938. /**
  72939. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72940. * This method calls `updateParticle()` for each particle of the SPS.
  72941. * For an animated SPS, it is usually called within the render loop.
  72942. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72943. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72944. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72945. * @returns the PCS.
  72946. */
  72947. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72948. /**
  72949. * Disposes the PCS.
  72950. */
  72951. dispose(): void;
  72952. /**
  72953. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72954. * doc :
  72955. * @returns the PCS.
  72956. */
  72957. refreshVisibleSize(): PointsCloudSystem;
  72958. /**
  72959. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72960. * @param size the size (float) of the visibility box
  72961. * note : this doesn't lock the PCS mesh bounding box.
  72962. * doc :
  72963. */
  72964. setVisibilityBox(size: number): void;
  72965. /**
  72966. * Gets whether the PCS is always visible or not
  72967. * doc :
  72968. */
  72969. get isAlwaysVisible(): boolean;
  72970. /**
  72971. * Sets the PCS as always visible or not
  72972. * doc :
  72973. */
  72974. set isAlwaysVisible(val: boolean);
  72975. /**
  72976. * Tells to `setParticles()` to compute the particle rotations or not
  72977. * Default value : false. The PCS is faster when it's set to false
  72978. * Note : particle rotations are only applied to parent particles
  72979. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72980. */
  72981. set computeParticleRotation(val: boolean);
  72982. /**
  72983. * Tells to `setParticles()` to compute the particle colors or not.
  72984. * Default value : true. The PCS is faster when it's set to false.
  72985. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72986. */
  72987. set computeParticleColor(val: boolean);
  72988. set computeParticleTexture(val: boolean);
  72989. /**
  72990. * Gets if `setParticles()` computes the particle colors or not.
  72991. * Default value : false. The PCS is faster when it's set to false.
  72992. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72993. */
  72994. get computeParticleColor(): boolean;
  72995. /**
  72996. * Gets if `setParticles()` computes the particle textures or not.
  72997. * Default value : false. The PCS is faster when it's set to false.
  72998. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72999. */
  73000. get computeParticleTexture(): boolean;
  73001. /**
  73002. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73003. */
  73004. set computeBoundingBox(val: boolean);
  73005. /**
  73006. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73007. */
  73008. get computeBoundingBox(): boolean;
  73009. /**
  73010. * This function does nothing. It may be overwritten to set all the particle first values.
  73011. * The PCS doesn't call this function, you may have to call it by your own.
  73012. * doc :
  73013. */
  73014. initParticles(): void;
  73015. /**
  73016. * This function does nothing. It may be overwritten to recycle a particle
  73017. * The PCS doesn't call this function, you can to call it
  73018. * doc :
  73019. * @param particle The particle to recycle
  73020. * @returns the recycled particle
  73021. */
  73022. recycleParticle(particle: CloudPoint): CloudPoint;
  73023. /**
  73024. * Updates a particle : this function should be overwritten by the user.
  73025. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73026. * doc :
  73027. * @example : just set a particle position or velocity and recycle conditions
  73028. * @param particle The particle to update
  73029. * @returns the updated particle
  73030. */
  73031. updateParticle(particle: CloudPoint): CloudPoint;
  73032. /**
  73033. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73034. * This does nothing and may be overwritten by the user.
  73035. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73036. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73037. * @param update the boolean update value actually passed to setParticles()
  73038. */
  73039. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73040. /**
  73041. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73042. * This will be passed three parameters.
  73043. * This does nothing and may be overwritten by the user.
  73044. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73045. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73046. * @param update the boolean update value actually passed to setParticles()
  73047. */
  73048. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73049. }
  73050. }
  73051. declare module "babylonjs/Particles/cloudPoint" {
  73052. import { Nullable } from "babylonjs/types";
  73053. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73054. import { Mesh } from "babylonjs/Meshes/mesh";
  73055. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73056. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73057. /**
  73058. * Represents one particle of a points cloud system.
  73059. */
  73060. export class CloudPoint {
  73061. /**
  73062. * particle global index
  73063. */
  73064. idx: number;
  73065. /**
  73066. * The color of the particle
  73067. */
  73068. color: Nullable<Color4>;
  73069. /**
  73070. * The world space position of the particle.
  73071. */
  73072. position: Vector3;
  73073. /**
  73074. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73075. */
  73076. rotation: Vector3;
  73077. /**
  73078. * The world space rotation quaternion of the particle.
  73079. */
  73080. rotationQuaternion: Nullable<Quaternion>;
  73081. /**
  73082. * The uv of the particle.
  73083. */
  73084. uv: Nullable<Vector2>;
  73085. /**
  73086. * The current speed of the particle.
  73087. */
  73088. velocity: Vector3;
  73089. /**
  73090. * The pivot point in the particle local space.
  73091. */
  73092. pivot: Vector3;
  73093. /**
  73094. * Must the particle be translated from its pivot point in its local space ?
  73095. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73096. * Default : false
  73097. */
  73098. translateFromPivot: boolean;
  73099. /**
  73100. * Index of this particle in the global "positions" array (Internal use)
  73101. * @hidden
  73102. */
  73103. _pos: number;
  73104. /**
  73105. * @hidden Index of this particle in the global "indices" array (Internal use)
  73106. */
  73107. _ind: number;
  73108. /**
  73109. * Group this particle belongs to
  73110. */
  73111. _group: PointsGroup;
  73112. /**
  73113. * Group id of this particle
  73114. */
  73115. groupId: number;
  73116. /**
  73117. * Index of the particle in its group id (Internal use)
  73118. */
  73119. idxInGroup: number;
  73120. /**
  73121. * @hidden Particle BoundingInfo object (Internal use)
  73122. */
  73123. _boundingInfo: BoundingInfo;
  73124. /**
  73125. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73126. */
  73127. _pcs: PointsCloudSystem;
  73128. /**
  73129. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73130. */
  73131. _stillInvisible: boolean;
  73132. /**
  73133. * @hidden Last computed particle rotation matrix
  73134. */
  73135. _rotationMatrix: number[];
  73136. /**
  73137. * Parent particle Id, if any.
  73138. * Default null.
  73139. */
  73140. parentId: Nullable<number>;
  73141. /**
  73142. * @hidden Internal global position in the PCS.
  73143. */
  73144. _globalPosition: Vector3;
  73145. /**
  73146. * Creates a Point Cloud object.
  73147. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73148. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73149. * @param group (PointsGroup) is the group the particle belongs to
  73150. * @param groupId (integer) is the group identifier in the PCS.
  73151. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73152. * @param pcs defines the PCS it is associated to
  73153. */
  73154. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73155. /**
  73156. * get point size
  73157. */
  73158. get size(): Vector3;
  73159. /**
  73160. * Set point size
  73161. */
  73162. set size(scale: Vector3);
  73163. /**
  73164. * Legacy support, changed quaternion to rotationQuaternion
  73165. */
  73166. get quaternion(): Nullable<Quaternion>;
  73167. /**
  73168. * Legacy support, changed quaternion to rotationQuaternion
  73169. */
  73170. set quaternion(q: Nullable<Quaternion>);
  73171. /**
  73172. * Returns a boolean. True if the particle intersects a mesh, else false
  73173. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73174. * @param target is the object (point or mesh) what the intersection is computed against
  73175. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73176. * @returns true if it intersects
  73177. */
  73178. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73179. /**
  73180. * get the rotation matrix of the particle
  73181. * @hidden
  73182. */
  73183. getRotationMatrix(m: Matrix): void;
  73184. }
  73185. /**
  73186. * Represents a group of points in a points cloud system
  73187. * * PCS internal tool, don't use it manually.
  73188. */
  73189. export class PointsGroup {
  73190. /**
  73191. * The group id
  73192. * @hidden
  73193. */
  73194. groupID: number;
  73195. /**
  73196. * image data for group (internal use)
  73197. * @hidden
  73198. */
  73199. _groupImageData: Nullable<ArrayBufferView>;
  73200. /**
  73201. * Image Width (internal use)
  73202. * @hidden
  73203. */
  73204. _groupImgWidth: number;
  73205. /**
  73206. * Image Height (internal use)
  73207. * @hidden
  73208. */
  73209. _groupImgHeight: number;
  73210. /**
  73211. * Custom position function (internal use)
  73212. * @hidden
  73213. */
  73214. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73215. /**
  73216. * density per facet for surface points
  73217. * @hidden
  73218. */
  73219. _groupDensity: number[];
  73220. /**
  73221. * Only when points are colored by texture carries pointer to texture list array
  73222. * @hidden
  73223. */
  73224. _textureNb: number;
  73225. /**
  73226. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73227. * PCS internal tool, don't use it manually.
  73228. * @hidden
  73229. */
  73230. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73231. }
  73232. }
  73233. declare module "babylonjs/Particles/index" {
  73234. export * from "babylonjs/Particles/baseParticleSystem";
  73235. export * from "babylonjs/Particles/EmitterTypes/index";
  73236. export * from "babylonjs/Particles/gpuParticleSystem";
  73237. export * from "babylonjs/Particles/IParticleSystem";
  73238. export * from "babylonjs/Particles/particle";
  73239. export * from "babylonjs/Particles/particleHelper";
  73240. export * from "babylonjs/Particles/particleSystem";
  73241. import "babylonjs/Particles/particleSystemComponent";
  73242. export * from "babylonjs/Particles/particleSystemComponent";
  73243. export * from "babylonjs/Particles/particleSystemSet";
  73244. export * from "babylonjs/Particles/solidParticle";
  73245. export * from "babylonjs/Particles/solidParticleSystem";
  73246. export * from "babylonjs/Particles/cloudPoint";
  73247. export * from "babylonjs/Particles/pointsCloudSystem";
  73248. export * from "babylonjs/Particles/subEmitter";
  73249. }
  73250. declare module "babylonjs/Physics/physicsEngineComponent" {
  73251. import { Nullable } from "babylonjs/types";
  73252. import { Observable, Observer } from "babylonjs/Misc/observable";
  73253. import { Vector3 } from "babylonjs/Maths/math.vector";
  73254. import { Mesh } from "babylonjs/Meshes/mesh";
  73255. import { ISceneComponent } from "babylonjs/sceneComponent";
  73256. import { Scene } from "babylonjs/scene";
  73257. import { Node } from "babylonjs/node";
  73258. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73259. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73260. module "babylonjs/scene" {
  73261. interface Scene {
  73262. /** @hidden (Backing field) */
  73263. _physicsEngine: Nullable<IPhysicsEngine>;
  73264. /** @hidden */
  73265. _physicsTimeAccumulator: number;
  73266. /**
  73267. * Gets the current physics engine
  73268. * @returns a IPhysicsEngine or null if none attached
  73269. */
  73270. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73271. /**
  73272. * Enables physics to the current scene
  73273. * @param gravity defines the scene's gravity for the physics engine
  73274. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73275. * @return a boolean indicating if the physics engine was initialized
  73276. */
  73277. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73278. /**
  73279. * Disables and disposes the physics engine associated with the scene
  73280. */
  73281. disablePhysicsEngine(): void;
  73282. /**
  73283. * Gets a boolean indicating if there is an active physics engine
  73284. * @returns a boolean indicating if there is an active physics engine
  73285. */
  73286. isPhysicsEnabled(): boolean;
  73287. /**
  73288. * Deletes a physics compound impostor
  73289. * @param compound defines the compound to delete
  73290. */
  73291. deleteCompoundImpostor(compound: any): void;
  73292. /**
  73293. * An event triggered when physic simulation is about to be run
  73294. */
  73295. onBeforePhysicsObservable: Observable<Scene>;
  73296. /**
  73297. * An event triggered when physic simulation has been done
  73298. */
  73299. onAfterPhysicsObservable: Observable<Scene>;
  73300. }
  73301. }
  73302. module "babylonjs/Meshes/abstractMesh" {
  73303. interface AbstractMesh {
  73304. /** @hidden */
  73305. _physicsImpostor: Nullable<PhysicsImpostor>;
  73306. /**
  73307. * Gets or sets impostor used for physic simulation
  73308. * @see https://doc.babylonjs.com/features/physics_engine
  73309. */
  73310. physicsImpostor: Nullable<PhysicsImpostor>;
  73311. /**
  73312. * Gets the current physics impostor
  73313. * @see https://doc.babylonjs.com/features/physics_engine
  73314. * @returns a physics impostor or null
  73315. */
  73316. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73317. /** Apply a physic impulse to the mesh
  73318. * @param force defines the force to apply
  73319. * @param contactPoint defines where to apply the force
  73320. * @returns the current mesh
  73321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73322. */
  73323. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73324. /**
  73325. * Creates a physic joint between two meshes
  73326. * @param otherMesh defines the other mesh to use
  73327. * @param pivot1 defines the pivot to use on this mesh
  73328. * @param pivot2 defines the pivot to use on the other mesh
  73329. * @param options defines additional options (can be plugin dependent)
  73330. * @returns the current mesh
  73331. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73332. */
  73333. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73334. /** @hidden */
  73335. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73336. }
  73337. }
  73338. /**
  73339. * Defines the physics engine scene component responsible to manage a physics engine
  73340. */
  73341. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73342. /**
  73343. * The component name helpful to identify the component in the list of scene components.
  73344. */
  73345. readonly name: string;
  73346. /**
  73347. * The scene the component belongs to.
  73348. */
  73349. scene: Scene;
  73350. /**
  73351. * Creates a new instance of the component for the given scene
  73352. * @param scene Defines the scene to register the component in
  73353. */
  73354. constructor(scene: Scene);
  73355. /**
  73356. * Registers the component in a given scene
  73357. */
  73358. register(): void;
  73359. /**
  73360. * Rebuilds the elements related to this component in case of
  73361. * context lost for instance.
  73362. */
  73363. rebuild(): void;
  73364. /**
  73365. * Disposes the component and the associated ressources
  73366. */
  73367. dispose(): void;
  73368. }
  73369. }
  73370. declare module "babylonjs/Physics/physicsHelper" {
  73371. import { Nullable } from "babylonjs/types";
  73372. import { Vector3 } from "babylonjs/Maths/math.vector";
  73373. import { Mesh } from "babylonjs/Meshes/mesh";
  73374. import { Scene } from "babylonjs/scene";
  73375. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73376. /**
  73377. * A helper for physics simulations
  73378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73379. */
  73380. export class PhysicsHelper {
  73381. private _scene;
  73382. private _physicsEngine;
  73383. /**
  73384. * Initializes the Physics helper
  73385. * @param scene Babylon.js scene
  73386. */
  73387. constructor(scene: Scene);
  73388. /**
  73389. * Applies a radial explosion impulse
  73390. * @param origin the origin of the explosion
  73391. * @param radiusOrEventOptions the radius or the options of radial explosion
  73392. * @param strength the explosion strength
  73393. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73394. * @returns A physics radial explosion event, or null
  73395. */
  73396. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73397. /**
  73398. * Applies a radial explosion force
  73399. * @param origin the origin of the explosion
  73400. * @param radiusOrEventOptions the radius or the options of radial explosion
  73401. * @param strength the explosion strength
  73402. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73403. * @returns A physics radial explosion event, or null
  73404. */
  73405. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73406. /**
  73407. * Creates a gravitational field
  73408. * @param origin the origin of the explosion
  73409. * @param radiusOrEventOptions the radius or the options of radial explosion
  73410. * @param strength the explosion strength
  73411. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73412. * @returns A physics gravitational field event, or null
  73413. */
  73414. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73415. /**
  73416. * Creates a physics updraft event
  73417. * @param origin the origin of the updraft
  73418. * @param radiusOrEventOptions the radius or the options of the updraft
  73419. * @param strength the strength of the updraft
  73420. * @param height the height of the updraft
  73421. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73422. * @returns A physics updraft event, or null
  73423. */
  73424. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73425. /**
  73426. * Creates a physics vortex event
  73427. * @param origin the of the vortex
  73428. * @param radiusOrEventOptions the radius or the options of the vortex
  73429. * @param strength the strength of the vortex
  73430. * @param height the height of the vortex
  73431. * @returns a Physics vortex event, or null
  73432. * A physics vortex event or null
  73433. */
  73434. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73435. }
  73436. /**
  73437. * Represents a physics radial explosion event
  73438. */
  73439. class PhysicsRadialExplosionEvent {
  73440. private _scene;
  73441. private _options;
  73442. private _sphere;
  73443. private _dataFetched;
  73444. /**
  73445. * Initializes a radial explosioin event
  73446. * @param _scene BabylonJS scene
  73447. * @param _options The options for the vortex event
  73448. */
  73449. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73450. /**
  73451. * Returns the data related to the radial explosion event (sphere).
  73452. * @returns The radial explosion event data
  73453. */
  73454. getData(): PhysicsRadialExplosionEventData;
  73455. /**
  73456. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73457. * @param impostor A physics imposter
  73458. * @param origin the origin of the explosion
  73459. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73460. */
  73461. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73462. /**
  73463. * Triggers affecterd impostors callbacks
  73464. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73465. */
  73466. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73467. /**
  73468. * Disposes the sphere.
  73469. * @param force Specifies if the sphere should be disposed by force
  73470. */
  73471. dispose(force?: boolean): void;
  73472. /*** Helpers ***/
  73473. private _prepareSphere;
  73474. private _intersectsWithSphere;
  73475. }
  73476. /**
  73477. * Represents a gravitational field event
  73478. */
  73479. class PhysicsGravitationalFieldEvent {
  73480. private _physicsHelper;
  73481. private _scene;
  73482. private _origin;
  73483. private _options;
  73484. private _tickCallback;
  73485. private _sphere;
  73486. private _dataFetched;
  73487. /**
  73488. * Initializes the physics gravitational field event
  73489. * @param _physicsHelper A physics helper
  73490. * @param _scene BabylonJS scene
  73491. * @param _origin The origin position of the gravitational field event
  73492. * @param _options The options for the vortex event
  73493. */
  73494. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73495. /**
  73496. * Returns the data related to the gravitational field event (sphere).
  73497. * @returns A gravitational field event
  73498. */
  73499. getData(): PhysicsGravitationalFieldEventData;
  73500. /**
  73501. * Enables the gravitational field.
  73502. */
  73503. enable(): void;
  73504. /**
  73505. * Disables the gravitational field.
  73506. */
  73507. disable(): void;
  73508. /**
  73509. * Disposes the sphere.
  73510. * @param force The force to dispose from the gravitational field event
  73511. */
  73512. dispose(force?: boolean): void;
  73513. private _tick;
  73514. }
  73515. /**
  73516. * Represents a physics updraft event
  73517. */
  73518. class PhysicsUpdraftEvent {
  73519. private _scene;
  73520. private _origin;
  73521. private _options;
  73522. private _physicsEngine;
  73523. private _originTop;
  73524. private _originDirection;
  73525. private _tickCallback;
  73526. private _cylinder;
  73527. private _cylinderPosition;
  73528. private _dataFetched;
  73529. /**
  73530. * Initializes the physics updraft event
  73531. * @param _scene BabylonJS scene
  73532. * @param _origin The origin position of the updraft
  73533. * @param _options The options for the updraft event
  73534. */
  73535. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73536. /**
  73537. * Returns the data related to the updraft event (cylinder).
  73538. * @returns A physics updraft event
  73539. */
  73540. getData(): PhysicsUpdraftEventData;
  73541. /**
  73542. * Enables the updraft.
  73543. */
  73544. enable(): void;
  73545. /**
  73546. * Disables the updraft.
  73547. */
  73548. disable(): void;
  73549. /**
  73550. * Disposes the cylinder.
  73551. * @param force Specifies if the updraft should be disposed by force
  73552. */
  73553. dispose(force?: boolean): void;
  73554. private getImpostorHitData;
  73555. private _tick;
  73556. /*** Helpers ***/
  73557. private _prepareCylinder;
  73558. private _intersectsWithCylinder;
  73559. }
  73560. /**
  73561. * Represents a physics vortex event
  73562. */
  73563. class PhysicsVortexEvent {
  73564. private _scene;
  73565. private _origin;
  73566. private _options;
  73567. private _physicsEngine;
  73568. private _originTop;
  73569. private _tickCallback;
  73570. private _cylinder;
  73571. private _cylinderPosition;
  73572. private _dataFetched;
  73573. /**
  73574. * Initializes the physics vortex event
  73575. * @param _scene The BabylonJS scene
  73576. * @param _origin The origin position of the vortex
  73577. * @param _options The options for the vortex event
  73578. */
  73579. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73580. /**
  73581. * Returns the data related to the vortex event (cylinder).
  73582. * @returns The physics vortex event data
  73583. */
  73584. getData(): PhysicsVortexEventData;
  73585. /**
  73586. * Enables the vortex.
  73587. */
  73588. enable(): void;
  73589. /**
  73590. * Disables the cortex.
  73591. */
  73592. disable(): void;
  73593. /**
  73594. * Disposes the sphere.
  73595. * @param force
  73596. */
  73597. dispose(force?: boolean): void;
  73598. private getImpostorHitData;
  73599. private _tick;
  73600. /*** Helpers ***/
  73601. private _prepareCylinder;
  73602. private _intersectsWithCylinder;
  73603. }
  73604. /**
  73605. * Options fot the radial explosion event
  73606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73607. */
  73608. export class PhysicsRadialExplosionEventOptions {
  73609. /**
  73610. * The radius of the sphere for the radial explosion.
  73611. */
  73612. radius: number;
  73613. /**
  73614. * The strenth of the explosion.
  73615. */
  73616. strength: number;
  73617. /**
  73618. * The strenght of the force in correspondence to the distance of the affected object
  73619. */
  73620. falloff: PhysicsRadialImpulseFalloff;
  73621. /**
  73622. * Sphere options for the radial explosion.
  73623. */
  73624. sphere: {
  73625. segments: number;
  73626. diameter: number;
  73627. };
  73628. /**
  73629. * Sphere options for the radial explosion.
  73630. */
  73631. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73632. }
  73633. /**
  73634. * Options fot the updraft event
  73635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73636. */
  73637. export class PhysicsUpdraftEventOptions {
  73638. /**
  73639. * The radius of the cylinder for the vortex
  73640. */
  73641. radius: number;
  73642. /**
  73643. * The strenth of the updraft.
  73644. */
  73645. strength: number;
  73646. /**
  73647. * The height of the cylinder for the updraft.
  73648. */
  73649. height: number;
  73650. /**
  73651. * The mode for the the updraft.
  73652. */
  73653. updraftMode: PhysicsUpdraftMode;
  73654. }
  73655. /**
  73656. * Options fot the vortex event
  73657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73658. */
  73659. export class PhysicsVortexEventOptions {
  73660. /**
  73661. * The radius of the cylinder for the vortex
  73662. */
  73663. radius: number;
  73664. /**
  73665. * The strenth of the vortex.
  73666. */
  73667. strength: number;
  73668. /**
  73669. * The height of the cylinder for the vortex.
  73670. */
  73671. height: number;
  73672. /**
  73673. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73674. */
  73675. centripetalForceThreshold: number;
  73676. /**
  73677. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73678. */
  73679. centripetalForceMultiplier: number;
  73680. /**
  73681. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73682. */
  73683. centrifugalForceMultiplier: number;
  73684. /**
  73685. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73686. */
  73687. updraftForceMultiplier: number;
  73688. }
  73689. /**
  73690. * The strenght of the force in correspondence to the distance of the affected object
  73691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73692. */
  73693. export enum PhysicsRadialImpulseFalloff {
  73694. /** Defines that impulse is constant in strength across it's whole radius */
  73695. Constant = 0,
  73696. /** Defines that impulse gets weaker if it's further from the origin */
  73697. Linear = 1
  73698. }
  73699. /**
  73700. * The strength of the force in correspondence to the distance of the affected object
  73701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73702. */
  73703. export enum PhysicsUpdraftMode {
  73704. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73705. Center = 0,
  73706. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73707. Perpendicular = 1
  73708. }
  73709. /**
  73710. * Interface for a physics hit data
  73711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73712. */
  73713. export interface PhysicsHitData {
  73714. /**
  73715. * The force applied at the contact point
  73716. */
  73717. force: Vector3;
  73718. /**
  73719. * The contact point
  73720. */
  73721. contactPoint: Vector3;
  73722. /**
  73723. * The distance from the origin to the contact point
  73724. */
  73725. distanceFromOrigin: number;
  73726. }
  73727. /**
  73728. * Interface for radial explosion event data
  73729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73730. */
  73731. export interface PhysicsRadialExplosionEventData {
  73732. /**
  73733. * A sphere used for the radial explosion event
  73734. */
  73735. sphere: Mesh;
  73736. }
  73737. /**
  73738. * Interface for gravitational field event data
  73739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73740. */
  73741. export interface PhysicsGravitationalFieldEventData {
  73742. /**
  73743. * A sphere mesh used for the gravitational field event
  73744. */
  73745. sphere: Mesh;
  73746. }
  73747. /**
  73748. * Interface for updraft event data
  73749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73750. */
  73751. export interface PhysicsUpdraftEventData {
  73752. /**
  73753. * A cylinder used for the updraft event
  73754. */
  73755. cylinder: Mesh;
  73756. }
  73757. /**
  73758. * Interface for vortex event data
  73759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73760. */
  73761. export interface PhysicsVortexEventData {
  73762. /**
  73763. * A cylinder used for the vortex event
  73764. */
  73765. cylinder: Mesh;
  73766. }
  73767. /**
  73768. * Interface for an affected physics impostor
  73769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73770. */
  73771. export interface PhysicsAffectedImpostorWithData {
  73772. /**
  73773. * The impostor affected by the effect
  73774. */
  73775. impostor: PhysicsImpostor;
  73776. /**
  73777. * The data about the hit/horce from the explosion
  73778. */
  73779. hitData: PhysicsHitData;
  73780. }
  73781. }
  73782. declare module "babylonjs/Physics/Plugins/index" {
  73783. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73784. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73785. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73786. }
  73787. declare module "babylonjs/Physics/index" {
  73788. export * from "babylonjs/Physics/IPhysicsEngine";
  73789. export * from "babylonjs/Physics/physicsEngine";
  73790. export * from "babylonjs/Physics/physicsEngineComponent";
  73791. export * from "babylonjs/Physics/physicsHelper";
  73792. export * from "babylonjs/Physics/physicsImpostor";
  73793. export * from "babylonjs/Physics/physicsJoint";
  73794. export * from "babylonjs/Physics/Plugins/index";
  73795. }
  73796. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73797. /** @hidden */
  73798. export var blackAndWhitePixelShader: {
  73799. name: string;
  73800. shader: string;
  73801. };
  73802. }
  73803. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73804. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73805. import { Camera } from "babylonjs/Cameras/camera";
  73806. import { Engine } from "babylonjs/Engines/engine";
  73807. import "babylonjs/Shaders/blackAndWhite.fragment";
  73808. import { Nullable } from "babylonjs/types";
  73809. import { Scene } from "babylonjs/scene";
  73810. /**
  73811. * Post process used to render in black and white
  73812. */
  73813. export class BlackAndWhitePostProcess extends PostProcess {
  73814. /**
  73815. * Linear about to convert he result to black and white (default: 1)
  73816. */
  73817. degree: number;
  73818. /**
  73819. * Gets a string identifying the name of the class
  73820. * @returns "BlackAndWhitePostProcess" string
  73821. */
  73822. getClassName(): string;
  73823. /**
  73824. * Creates a black and white post process
  73825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73826. * @param name The name of the effect.
  73827. * @param options The required width/height ratio to downsize to before computing the render pass.
  73828. * @param camera The camera to apply the render pass to.
  73829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73830. * @param engine The engine which the post process will be applied. (default: current engine)
  73831. * @param reusable If the post process can be reused on the same frame. (default: false)
  73832. */
  73833. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73834. /** @hidden */
  73835. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73836. }
  73837. }
  73838. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73839. import { Nullable } from "babylonjs/types";
  73840. import { Camera } from "babylonjs/Cameras/camera";
  73841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73842. import { Engine } from "babylonjs/Engines/engine";
  73843. /**
  73844. * This represents a set of one or more post processes in Babylon.
  73845. * A post process can be used to apply a shader to a texture after it is rendered.
  73846. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73847. */
  73848. export class PostProcessRenderEffect {
  73849. private _postProcesses;
  73850. private _getPostProcesses;
  73851. private _singleInstance;
  73852. private _cameras;
  73853. private _indicesForCamera;
  73854. /**
  73855. * Name of the effect
  73856. * @hidden
  73857. */
  73858. _name: string;
  73859. /**
  73860. * Instantiates a post process render effect.
  73861. * A post process can be used to apply a shader to a texture after it is rendered.
  73862. * @param engine The engine the effect is tied to
  73863. * @param name The name of the effect
  73864. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73865. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73866. */
  73867. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73868. /**
  73869. * Checks if all the post processes in the effect are supported.
  73870. */
  73871. get isSupported(): boolean;
  73872. /**
  73873. * Updates the current state of the effect
  73874. * @hidden
  73875. */
  73876. _update(): void;
  73877. /**
  73878. * Attaches the effect on cameras
  73879. * @param cameras The camera to attach to.
  73880. * @hidden
  73881. */
  73882. _attachCameras(cameras: Camera): void;
  73883. /**
  73884. * Attaches the effect on cameras
  73885. * @param cameras The camera to attach to.
  73886. * @hidden
  73887. */
  73888. _attachCameras(cameras: Camera[]): void;
  73889. /**
  73890. * Detaches the effect on cameras
  73891. * @param cameras The camera to detatch from.
  73892. * @hidden
  73893. */
  73894. _detachCameras(cameras: Camera): void;
  73895. /**
  73896. * Detatches the effect on cameras
  73897. * @param cameras The camera to detatch from.
  73898. * @hidden
  73899. */
  73900. _detachCameras(cameras: Camera[]): void;
  73901. /**
  73902. * Enables the effect on given cameras
  73903. * @param cameras The camera to enable.
  73904. * @hidden
  73905. */
  73906. _enable(cameras: Camera): void;
  73907. /**
  73908. * Enables the effect on given cameras
  73909. * @param cameras The camera to enable.
  73910. * @hidden
  73911. */
  73912. _enable(cameras: Nullable<Camera[]>): void;
  73913. /**
  73914. * Disables the effect on the given cameras
  73915. * @param cameras The camera to disable.
  73916. * @hidden
  73917. */
  73918. _disable(cameras: Camera): void;
  73919. /**
  73920. * Disables the effect on the given cameras
  73921. * @param cameras The camera to disable.
  73922. * @hidden
  73923. */
  73924. _disable(cameras: Nullable<Camera[]>): void;
  73925. /**
  73926. * Gets a list of the post processes contained in the effect.
  73927. * @param camera The camera to get the post processes on.
  73928. * @returns The list of the post processes in the effect.
  73929. */
  73930. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73931. }
  73932. }
  73933. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73934. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73935. /** @hidden */
  73936. export var extractHighlightsPixelShader: {
  73937. name: string;
  73938. shader: string;
  73939. };
  73940. }
  73941. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73942. import { Nullable } from "babylonjs/types";
  73943. import { Camera } from "babylonjs/Cameras/camera";
  73944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73945. import { Engine } from "babylonjs/Engines/engine";
  73946. import "babylonjs/Shaders/extractHighlights.fragment";
  73947. /**
  73948. * 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.
  73949. */
  73950. export class ExtractHighlightsPostProcess extends PostProcess {
  73951. /**
  73952. * The luminance threshold, pixels below this value will be set to black.
  73953. */
  73954. threshold: number;
  73955. /** @hidden */
  73956. _exposure: number;
  73957. /**
  73958. * Post process which has the input texture to be used when performing highlight extraction
  73959. * @hidden
  73960. */
  73961. _inputPostProcess: Nullable<PostProcess>;
  73962. /**
  73963. * Gets a string identifying the name of the class
  73964. * @returns "ExtractHighlightsPostProcess" string
  73965. */
  73966. getClassName(): string;
  73967. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73968. }
  73969. }
  73970. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73971. /** @hidden */
  73972. export var bloomMergePixelShader: {
  73973. name: string;
  73974. shader: string;
  73975. };
  73976. }
  73977. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73978. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73979. import { Nullable } from "babylonjs/types";
  73980. import { Engine } from "babylonjs/Engines/engine";
  73981. import { Camera } from "babylonjs/Cameras/camera";
  73982. import "babylonjs/Shaders/bloomMerge.fragment";
  73983. /**
  73984. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73985. */
  73986. export class BloomMergePostProcess extends PostProcess {
  73987. /** Weight of the bloom to be added to the original input. */
  73988. weight: number;
  73989. /**
  73990. * Gets a string identifying the name of the class
  73991. * @returns "BloomMergePostProcess" string
  73992. */
  73993. getClassName(): string;
  73994. /**
  73995. * Creates a new instance of @see BloomMergePostProcess
  73996. * @param name The name of the effect.
  73997. * @param originalFromInput Post process which's input will be used for the merge.
  73998. * @param blurred Blurred highlights post process which's output will be used.
  73999. * @param weight Weight of the bloom to be added to the original input.
  74000. * @param options The required width/height ratio to downsize to before computing the render pass.
  74001. * @param camera The camera to apply the render pass to.
  74002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74003. * @param engine The engine which the post process will be applied. (default: current engine)
  74004. * @param reusable If the post process can be reused on the same frame. (default: false)
  74005. * @param textureType Type of textures used when performing the post process. (default: 0)
  74006. * @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)
  74007. */
  74008. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74009. /** Weight of the bloom to be added to the original input. */
  74010. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74011. }
  74012. }
  74013. declare module "babylonjs/PostProcesses/bloomEffect" {
  74014. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74015. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74016. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74017. import { Camera } from "babylonjs/Cameras/camera";
  74018. import { Scene } from "babylonjs/scene";
  74019. /**
  74020. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74021. */
  74022. export class BloomEffect extends PostProcessRenderEffect {
  74023. private bloomScale;
  74024. /**
  74025. * @hidden Internal
  74026. */
  74027. _effects: Array<PostProcess>;
  74028. /**
  74029. * @hidden Internal
  74030. */
  74031. _downscale: ExtractHighlightsPostProcess;
  74032. private _blurX;
  74033. private _blurY;
  74034. private _merge;
  74035. /**
  74036. * The luminance threshold to find bright areas of the image to bloom.
  74037. */
  74038. get threshold(): number;
  74039. set threshold(value: number);
  74040. /**
  74041. * The strength of the bloom.
  74042. */
  74043. get weight(): number;
  74044. set weight(value: number);
  74045. /**
  74046. * Specifies the size of the bloom blur kernel, relative to the final output size
  74047. */
  74048. get kernel(): number;
  74049. set kernel(value: number);
  74050. /**
  74051. * Creates a new instance of @see BloomEffect
  74052. * @param scene The scene the effect belongs to.
  74053. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74054. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74055. * @param bloomWeight The the strength of bloom.
  74056. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74057. * @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)
  74058. */
  74059. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74060. /**
  74061. * Disposes each of the internal effects for a given camera.
  74062. * @param camera The camera to dispose the effect on.
  74063. */
  74064. disposeEffects(camera: Camera): void;
  74065. /**
  74066. * @hidden Internal
  74067. */
  74068. _updateEffects(): void;
  74069. /**
  74070. * Internal
  74071. * @returns if all the contained post processes are ready.
  74072. * @hidden
  74073. */
  74074. _isReady(): boolean;
  74075. }
  74076. }
  74077. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74078. /** @hidden */
  74079. export var chromaticAberrationPixelShader: {
  74080. name: string;
  74081. shader: string;
  74082. };
  74083. }
  74084. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74085. import { Vector2 } from "babylonjs/Maths/math.vector";
  74086. import { Nullable } from "babylonjs/types";
  74087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74088. import { Camera } from "babylonjs/Cameras/camera";
  74089. import { Engine } from "babylonjs/Engines/engine";
  74090. import "babylonjs/Shaders/chromaticAberration.fragment";
  74091. import { Scene } from "babylonjs/scene";
  74092. /**
  74093. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74094. */
  74095. export class ChromaticAberrationPostProcess extends PostProcess {
  74096. /**
  74097. * The amount of seperation of rgb channels (default: 30)
  74098. */
  74099. aberrationAmount: number;
  74100. /**
  74101. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74102. */
  74103. radialIntensity: number;
  74104. /**
  74105. * 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))
  74106. */
  74107. direction: Vector2;
  74108. /**
  74109. * 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))
  74110. */
  74111. centerPosition: Vector2;
  74112. /** The width of the screen to apply the effect on */
  74113. screenWidth: number;
  74114. /** The height of the screen to apply the effect on */
  74115. screenHeight: number;
  74116. /**
  74117. * Gets a string identifying the name of the class
  74118. * @returns "ChromaticAberrationPostProcess" string
  74119. */
  74120. getClassName(): string;
  74121. /**
  74122. * Creates a new instance ChromaticAberrationPostProcess
  74123. * @param name The name of the effect.
  74124. * @param screenWidth The width of the screen to apply the effect on.
  74125. * @param screenHeight The height of the screen to apply the effect on.
  74126. * @param options The required width/height ratio to downsize to before computing the render pass.
  74127. * @param camera The camera to apply the render pass to.
  74128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74129. * @param engine The engine which the post process will be applied. (default: current engine)
  74130. * @param reusable If the post process can be reused on the same frame. (default: false)
  74131. * @param textureType Type of textures used when performing the post process. (default: 0)
  74132. * @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)
  74133. */
  74134. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74135. /** @hidden */
  74136. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74137. }
  74138. }
  74139. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74140. /** @hidden */
  74141. export var circleOfConfusionPixelShader: {
  74142. name: string;
  74143. shader: string;
  74144. };
  74145. }
  74146. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74147. import { Nullable } from "babylonjs/types";
  74148. import { Engine } from "babylonjs/Engines/engine";
  74149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74150. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74151. import { Camera } from "babylonjs/Cameras/camera";
  74152. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74153. /**
  74154. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74155. */
  74156. export class CircleOfConfusionPostProcess extends PostProcess {
  74157. /**
  74158. * 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.
  74159. */
  74160. lensSize: number;
  74161. /**
  74162. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74163. */
  74164. fStop: number;
  74165. /**
  74166. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74167. */
  74168. focusDistance: number;
  74169. /**
  74170. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74171. */
  74172. focalLength: number;
  74173. /**
  74174. * Gets a string identifying the name of the class
  74175. * @returns "CircleOfConfusionPostProcess" string
  74176. */
  74177. getClassName(): string;
  74178. private _depthTexture;
  74179. /**
  74180. * Creates a new instance CircleOfConfusionPostProcess
  74181. * @param name The name of the effect.
  74182. * @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.
  74183. * @param options The required width/height ratio to downsize to before computing the render pass.
  74184. * @param camera The camera to apply the render pass to.
  74185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74186. * @param engine The engine which the post process will be applied. (default: current engine)
  74187. * @param reusable If the post process can be reused on the same frame. (default: false)
  74188. * @param textureType Type of textures used when performing the post process. (default: 0)
  74189. * @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)
  74190. */
  74191. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74192. /**
  74193. * 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.
  74194. */
  74195. set depthTexture(value: RenderTargetTexture);
  74196. }
  74197. }
  74198. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74199. /** @hidden */
  74200. export var colorCorrectionPixelShader: {
  74201. name: string;
  74202. shader: string;
  74203. };
  74204. }
  74205. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74206. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74207. import { Engine } from "babylonjs/Engines/engine";
  74208. import { Camera } from "babylonjs/Cameras/camera";
  74209. import "babylonjs/Shaders/colorCorrection.fragment";
  74210. import { Nullable } from "babylonjs/types";
  74211. import { Scene } from "babylonjs/scene";
  74212. /**
  74213. *
  74214. * This post-process allows the modification of rendered colors by using
  74215. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74216. *
  74217. * The object needs to be provided an url to a texture containing the color
  74218. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74219. * Use an image editing software to tweak the LUT to match your needs.
  74220. *
  74221. * For an example of a color LUT, see here:
  74222. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74223. * For explanations on color grading, see here:
  74224. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74225. *
  74226. */
  74227. export class ColorCorrectionPostProcess extends PostProcess {
  74228. private _colorTableTexture;
  74229. /**
  74230. * Gets the color table url used to create the LUT texture
  74231. */
  74232. colorTableUrl: string;
  74233. /**
  74234. * Gets a string identifying the name of the class
  74235. * @returns "ColorCorrectionPostProcess" string
  74236. */
  74237. getClassName(): string;
  74238. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74239. /** @hidden */
  74240. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74241. }
  74242. }
  74243. declare module "babylonjs/Shaders/convolution.fragment" {
  74244. /** @hidden */
  74245. export var convolutionPixelShader: {
  74246. name: string;
  74247. shader: string;
  74248. };
  74249. }
  74250. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74252. import { Nullable } from "babylonjs/types";
  74253. import { Camera } from "babylonjs/Cameras/camera";
  74254. import { Engine } from "babylonjs/Engines/engine";
  74255. import "babylonjs/Shaders/convolution.fragment";
  74256. import { Scene } from "babylonjs/scene";
  74257. /**
  74258. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74259. * input texture to perform effects such as edge detection or sharpening
  74260. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74261. */
  74262. export class ConvolutionPostProcess extends PostProcess {
  74263. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74264. kernel: number[];
  74265. /**
  74266. * Gets a string identifying the name of the class
  74267. * @returns "ConvolutionPostProcess" string
  74268. */
  74269. getClassName(): string;
  74270. /**
  74271. * Creates a new instance ConvolutionPostProcess
  74272. * @param name The name of the effect.
  74273. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74274. * @param options The required width/height ratio to downsize to before computing the render pass.
  74275. * @param camera The camera to apply the render pass to.
  74276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74277. * @param engine The engine which the post process will be applied. (default: current engine)
  74278. * @param reusable If the post process can be reused on the same frame. (default: false)
  74279. * @param textureType Type of textures used when performing the post process. (default: 0)
  74280. */
  74281. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74282. /** @hidden */
  74283. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74284. /**
  74285. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74286. */
  74287. static EdgeDetect0Kernel: number[];
  74288. /**
  74289. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74290. */
  74291. static EdgeDetect1Kernel: number[];
  74292. /**
  74293. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74294. */
  74295. static EdgeDetect2Kernel: number[];
  74296. /**
  74297. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74298. */
  74299. static SharpenKernel: number[];
  74300. /**
  74301. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74302. */
  74303. static EmbossKernel: number[];
  74304. /**
  74305. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74306. */
  74307. static GaussianKernel: number[];
  74308. }
  74309. }
  74310. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74311. import { Nullable } from "babylonjs/types";
  74312. import { Vector2 } from "babylonjs/Maths/math.vector";
  74313. import { Camera } from "babylonjs/Cameras/camera";
  74314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74315. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74316. import { Engine } from "babylonjs/Engines/engine";
  74317. import { Scene } from "babylonjs/scene";
  74318. /**
  74319. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74320. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74321. * based on samples that have a large difference in distance than the center pixel.
  74322. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74323. */
  74324. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74325. /**
  74326. * The direction the blur should be applied
  74327. */
  74328. direction: Vector2;
  74329. /**
  74330. * Gets a string identifying the name of the class
  74331. * @returns "DepthOfFieldBlurPostProcess" string
  74332. */
  74333. getClassName(): string;
  74334. /**
  74335. * Creates a new instance CircleOfConfusionPostProcess
  74336. * @param name The name of the effect.
  74337. * @param scene The scene the effect belongs to.
  74338. * @param direction The direction the blur should be applied.
  74339. * @param kernel The size of the kernel used to blur.
  74340. * @param options The required width/height ratio to downsize to before computing the render pass.
  74341. * @param camera The camera to apply the render pass to.
  74342. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74343. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74345. * @param engine The engine which the post process will be applied. (default: current engine)
  74346. * @param reusable If the post process can be reused on the same frame. (default: false)
  74347. * @param textureType Type of textures used when performing the post process. (default: 0)
  74348. * @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)
  74349. */
  74350. 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);
  74351. }
  74352. }
  74353. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74354. /** @hidden */
  74355. export var depthOfFieldMergePixelShader: {
  74356. name: string;
  74357. shader: string;
  74358. };
  74359. }
  74360. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74361. import { Nullable } from "babylonjs/types";
  74362. import { Camera } from "babylonjs/Cameras/camera";
  74363. import { Effect } from "babylonjs/Materials/effect";
  74364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74365. import { Engine } from "babylonjs/Engines/engine";
  74366. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74367. /**
  74368. * Options to be set when merging outputs from the default pipeline.
  74369. */
  74370. export class DepthOfFieldMergePostProcessOptions {
  74371. /**
  74372. * The original image to merge on top of
  74373. */
  74374. originalFromInput: PostProcess;
  74375. /**
  74376. * Parameters to perform the merge of the depth of field effect
  74377. */
  74378. depthOfField?: {
  74379. circleOfConfusion: PostProcess;
  74380. blurSteps: Array<PostProcess>;
  74381. };
  74382. /**
  74383. * Parameters to perform the merge of bloom effect
  74384. */
  74385. bloom?: {
  74386. blurred: PostProcess;
  74387. weight: number;
  74388. };
  74389. }
  74390. /**
  74391. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74392. */
  74393. export class DepthOfFieldMergePostProcess extends PostProcess {
  74394. private blurSteps;
  74395. /**
  74396. * Gets a string identifying the name of the class
  74397. * @returns "DepthOfFieldMergePostProcess" string
  74398. */
  74399. getClassName(): string;
  74400. /**
  74401. * Creates a new instance of DepthOfFieldMergePostProcess
  74402. * @param name The name of the effect.
  74403. * @param originalFromInput Post process which's input will be used for the merge.
  74404. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74405. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74406. * @param options The required width/height ratio to downsize to before computing the render pass.
  74407. * @param camera The camera to apply the render pass to.
  74408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74409. * @param engine The engine which the post process will be applied. (default: current engine)
  74410. * @param reusable If the post process can be reused on the same frame. (default: false)
  74411. * @param textureType Type of textures used when performing the post process. (default: 0)
  74412. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  74413. */
  74414. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74415. /**
  74416. * Updates the effect with the current post process compile time values and recompiles the shader.
  74417. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74418. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74419. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74420. * @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
  74421. * @param onCompiled Called when the shader has been compiled.
  74422. * @param onError Called if there is an error when compiling a shader.
  74423. */
  74424. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74425. }
  74426. }
  74427. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74428. import { Nullable } from "babylonjs/types";
  74429. import { Camera } from "babylonjs/Cameras/camera";
  74430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74431. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74432. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74433. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74434. import { Scene } from "babylonjs/scene";
  74435. /**
  74436. * Specifies the level of max blur that should be applied when using the depth of field effect
  74437. */
  74438. export enum DepthOfFieldEffectBlurLevel {
  74439. /**
  74440. * Subtle blur
  74441. */
  74442. Low = 0,
  74443. /**
  74444. * Medium blur
  74445. */
  74446. Medium = 1,
  74447. /**
  74448. * Large blur
  74449. */
  74450. High = 2
  74451. }
  74452. /**
  74453. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74454. */
  74455. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74456. private _circleOfConfusion;
  74457. /**
  74458. * @hidden Internal, blurs from high to low
  74459. */
  74460. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74461. private _depthOfFieldBlurY;
  74462. private _dofMerge;
  74463. /**
  74464. * @hidden Internal post processes in depth of field effect
  74465. */
  74466. _effects: Array<PostProcess>;
  74467. /**
  74468. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74469. */
  74470. set focalLength(value: number);
  74471. get focalLength(): number;
  74472. /**
  74473. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74474. */
  74475. set fStop(value: number);
  74476. get fStop(): number;
  74477. /**
  74478. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74479. */
  74480. set focusDistance(value: number);
  74481. get focusDistance(): number;
  74482. /**
  74483. * 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.
  74484. */
  74485. set lensSize(value: number);
  74486. get lensSize(): number;
  74487. /**
  74488. * Creates a new instance DepthOfFieldEffect
  74489. * @param scene The scene the effect belongs to.
  74490. * @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.
  74491. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74492. * @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)
  74493. */
  74494. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74495. /**
  74496. * Get the current class name of the current effet
  74497. * @returns "DepthOfFieldEffect"
  74498. */
  74499. getClassName(): string;
  74500. /**
  74501. * 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.
  74502. */
  74503. set depthTexture(value: RenderTargetTexture);
  74504. /**
  74505. * Disposes each of the internal effects for a given camera.
  74506. * @param camera The camera to dispose the effect on.
  74507. */
  74508. disposeEffects(camera: Camera): void;
  74509. /**
  74510. * @hidden Internal
  74511. */
  74512. _updateEffects(): void;
  74513. /**
  74514. * Internal
  74515. * @returns if all the contained post processes are ready.
  74516. * @hidden
  74517. */
  74518. _isReady(): boolean;
  74519. }
  74520. }
  74521. declare module "babylonjs/Shaders/displayPass.fragment" {
  74522. /** @hidden */
  74523. export var displayPassPixelShader: {
  74524. name: string;
  74525. shader: string;
  74526. };
  74527. }
  74528. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74529. import { Nullable } from "babylonjs/types";
  74530. import { Camera } from "babylonjs/Cameras/camera";
  74531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74532. import { Engine } from "babylonjs/Engines/engine";
  74533. import "babylonjs/Shaders/displayPass.fragment";
  74534. import { Scene } from "babylonjs/scene";
  74535. /**
  74536. * DisplayPassPostProcess which produces an output the same as it's input
  74537. */
  74538. export class DisplayPassPostProcess extends PostProcess {
  74539. /**
  74540. * Gets a string identifying the name of the class
  74541. * @returns "DisplayPassPostProcess" string
  74542. */
  74543. getClassName(): string;
  74544. /**
  74545. * Creates the DisplayPassPostProcess
  74546. * @param name The name of the effect.
  74547. * @param options The required width/height ratio to downsize to before computing the render pass.
  74548. * @param camera The camera to apply the render pass to.
  74549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74550. * @param engine The engine which the post process will be applied. (default: current engine)
  74551. * @param reusable If the post process can be reused on the same frame. (default: false)
  74552. */
  74553. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74554. /** @hidden */
  74555. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74556. }
  74557. }
  74558. declare module "babylonjs/Shaders/filter.fragment" {
  74559. /** @hidden */
  74560. export var filterPixelShader: {
  74561. name: string;
  74562. shader: string;
  74563. };
  74564. }
  74565. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74566. import { Nullable } from "babylonjs/types";
  74567. import { Matrix } from "babylonjs/Maths/math.vector";
  74568. import { Camera } from "babylonjs/Cameras/camera";
  74569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74570. import { Engine } from "babylonjs/Engines/engine";
  74571. import "babylonjs/Shaders/filter.fragment";
  74572. import { Scene } from "babylonjs/scene";
  74573. /**
  74574. * Applies a kernel filter to the image
  74575. */
  74576. export class FilterPostProcess extends PostProcess {
  74577. /** The matrix to be applied to the image */
  74578. kernelMatrix: Matrix;
  74579. /**
  74580. * Gets a string identifying the name of the class
  74581. * @returns "FilterPostProcess" string
  74582. */
  74583. getClassName(): string;
  74584. /**
  74585. *
  74586. * @param name The name of the effect.
  74587. * @param kernelMatrix The matrix to be applied to the image
  74588. * @param options The required width/height ratio to downsize to before computing the render pass.
  74589. * @param camera The camera to apply the render pass to.
  74590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74591. * @param engine The engine which the post process will be applied. (default: current engine)
  74592. * @param reusable If the post process can be reused on the same frame. (default: false)
  74593. */
  74594. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74595. /** @hidden */
  74596. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74597. }
  74598. }
  74599. declare module "babylonjs/Shaders/fxaa.fragment" {
  74600. /** @hidden */
  74601. export var fxaaPixelShader: {
  74602. name: string;
  74603. shader: string;
  74604. };
  74605. }
  74606. declare module "babylonjs/Shaders/fxaa.vertex" {
  74607. /** @hidden */
  74608. export var fxaaVertexShader: {
  74609. name: string;
  74610. shader: string;
  74611. };
  74612. }
  74613. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74614. import { Nullable } from "babylonjs/types";
  74615. import { Camera } from "babylonjs/Cameras/camera";
  74616. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74617. import { Engine } from "babylonjs/Engines/engine";
  74618. import "babylonjs/Shaders/fxaa.fragment";
  74619. import "babylonjs/Shaders/fxaa.vertex";
  74620. import { Scene } from "babylonjs/scene";
  74621. /**
  74622. * Fxaa post process
  74623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74624. */
  74625. export class FxaaPostProcess extends PostProcess {
  74626. /**
  74627. * Gets a string identifying the name of the class
  74628. * @returns "FxaaPostProcess" string
  74629. */
  74630. getClassName(): string;
  74631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74632. private _getDefines;
  74633. /** @hidden */
  74634. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74635. }
  74636. }
  74637. declare module "babylonjs/Shaders/grain.fragment" {
  74638. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74639. /** @hidden */
  74640. export var grainPixelShader: {
  74641. name: string;
  74642. shader: string;
  74643. };
  74644. }
  74645. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74646. import { Nullable } from "babylonjs/types";
  74647. import { Camera } from "babylonjs/Cameras/camera";
  74648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74649. import { Engine } from "babylonjs/Engines/engine";
  74650. import "babylonjs/Shaders/grain.fragment";
  74651. import { Scene } from "babylonjs/scene";
  74652. /**
  74653. * The GrainPostProcess adds noise to the image at mid luminance levels
  74654. */
  74655. export class GrainPostProcess extends PostProcess {
  74656. /**
  74657. * The intensity of the grain added (default: 30)
  74658. */
  74659. intensity: number;
  74660. /**
  74661. * If the grain should be randomized on every frame
  74662. */
  74663. animated: boolean;
  74664. /**
  74665. * Gets a string identifying the name of the class
  74666. * @returns "GrainPostProcess" string
  74667. */
  74668. getClassName(): string;
  74669. /**
  74670. * Creates a new instance of @see GrainPostProcess
  74671. * @param name The name of the effect.
  74672. * @param options The required width/height ratio to downsize to before computing the render pass.
  74673. * @param camera The camera to apply the render pass to.
  74674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74675. * @param engine The engine which the post process will be applied. (default: current engine)
  74676. * @param reusable If the post process can be reused on the same frame. (default: false)
  74677. * @param textureType Type of textures used when performing the post process. (default: 0)
  74678. * @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)
  74679. */
  74680. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74681. /** @hidden */
  74682. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74683. }
  74684. }
  74685. declare module "babylonjs/Shaders/highlights.fragment" {
  74686. /** @hidden */
  74687. export var highlightsPixelShader: {
  74688. name: string;
  74689. shader: string;
  74690. };
  74691. }
  74692. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74693. import { Nullable } from "babylonjs/types";
  74694. import { Camera } from "babylonjs/Cameras/camera";
  74695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74696. import { Engine } from "babylonjs/Engines/engine";
  74697. import "babylonjs/Shaders/highlights.fragment";
  74698. /**
  74699. * Extracts highlights from the image
  74700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74701. */
  74702. export class HighlightsPostProcess extends PostProcess {
  74703. /**
  74704. * Gets a string identifying the name of the class
  74705. * @returns "HighlightsPostProcess" string
  74706. */
  74707. getClassName(): string;
  74708. /**
  74709. * Extracts highlights from the image
  74710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74711. * @param name The name of the effect.
  74712. * @param options The required width/height ratio to downsize to before computing the render pass.
  74713. * @param camera The camera to apply the render pass to.
  74714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74715. * @param engine The engine which the post process will be applied. (default: current engine)
  74716. * @param reusable If the post process can be reused on the same frame. (default: false)
  74717. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74718. */
  74719. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74720. }
  74721. }
  74722. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74723. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74724. /**
  74725. * Contains all parameters needed for the prepass to perform
  74726. * motion blur
  74727. */
  74728. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74729. /**
  74730. * Is motion blur enabled
  74731. */
  74732. enabled: boolean;
  74733. /**
  74734. * Name of the configuration
  74735. */
  74736. name: string;
  74737. /**
  74738. * Textures that should be present in the MRT for this effect to work
  74739. */
  74740. readonly texturesRequired: number[];
  74741. }
  74742. }
  74743. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74744. import { Nullable } from "babylonjs/types";
  74745. import { Scene } from "babylonjs/scene";
  74746. import { ISceneComponent } from "babylonjs/sceneComponent";
  74747. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74748. module "babylonjs/scene" {
  74749. interface Scene {
  74750. /** @hidden (Backing field) */
  74751. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74752. /**
  74753. * Gets or Sets the current geometry buffer associated to the scene.
  74754. */
  74755. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74756. /**
  74757. * Enables a GeometryBufferRender and associates it with the scene
  74758. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74759. * @returns the GeometryBufferRenderer
  74760. */
  74761. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74762. /**
  74763. * Disables the GeometryBufferRender associated with the scene
  74764. */
  74765. disableGeometryBufferRenderer(): void;
  74766. }
  74767. }
  74768. /**
  74769. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74770. * in several rendering techniques.
  74771. */
  74772. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74773. /**
  74774. * The component name helpful to identify the component in the list of scene components.
  74775. */
  74776. readonly name: string;
  74777. /**
  74778. * The scene the component belongs to.
  74779. */
  74780. scene: Scene;
  74781. /**
  74782. * Creates a new instance of the component for the given scene
  74783. * @param scene Defines the scene to register the component in
  74784. */
  74785. constructor(scene: Scene);
  74786. /**
  74787. * Registers the component in a given scene
  74788. */
  74789. register(): void;
  74790. /**
  74791. * Rebuilds the elements related to this component in case of
  74792. * context lost for instance.
  74793. */
  74794. rebuild(): void;
  74795. /**
  74796. * Disposes the component and the associated ressources
  74797. */
  74798. dispose(): void;
  74799. private _gatherRenderTargets;
  74800. }
  74801. }
  74802. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74803. /** @hidden */
  74804. export var motionBlurPixelShader: {
  74805. name: string;
  74806. shader: string;
  74807. };
  74808. }
  74809. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74810. import { Nullable } from "babylonjs/types";
  74811. import { Camera } from "babylonjs/Cameras/camera";
  74812. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74814. import "babylonjs/Animations/animatable";
  74815. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74816. import "babylonjs/Shaders/motionBlur.fragment";
  74817. import { Engine } from "babylonjs/Engines/engine";
  74818. import { Scene } from "babylonjs/scene";
  74819. /**
  74820. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74821. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74822. * As an example, all you have to do is to create the post-process:
  74823. * var mb = new BABYLON.MotionBlurPostProcess(
  74824. * 'mb', // The name of the effect.
  74825. * scene, // The scene containing the objects to blur according to their velocity.
  74826. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74827. * camera // The camera to apply the render pass to.
  74828. * );
  74829. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74830. */
  74831. export class MotionBlurPostProcess extends PostProcess {
  74832. /**
  74833. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74834. */
  74835. motionStrength: number;
  74836. /**
  74837. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74838. */
  74839. get motionBlurSamples(): number;
  74840. /**
  74841. * Sets the number of iterations to be used for motion blur quality
  74842. */
  74843. set motionBlurSamples(samples: number);
  74844. private _motionBlurSamples;
  74845. private _forceGeometryBuffer;
  74846. private _geometryBufferRenderer;
  74847. private _prePassRenderer;
  74848. /**
  74849. * Gets a string identifying the name of the class
  74850. * @returns "MotionBlurPostProcess" string
  74851. */
  74852. getClassName(): string;
  74853. /**
  74854. * Creates a new instance MotionBlurPostProcess
  74855. * @param name The name of the effect.
  74856. * @param scene The scene containing the objects to blur according to their velocity.
  74857. * @param options The required width/height ratio to downsize to before computing the render pass.
  74858. * @param camera The camera to apply the render pass to.
  74859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74860. * @param engine The engine which the post process will be applied. (default: current engine)
  74861. * @param reusable If the post process can be reused on the same frame. (default: false)
  74862. * @param textureType Type of textures used when performing the post process. (default: 0)
  74863. * @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)
  74864. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74865. */
  74866. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74867. /**
  74868. * Excludes the given skinned mesh from computing bones velocities.
  74869. * 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.
  74870. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74871. */
  74872. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74873. /**
  74874. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74875. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74876. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74877. */
  74878. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74879. /**
  74880. * Disposes the post process.
  74881. * @param camera The camera to dispose the post process on.
  74882. */
  74883. dispose(camera?: Camera): void;
  74884. /** @hidden */
  74885. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74886. }
  74887. }
  74888. declare module "babylonjs/Shaders/refraction.fragment" {
  74889. /** @hidden */
  74890. export var refractionPixelShader: {
  74891. name: string;
  74892. shader: string;
  74893. };
  74894. }
  74895. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74896. import { Color3 } from "babylonjs/Maths/math.color";
  74897. import { Camera } from "babylonjs/Cameras/camera";
  74898. import { Texture } from "babylonjs/Materials/Textures/texture";
  74899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74900. import { Engine } from "babylonjs/Engines/engine";
  74901. import "babylonjs/Shaders/refraction.fragment";
  74902. import { Scene } from "babylonjs/scene";
  74903. /**
  74904. * Post process which applies a refractin texture
  74905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74906. */
  74907. export class RefractionPostProcess extends PostProcess {
  74908. private _refTexture;
  74909. private _ownRefractionTexture;
  74910. /** the base color of the refraction (used to taint the rendering) */
  74911. color: Color3;
  74912. /** simulated refraction depth */
  74913. depth: number;
  74914. /** the coefficient of the base color (0 to remove base color tainting) */
  74915. colorLevel: number;
  74916. /** Gets the url used to load the refraction texture */
  74917. refractionTextureUrl: string;
  74918. /**
  74919. * Gets or sets the refraction texture
  74920. * Please note that you are responsible for disposing the texture if you set it manually
  74921. */
  74922. get refractionTexture(): Texture;
  74923. set refractionTexture(value: Texture);
  74924. /**
  74925. * Gets a string identifying the name of the class
  74926. * @returns "RefractionPostProcess" string
  74927. */
  74928. getClassName(): string;
  74929. /**
  74930. * Initializes the RefractionPostProcess
  74931. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74932. * @param name The name of the effect.
  74933. * @param refractionTextureUrl Url of the refraction texture to use
  74934. * @param color the base color of the refraction (used to taint the rendering)
  74935. * @param depth simulated refraction depth
  74936. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74937. * @param camera The camera to apply the render pass to.
  74938. * @param options The required width/height ratio to downsize to before computing the render pass.
  74939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74940. * @param engine The engine which the post process will be applied. (default: current engine)
  74941. * @param reusable If the post process can be reused on the same frame. (default: false)
  74942. */
  74943. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74944. /**
  74945. * Disposes of the post process
  74946. * @param camera Camera to dispose post process on
  74947. */
  74948. dispose(camera: Camera): void;
  74949. /** @hidden */
  74950. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74951. }
  74952. }
  74953. declare module "babylonjs/Shaders/sharpen.fragment" {
  74954. /** @hidden */
  74955. export var sharpenPixelShader: {
  74956. name: string;
  74957. shader: string;
  74958. };
  74959. }
  74960. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74961. import { Nullable } from "babylonjs/types";
  74962. import { Camera } from "babylonjs/Cameras/camera";
  74963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74964. import "babylonjs/Shaders/sharpen.fragment";
  74965. import { Engine } from "babylonjs/Engines/engine";
  74966. import { Scene } from "babylonjs/scene";
  74967. /**
  74968. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74969. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74970. */
  74971. export class SharpenPostProcess extends PostProcess {
  74972. /**
  74973. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74974. */
  74975. colorAmount: number;
  74976. /**
  74977. * How much sharpness should be applied (default: 0.3)
  74978. */
  74979. edgeAmount: number;
  74980. /**
  74981. * Gets a string identifying the name of the class
  74982. * @returns "SharpenPostProcess" string
  74983. */
  74984. getClassName(): string;
  74985. /**
  74986. * Creates a new instance ConvolutionPostProcess
  74987. * @param name The name of the effect.
  74988. * @param options The required width/height ratio to downsize to before computing the render pass.
  74989. * @param camera The camera to apply the render pass to.
  74990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74991. * @param engine The engine which the post process will be applied. (default: current engine)
  74992. * @param reusable If the post process can be reused on the same frame. (default: false)
  74993. * @param textureType Type of textures used when performing the post process. (default: 0)
  74994. * @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)
  74995. */
  74996. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74997. /** @hidden */
  74998. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74999. }
  75000. }
  75001. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  75002. import { Nullable } from "babylonjs/types";
  75003. import { Camera } from "babylonjs/Cameras/camera";
  75004. import { Engine } from "babylonjs/Engines/engine";
  75005. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75006. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75007. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75008. /**
  75009. * PostProcessRenderPipeline
  75010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75011. */
  75012. export class PostProcessRenderPipeline {
  75013. private engine;
  75014. private _renderEffects;
  75015. private _renderEffectsForIsolatedPass;
  75016. /**
  75017. * List of inspectable custom properties (used by the Inspector)
  75018. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75019. */
  75020. inspectableCustomProperties: IInspectable[];
  75021. /**
  75022. * @hidden
  75023. */
  75024. protected _cameras: Camera[];
  75025. /** @hidden */
  75026. _name: string;
  75027. /**
  75028. * Gets pipeline name
  75029. */
  75030. get name(): string;
  75031. /** Gets the list of attached cameras */
  75032. get cameras(): Camera[];
  75033. /**
  75034. * Initializes a PostProcessRenderPipeline
  75035. * @param engine engine to add the pipeline to
  75036. * @param name name of the pipeline
  75037. */
  75038. constructor(engine: Engine, name: string);
  75039. /**
  75040. * Gets the class name
  75041. * @returns "PostProcessRenderPipeline"
  75042. */
  75043. getClassName(): string;
  75044. /**
  75045. * If all the render effects in the pipeline are supported
  75046. */
  75047. get isSupported(): boolean;
  75048. /**
  75049. * Adds an effect to the pipeline
  75050. * @param renderEffect the effect to add
  75051. */
  75052. addEffect(renderEffect: PostProcessRenderEffect): void;
  75053. /** @hidden */
  75054. _rebuild(): void;
  75055. /** @hidden */
  75056. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75057. /** @hidden */
  75058. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75059. /** @hidden */
  75060. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75061. /** @hidden */
  75062. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75063. /** @hidden */
  75064. _attachCameras(cameras: Camera, unique: boolean): void;
  75065. /** @hidden */
  75066. _attachCameras(cameras: Camera[], unique: boolean): void;
  75067. /** @hidden */
  75068. _detachCameras(cameras: Camera): void;
  75069. /** @hidden */
  75070. _detachCameras(cameras: Nullable<Camera[]>): void;
  75071. /** @hidden */
  75072. _update(): void;
  75073. /** @hidden */
  75074. _reset(): void;
  75075. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75076. /**
  75077. * Sets the required values to the prepass renderer.
  75078. * @param prePassRenderer defines the prepass renderer to setup.
  75079. * @returns true if the pre pass is needed.
  75080. */
  75081. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75082. /**
  75083. * Disposes of the pipeline
  75084. */
  75085. dispose(): void;
  75086. }
  75087. }
  75088. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75089. import { Camera } from "babylonjs/Cameras/camera";
  75090. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75091. /**
  75092. * PostProcessRenderPipelineManager class
  75093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75094. */
  75095. export class PostProcessRenderPipelineManager {
  75096. private _renderPipelines;
  75097. /**
  75098. * Initializes a PostProcessRenderPipelineManager
  75099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75100. */
  75101. constructor();
  75102. /**
  75103. * Gets the list of supported render pipelines
  75104. */
  75105. get supportedPipelines(): PostProcessRenderPipeline[];
  75106. /**
  75107. * Adds a pipeline to the manager
  75108. * @param renderPipeline The pipeline to add
  75109. */
  75110. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75111. /**
  75112. * Attaches a camera to the pipeline
  75113. * @param renderPipelineName The name of the pipeline to attach to
  75114. * @param cameras the camera to attach
  75115. * @param unique if the camera can be attached multiple times to the pipeline
  75116. */
  75117. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75118. /**
  75119. * Detaches a camera from the pipeline
  75120. * @param renderPipelineName The name of the pipeline to detach from
  75121. * @param cameras the camera to detach
  75122. */
  75123. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75124. /**
  75125. * Enables an effect by name on a pipeline
  75126. * @param renderPipelineName the name of the pipeline to enable the effect in
  75127. * @param renderEffectName the name of the effect to enable
  75128. * @param cameras the cameras that the effect should be enabled on
  75129. */
  75130. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75131. /**
  75132. * Disables an effect by name on a pipeline
  75133. * @param renderPipelineName the name of the pipeline to disable the effect in
  75134. * @param renderEffectName the name of the effect to disable
  75135. * @param cameras the cameras that the effect should be disabled on
  75136. */
  75137. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75138. /**
  75139. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75140. */
  75141. update(): void;
  75142. /** @hidden */
  75143. _rebuild(): void;
  75144. /**
  75145. * Disposes of the manager and pipelines
  75146. */
  75147. dispose(): void;
  75148. }
  75149. }
  75150. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75151. import { ISceneComponent } from "babylonjs/sceneComponent";
  75152. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75153. import { Scene } from "babylonjs/scene";
  75154. module "babylonjs/scene" {
  75155. interface Scene {
  75156. /** @hidden (Backing field) */
  75157. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75158. /**
  75159. * Gets the postprocess render pipeline manager
  75160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75161. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75162. */
  75163. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75164. }
  75165. }
  75166. /**
  75167. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75168. */
  75169. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75170. /**
  75171. * The component name helpfull to identify the component in the list of scene components.
  75172. */
  75173. readonly name: string;
  75174. /**
  75175. * The scene the component belongs to.
  75176. */
  75177. scene: Scene;
  75178. /**
  75179. * Creates a new instance of the component for the given scene
  75180. * @param scene Defines the scene to register the component in
  75181. */
  75182. constructor(scene: Scene);
  75183. /**
  75184. * Registers the component in a given scene
  75185. */
  75186. register(): void;
  75187. /**
  75188. * Rebuilds the elements related to this component in case of
  75189. * context lost for instance.
  75190. */
  75191. rebuild(): void;
  75192. /**
  75193. * Disposes the component and the associated ressources
  75194. */
  75195. dispose(): void;
  75196. private _gatherRenderTargets;
  75197. }
  75198. }
  75199. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75200. import { Nullable } from "babylonjs/types";
  75201. import { Observable } from "babylonjs/Misc/observable";
  75202. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75203. import { Camera } from "babylonjs/Cameras/camera";
  75204. import { IDisposable } from "babylonjs/scene";
  75205. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75206. import { Scene } from "babylonjs/scene";
  75207. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75208. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75209. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75210. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75211. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75212. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75213. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75214. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75215. import { Animation } from "babylonjs/Animations/animation";
  75216. /**
  75217. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75218. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75219. */
  75220. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75221. private _scene;
  75222. private _camerasToBeAttached;
  75223. /**
  75224. * ID of the sharpen post process,
  75225. */
  75226. private readonly SharpenPostProcessId;
  75227. /**
  75228. * @ignore
  75229. * ID of the image processing post process;
  75230. */
  75231. readonly ImageProcessingPostProcessId: string;
  75232. /**
  75233. * @ignore
  75234. * ID of the Fast Approximate Anti-Aliasing post process;
  75235. */
  75236. readonly FxaaPostProcessId: string;
  75237. /**
  75238. * ID of the chromatic aberration post process,
  75239. */
  75240. private readonly ChromaticAberrationPostProcessId;
  75241. /**
  75242. * ID of the grain post process
  75243. */
  75244. private readonly GrainPostProcessId;
  75245. /**
  75246. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75247. */
  75248. sharpen: SharpenPostProcess;
  75249. private _sharpenEffect;
  75250. private bloom;
  75251. /**
  75252. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75253. */
  75254. depthOfField: DepthOfFieldEffect;
  75255. /**
  75256. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75257. */
  75258. fxaa: FxaaPostProcess;
  75259. /**
  75260. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75261. */
  75262. imageProcessing: ImageProcessingPostProcess;
  75263. /**
  75264. * Chromatic aberration post process which will shift rgb colors in the image
  75265. */
  75266. chromaticAberration: ChromaticAberrationPostProcess;
  75267. private _chromaticAberrationEffect;
  75268. /**
  75269. * Grain post process which add noise to the image
  75270. */
  75271. grain: GrainPostProcess;
  75272. private _grainEffect;
  75273. /**
  75274. * Glow post process which adds a glow to emissive areas of the image
  75275. */
  75276. private _glowLayer;
  75277. /**
  75278. * Animations which can be used to tweak settings over a period of time
  75279. */
  75280. animations: Animation[];
  75281. private _imageProcessingConfigurationObserver;
  75282. private _sharpenEnabled;
  75283. private _bloomEnabled;
  75284. private _depthOfFieldEnabled;
  75285. private _depthOfFieldBlurLevel;
  75286. private _fxaaEnabled;
  75287. private _imageProcessingEnabled;
  75288. private _defaultPipelineTextureType;
  75289. private _bloomScale;
  75290. private _chromaticAberrationEnabled;
  75291. private _grainEnabled;
  75292. private _buildAllowed;
  75293. /**
  75294. * This is triggered each time the pipeline has been built.
  75295. */
  75296. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75297. /**
  75298. * Gets active scene
  75299. */
  75300. get scene(): Scene;
  75301. /**
  75302. * Enable or disable the sharpen process from the pipeline
  75303. */
  75304. set sharpenEnabled(enabled: boolean);
  75305. get sharpenEnabled(): boolean;
  75306. private _resizeObserver;
  75307. private _hardwareScaleLevel;
  75308. private _bloomKernel;
  75309. /**
  75310. * Specifies the size of the bloom blur kernel, relative to the final output size
  75311. */
  75312. get bloomKernel(): number;
  75313. set bloomKernel(value: number);
  75314. /**
  75315. * Specifies the weight of the bloom in the final rendering
  75316. */
  75317. private _bloomWeight;
  75318. /**
  75319. * Specifies the luma threshold for the area that will be blurred by the bloom
  75320. */
  75321. private _bloomThreshold;
  75322. private _hdr;
  75323. /**
  75324. * The strength of the bloom.
  75325. */
  75326. set bloomWeight(value: number);
  75327. get bloomWeight(): number;
  75328. /**
  75329. * The strength of the bloom.
  75330. */
  75331. set bloomThreshold(value: number);
  75332. get bloomThreshold(): number;
  75333. /**
  75334. * The scale of the bloom, lower value will provide better performance.
  75335. */
  75336. set bloomScale(value: number);
  75337. get bloomScale(): number;
  75338. /**
  75339. * Enable or disable the bloom from the pipeline
  75340. */
  75341. set bloomEnabled(enabled: boolean);
  75342. get bloomEnabled(): boolean;
  75343. private _rebuildBloom;
  75344. /**
  75345. * If the depth of field is enabled.
  75346. */
  75347. get depthOfFieldEnabled(): boolean;
  75348. set depthOfFieldEnabled(enabled: boolean);
  75349. /**
  75350. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75351. */
  75352. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75353. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75354. /**
  75355. * If the anti aliasing is enabled.
  75356. */
  75357. set fxaaEnabled(enabled: boolean);
  75358. get fxaaEnabled(): boolean;
  75359. private _samples;
  75360. /**
  75361. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75362. */
  75363. set samples(sampleCount: number);
  75364. get samples(): number;
  75365. /**
  75366. * If image processing is enabled.
  75367. */
  75368. set imageProcessingEnabled(enabled: boolean);
  75369. get imageProcessingEnabled(): boolean;
  75370. /**
  75371. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75372. */
  75373. set glowLayerEnabled(enabled: boolean);
  75374. get glowLayerEnabled(): boolean;
  75375. /**
  75376. * Gets the glow layer (or null if not defined)
  75377. */
  75378. get glowLayer(): Nullable<GlowLayer>;
  75379. /**
  75380. * Enable or disable the chromaticAberration process from the pipeline
  75381. */
  75382. set chromaticAberrationEnabled(enabled: boolean);
  75383. get chromaticAberrationEnabled(): boolean;
  75384. /**
  75385. * Enable or disable the grain process from the pipeline
  75386. */
  75387. set grainEnabled(enabled: boolean);
  75388. get grainEnabled(): boolean;
  75389. /**
  75390. * @constructor
  75391. * @param name - The rendering pipeline name (default: "")
  75392. * @param hdr - If high dynamic range textures should be used (default: true)
  75393. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75394. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75395. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75396. */
  75397. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75398. /**
  75399. * Get the class name
  75400. * @returns "DefaultRenderingPipeline"
  75401. */
  75402. getClassName(): string;
  75403. /**
  75404. * Force the compilation of the entire pipeline.
  75405. */
  75406. prepare(): void;
  75407. private _hasCleared;
  75408. private _prevPostProcess;
  75409. private _prevPrevPostProcess;
  75410. private _setAutoClearAndTextureSharing;
  75411. private _depthOfFieldSceneObserver;
  75412. private _buildPipeline;
  75413. private _disposePostProcesses;
  75414. /**
  75415. * Adds a camera to the pipeline
  75416. * @param camera the camera to be added
  75417. */
  75418. addCamera(camera: Camera): void;
  75419. /**
  75420. * Removes a camera from the pipeline
  75421. * @param camera the camera to remove
  75422. */
  75423. removeCamera(camera: Camera): void;
  75424. /**
  75425. * Dispose of the pipeline and stop all post processes
  75426. */
  75427. dispose(): void;
  75428. /**
  75429. * Serialize the rendering pipeline (Used when exporting)
  75430. * @returns the serialized object
  75431. */
  75432. serialize(): any;
  75433. /**
  75434. * Parse the serialized pipeline
  75435. * @param source Source pipeline.
  75436. * @param scene The scene to load the pipeline to.
  75437. * @param rootUrl The URL of the serialized pipeline.
  75438. * @returns An instantiated pipeline from the serialized object.
  75439. */
  75440. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75441. }
  75442. }
  75443. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75444. /** @hidden */
  75445. export var lensHighlightsPixelShader: {
  75446. name: string;
  75447. shader: string;
  75448. };
  75449. }
  75450. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75451. /** @hidden */
  75452. export var depthOfFieldPixelShader: {
  75453. name: string;
  75454. shader: string;
  75455. };
  75456. }
  75457. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75458. import { Camera } from "babylonjs/Cameras/camera";
  75459. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75460. import { Scene } from "babylonjs/scene";
  75461. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75462. import "babylonjs/Shaders/chromaticAberration.fragment";
  75463. import "babylonjs/Shaders/lensHighlights.fragment";
  75464. import "babylonjs/Shaders/depthOfField.fragment";
  75465. /**
  75466. * BABYLON.JS Chromatic Aberration GLSL Shader
  75467. * Author: Olivier Guyot
  75468. * Separates very slightly R, G and B colors on the edges of the screen
  75469. * Inspired by Francois Tarlier & Martins Upitis
  75470. */
  75471. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75472. /**
  75473. * @ignore
  75474. * The chromatic aberration PostProcess id in the pipeline
  75475. */
  75476. LensChromaticAberrationEffect: string;
  75477. /**
  75478. * @ignore
  75479. * The highlights enhancing PostProcess id in the pipeline
  75480. */
  75481. HighlightsEnhancingEffect: string;
  75482. /**
  75483. * @ignore
  75484. * The depth-of-field PostProcess id in the pipeline
  75485. */
  75486. LensDepthOfFieldEffect: string;
  75487. private _scene;
  75488. private _depthTexture;
  75489. private _grainTexture;
  75490. private _chromaticAberrationPostProcess;
  75491. private _highlightsPostProcess;
  75492. private _depthOfFieldPostProcess;
  75493. private _edgeBlur;
  75494. private _grainAmount;
  75495. private _chromaticAberration;
  75496. private _distortion;
  75497. private _highlightsGain;
  75498. private _highlightsThreshold;
  75499. private _dofDistance;
  75500. private _dofAperture;
  75501. private _dofDarken;
  75502. private _dofPentagon;
  75503. private _blurNoise;
  75504. /**
  75505. * @constructor
  75506. *
  75507. * Effect parameters are as follow:
  75508. * {
  75509. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75510. * edge_blur: number; // from 0 to x (1 for realism)
  75511. * distortion: number; // from 0 to x (1 for realism)
  75512. * grain_amount: number; // from 0 to 1
  75513. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75514. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75515. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75516. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75517. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75518. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75519. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75520. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75521. * }
  75522. * Note: if an effect parameter is unset, effect is disabled
  75523. *
  75524. * @param name The rendering pipeline name
  75525. * @param parameters - An object containing all parameters (see above)
  75526. * @param scene The scene linked to this pipeline
  75527. * @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)
  75528. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75529. */
  75530. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75531. /**
  75532. * Get the class name
  75533. * @returns "LensRenderingPipeline"
  75534. */
  75535. getClassName(): string;
  75536. /**
  75537. * Gets associated scene
  75538. */
  75539. get scene(): Scene;
  75540. /**
  75541. * Gets or sets the edge blur
  75542. */
  75543. get edgeBlur(): number;
  75544. set edgeBlur(value: number);
  75545. /**
  75546. * Gets or sets the grain amount
  75547. */
  75548. get grainAmount(): number;
  75549. set grainAmount(value: number);
  75550. /**
  75551. * Gets or sets the chromatic aberration amount
  75552. */
  75553. get chromaticAberration(): number;
  75554. set chromaticAberration(value: number);
  75555. /**
  75556. * Gets or sets the depth of field aperture
  75557. */
  75558. get dofAperture(): number;
  75559. set dofAperture(value: number);
  75560. /**
  75561. * Gets or sets the edge distortion
  75562. */
  75563. get edgeDistortion(): number;
  75564. set edgeDistortion(value: number);
  75565. /**
  75566. * Gets or sets the depth of field distortion
  75567. */
  75568. get dofDistortion(): number;
  75569. set dofDistortion(value: number);
  75570. /**
  75571. * Gets or sets the darken out of focus amount
  75572. */
  75573. get darkenOutOfFocus(): number;
  75574. set darkenOutOfFocus(value: number);
  75575. /**
  75576. * Gets or sets a boolean indicating if blur noise is enabled
  75577. */
  75578. get blurNoise(): boolean;
  75579. set blurNoise(value: boolean);
  75580. /**
  75581. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75582. */
  75583. get pentagonBokeh(): boolean;
  75584. set pentagonBokeh(value: boolean);
  75585. /**
  75586. * Gets or sets the highlight grain amount
  75587. */
  75588. get highlightsGain(): number;
  75589. set highlightsGain(value: number);
  75590. /**
  75591. * Gets or sets the highlight threshold
  75592. */
  75593. get highlightsThreshold(): number;
  75594. set highlightsThreshold(value: number);
  75595. /**
  75596. * Sets the amount of blur at the edges
  75597. * @param amount blur amount
  75598. */
  75599. setEdgeBlur(amount: number): void;
  75600. /**
  75601. * Sets edge blur to 0
  75602. */
  75603. disableEdgeBlur(): void;
  75604. /**
  75605. * Sets the amout of grain
  75606. * @param amount Amount of grain
  75607. */
  75608. setGrainAmount(amount: number): void;
  75609. /**
  75610. * Set grain amount to 0
  75611. */
  75612. disableGrain(): void;
  75613. /**
  75614. * Sets the chromatic aberration amount
  75615. * @param amount amount of chromatic aberration
  75616. */
  75617. setChromaticAberration(amount: number): void;
  75618. /**
  75619. * Sets chromatic aberration amount to 0
  75620. */
  75621. disableChromaticAberration(): void;
  75622. /**
  75623. * Sets the EdgeDistortion amount
  75624. * @param amount amount of EdgeDistortion
  75625. */
  75626. setEdgeDistortion(amount: number): void;
  75627. /**
  75628. * Sets edge distortion to 0
  75629. */
  75630. disableEdgeDistortion(): void;
  75631. /**
  75632. * Sets the FocusDistance amount
  75633. * @param amount amount of FocusDistance
  75634. */
  75635. setFocusDistance(amount: number): void;
  75636. /**
  75637. * Disables depth of field
  75638. */
  75639. disableDepthOfField(): void;
  75640. /**
  75641. * Sets the Aperture amount
  75642. * @param amount amount of Aperture
  75643. */
  75644. setAperture(amount: number): void;
  75645. /**
  75646. * Sets the DarkenOutOfFocus amount
  75647. * @param amount amount of DarkenOutOfFocus
  75648. */
  75649. setDarkenOutOfFocus(amount: number): void;
  75650. private _pentagonBokehIsEnabled;
  75651. /**
  75652. * Creates a pentagon bokeh effect
  75653. */
  75654. enablePentagonBokeh(): void;
  75655. /**
  75656. * Disables the pentagon bokeh effect
  75657. */
  75658. disablePentagonBokeh(): void;
  75659. /**
  75660. * Enables noise blur
  75661. */
  75662. enableNoiseBlur(): void;
  75663. /**
  75664. * Disables noise blur
  75665. */
  75666. disableNoiseBlur(): void;
  75667. /**
  75668. * Sets the HighlightsGain amount
  75669. * @param amount amount of HighlightsGain
  75670. */
  75671. setHighlightsGain(amount: number): void;
  75672. /**
  75673. * Sets the HighlightsThreshold amount
  75674. * @param amount amount of HighlightsThreshold
  75675. */
  75676. setHighlightsThreshold(amount: number): void;
  75677. /**
  75678. * Disables highlights
  75679. */
  75680. disableHighlights(): void;
  75681. /**
  75682. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75683. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75684. */
  75685. dispose(disableDepthRender?: boolean): void;
  75686. private _createChromaticAberrationPostProcess;
  75687. private _createHighlightsPostProcess;
  75688. private _createDepthOfFieldPostProcess;
  75689. private _createGrainTexture;
  75690. }
  75691. }
  75692. declare module "babylonjs/Rendering/ssao2Configuration" {
  75693. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75694. /**
  75695. * Contains all parameters needed for the prepass to perform
  75696. * screen space subsurface scattering
  75697. */
  75698. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75699. /**
  75700. * Is subsurface enabled
  75701. */
  75702. enabled: boolean;
  75703. /**
  75704. * Name of the configuration
  75705. */
  75706. name: string;
  75707. /**
  75708. * Textures that should be present in the MRT for this effect to work
  75709. */
  75710. readonly texturesRequired: number[];
  75711. }
  75712. }
  75713. declare module "babylonjs/Shaders/ssao2.fragment" {
  75714. /** @hidden */
  75715. export var ssao2PixelShader: {
  75716. name: string;
  75717. shader: string;
  75718. };
  75719. }
  75720. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75721. /** @hidden */
  75722. export var ssaoCombinePixelShader: {
  75723. name: string;
  75724. shader: string;
  75725. };
  75726. }
  75727. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75728. import { Camera } from "babylonjs/Cameras/camera";
  75729. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75730. import { Scene } from "babylonjs/scene";
  75731. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75732. import "babylonjs/Shaders/ssao2.fragment";
  75733. import "babylonjs/Shaders/ssaoCombine.fragment";
  75734. /**
  75735. * Render pipeline to produce ssao effect
  75736. */
  75737. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75738. /**
  75739. * @ignore
  75740. * The PassPostProcess id in the pipeline that contains the original scene color
  75741. */
  75742. SSAOOriginalSceneColorEffect: string;
  75743. /**
  75744. * @ignore
  75745. * The SSAO PostProcess id in the pipeline
  75746. */
  75747. SSAORenderEffect: string;
  75748. /**
  75749. * @ignore
  75750. * The horizontal blur PostProcess id in the pipeline
  75751. */
  75752. SSAOBlurHRenderEffect: string;
  75753. /**
  75754. * @ignore
  75755. * The vertical blur PostProcess id in the pipeline
  75756. */
  75757. SSAOBlurVRenderEffect: string;
  75758. /**
  75759. * @ignore
  75760. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75761. */
  75762. SSAOCombineRenderEffect: string;
  75763. /**
  75764. * The output strength of the SSAO post-process. Default value is 1.0.
  75765. */
  75766. totalStrength: number;
  75767. /**
  75768. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75769. */
  75770. maxZ: number;
  75771. /**
  75772. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75773. */
  75774. minZAspect: number;
  75775. private _samples;
  75776. /**
  75777. * Number of samples used for the SSAO calculations. Default value is 8
  75778. */
  75779. set samples(n: number);
  75780. get samples(): number;
  75781. private _textureSamples;
  75782. /**
  75783. * Number of samples to use for antialiasing
  75784. */
  75785. set textureSamples(n: number);
  75786. get textureSamples(): number;
  75787. /**
  75788. * Force rendering the geometry through geometry buffer
  75789. */
  75790. private _forceGeometryBuffer;
  75791. /**
  75792. * Ratio object used for SSAO ratio and blur ratio
  75793. */
  75794. private _ratio;
  75795. /**
  75796. * Dynamically generated sphere sampler.
  75797. */
  75798. private _sampleSphere;
  75799. /**
  75800. * Blur filter offsets
  75801. */
  75802. private _samplerOffsets;
  75803. private _expensiveBlur;
  75804. /**
  75805. * If bilateral blur should be used
  75806. */
  75807. set expensiveBlur(b: boolean);
  75808. get expensiveBlur(): boolean;
  75809. /**
  75810. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75811. */
  75812. radius: number;
  75813. /**
  75814. * The base color of the SSAO post-process
  75815. * The final result is "base + ssao" between [0, 1]
  75816. */
  75817. base: number;
  75818. /**
  75819. * Support test.
  75820. */
  75821. static get IsSupported(): boolean;
  75822. private _scene;
  75823. private _randomTexture;
  75824. private _originalColorPostProcess;
  75825. private _ssaoPostProcess;
  75826. private _blurHPostProcess;
  75827. private _blurVPostProcess;
  75828. private _ssaoCombinePostProcess;
  75829. private _prePassRenderer;
  75830. /**
  75831. * Gets active scene
  75832. */
  75833. get scene(): Scene;
  75834. /**
  75835. * @constructor
  75836. * @param name The rendering pipeline name
  75837. * @param scene The scene linked to this pipeline
  75838. * @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 }
  75839. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75840. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75841. */
  75842. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75843. /**
  75844. * Get the class name
  75845. * @returns "SSAO2RenderingPipeline"
  75846. */
  75847. getClassName(): string;
  75848. /**
  75849. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75850. */
  75851. dispose(disableGeometryBufferRenderer?: boolean): void;
  75852. private _createBlurPostProcess;
  75853. /** @hidden */
  75854. _rebuild(): void;
  75855. private _bits;
  75856. private _radicalInverse_VdC;
  75857. private _hammersley;
  75858. private _hemisphereSample_uniform;
  75859. private _generateHemisphere;
  75860. private _getDefinesForSSAO;
  75861. private _createSSAOPostProcess;
  75862. private _createSSAOCombinePostProcess;
  75863. private _createRandomTexture;
  75864. /**
  75865. * Serialize the rendering pipeline (Used when exporting)
  75866. * @returns the serialized object
  75867. */
  75868. serialize(): any;
  75869. /**
  75870. * Parse the serialized pipeline
  75871. * @param source Source pipeline.
  75872. * @param scene The scene to load the pipeline to.
  75873. * @param rootUrl The URL of the serialized pipeline.
  75874. * @returns An instantiated pipeline from the serialized object.
  75875. */
  75876. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75877. }
  75878. }
  75879. declare module "babylonjs/Shaders/ssao.fragment" {
  75880. /** @hidden */
  75881. export var ssaoPixelShader: {
  75882. name: string;
  75883. shader: string;
  75884. };
  75885. }
  75886. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75887. import { Camera } from "babylonjs/Cameras/camera";
  75888. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75889. import { Scene } from "babylonjs/scene";
  75890. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75891. import "babylonjs/Shaders/ssao.fragment";
  75892. import "babylonjs/Shaders/ssaoCombine.fragment";
  75893. /**
  75894. * Render pipeline to produce ssao effect
  75895. */
  75896. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75897. /**
  75898. * @ignore
  75899. * The PassPostProcess id in the pipeline that contains the original scene color
  75900. */
  75901. SSAOOriginalSceneColorEffect: string;
  75902. /**
  75903. * @ignore
  75904. * The SSAO PostProcess id in the pipeline
  75905. */
  75906. SSAORenderEffect: string;
  75907. /**
  75908. * @ignore
  75909. * The horizontal blur PostProcess id in the pipeline
  75910. */
  75911. SSAOBlurHRenderEffect: string;
  75912. /**
  75913. * @ignore
  75914. * The vertical blur PostProcess id in the pipeline
  75915. */
  75916. SSAOBlurVRenderEffect: string;
  75917. /**
  75918. * @ignore
  75919. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75920. */
  75921. SSAOCombineRenderEffect: string;
  75922. /**
  75923. * The output strength of the SSAO post-process. Default value is 1.0.
  75924. */
  75925. totalStrength: number;
  75926. /**
  75927. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75928. */
  75929. radius: number;
  75930. /**
  75931. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75932. * Must not be equal to fallOff and superior to fallOff.
  75933. * Default value is 0.0075
  75934. */
  75935. area: number;
  75936. /**
  75937. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75938. * Must not be equal to area and inferior to area.
  75939. * Default value is 0.000001
  75940. */
  75941. fallOff: number;
  75942. /**
  75943. * The base color of the SSAO post-process
  75944. * The final result is "base + ssao" between [0, 1]
  75945. */
  75946. base: number;
  75947. private _scene;
  75948. private _depthTexture;
  75949. private _randomTexture;
  75950. private _originalColorPostProcess;
  75951. private _ssaoPostProcess;
  75952. private _blurHPostProcess;
  75953. private _blurVPostProcess;
  75954. private _ssaoCombinePostProcess;
  75955. private _firstUpdate;
  75956. /**
  75957. * Gets active scene
  75958. */
  75959. get scene(): Scene;
  75960. /**
  75961. * @constructor
  75962. * @param name - The rendering pipeline name
  75963. * @param scene - The scene linked to this pipeline
  75964. * @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 }
  75965. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75966. */
  75967. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75968. /**
  75969. * Get the class name
  75970. * @returns "SSAORenderingPipeline"
  75971. */
  75972. getClassName(): string;
  75973. /**
  75974. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75975. */
  75976. dispose(disableDepthRender?: boolean): void;
  75977. private _createBlurPostProcess;
  75978. /** @hidden */
  75979. _rebuild(): void;
  75980. private _createSSAOPostProcess;
  75981. private _createSSAOCombinePostProcess;
  75982. private _createRandomTexture;
  75983. }
  75984. }
  75985. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75986. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75987. /**
  75988. * Contains all parameters needed for the prepass to perform
  75989. * screen space reflections
  75990. */
  75991. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75992. /**
  75993. * Is ssr enabled
  75994. */
  75995. enabled: boolean;
  75996. /**
  75997. * Name of the configuration
  75998. */
  75999. name: string;
  76000. /**
  76001. * Textures that should be present in the MRT for this effect to work
  76002. */
  76003. readonly texturesRequired: number[];
  76004. }
  76005. }
  76006. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  76007. /** @hidden */
  76008. export var screenSpaceReflectionPixelShader: {
  76009. name: string;
  76010. shader: string;
  76011. };
  76012. }
  76013. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76014. import { Nullable } from "babylonjs/types";
  76015. import { Camera } from "babylonjs/Cameras/camera";
  76016. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76017. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76018. import { Engine } from "babylonjs/Engines/engine";
  76019. import { Scene } from "babylonjs/scene";
  76020. /**
  76021. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76022. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76023. */
  76024. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76025. /**
  76026. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76027. */
  76028. threshold: number;
  76029. /**
  76030. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76031. */
  76032. strength: number;
  76033. /**
  76034. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76035. */
  76036. reflectionSpecularFalloffExponent: number;
  76037. /**
  76038. * 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]
  76039. */
  76040. step: number;
  76041. /**
  76042. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76043. */
  76044. roughnessFactor: number;
  76045. private _forceGeometryBuffer;
  76046. private _geometryBufferRenderer;
  76047. private _prePassRenderer;
  76048. private _enableSmoothReflections;
  76049. private _reflectionSamples;
  76050. private _smoothSteps;
  76051. /**
  76052. * Gets a string identifying the name of the class
  76053. * @returns "ScreenSpaceReflectionPostProcess" string
  76054. */
  76055. getClassName(): string;
  76056. /**
  76057. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76058. * @param name The name of the effect.
  76059. * @param scene The scene containing the objects to calculate reflections.
  76060. * @param options The required width/height ratio to downsize to before computing the render pass.
  76061. * @param camera The camera to apply the render pass to.
  76062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76063. * @param engine The engine which the post process will be applied. (default: current engine)
  76064. * @param reusable If the post process can be reused on the same frame. (default: false)
  76065. * @param textureType Type of textures used when performing the post process. (default: 0)
  76066. * @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)
  76067. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76068. */
  76069. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76070. /**
  76071. * Gets wether or not smoothing reflections is enabled.
  76072. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76073. */
  76074. get enableSmoothReflections(): boolean;
  76075. /**
  76076. * Sets wether or not smoothing reflections is enabled.
  76077. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76078. */
  76079. set enableSmoothReflections(enabled: boolean);
  76080. /**
  76081. * Gets the number of samples taken while computing reflections. More samples count is high,
  76082. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76083. */
  76084. get reflectionSamples(): number;
  76085. /**
  76086. * Sets the number of samples taken while computing reflections. More samples count is high,
  76087. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76088. */
  76089. set reflectionSamples(samples: number);
  76090. /**
  76091. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76092. * more the post-process will require GPU power and can generate a drop in FPS.
  76093. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76094. */
  76095. get smoothSteps(): number;
  76096. set smoothSteps(steps: number);
  76097. private _updateEffectDefines;
  76098. /** @hidden */
  76099. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76100. }
  76101. }
  76102. declare module "babylonjs/Shaders/standard.fragment" {
  76103. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76104. /** @hidden */
  76105. export var standardPixelShader: {
  76106. name: string;
  76107. shader: string;
  76108. };
  76109. }
  76110. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76111. import { Nullable } from "babylonjs/types";
  76112. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76113. import { Camera } from "babylonjs/Cameras/camera";
  76114. import { Texture } from "babylonjs/Materials/Textures/texture";
  76115. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76116. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76117. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76118. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76119. import { IDisposable } from "babylonjs/scene";
  76120. import { SpotLight } from "babylonjs/Lights/spotLight";
  76121. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76122. import { Scene } from "babylonjs/scene";
  76123. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76124. import { Animation } from "babylonjs/Animations/animation";
  76125. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76126. import "babylonjs/Shaders/standard.fragment";
  76127. /**
  76128. * Standard rendering pipeline
  76129. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76130. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76131. */
  76132. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76133. /**
  76134. * Public members
  76135. */
  76136. /**
  76137. * Post-process which contains the original scene color before the pipeline applies all the effects
  76138. */
  76139. originalPostProcess: Nullable<PostProcess>;
  76140. /**
  76141. * Post-process used to down scale an image x4
  76142. */
  76143. downSampleX4PostProcess: Nullable<PostProcess>;
  76144. /**
  76145. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76146. */
  76147. brightPassPostProcess: Nullable<PostProcess>;
  76148. /**
  76149. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76150. */
  76151. blurHPostProcesses: PostProcess[];
  76152. /**
  76153. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76154. */
  76155. blurVPostProcesses: PostProcess[];
  76156. /**
  76157. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76158. */
  76159. textureAdderPostProcess: Nullable<PostProcess>;
  76160. /**
  76161. * Post-process used to create volumetric lighting effect
  76162. */
  76163. volumetricLightPostProcess: Nullable<PostProcess>;
  76164. /**
  76165. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76166. */
  76167. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76168. /**
  76169. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76170. */
  76171. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76172. /**
  76173. * Post-process used to merge the volumetric light effect and the real scene color
  76174. */
  76175. volumetricLightMergePostProces: Nullable<PostProcess>;
  76176. /**
  76177. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76178. */
  76179. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76180. /**
  76181. * Base post-process used to calculate the average luminance of the final image for HDR
  76182. */
  76183. luminancePostProcess: Nullable<PostProcess>;
  76184. /**
  76185. * Post-processes used to create down sample post-processes in order to get
  76186. * the average luminance of the final image for HDR
  76187. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76188. */
  76189. luminanceDownSamplePostProcesses: PostProcess[];
  76190. /**
  76191. * Post-process used to create a HDR effect (light adaptation)
  76192. */
  76193. hdrPostProcess: Nullable<PostProcess>;
  76194. /**
  76195. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76196. */
  76197. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76198. /**
  76199. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76200. */
  76201. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76202. /**
  76203. * Post-process used to merge the final HDR post-process and the real scene color
  76204. */
  76205. hdrFinalPostProcess: Nullable<PostProcess>;
  76206. /**
  76207. * Post-process used to create a lens flare effect
  76208. */
  76209. lensFlarePostProcess: Nullable<PostProcess>;
  76210. /**
  76211. * Post-process that merges the result of the lens flare post-process and the real scene color
  76212. */
  76213. lensFlareComposePostProcess: Nullable<PostProcess>;
  76214. /**
  76215. * Post-process used to create a motion blur effect
  76216. */
  76217. motionBlurPostProcess: Nullable<PostProcess>;
  76218. /**
  76219. * Post-process used to create a depth of field effect
  76220. */
  76221. depthOfFieldPostProcess: Nullable<PostProcess>;
  76222. /**
  76223. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76224. */
  76225. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76226. /**
  76227. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76228. */
  76229. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76230. /**
  76231. * Represents the brightness threshold in order to configure the illuminated surfaces
  76232. */
  76233. brightThreshold: number;
  76234. /**
  76235. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76236. */
  76237. blurWidth: number;
  76238. /**
  76239. * Sets if the blur for highlighted surfaces must be only horizontal
  76240. */
  76241. horizontalBlur: boolean;
  76242. /**
  76243. * Gets the overall exposure used by the pipeline
  76244. */
  76245. get exposure(): number;
  76246. /**
  76247. * Sets the overall exposure used by the pipeline
  76248. */
  76249. set exposure(value: number);
  76250. /**
  76251. * Texture used typically to simulate "dirty" on camera lens
  76252. */
  76253. lensTexture: Nullable<Texture>;
  76254. /**
  76255. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76256. */
  76257. volumetricLightCoefficient: number;
  76258. /**
  76259. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76260. */
  76261. volumetricLightPower: number;
  76262. /**
  76263. * Used the set the blur intensity to smooth the volumetric lights
  76264. */
  76265. volumetricLightBlurScale: number;
  76266. /**
  76267. * Light (spot or directional) used to generate the volumetric lights rays
  76268. * The source light must have a shadow generate so the pipeline can get its
  76269. * depth map
  76270. */
  76271. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76272. /**
  76273. * For eye adaptation, represents the minimum luminance the eye can see
  76274. */
  76275. hdrMinimumLuminance: number;
  76276. /**
  76277. * For eye adaptation, represents the decrease luminance speed
  76278. */
  76279. hdrDecreaseRate: number;
  76280. /**
  76281. * For eye adaptation, represents the increase luminance speed
  76282. */
  76283. hdrIncreaseRate: number;
  76284. /**
  76285. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76286. */
  76287. get hdrAutoExposure(): boolean;
  76288. /**
  76289. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76290. */
  76291. set hdrAutoExposure(value: boolean);
  76292. /**
  76293. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76294. */
  76295. lensColorTexture: Nullable<Texture>;
  76296. /**
  76297. * The overall strengh for the lens flare effect
  76298. */
  76299. lensFlareStrength: number;
  76300. /**
  76301. * Dispersion coefficient for lens flare ghosts
  76302. */
  76303. lensFlareGhostDispersal: number;
  76304. /**
  76305. * Main lens flare halo width
  76306. */
  76307. lensFlareHaloWidth: number;
  76308. /**
  76309. * Based on the lens distortion effect, defines how much the lens flare result
  76310. * is distorted
  76311. */
  76312. lensFlareDistortionStrength: number;
  76313. /**
  76314. * Configures the blur intensity used for for lens flare (halo)
  76315. */
  76316. lensFlareBlurWidth: number;
  76317. /**
  76318. * Lens star texture must be used to simulate rays on the flares and is available
  76319. * in the documentation
  76320. */
  76321. lensStarTexture: Nullable<Texture>;
  76322. /**
  76323. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76324. * flare effect by taking account of the dirt texture
  76325. */
  76326. lensFlareDirtTexture: Nullable<Texture>;
  76327. /**
  76328. * Represents the focal length for the depth of field effect
  76329. */
  76330. depthOfFieldDistance: number;
  76331. /**
  76332. * Represents the blur intensity for the blurred part of the depth of field effect
  76333. */
  76334. depthOfFieldBlurWidth: number;
  76335. /**
  76336. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76337. */
  76338. get motionStrength(): number;
  76339. /**
  76340. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76341. */
  76342. set motionStrength(strength: number);
  76343. /**
  76344. * Gets wether or not the motion blur post-process is object based or screen based.
  76345. */
  76346. get objectBasedMotionBlur(): boolean;
  76347. /**
  76348. * Sets wether or not the motion blur post-process should be object based or screen based
  76349. */
  76350. set objectBasedMotionBlur(value: boolean);
  76351. /**
  76352. * List of animations for the pipeline (IAnimatable implementation)
  76353. */
  76354. animations: Animation[];
  76355. /**
  76356. * Private members
  76357. */
  76358. private _scene;
  76359. private _currentDepthOfFieldSource;
  76360. private _basePostProcess;
  76361. private _fixedExposure;
  76362. private _currentExposure;
  76363. private _hdrAutoExposure;
  76364. private _hdrCurrentLuminance;
  76365. private _motionStrength;
  76366. private _isObjectBasedMotionBlur;
  76367. private _floatTextureType;
  76368. private _camerasToBeAttached;
  76369. private _ratio;
  76370. private _bloomEnabled;
  76371. private _depthOfFieldEnabled;
  76372. private _vlsEnabled;
  76373. private _lensFlareEnabled;
  76374. private _hdrEnabled;
  76375. private _motionBlurEnabled;
  76376. private _fxaaEnabled;
  76377. private _screenSpaceReflectionsEnabled;
  76378. private _motionBlurSamples;
  76379. private _volumetricLightStepsCount;
  76380. private _samples;
  76381. /**
  76382. * @ignore
  76383. * Specifies if the bloom pipeline is enabled
  76384. */
  76385. get BloomEnabled(): boolean;
  76386. set BloomEnabled(enabled: boolean);
  76387. /**
  76388. * @ignore
  76389. * Specifies if the depth of field pipeline is enabed
  76390. */
  76391. get DepthOfFieldEnabled(): boolean;
  76392. set DepthOfFieldEnabled(enabled: boolean);
  76393. /**
  76394. * @ignore
  76395. * Specifies if the lens flare pipeline is enabed
  76396. */
  76397. get LensFlareEnabled(): boolean;
  76398. set LensFlareEnabled(enabled: boolean);
  76399. /**
  76400. * @ignore
  76401. * Specifies if the HDR pipeline is enabled
  76402. */
  76403. get HDREnabled(): boolean;
  76404. set HDREnabled(enabled: boolean);
  76405. /**
  76406. * @ignore
  76407. * Specifies if the volumetric lights scattering effect is enabled
  76408. */
  76409. get VLSEnabled(): boolean;
  76410. set VLSEnabled(enabled: boolean);
  76411. /**
  76412. * @ignore
  76413. * Specifies if the motion blur effect is enabled
  76414. */
  76415. get MotionBlurEnabled(): boolean;
  76416. set MotionBlurEnabled(enabled: boolean);
  76417. /**
  76418. * Specifies if anti-aliasing is enabled
  76419. */
  76420. get fxaaEnabled(): boolean;
  76421. set fxaaEnabled(enabled: boolean);
  76422. /**
  76423. * Specifies if screen space reflections are enabled.
  76424. */
  76425. get screenSpaceReflectionsEnabled(): boolean;
  76426. set screenSpaceReflectionsEnabled(enabled: boolean);
  76427. /**
  76428. * Specifies the number of steps used to calculate the volumetric lights
  76429. * Typically in interval [50, 200]
  76430. */
  76431. get volumetricLightStepsCount(): number;
  76432. set volumetricLightStepsCount(count: number);
  76433. /**
  76434. * Specifies the number of samples used for the motion blur effect
  76435. * Typically in interval [16, 64]
  76436. */
  76437. get motionBlurSamples(): number;
  76438. set motionBlurSamples(samples: number);
  76439. /**
  76440. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76441. */
  76442. get samples(): number;
  76443. set samples(sampleCount: number);
  76444. /**
  76445. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76446. * @constructor
  76447. * @param name The rendering pipeline name
  76448. * @param scene The scene linked to this pipeline
  76449. * @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)
  76450. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76451. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76452. */
  76453. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76454. private _buildPipeline;
  76455. private _createDownSampleX4PostProcess;
  76456. private _createBrightPassPostProcess;
  76457. private _createBlurPostProcesses;
  76458. private _createTextureAdderPostProcess;
  76459. private _createVolumetricLightPostProcess;
  76460. private _createLuminancePostProcesses;
  76461. private _createHdrPostProcess;
  76462. private _createLensFlarePostProcess;
  76463. private _createDepthOfFieldPostProcess;
  76464. private _createMotionBlurPostProcess;
  76465. private _getDepthTexture;
  76466. private _disposePostProcesses;
  76467. /**
  76468. * Dispose of the pipeline and stop all post processes
  76469. */
  76470. dispose(): void;
  76471. /**
  76472. * Serialize the rendering pipeline (Used when exporting)
  76473. * @returns the serialized object
  76474. */
  76475. serialize(): any;
  76476. /**
  76477. * Parse the serialized pipeline
  76478. * @param source Source pipeline.
  76479. * @param scene The scene to load the pipeline to.
  76480. * @param rootUrl The URL of the serialized pipeline.
  76481. * @returns An instantiated pipeline from the serialized object.
  76482. */
  76483. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76484. /**
  76485. * Luminance steps
  76486. */
  76487. static LuminanceSteps: number;
  76488. }
  76489. }
  76490. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76491. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76492. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76493. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76494. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76495. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76496. }
  76497. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76498. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76499. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76500. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76501. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76502. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76503. }
  76504. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76505. /** @hidden */
  76506. export var stereoscopicInterlacePixelShader: {
  76507. name: string;
  76508. shader: string;
  76509. };
  76510. }
  76511. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76512. import { Camera } from "babylonjs/Cameras/camera";
  76513. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76514. import { Engine } from "babylonjs/Engines/engine";
  76515. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76516. /**
  76517. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76518. */
  76519. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76520. private _stepSize;
  76521. private _passedProcess;
  76522. /**
  76523. * Gets a string identifying the name of the class
  76524. * @returns "StereoscopicInterlacePostProcessI" string
  76525. */
  76526. getClassName(): string;
  76527. /**
  76528. * Initializes a StereoscopicInterlacePostProcessI
  76529. * @param name The name of the effect.
  76530. * @param rigCameras The rig cameras to be appled to the post process
  76531. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76532. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76534. * @param engine The engine which the post process will be applied. (default: current engine)
  76535. * @param reusable If the post process can be reused on the same frame. (default: false)
  76536. */
  76537. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76538. }
  76539. /**
  76540. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76541. */
  76542. export class StereoscopicInterlacePostProcess extends PostProcess {
  76543. private _stepSize;
  76544. private _passedProcess;
  76545. /**
  76546. * Gets a string identifying the name of the class
  76547. * @returns "StereoscopicInterlacePostProcess" string
  76548. */
  76549. getClassName(): string;
  76550. /**
  76551. * Initializes a StereoscopicInterlacePostProcess
  76552. * @param name The name of the effect.
  76553. * @param rigCameras The rig cameras to be appled to the post process
  76554. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76556. * @param engine The engine which the post process will be applied. (default: current engine)
  76557. * @param reusable If the post process can be reused on the same frame. (default: false)
  76558. */
  76559. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76560. }
  76561. }
  76562. declare module "babylonjs/Shaders/tonemap.fragment" {
  76563. /** @hidden */
  76564. export var tonemapPixelShader: {
  76565. name: string;
  76566. shader: string;
  76567. };
  76568. }
  76569. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76570. import { Camera } from "babylonjs/Cameras/camera";
  76571. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76572. import "babylonjs/Shaders/tonemap.fragment";
  76573. import { Engine } from "babylonjs/Engines/engine";
  76574. /** Defines operator used for tonemapping */
  76575. export enum TonemappingOperator {
  76576. /** Hable */
  76577. Hable = 0,
  76578. /** Reinhard */
  76579. Reinhard = 1,
  76580. /** HejiDawson */
  76581. HejiDawson = 2,
  76582. /** Photographic */
  76583. Photographic = 3
  76584. }
  76585. /**
  76586. * Defines a post process to apply tone mapping
  76587. */
  76588. export class TonemapPostProcess extends PostProcess {
  76589. private _operator;
  76590. /** Defines the required exposure adjustement */
  76591. exposureAdjustment: number;
  76592. /**
  76593. * Gets a string identifying the name of the class
  76594. * @returns "TonemapPostProcess" string
  76595. */
  76596. getClassName(): string;
  76597. /**
  76598. * Creates a new TonemapPostProcess
  76599. * @param name defines the name of the postprocess
  76600. * @param _operator defines the operator to use
  76601. * @param exposureAdjustment defines the required exposure adjustement
  76602. * @param camera defines the camera to use (can be null)
  76603. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76604. * @param engine defines the hosting engine (can be ignore if camera is set)
  76605. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76606. */
  76607. constructor(name: string, _operator: TonemappingOperator,
  76608. /** Defines the required exposure adjustement */
  76609. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76610. }
  76611. }
  76612. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76613. /** @hidden */
  76614. export var volumetricLightScatteringPixelShader: {
  76615. name: string;
  76616. shader: string;
  76617. };
  76618. }
  76619. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76620. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76621. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76622. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76623. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76624. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76625. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76626. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76627. /** @hidden */
  76628. export var volumetricLightScatteringPassVertexShader: {
  76629. name: string;
  76630. shader: string;
  76631. };
  76632. }
  76633. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76634. /** @hidden */
  76635. export var volumetricLightScatteringPassPixelShader: {
  76636. name: string;
  76637. shader: string;
  76638. };
  76639. }
  76640. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76641. import { Vector3 } from "babylonjs/Maths/math.vector";
  76642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76643. import { Mesh } from "babylonjs/Meshes/mesh";
  76644. import { Camera } from "babylonjs/Cameras/camera";
  76645. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76646. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76647. import { Scene } from "babylonjs/scene";
  76648. import "babylonjs/Meshes/Builders/planeBuilder";
  76649. import "babylonjs/Shaders/depth.vertex";
  76650. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76651. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76652. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76653. import { Engine } from "babylonjs/Engines/engine";
  76654. /**
  76655. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76656. */
  76657. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76658. private _volumetricLightScatteringPass;
  76659. private _volumetricLightScatteringRTT;
  76660. private _viewPort;
  76661. private _screenCoordinates;
  76662. private _cachedDefines;
  76663. /**
  76664. * If not undefined, the mesh position is computed from the attached node position
  76665. */
  76666. attachedNode: {
  76667. position: Vector3;
  76668. };
  76669. /**
  76670. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76671. */
  76672. customMeshPosition: Vector3;
  76673. /**
  76674. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76675. */
  76676. useCustomMeshPosition: boolean;
  76677. /**
  76678. * If the post-process should inverse the light scattering direction
  76679. */
  76680. invert: boolean;
  76681. /**
  76682. * The internal mesh used by the post-process
  76683. */
  76684. mesh: Mesh;
  76685. /**
  76686. * @hidden
  76687. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76688. */
  76689. get useDiffuseColor(): boolean;
  76690. set useDiffuseColor(useDiffuseColor: boolean);
  76691. /**
  76692. * Array containing the excluded meshes not rendered in the internal pass
  76693. */
  76694. excludedMeshes: AbstractMesh[];
  76695. /**
  76696. * Controls the overall intensity of the post-process
  76697. */
  76698. exposure: number;
  76699. /**
  76700. * Dissipates each sample's contribution in range [0, 1]
  76701. */
  76702. decay: number;
  76703. /**
  76704. * Controls the overall intensity of each sample
  76705. */
  76706. weight: number;
  76707. /**
  76708. * Controls the density of each sample
  76709. */
  76710. density: number;
  76711. /**
  76712. * @constructor
  76713. * @param name The post-process name
  76714. * @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)
  76715. * @param camera The camera that the post-process will be attached to
  76716. * @param mesh The mesh used to create the light scattering
  76717. * @param samples The post-process quality, default 100
  76718. * @param samplingModeThe post-process filtering mode
  76719. * @param engine The babylon engine
  76720. * @param reusable If the post-process is reusable
  76721. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76722. */
  76723. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76724. /**
  76725. * Returns the string "VolumetricLightScatteringPostProcess"
  76726. * @returns "VolumetricLightScatteringPostProcess"
  76727. */
  76728. getClassName(): string;
  76729. private _isReady;
  76730. /**
  76731. * Sets the new light position for light scattering effect
  76732. * @param position The new custom light position
  76733. */
  76734. setCustomMeshPosition(position: Vector3): void;
  76735. /**
  76736. * Returns the light position for light scattering effect
  76737. * @return Vector3 The custom light position
  76738. */
  76739. getCustomMeshPosition(): Vector3;
  76740. /**
  76741. * Disposes the internal assets and detaches the post-process from the camera
  76742. */
  76743. dispose(camera: Camera): void;
  76744. /**
  76745. * Returns the render target texture used by the post-process
  76746. * @return the render target texture used by the post-process
  76747. */
  76748. getPass(): RenderTargetTexture;
  76749. private _meshExcluded;
  76750. private _createPass;
  76751. private _updateMeshScreenCoordinates;
  76752. /**
  76753. * Creates a default mesh for the Volumeric Light Scattering post-process
  76754. * @param name The mesh name
  76755. * @param scene The scene where to create the mesh
  76756. * @return the default mesh
  76757. */
  76758. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76759. }
  76760. }
  76761. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76762. /** @hidden */
  76763. export var screenSpaceCurvaturePixelShader: {
  76764. name: string;
  76765. shader: string;
  76766. };
  76767. }
  76768. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76769. import { Nullable } from "babylonjs/types";
  76770. import { Camera } from "babylonjs/Cameras/camera";
  76771. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76772. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76773. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76774. import { Engine } from "babylonjs/Engines/engine";
  76775. import { Scene } from "babylonjs/scene";
  76776. /**
  76777. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76778. */
  76779. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76780. /**
  76781. * Defines how much ridge the curvature effect displays.
  76782. */
  76783. ridge: number;
  76784. /**
  76785. * Defines how much valley the curvature effect displays.
  76786. */
  76787. valley: number;
  76788. private _geometryBufferRenderer;
  76789. /**
  76790. * Gets a string identifying the name of the class
  76791. * @returns "ScreenSpaceCurvaturePostProcess" string
  76792. */
  76793. getClassName(): string;
  76794. /**
  76795. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76796. * @param name The name of the effect.
  76797. * @param scene The scene containing the objects to blur according to their velocity.
  76798. * @param options The required width/height ratio to downsize to before computing the render pass.
  76799. * @param camera The camera to apply the render pass to.
  76800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76801. * @param engine The engine which the post process will be applied. (default: current engine)
  76802. * @param reusable If the post process can be reused on the same frame. (default: false)
  76803. * @param textureType Type of textures used when performing the post process. (default: 0)
  76804. * @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)
  76805. */
  76806. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76807. /**
  76808. * Support test.
  76809. */
  76810. static get IsSupported(): boolean;
  76811. /** @hidden */
  76812. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76813. }
  76814. }
  76815. declare module "babylonjs/PostProcesses/index" {
  76816. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76817. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76818. export * from "babylonjs/PostProcesses/bloomEffect";
  76819. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76820. export * from "babylonjs/PostProcesses/blurPostProcess";
  76821. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76822. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76823. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76824. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76825. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76826. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76827. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76828. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76829. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76830. export * from "babylonjs/PostProcesses/filterPostProcess";
  76831. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76832. export * from "babylonjs/PostProcesses/grainPostProcess";
  76833. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76834. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76835. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76836. export * from "babylonjs/PostProcesses/passPostProcess";
  76837. export * from "babylonjs/PostProcesses/postProcess";
  76838. export * from "babylonjs/PostProcesses/postProcessManager";
  76839. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76840. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76841. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76842. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76843. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76844. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76845. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76846. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76847. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76848. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76849. }
  76850. declare module "babylonjs/Probes/index" {
  76851. export * from "babylonjs/Probes/reflectionProbe";
  76852. }
  76853. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76854. import { Scene } from "babylonjs/scene";
  76855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76856. import { SmartArray } from "babylonjs/Misc/smartArray";
  76857. import { ISceneComponent } from "babylonjs/sceneComponent";
  76858. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76859. import "babylonjs/Meshes/Builders/boxBuilder";
  76860. import "babylonjs/Shaders/color.fragment";
  76861. import "babylonjs/Shaders/color.vertex";
  76862. import { Color3 } from "babylonjs/Maths/math.color";
  76863. import { Observable } from "babylonjs/Misc/observable";
  76864. module "babylonjs/scene" {
  76865. interface Scene {
  76866. /** @hidden (Backing field) */
  76867. _boundingBoxRenderer: BoundingBoxRenderer;
  76868. /** @hidden (Backing field) */
  76869. _forceShowBoundingBoxes: boolean;
  76870. /**
  76871. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76872. */
  76873. forceShowBoundingBoxes: boolean;
  76874. /**
  76875. * Gets the bounding box renderer associated with the scene
  76876. * @returns a BoundingBoxRenderer
  76877. */
  76878. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76879. }
  76880. }
  76881. module "babylonjs/Meshes/abstractMesh" {
  76882. interface AbstractMesh {
  76883. /** @hidden (Backing field) */
  76884. _showBoundingBox: boolean;
  76885. /**
  76886. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76887. */
  76888. showBoundingBox: boolean;
  76889. }
  76890. }
  76891. /**
  76892. * Component responsible of rendering the bounding box of the meshes in a scene.
  76893. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76894. */
  76895. export class BoundingBoxRenderer implements ISceneComponent {
  76896. /**
  76897. * The component name helpfull to identify the component in the list of scene components.
  76898. */
  76899. readonly name: string;
  76900. /**
  76901. * The scene the component belongs to.
  76902. */
  76903. scene: Scene;
  76904. /**
  76905. * Color of the bounding box lines placed in front of an object
  76906. */
  76907. frontColor: Color3;
  76908. /**
  76909. * Color of the bounding box lines placed behind an object
  76910. */
  76911. backColor: Color3;
  76912. /**
  76913. * Defines if the renderer should show the back lines or not
  76914. */
  76915. showBackLines: boolean;
  76916. /**
  76917. * Observable raised before rendering a bounding box
  76918. */
  76919. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76920. /**
  76921. * Observable raised after rendering a bounding box
  76922. */
  76923. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76924. /**
  76925. * Observable raised after resources are created
  76926. */
  76927. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76928. /**
  76929. * When false, no bounding boxes will be rendered
  76930. */
  76931. enabled: boolean;
  76932. /**
  76933. * @hidden
  76934. */
  76935. renderList: SmartArray<BoundingBox>;
  76936. private _colorShader;
  76937. private _vertexBuffers;
  76938. private _indexBuffer;
  76939. private _fillIndexBuffer;
  76940. private _fillIndexData;
  76941. /**
  76942. * Instantiates a new bounding box renderer in a scene.
  76943. * @param scene the scene the renderer renders in
  76944. */
  76945. constructor(scene: Scene);
  76946. /**
  76947. * Registers the component in a given scene
  76948. */
  76949. register(): void;
  76950. private _evaluateSubMesh;
  76951. private _preActiveMesh;
  76952. private _prepareResources;
  76953. private _createIndexBuffer;
  76954. /**
  76955. * Rebuilds the elements related to this component in case of
  76956. * context lost for instance.
  76957. */
  76958. rebuild(): void;
  76959. /**
  76960. * @hidden
  76961. */
  76962. reset(): void;
  76963. /**
  76964. * Render the bounding boxes of a specific rendering group
  76965. * @param renderingGroupId defines the rendering group to render
  76966. */
  76967. render(renderingGroupId: number): void;
  76968. /**
  76969. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76970. * @param mesh Define the mesh to render the occlusion bounding box for
  76971. */
  76972. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76973. /**
  76974. * Dispose and release the resources attached to this renderer.
  76975. */
  76976. dispose(): void;
  76977. }
  76978. }
  76979. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76980. import { Nullable } from "babylonjs/types";
  76981. import { Scene } from "babylonjs/scene";
  76982. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76983. import { Camera } from "babylonjs/Cameras/camera";
  76984. import { ISceneComponent } from "babylonjs/sceneComponent";
  76985. module "babylonjs/scene" {
  76986. interface Scene {
  76987. /** @hidden (Backing field) */
  76988. _depthRenderer: {
  76989. [id: string]: DepthRenderer;
  76990. };
  76991. /**
  76992. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76993. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76994. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76995. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76996. * @returns the created depth renderer
  76997. */
  76998. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76999. /**
  77000. * Disables a depth renderer for a given camera
  77001. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77002. */
  77003. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77004. }
  77005. }
  77006. /**
  77007. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77008. * in several rendering techniques.
  77009. */
  77010. export class DepthRendererSceneComponent implements ISceneComponent {
  77011. /**
  77012. * The component name helpfull to identify the component in the list of scene components.
  77013. */
  77014. readonly name: string;
  77015. /**
  77016. * The scene the component belongs to.
  77017. */
  77018. scene: Scene;
  77019. /**
  77020. * Creates a new instance of the component for the given scene
  77021. * @param scene Defines the scene to register the component in
  77022. */
  77023. constructor(scene: Scene);
  77024. /**
  77025. * Registers the component in a given scene
  77026. */
  77027. register(): void;
  77028. /**
  77029. * Rebuilds the elements related to this component in case of
  77030. * context lost for instance.
  77031. */
  77032. rebuild(): void;
  77033. /**
  77034. * Disposes the component and the associated ressources
  77035. */
  77036. dispose(): void;
  77037. private _gatherRenderTargets;
  77038. private _gatherActiveCameraRenderTargets;
  77039. }
  77040. }
  77041. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77042. import { Nullable } from "babylonjs/types";
  77043. import { Scene } from "babylonjs/scene";
  77044. import { ISceneComponent } from "babylonjs/sceneComponent";
  77045. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77046. module "babylonjs/abstractScene" {
  77047. interface AbstractScene {
  77048. /** @hidden (Backing field) */
  77049. _prePassRenderer: Nullable<PrePassRenderer>;
  77050. /**
  77051. * Gets or Sets the current prepass renderer associated to the scene.
  77052. */
  77053. prePassRenderer: Nullable<PrePassRenderer>;
  77054. /**
  77055. * Enables the prepass and associates it with the scene
  77056. * @returns the PrePassRenderer
  77057. */
  77058. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77059. /**
  77060. * Disables the prepass associated with the scene
  77061. */
  77062. disablePrePassRenderer(): void;
  77063. }
  77064. }
  77065. /**
  77066. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77067. * in several rendering techniques.
  77068. */
  77069. export class PrePassRendererSceneComponent implements ISceneComponent {
  77070. /**
  77071. * The component name helpful to identify the component in the list of scene components.
  77072. */
  77073. readonly name: string;
  77074. /**
  77075. * The scene the component belongs to.
  77076. */
  77077. scene: Scene;
  77078. /**
  77079. * Creates a new instance of the component for the given scene
  77080. * @param scene Defines the scene to register the component in
  77081. */
  77082. constructor(scene: Scene);
  77083. /**
  77084. * Registers the component in a given scene
  77085. */
  77086. register(): void;
  77087. private _beforeCameraDraw;
  77088. private _afterCameraDraw;
  77089. private _beforeClearStage;
  77090. /**
  77091. * Rebuilds the elements related to this component in case of
  77092. * context lost for instance.
  77093. */
  77094. rebuild(): void;
  77095. /**
  77096. * Disposes the component and the associated ressources
  77097. */
  77098. dispose(): void;
  77099. }
  77100. }
  77101. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77102. /** @hidden */
  77103. export var fibonacci: {
  77104. name: string;
  77105. shader: string;
  77106. };
  77107. }
  77108. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77109. /** @hidden */
  77110. export var diffusionProfile: {
  77111. name: string;
  77112. shader: string;
  77113. };
  77114. }
  77115. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77116. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77117. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77118. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77119. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77120. /** @hidden */
  77121. export var subSurfaceScatteringPixelShader: {
  77122. name: string;
  77123. shader: string;
  77124. };
  77125. }
  77126. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77127. import { Nullable } from "babylonjs/types";
  77128. import { Camera } from "babylonjs/Cameras/camera";
  77129. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77130. import { Engine } from "babylonjs/Engines/engine";
  77131. import { Scene } from "babylonjs/scene";
  77132. import "babylonjs/Shaders/imageProcessing.fragment";
  77133. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77134. import "babylonjs/Shaders/postprocess.vertex";
  77135. /**
  77136. * Sub surface scattering post process
  77137. */
  77138. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77139. /**
  77140. * Gets a string identifying the name of the class
  77141. * @returns "SubSurfaceScatteringPostProcess" string
  77142. */
  77143. getClassName(): string;
  77144. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77145. }
  77146. }
  77147. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77148. import { Scene } from "babylonjs/scene";
  77149. import { Color3 } from "babylonjs/Maths/math.color";
  77150. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77151. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77152. /**
  77153. * Contains all parameters needed for the prepass to perform
  77154. * screen space subsurface scattering
  77155. */
  77156. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77157. /** @hidden */
  77158. static _SceneComponentInitialization: (scene: Scene) => void;
  77159. private _ssDiffusionS;
  77160. private _ssFilterRadii;
  77161. private _ssDiffusionD;
  77162. /**
  77163. * Post process to attach for screen space subsurface scattering
  77164. */
  77165. postProcess: SubSurfaceScatteringPostProcess;
  77166. /**
  77167. * Diffusion profile color for subsurface scattering
  77168. */
  77169. get ssDiffusionS(): number[];
  77170. /**
  77171. * Diffusion profile max color channel value for subsurface scattering
  77172. */
  77173. get ssDiffusionD(): number[];
  77174. /**
  77175. * Diffusion profile filter radius for subsurface scattering
  77176. */
  77177. get ssFilterRadii(): number[];
  77178. /**
  77179. * Is subsurface enabled
  77180. */
  77181. enabled: boolean;
  77182. /**
  77183. * Name of the configuration
  77184. */
  77185. name: string;
  77186. /**
  77187. * Diffusion profile colors for subsurface scattering
  77188. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77189. * See ...
  77190. * Note that you can only store up to 5 of them
  77191. */
  77192. ssDiffusionProfileColors: Color3[];
  77193. /**
  77194. * Defines the ratio real world => scene units.
  77195. * Used for subsurface scattering
  77196. */
  77197. metersPerUnit: number;
  77198. /**
  77199. * Textures that should be present in the MRT for this effect to work
  77200. */
  77201. readonly texturesRequired: number[];
  77202. private _scene;
  77203. /**
  77204. * Builds a subsurface configuration object
  77205. * @param scene The scene
  77206. */
  77207. constructor(scene: Scene);
  77208. /**
  77209. * Adds a new diffusion profile.
  77210. * Useful for more realistic subsurface scattering on diverse materials.
  77211. * @param color The color of the diffusion profile. Should be the average color of the material.
  77212. * @return The index of the diffusion profile for the material subsurface configuration
  77213. */
  77214. addDiffusionProfile(color: Color3): number;
  77215. /**
  77216. * Creates the sss post process
  77217. * @return The created post process
  77218. */
  77219. createPostProcess(): SubSurfaceScatteringPostProcess;
  77220. /**
  77221. * Deletes all diffusion profiles.
  77222. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77223. */
  77224. clearAllDiffusionProfiles(): void;
  77225. /**
  77226. * Disposes this object
  77227. */
  77228. dispose(): void;
  77229. /**
  77230. * @hidden
  77231. * https://zero-radiance.github.io/post/sampling-diffusion/
  77232. *
  77233. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77234. * ------------------------------------------------------------------------------------
  77235. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77236. * PDF[r, phi, s] = r * R[r, phi, s]
  77237. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77238. * ------------------------------------------------------------------------------------
  77239. * We importance sample the color channel with the widest scattering distance.
  77240. */
  77241. getDiffusionProfileParameters(color: Color3): number;
  77242. /**
  77243. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77244. * 'u' is the random number (the value of the CDF): [0, 1).
  77245. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77246. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77247. */
  77248. private _sampleBurleyDiffusionProfile;
  77249. }
  77250. }
  77251. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77252. import { Nullable } from "babylonjs/types";
  77253. import { Scene } from "babylonjs/scene";
  77254. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77255. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77256. import { AbstractScene } from "babylonjs/abstractScene";
  77257. module "babylonjs/abstractScene" {
  77258. interface AbstractScene {
  77259. /** @hidden (Backing field) */
  77260. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77261. /**
  77262. * Gets or Sets the current prepass renderer associated to the scene.
  77263. */
  77264. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77265. /**
  77266. * Enables the subsurface effect for prepass
  77267. * @returns the SubSurfaceConfiguration
  77268. */
  77269. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77270. /**
  77271. * Disables the subsurface effect for prepass
  77272. */
  77273. disableSubSurfaceForPrePass(): void;
  77274. }
  77275. }
  77276. /**
  77277. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77278. * in several rendering techniques.
  77279. */
  77280. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77281. /**
  77282. * The component name helpful to identify the component in the list of scene components.
  77283. */
  77284. readonly name: string;
  77285. /**
  77286. * The scene the component belongs to.
  77287. */
  77288. scene: Scene;
  77289. /**
  77290. * Creates a new instance of the component for the given scene
  77291. * @param scene Defines the scene to register the component in
  77292. */
  77293. constructor(scene: Scene);
  77294. /**
  77295. * Registers the component in a given scene
  77296. */
  77297. register(): void;
  77298. /**
  77299. * Serializes the component data to the specified json object
  77300. * @param serializationObject The object to serialize to
  77301. */
  77302. serialize(serializationObject: any): void;
  77303. /**
  77304. * Adds all the elements from the container to the scene
  77305. * @param container the container holding the elements
  77306. */
  77307. addFromContainer(container: AbstractScene): void;
  77308. /**
  77309. * Removes all the elements in the container from the scene
  77310. * @param container contains the elements to remove
  77311. * @param dispose if the removed element should be disposed (default: false)
  77312. */
  77313. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77314. /**
  77315. * Rebuilds the elements related to this component in case of
  77316. * context lost for instance.
  77317. */
  77318. rebuild(): void;
  77319. /**
  77320. * Disposes the component and the associated ressources
  77321. */
  77322. dispose(): void;
  77323. }
  77324. }
  77325. declare module "babylonjs/Shaders/outline.fragment" {
  77326. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77327. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77328. /** @hidden */
  77329. export var outlinePixelShader: {
  77330. name: string;
  77331. shader: string;
  77332. };
  77333. }
  77334. declare module "babylonjs/Shaders/outline.vertex" {
  77335. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77336. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77337. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77339. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77340. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77341. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77342. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77343. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77344. /** @hidden */
  77345. export var outlineVertexShader: {
  77346. name: string;
  77347. shader: string;
  77348. };
  77349. }
  77350. declare module "babylonjs/Rendering/outlineRenderer" {
  77351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77352. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77353. import { Scene } from "babylonjs/scene";
  77354. import { ISceneComponent } from "babylonjs/sceneComponent";
  77355. import "babylonjs/Shaders/outline.fragment";
  77356. import "babylonjs/Shaders/outline.vertex";
  77357. module "babylonjs/scene" {
  77358. interface Scene {
  77359. /** @hidden */
  77360. _outlineRenderer: OutlineRenderer;
  77361. /**
  77362. * Gets the outline renderer associated with the scene
  77363. * @returns a OutlineRenderer
  77364. */
  77365. getOutlineRenderer(): OutlineRenderer;
  77366. }
  77367. }
  77368. module "babylonjs/Meshes/abstractMesh" {
  77369. interface AbstractMesh {
  77370. /** @hidden (Backing field) */
  77371. _renderOutline: boolean;
  77372. /**
  77373. * Gets or sets a boolean indicating if the outline must be rendered as well
  77374. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77375. */
  77376. renderOutline: boolean;
  77377. /** @hidden (Backing field) */
  77378. _renderOverlay: boolean;
  77379. /**
  77380. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77381. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77382. */
  77383. renderOverlay: boolean;
  77384. }
  77385. }
  77386. /**
  77387. * This class is responsible to draw bothe outline/overlay of meshes.
  77388. * It should not be used directly but through the available method on mesh.
  77389. */
  77390. export class OutlineRenderer implements ISceneComponent {
  77391. /**
  77392. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77393. */
  77394. private static _StencilReference;
  77395. /**
  77396. * The name of the component. Each component must have a unique name.
  77397. */
  77398. name: string;
  77399. /**
  77400. * The scene the component belongs to.
  77401. */
  77402. scene: Scene;
  77403. /**
  77404. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77405. */
  77406. zOffset: number;
  77407. private _engine;
  77408. private _effect;
  77409. private _cachedDefines;
  77410. private _savedDepthWrite;
  77411. /**
  77412. * Instantiates a new outline renderer. (There could be only one per scene).
  77413. * @param scene Defines the scene it belongs to
  77414. */
  77415. constructor(scene: Scene);
  77416. /**
  77417. * Register the component to one instance of a scene.
  77418. */
  77419. register(): void;
  77420. /**
  77421. * Rebuilds the elements related to this component in case of
  77422. * context lost for instance.
  77423. */
  77424. rebuild(): void;
  77425. /**
  77426. * Disposes the component and the associated ressources.
  77427. */
  77428. dispose(): void;
  77429. /**
  77430. * Renders the outline in the canvas.
  77431. * @param subMesh Defines the sumesh to render
  77432. * @param batch Defines the batch of meshes in case of instances
  77433. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77434. */
  77435. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77436. /**
  77437. * Returns whether or not the outline renderer is ready for a given submesh.
  77438. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77439. * @param subMesh Defines the submesh to check readyness for
  77440. * @param useInstances Defines wheter wee are trying to render instances or not
  77441. * @returns true if ready otherwise false
  77442. */
  77443. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77444. private _beforeRenderingMesh;
  77445. private _afterRenderingMesh;
  77446. }
  77447. }
  77448. declare module "babylonjs/Rendering/index" {
  77449. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77450. export * from "babylonjs/Rendering/depthRenderer";
  77451. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77452. export * from "babylonjs/Rendering/edgesRenderer";
  77453. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77454. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77455. export * from "babylonjs/Rendering/prePassRenderer";
  77456. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77457. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77458. export * from "babylonjs/Rendering/outlineRenderer";
  77459. export * from "babylonjs/Rendering/renderingGroup";
  77460. export * from "babylonjs/Rendering/renderingManager";
  77461. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77462. }
  77463. declare module "babylonjs/Sprites/ISprites" {
  77464. /**
  77465. * Defines the basic options interface of a Sprite Frame Source Size.
  77466. */
  77467. export interface ISpriteJSONSpriteSourceSize {
  77468. /**
  77469. * number of the original width of the Frame
  77470. */
  77471. w: number;
  77472. /**
  77473. * number of the original height of the Frame
  77474. */
  77475. h: number;
  77476. }
  77477. /**
  77478. * Defines the basic options interface of a Sprite Frame Data.
  77479. */
  77480. export interface ISpriteJSONSpriteFrameData {
  77481. /**
  77482. * number of the x offset of the Frame
  77483. */
  77484. x: number;
  77485. /**
  77486. * number of the y offset of the Frame
  77487. */
  77488. y: number;
  77489. /**
  77490. * number of the width of the Frame
  77491. */
  77492. w: number;
  77493. /**
  77494. * number of the height of the Frame
  77495. */
  77496. h: number;
  77497. }
  77498. /**
  77499. * Defines the basic options interface of a JSON Sprite.
  77500. */
  77501. export interface ISpriteJSONSprite {
  77502. /**
  77503. * string name of the Frame
  77504. */
  77505. filename: string;
  77506. /**
  77507. * ISpriteJSONSpriteFrame basic object of the frame data
  77508. */
  77509. frame: ISpriteJSONSpriteFrameData;
  77510. /**
  77511. * boolean to flag is the frame was rotated.
  77512. */
  77513. rotated: boolean;
  77514. /**
  77515. * boolean to flag is the frame was trimmed.
  77516. */
  77517. trimmed: boolean;
  77518. /**
  77519. * ISpriteJSONSpriteFrame basic object of the source data
  77520. */
  77521. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77522. /**
  77523. * ISpriteJSONSpriteFrame basic object of the source data
  77524. */
  77525. sourceSize: ISpriteJSONSpriteSourceSize;
  77526. }
  77527. /**
  77528. * Defines the basic options interface of a JSON atlas.
  77529. */
  77530. export interface ISpriteJSONAtlas {
  77531. /**
  77532. * Array of objects that contain the frame data.
  77533. */
  77534. frames: Array<ISpriteJSONSprite>;
  77535. /**
  77536. * object basic object containing the sprite meta data.
  77537. */
  77538. meta?: object;
  77539. }
  77540. }
  77541. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77542. /** @hidden */
  77543. export var spriteMapPixelShader: {
  77544. name: string;
  77545. shader: string;
  77546. };
  77547. }
  77548. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77549. /** @hidden */
  77550. export var spriteMapVertexShader: {
  77551. name: string;
  77552. shader: string;
  77553. };
  77554. }
  77555. declare module "babylonjs/Sprites/spriteMap" {
  77556. import { IDisposable, Scene } from "babylonjs/scene";
  77557. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77558. import { Texture } from "babylonjs/Materials/Textures/texture";
  77559. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77560. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77561. import "babylonjs/Meshes/Builders/planeBuilder";
  77562. import "babylonjs/Shaders/spriteMap.fragment";
  77563. import "babylonjs/Shaders/spriteMap.vertex";
  77564. /**
  77565. * Defines the basic options interface of a SpriteMap
  77566. */
  77567. export interface ISpriteMapOptions {
  77568. /**
  77569. * Vector2 of the number of cells in the grid.
  77570. */
  77571. stageSize?: Vector2;
  77572. /**
  77573. * Vector2 of the size of the output plane in World Units.
  77574. */
  77575. outputSize?: Vector2;
  77576. /**
  77577. * Vector3 of the position of the output plane in World Units.
  77578. */
  77579. outputPosition?: Vector3;
  77580. /**
  77581. * Vector3 of the rotation of the output plane.
  77582. */
  77583. outputRotation?: Vector3;
  77584. /**
  77585. * number of layers that the system will reserve in resources.
  77586. */
  77587. layerCount?: number;
  77588. /**
  77589. * number of max animation frames a single cell will reserve in resources.
  77590. */
  77591. maxAnimationFrames?: number;
  77592. /**
  77593. * number cell index of the base tile when the system compiles.
  77594. */
  77595. baseTile?: number;
  77596. /**
  77597. * boolean flip the sprite after its been repositioned by the framing data.
  77598. */
  77599. flipU?: boolean;
  77600. /**
  77601. * Vector3 scalar of the global RGB values of the SpriteMap.
  77602. */
  77603. colorMultiply?: Vector3;
  77604. }
  77605. /**
  77606. * Defines the IDisposable interface in order to be cleanable from resources.
  77607. */
  77608. export interface ISpriteMap extends IDisposable {
  77609. /**
  77610. * String name of the SpriteMap.
  77611. */
  77612. name: string;
  77613. /**
  77614. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77615. */
  77616. atlasJSON: ISpriteJSONAtlas;
  77617. /**
  77618. * Texture of the SpriteMap.
  77619. */
  77620. spriteSheet: Texture;
  77621. /**
  77622. * The parameters to initialize the SpriteMap with.
  77623. */
  77624. options: ISpriteMapOptions;
  77625. }
  77626. /**
  77627. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77628. */
  77629. export class SpriteMap implements ISpriteMap {
  77630. /** The Name of the spriteMap */
  77631. name: string;
  77632. /** The JSON file with the frame and meta data */
  77633. atlasJSON: ISpriteJSONAtlas;
  77634. /** The systems Sprite Sheet Texture */
  77635. spriteSheet: Texture;
  77636. /** Arguments passed with the Constructor */
  77637. options: ISpriteMapOptions;
  77638. /** Public Sprite Storage array, parsed from atlasJSON */
  77639. sprites: Array<ISpriteJSONSprite>;
  77640. /** Returns the Number of Sprites in the System */
  77641. get spriteCount(): number;
  77642. /** Returns the Position of Output Plane*/
  77643. get position(): Vector3;
  77644. /** Returns the Position of Output Plane*/
  77645. set position(v: Vector3);
  77646. /** Returns the Rotation of Output Plane*/
  77647. get rotation(): Vector3;
  77648. /** Returns the Rotation of Output Plane*/
  77649. set rotation(v: Vector3);
  77650. /** Sets the AnimationMap*/
  77651. get animationMap(): RawTexture;
  77652. /** Sets the AnimationMap*/
  77653. set animationMap(v: RawTexture);
  77654. /** Scene that the SpriteMap was created in */
  77655. private _scene;
  77656. /** Texture Buffer of Float32 that holds tile frame data*/
  77657. private _frameMap;
  77658. /** Texture Buffers of Float32 that holds tileMap data*/
  77659. private _tileMaps;
  77660. /** Texture Buffer of Float32 that holds Animation Data*/
  77661. private _animationMap;
  77662. /** Custom ShaderMaterial Central to the System*/
  77663. private _material;
  77664. /** Custom ShaderMaterial Central to the System*/
  77665. private _output;
  77666. /** Systems Time Ticker*/
  77667. private _time;
  77668. /**
  77669. * Creates a new SpriteMap
  77670. * @param name defines the SpriteMaps Name
  77671. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77672. * @param spriteSheet is the Texture that the Sprites are on.
  77673. * @param options a basic deployment configuration
  77674. * @param scene The Scene that the map is deployed on
  77675. */
  77676. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77677. /**
  77678. * Returns tileID location
  77679. * @returns Vector2 the cell position ID
  77680. */
  77681. getTileID(): Vector2;
  77682. /**
  77683. * Gets the UV location of the mouse over the SpriteMap.
  77684. * @returns Vector2 the UV position of the mouse interaction
  77685. */
  77686. getMousePosition(): Vector2;
  77687. /**
  77688. * Creates the "frame" texture Buffer
  77689. * -------------------------------------
  77690. * Structure of frames
  77691. * "filename": "Falling-Water-2.png",
  77692. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77693. * "rotated": true,
  77694. * "trimmed": true,
  77695. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77696. * "sourceSize": {"w":32,"h":32}
  77697. * @returns RawTexture of the frameMap
  77698. */
  77699. private _createFrameBuffer;
  77700. /**
  77701. * Creates the tileMap texture Buffer
  77702. * @param buffer normally and array of numbers, or a false to generate from scratch
  77703. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77704. * @returns RawTexture of the tileMap
  77705. */
  77706. private _createTileBuffer;
  77707. /**
  77708. * Modifies the data of the tileMaps
  77709. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77710. * @param pos is the iVector2 Coordinates of the Tile
  77711. * @param tile The SpriteIndex of the new Tile
  77712. */
  77713. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77714. /**
  77715. * Creates the animationMap texture Buffer
  77716. * @param buffer normally and array of numbers, or a false to generate from scratch
  77717. * @returns RawTexture of the animationMap
  77718. */
  77719. private _createTileAnimationBuffer;
  77720. /**
  77721. * Modifies the data of the animationMap
  77722. * @param cellID is the Index of the Sprite
  77723. * @param _frame is the target Animation frame
  77724. * @param toCell is the Target Index of the next frame of the animation
  77725. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77726. * @param speed is a global scalar of the time variable on the map.
  77727. */
  77728. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77729. /**
  77730. * Exports the .tilemaps file
  77731. */
  77732. saveTileMaps(): void;
  77733. /**
  77734. * Imports the .tilemaps file
  77735. * @param url of the .tilemaps file
  77736. */
  77737. loadTileMaps(url: string): void;
  77738. /**
  77739. * Release associated resources
  77740. */
  77741. dispose(): void;
  77742. }
  77743. }
  77744. declare module "babylonjs/Sprites/spritePackedManager" {
  77745. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77746. import { Scene } from "babylonjs/scene";
  77747. /**
  77748. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77749. * @see https://doc.babylonjs.com/babylon101/sprites
  77750. */
  77751. export class SpritePackedManager extends SpriteManager {
  77752. /** defines the packed manager's name */
  77753. name: string;
  77754. /**
  77755. * Creates a new sprite manager from a packed sprite sheet
  77756. * @param name defines the manager's name
  77757. * @param imgUrl defines the sprite sheet url
  77758. * @param capacity defines the maximum allowed number of sprites
  77759. * @param scene defines the hosting scene
  77760. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77761. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77762. * @param samplingMode defines the smapling mode to use with spritesheet
  77763. * @param fromPacked set to true; do not alter
  77764. */
  77765. constructor(
  77766. /** defines the packed manager's name */
  77767. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77768. }
  77769. }
  77770. declare module "babylonjs/Sprites/index" {
  77771. export * from "babylonjs/Sprites/sprite";
  77772. export * from "babylonjs/Sprites/ISprites";
  77773. export * from "babylonjs/Sprites/spriteManager";
  77774. export * from "babylonjs/Sprites/spriteMap";
  77775. export * from "babylonjs/Sprites/spritePackedManager";
  77776. export * from "babylonjs/Sprites/spriteSceneComponent";
  77777. }
  77778. declare module "babylonjs/States/index" {
  77779. export * from "babylonjs/States/alphaCullingState";
  77780. export * from "babylonjs/States/depthCullingState";
  77781. export * from "babylonjs/States/stencilState";
  77782. }
  77783. declare module "babylonjs/Misc/assetsManager" {
  77784. import { Scene } from "babylonjs/scene";
  77785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77786. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77787. import { Skeleton } from "babylonjs/Bones/skeleton";
  77788. import { Observable } from "babylonjs/Misc/observable";
  77789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77790. import { Texture } from "babylonjs/Materials/Textures/texture";
  77791. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77792. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77793. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77794. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77795. import { AssetContainer } from "babylonjs/assetContainer";
  77796. /**
  77797. * Defines the list of states available for a task inside a AssetsManager
  77798. */
  77799. export enum AssetTaskState {
  77800. /**
  77801. * Initialization
  77802. */
  77803. INIT = 0,
  77804. /**
  77805. * Running
  77806. */
  77807. RUNNING = 1,
  77808. /**
  77809. * Done
  77810. */
  77811. DONE = 2,
  77812. /**
  77813. * Error
  77814. */
  77815. ERROR = 3
  77816. }
  77817. /**
  77818. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77819. */
  77820. export abstract class AbstractAssetTask {
  77821. /**
  77822. * Task name
  77823. */ name: string;
  77824. /**
  77825. * Callback called when the task is successful
  77826. */
  77827. onSuccess: (task: any) => void;
  77828. /**
  77829. * Callback called when the task is not successful
  77830. */
  77831. onError: (task: any, message?: string, exception?: any) => void;
  77832. /**
  77833. * Creates a new AssetsManager
  77834. * @param name defines the name of the task
  77835. */
  77836. constructor(
  77837. /**
  77838. * Task name
  77839. */ name: string);
  77840. private _isCompleted;
  77841. private _taskState;
  77842. private _errorObject;
  77843. /**
  77844. * Get if the task is completed
  77845. */
  77846. get isCompleted(): boolean;
  77847. /**
  77848. * Gets the current state of the task
  77849. */
  77850. get taskState(): AssetTaskState;
  77851. /**
  77852. * Gets the current error object (if task is in error)
  77853. */
  77854. get errorObject(): {
  77855. message?: string;
  77856. exception?: any;
  77857. };
  77858. /**
  77859. * Internal only
  77860. * @hidden
  77861. */
  77862. _setErrorObject(message?: string, exception?: any): void;
  77863. /**
  77864. * Execute the current task
  77865. * @param scene defines the scene where you want your assets to be loaded
  77866. * @param onSuccess is a callback called when the task is successfully executed
  77867. * @param onError is a callback called if an error occurs
  77868. */
  77869. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77870. /**
  77871. * Execute the current task
  77872. * @param scene defines the scene where you want your assets to be loaded
  77873. * @param onSuccess is a callback called when the task is successfully executed
  77874. * @param onError is a callback called if an error occurs
  77875. */
  77876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77877. /**
  77878. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77879. * This can be used with failed tasks that have the reason for failure fixed.
  77880. */
  77881. reset(): void;
  77882. private onErrorCallback;
  77883. private onDoneCallback;
  77884. }
  77885. /**
  77886. * Define the interface used by progress events raised during assets loading
  77887. */
  77888. export interface IAssetsProgressEvent {
  77889. /**
  77890. * Defines the number of remaining tasks to process
  77891. */
  77892. remainingCount: number;
  77893. /**
  77894. * Defines the total number of tasks
  77895. */
  77896. totalCount: number;
  77897. /**
  77898. * Defines the task that was just processed
  77899. */
  77900. task: AbstractAssetTask;
  77901. }
  77902. /**
  77903. * Class used to share progress information about assets loading
  77904. */
  77905. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77906. /**
  77907. * Defines the number of remaining tasks to process
  77908. */
  77909. remainingCount: number;
  77910. /**
  77911. * Defines the total number of tasks
  77912. */
  77913. totalCount: number;
  77914. /**
  77915. * Defines the task that was just processed
  77916. */
  77917. task: AbstractAssetTask;
  77918. /**
  77919. * Creates a AssetsProgressEvent
  77920. * @param remainingCount defines the number of remaining tasks to process
  77921. * @param totalCount defines the total number of tasks
  77922. * @param task defines the task that was just processed
  77923. */
  77924. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77925. }
  77926. /**
  77927. * Define a task used by AssetsManager to load assets into a container
  77928. */
  77929. export class ContainerAssetTask extends AbstractAssetTask {
  77930. /**
  77931. * Defines the name of the task
  77932. */
  77933. name: string;
  77934. /**
  77935. * Defines the list of mesh's names you want to load
  77936. */
  77937. meshesNames: any;
  77938. /**
  77939. * Defines the root url to use as a base to load your meshes and associated resources
  77940. */
  77941. rootUrl: string;
  77942. /**
  77943. * Defines the filename or File of the scene to load from
  77944. */
  77945. sceneFilename: string | File;
  77946. /**
  77947. * Get the loaded asset container
  77948. */
  77949. loadedContainer: AssetContainer;
  77950. /**
  77951. * Gets the list of loaded meshes
  77952. */
  77953. loadedMeshes: Array<AbstractMesh>;
  77954. /**
  77955. * Gets the list of loaded particle systems
  77956. */
  77957. loadedParticleSystems: Array<IParticleSystem>;
  77958. /**
  77959. * Gets the list of loaded skeletons
  77960. */
  77961. loadedSkeletons: Array<Skeleton>;
  77962. /**
  77963. * Gets the list of loaded animation groups
  77964. */
  77965. loadedAnimationGroups: Array<AnimationGroup>;
  77966. /**
  77967. * Callback called when the task is successful
  77968. */
  77969. onSuccess: (task: ContainerAssetTask) => void;
  77970. /**
  77971. * Callback called when the task is successful
  77972. */
  77973. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77974. /**
  77975. * Creates a new ContainerAssetTask
  77976. * @param name defines the name of the task
  77977. * @param meshesNames defines the list of mesh's names you want to load
  77978. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77979. * @param sceneFilename defines the filename or File of the scene to load from
  77980. */
  77981. constructor(
  77982. /**
  77983. * Defines the name of the task
  77984. */
  77985. name: string,
  77986. /**
  77987. * Defines the list of mesh's names you want to load
  77988. */
  77989. meshesNames: any,
  77990. /**
  77991. * Defines the root url to use as a base to load your meshes and associated resources
  77992. */
  77993. rootUrl: string,
  77994. /**
  77995. * Defines the filename or File of the scene to load from
  77996. */
  77997. sceneFilename: string | File);
  77998. /**
  77999. * Execute the current task
  78000. * @param scene defines the scene where you want your assets to be loaded
  78001. * @param onSuccess is a callback called when the task is successfully executed
  78002. * @param onError is a callback called if an error occurs
  78003. */
  78004. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78005. }
  78006. /**
  78007. * Define a task used by AssetsManager to load meshes
  78008. */
  78009. export class MeshAssetTask extends AbstractAssetTask {
  78010. /**
  78011. * Defines the name of the task
  78012. */
  78013. name: string;
  78014. /**
  78015. * Defines the list of mesh's names you want to load
  78016. */
  78017. meshesNames: any;
  78018. /**
  78019. * Defines the root url to use as a base to load your meshes and associated resources
  78020. */
  78021. rootUrl: string;
  78022. /**
  78023. * Defines the filename or File of the scene to load from
  78024. */
  78025. sceneFilename: string | File;
  78026. /**
  78027. * Gets the list of loaded meshes
  78028. */
  78029. loadedMeshes: Array<AbstractMesh>;
  78030. /**
  78031. * Gets the list of loaded particle systems
  78032. */
  78033. loadedParticleSystems: Array<IParticleSystem>;
  78034. /**
  78035. * Gets the list of loaded skeletons
  78036. */
  78037. loadedSkeletons: Array<Skeleton>;
  78038. /**
  78039. * Gets the list of loaded animation groups
  78040. */
  78041. loadedAnimationGroups: Array<AnimationGroup>;
  78042. /**
  78043. * Callback called when the task is successful
  78044. */
  78045. onSuccess: (task: MeshAssetTask) => void;
  78046. /**
  78047. * Callback called when the task is successful
  78048. */
  78049. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78050. /**
  78051. * Creates a new MeshAssetTask
  78052. * @param name defines the name of the task
  78053. * @param meshesNames defines the list of mesh's names you want to load
  78054. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78055. * @param sceneFilename defines the filename or File of the scene to load from
  78056. */
  78057. constructor(
  78058. /**
  78059. * Defines the name of the task
  78060. */
  78061. name: string,
  78062. /**
  78063. * Defines the list of mesh's names you want to load
  78064. */
  78065. meshesNames: any,
  78066. /**
  78067. * Defines the root url to use as a base to load your meshes and associated resources
  78068. */
  78069. rootUrl: string,
  78070. /**
  78071. * Defines the filename or File of the scene to load from
  78072. */
  78073. sceneFilename: string | File);
  78074. /**
  78075. * Execute the current task
  78076. * @param scene defines the scene where you want your assets to be loaded
  78077. * @param onSuccess is a callback called when the task is successfully executed
  78078. * @param onError is a callback called if an error occurs
  78079. */
  78080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78081. }
  78082. /**
  78083. * Define a task used by AssetsManager to load text content
  78084. */
  78085. export class TextFileAssetTask extends AbstractAssetTask {
  78086. /**
  78087. * Defines the name of the task
  78088. */
  78089. name: string;
  78090. /**
  78091. * Defines the location of the file to load
  78092. */
  78093. url: string;
  78094. /**
  78095. * Gets the loaded text string
  78096. */
  78097. text: string;
  78098. /**
  78099. * Callback called when the task is successful
  78100. */
  78101. onSuccess: (task: TextFileAssetTask) => void;
  78102. /**
  78103. * Callback called when the task is successful
  78104. */
  78105. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78106. /**
  78107. * Creates a new TextFileAssetTask object
  78108. * @param name defines the name of the task
  78109. * @param url defines the location of the file to load
  78110. */
  78111. constructor(
  78112. /**
  78113. * Defines the name of the task
  78114. */
  78115. name: string,
  78116. /**
  78117. * Defines the location of the file to load
  78118. */
  78119. url: string);
  78120. /**
  78121. * Execute the current task
  78122. * @param scene defines the scene where you want your assets to be loaded
  78123. * @param onSuccess is a callback called when the task is successfully executed
  78124. * @param onError is a callback called if an error occurs
  78125. */
  78126. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78127. }
  78128. /**
  78129. * Define a task used by AssetsManager to load binary data
  78130. */
  78131. export class BinaryFileAssetTask extends AbstractAssetTask {
  78132. /**
  78133. * Defines the name of the task
  78134. */
  78135. name: string;
  78136. /**
  78137. * Defines the location of the file to load
  78138. */
  78139. url: string;
  78140. /**
  78141. * Gets the lodaded data (as an array buffer)
  78142. */
  78143. data: ArrayBuffer;
  78144. /**
  78145. * Callback called when the task is successful
  78146. */
  78147. onSuccess: (task: BinaryFileAssetTask) => void;
  78148. /**
  78149. * Callback called when the task is successful
  78150. */
  78151. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78152. /**
  78153. * Creates a new BinaryFileAssetTask object
  78154. * @param name defines the name of the new task
  78155. * @param url defines the location of the file to load
  78156. */
  78157. constructor(
  78158. /**
  78159. * Defines the name of the task
  78160. */
  78161. name: string,
  78162. /**
  78163. * Defines the location of the file to load
  78164. */
  78165. url: string);
  78166. /**
  78167. * Execute the current task
  78168. * @param scene defines the scene where you want your assets to be loaded
  78169. * @param onSuccess is a callback called when the task is successfully executed
  78170. * @param onError is a callback called if an error occurs
  78171. */
  78172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78173. }
  78174. /**
  78175. * Define a task used by AssetsManager to load images
  78176. */
  78177. export class ImageAssetTask extends AbstractAssetTask {
  78178. /**
  78179. * Defines the name of the task
  78180. */
  78181. name: string;
  78182. /**
  78183. * Defines the location of the image to load
  78184. */
  78185. url: string;
  78186. /**
  78187. * Gets the loaded images
  78188. */
  78189. image: HTMLImageElement;
  78190. /**
  78191. * Callback called when the task is successful
  78192. */
  78193. onSuccess: (task: ImageAssetTask) => void;
  78194. /**
  78195. * Callback called when the task is successful
  78196. */
  78197. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78198. /**
  78199. * Creates a new ImageAssetTask
  78200. * @param name defines the name of the task
  78201. * @param url defines the location of the image to load
  78202. */
  78203. constructor(
  78204. /**
  78205. * Defines the name of the task
  78206. */
  78207. name: string,
  78208. /**
  78209. * Defines the location of the image to load
  78210. */
  78211. url: string);
  78212. /**
  78213. * Execute the current task
  78214. * @param scene defines the scene where you want your assets to be loaded
  78215. * @param onSuccess is a callback called when the task is successfully executed
  78216. * @param onError is a callback called if an error occurs
  78217. */
  78218. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78219. }
  78220. /**
  78221. * Defines the interface used by texture loading tasks
  78222. */
  78223. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78224. /**
  78225. * Gets the loaded texture
  78226. */
  78227. texture: TEX;
  78228. }
  78229. /**
  78230. * Define a task used by AssetsManager to load 2D textures
  78231. */
  78232. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78233. /**
  78234. * Defines the name of the task
  78235. */
  78236. name: string;
  78237. /**
  78238. * Defines the location of the file to load
  78239. */
  78240. url: string;
  78241. /**
  78242. * Defines if mipmap should not be generated (default is false)
  78243. */
  78244. noMipmap?: boolean | undefined;
  78245. /**
  78246. * Defines if texture must be inverted on Y axis (default is true)
  78247. */
  78248. invertY: boolean;
  78249. /**
  78250. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78251. */
  78252. samplingMode: number;
  78253. /**
  78254. * Gets the loaded texture
  78255. */
  78256. texture: Texture;
  78257. /**
  78258. * Callback called when the task is successful
  78259. */
  78260. onSuccess: (task: TextureAssetTask) => void;
  78261. /**
  78262. * Callback called when the task is successful
  78263. */
  78264. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78265. /**
  78266. * Creates a new TextureAssetTask object
  78267. * @param name defines the name of the task
  78268. * @param url defines the location of the file to load
  78269. * @param noMipmap defines if mipmap should not be generated (default is false)
  78270. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78271. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78272. */
  78273. constructor(
  78274. /**
  78275. * Defines the name of the task
  78276. */
  78277. name: string,
  78278. /**
  78279. * Defines the location of the file to load
  78280. */
  78281. url: string,
  78282. /**
  78283. * Defines if mipmap should not be generated (default is false)
  78284. */
  78285. noMipmap?: boolean | undefined,
  78286. /**
  78287. * Defines if texture must be inverted on Y axis (default is true)
  78288. */
  78289. invertY?: boolean,
  78290. /**
  78291. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78292. */
  78293. samplingMode?: number);
  78294. /**
  78295. * Execute the current task
  78296. * @param scene defines the scene where you want your assets to be loaded
  78297. * @param onSuccess is a callback called when the task is successfully executed
  78298. * @param onError is a callback called if an error occurs
  78299. */
  78300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78301. }
  78302. /**
  78303. * Define a task used by AssetsManager to load cube textures
  78304. */
  78305. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78306. /**
  78307. * Defines the name of the task
  78308. */
  78309. name: string;
  78310. /**
  78311. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78312. */
  78313. url: string;
  78314. /**
  78315. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78316. */
  78317. extensions?: string[] | undefined;
  78318. /**
  78319. * Defines if mipmaps should not be generated (default is false)
  78320. */
  78321. noMipmap?: boolean | undefined;
  78322. /**
  78323. * Defines the explicit list of files (undefined by default)
  78324. */
  78325. files?: string[] | undefined;
  78326. /**
  78327. * Gets the loaded texture
  78328. */
  78329. texture: CubeTexture;
  78330. /**
  78331. * Callback called when the task is successful
  78332. */
  78333. onSuccess: (task: CubeTextureAssetTask) => void;
  78334. /**
  78335. * Callback called when the task is successful
  78336. */
  78337. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78338. /**
  78339. * Creates a new CubeTextureAssetTask
  78340. * @param name defines the name of the task
  78341. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78342. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78343. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78344. * @param files defines the explicit list of files (undefined by default)
  78345. */
  78346. constructor(
  78347. /**
  78348. * Defines the name of the task
  78349. */
  78350. name: string,
  78351. /**
  78352. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78353. */
  78354. url: string,
  78355. /**
  78356. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78357. */
  78358. extensions?: string[] | undefined,
  78359. /**
  78360. * Defines if mipmaps should not be generated (default is false)
  78361. */
  78362. noMipmap?: boolean | undefined,
  78363. /**
  78364. * Defines the explicit list of files (undefined by default)
  78365. */
  78366. files?: string[] | undefined);
  78367. /**
  78368. * Execute the current task
  78369. * @param scene defines the scene where you want your assets to be loaded
  78370. * @param onSuccess is a callback called when the task is successfully executed
  78371. * @param onError is a callback called if an error occurs
  78372. */
  78373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78374. }
  78375. /**
  78376. * Define a task used by AssetsManager to load HDR cube textures
  78377. */
  78378. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78379. /**
  78380. * Defines the name of the task
  78381. */
  78382. name: string;
  78383. /**
  78384. * Defines the location of the file to load
  78385. */
  78386. url: string;
  78387. /**
  78388. * Defines the desired size (the more it increases the longer the generation will be)
  78389. */
  78390. size: number;
  78391. /**
  78392. * Defines if mipmaps should not be generated (default is false)
  78393. */
  78394. noMipmap: boolean;
  78395. /**
  78396. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78397. */
  78398. generateHarmonics: boolean;
  78399. /**
  78400. * 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)
  78401. */
  78402. gammaSpace: boolean;
  78403. /**
  78404. * Internal Use Only
  78405. */
  78406. reserved: boolean;
  78407. /**
  78408. * Gets the loaded texture
  78409. */
  78410. texture: HDRCubeTexture;
  78411. /**
  78412. * Callback called when the task is successful
  78413. */
  78414. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78415. /**
  78416. * Callback called when the task is successful
  78417. */
  78418. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78419. /**
  78420. * Creates a new HDRCubeTextureAssetTask object
  78421. * @param name defines the name of the task
  78422. * @param url defines the location of the file to load
  78423. * @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.
  78424. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78425. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78426. * @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)
  78427. * @param reserved Internal use only
  78428. */
  78429. constructor(
  78430. /**
  78431. * Defines the name of the task
  78432. */
  78433. name: string,
  78434. /**
  78435. * Defines the location of the file to load
  78436. */
  78437. url: string,
  78438. /**
  78439. * Defines the desired size (the more it increases the longer the generation will be)
  78440. */
  78441. size: number,
  78442. /**
  78443. * Defines if mipmaps should not be generated (default is false)
  78444. */
  78445. noMipmap?: boolean,
  78446. /**
  78447. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78448. */
  78449. generateHarmonics?: boolean,
  78450. /**
  78451. * 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)
  78452. */
  78453. gammaSpace?: boolean,
  78454. /**
  78455. * Internal Use Only
  78456. */
  78457. reserved?: boolean);
  78458. /**
  78459. * Execute the current task
  78460. * @param scene defines the scene where you want your assets to be loaded
  78461. * @param onSuccess is a callback called when the task is successfully executed
  78462. * @param onError is a callback called if an error occurs
  78463. */
  78464. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78465. }
  78466. /**
  78467. * Define a task used by AssetsManager to load Equirectangular cube textures
  78468. */
  78469. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78470. /**
  78471. * Defines the name of the task
  78472. */
  78473. name: string;
  78474. /**
  78475. * Defines the location of the file to load
  78476. */
  78477. url: string;
  78478. /**
  78479. * Defines the desired size (the more it increases the longer the generation will be)
  78480. */
  78481. size: number;
  78482. /**
  78483. * Defines if mipmaps should not be generated (default is false)
  78484. */
  78485. noMipmap: boolean;
  78486. /**
  78487. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78488. * but the standard material would require them in Gamma space) (default is true)
  78489. */
  78490. gammaSpace: boolean;
  78491. /**
  78492. * Gets the loaded texture
  78493. */
  78494. texture: EquiRectangularCubeTexture;
  78495. /**
  78496. * Callback called when the task is successful
  78497. */
  78498. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78499. /**
  78500. * Callback called when the task is successful
  78501. */
  78502. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78503. /**
  78504. * Creates a new EquiRectangularCubeTextureAssetTask object
  78505. * @param name defines the name of the task
  78506. * @param url defines the location of the file to load
  78507. * @param size defines the desired size (the more it increases the longer the generation will be)
  78508. * If the size is omitted this implies you are using a preprocessed cubemap.
  78509. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78510. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78511. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78512. * (default is true)
  78513. */
  78514. constructor(
  78515. /**
  78516. * Defines the name of the task
  78517. */
  78518. name: string,
  78519. /**
  78520. * Defines the location of the file to load
  78521. */
  78522. url: string,
  78523. /**
  78524. * Defines the desired size (the more it increases the longer the generation will be)
  78525. */
  78526. size: number,
  78527. /**
  78528. * Defines if mipmaps should not be generated (default is false)
  78529. */
  78530. noMipmap?: boolean,
  78531. /**
  78532. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78533. * but the standard material would require them in Gamma space) (default is true)
  78534. */
  78535. gammaSpace?: boolean);
  78536. /**
  78537. * Execute the current task
  78538. * @param scene defines the scene where you want your assets to be loaded
  78539. * @param onSuccess is a callback called when the task is successfully executed
  78540. * @param onError is a callback called if an error occurs
  78541. */
  78542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78543. }
  78544. /**
  78545. * This class can be used to easily import assets into a scene
  78546. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78547. */
  78548. export class AssetsManager {
  78549. private _scene;
  78550. private _isLoading;
  78551. protected _tasks: AbstractAssetTask[];
  78552. protected _waitingTasksCount: number;
  78553. protected _totalTasksCount: number;
  78554. /**
  78555. * Callback called when all tasks are processed
  78556. */
  78557. onFinish: (tasks: AbstractAssetTask[]) => void;
  78558. /**
  78559. * Callback called when a task is successful
  78560. */
  78561. onTaskSuccess: (task: AbstractAssetTask) => void;
  78562. /**
  78563. * Callback called when a task had an error
  78564. */
  78565. onTaskError: (task: AbstractAssetTask) => void;
  78566. /**
  78567. * Callback called when a task is done (whatever the result is)
  78568. */
  78569. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78570. /**
  78571. * Observable called when all tasks are processed
  78572. */
  78573. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78574. /**
  78575. * Observable called when a task had an error
  78576. */
  78577. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78578. /**
  78579. * Observable called when all tasks were executed
  78580. */
  78581. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78582. /**
  78583. * Observable called when a task is done (whatever the result is)
  78584. */
  78585. onProgressObservable: Observable<IAssetsProgressEvent>;
  78586. /**
  78587. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78588. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78589. */
  78590. useDefaultLoadingScreen: boolean;
  78591. /**
  78592. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78593. * when all assets have been downloaded.
  78594. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78595. */
  78596. autoHideLoadingUI: boolean;
  78597. /**
  78598. * Creates a new AssetsManager
  78599. * @param scene defines the scene to work on
  78600. */
  78601. constructor(scene: Scene);
  78602. /**
  78603. * Add a ContainerAssetTask to the list of active tasks
  78604. * @param taskName defines the name of the new task
  78605. * @param meshesNames defines the name of meshes to load
  78606. * @param rootUrl defines the root url to use to locate files
  78607. * @param sceneFilename defines the filename of the scene file
  78608. * @returns a new ContainerAssetTask object
  78609. */
  78610. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78611. /**
  78612. * Add a MeshAssetTask to the list of active tasks
  78613. * @param taskName defines the name of the new task
  78614. * @param meshesNames defines the name of meshes to load
  78615. * @param rootUrl defines the root url to use to locate files
  78616. * @param sceneFilename defines the filename of the scene file
  78617. * @returns a new MeshAssetTask object
  78618. */
  78619. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78620. /**
  78621. * Add a TextFileAssetTask to the list of active tasks
  78622. * @param taskName defines the name of the new task
  78623. * @param url defines the url of the file to load
  78624. * @returns a new TextFileAssetTask object
  78625. */
  78626. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78627. /**
  78628. * Add a BinaryFileAssetTask to the list of active tasks
  78629. * @param taskName defines the name of the new task
  78630. * @param url defines the url of the file to load
  78631. * @returns a new BinaryFileAssetTask object
  78632. */
  78633. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78634. /**
  78635. * Add a ImageAssetTask to the list of active tasks
  78636. * @param taskName defines the name of the new task
  78637. * @param url defines the url of the file to load
  78638. * @returns a new ImageAssetTask object
  78639. */
  78640. addImageTask(taskName: string, url: string): ImageAssetTask;
  78641. /**
  78642. * Add a TextureAssetTask to the list of active tasks
  78643. * @param taskName defines the name of the new task
  78644. * @param url defines the url of the file to load
  78645. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78646. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78647. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78648. * @returns a new TextureAssetTask object
  78649. */
  78650. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78651. /**
  78652. * Add a CubeTextureAssetTask to the list of active tasks
  78653. * @param taskName defines the name of the new task
  78654. * @param url defines the url of the file to load
  78655. * @param extensions defines the extension to use to load the cube map (can be null)
  78656. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78657. * @param files defines the list of files to load (can be null)
  78658. * @returns a new CubeTextureAssetTask object
  78659. */
  78660. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78661. /**
  78662. *
  78663. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78664. * @param taskName defines the name of the new task
  78665. * @param url defines the url of the file to load
  78666. * @param size defines the size you want for the cubemap (can be null)
  78667. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78668. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78669. * @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)
  78670. * @param reserved Internal use only
  78671. * @returns a new HDRCubeTextureAssetTask object
  78672. */
  78673. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78674. /**
  78675. *
  78676. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78677. * @param taskName defines the name of the new task
  78678. * @param url defines the url of the file to load
  78679. * @param size defines the size you want for the cubemap (can be null)
  78680. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78681. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78682. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78683. * @returns a new EquiRectangularCubeTextureAssetTask object
  78684. */
  78685. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78686. /**
  78687. * Remove a task from the assets manager.
  78688. * @param task the task to remove
  78689. */
  78690. removeTask(task: AbstractAssetTask): void;
  78691. private _decreaseWaitingTasksCount;
  78692. private _runTask;
  78693. /**
  78694. * Reset the AssetsManager and remove all tasks
  78695. * @return the current instance of the AssetsManager
  78696. */
  78697. reset(): AssetsManager;
  78698. /**
  78699. * Start the loading process
  78700. * @return the current instance of the AssetsManager
  78701. */
  78702. load(): AssetsManager;
  78703. /**
  78704. * Start the loading process as an async operation
  78705. * @return a promise returning the list of failed tasks
  78706. */
  78707. loadAsync(): Promise<void>;
  78708. }
  78709. }
  78710. declare module "babylonjs/Misc/deferred" {
  78711. /**
  78712. * Wrapper class for promise with external resolve and reject.
  78713. */
  78714. export class Deferred<T> {
  78715. /**
  78716. * The promise associated with this deferred object.
  78717. */
  78718. readonly promise: Promise<T>;
  78719. private _resolve;
  78720. private _reject;
  78721. /**
  78722. * The resolve method of the promise associated with this deferred object.
  78723. */
  78724. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78725. /**
  78726. * The reject method of the promise associated with this deferred object.
  78727. */
  78728. get reject(): (reason?: any) => void;
  78729. /**
  78730. * Constructor for this deferred object.
  78731. */
  78732. constructor();
  78733. }
  78734. }
  78735. declare module "babylonjs/Misc/meshExploder" {
  78736. import { Mesh } from "babylonjs/Meshes/mesh";
  78737. /**
  78738. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78739. */
  78740. export class MeshExploder {
  78741. private _centerMesh;
  78742. private _meshes;
  78743. private _meshesOrigins;
  78744. private _toCenterVectors;
  78745. private _scaledDirection;
  78746. private _newPosition;
  78747. private _centerPosition;
  78748. /**
  78749. * Explodes meshes from a center mesh.
  78750. * @param meshes The meshes to explode.
  78751. * @param centerMesh The mesh to be center of explosion.
  78752. */
  78753. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78754. private _setCenterMesh;
  78755. /**
  78756. * Get class name
  78757. * @returns "MeshExploder"
  78758. */
  78759. getClassName(): string;
  78760. /**
  78761. * "Exploded meshes"
  78762. * @returns Array of meshes with the centerMesh at index 0.
  78763. */
  78764. getMeshes(): Array<Mesh>;
  78765. /**
  78766. * Explodes meshes giving a specific direction
  78767. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78768. */
  78769. explode(direction?: number): void;
  78770. }
  78771. }
  78772. declare module "babylonjs/Misc/filesInput" {
  78773. import { Engine } from "babylonjs/Engines/engine";
  78774. import { Scene } from "babylonjs/scene";
  78775. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78776. import { Nullable } from "babylonjs/types";
  78777. /**
  78778. * Class used to help managing file picking and drag'n'drop
  78779. */
  78780. export class FilesInput {
  78781. /**
  78782. * List of files ready to be loaded
  78783. */
  78784. static get FilesToLoad(): {
  78785. [key: string]: File;
  78786. };
  78787. /**
  78788. * Callback called when a file is processed
  78789. */
  78790. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78791. private _engine;
  78792. private _currentScene;
  78793. private _sceneLoadedCallback;
  78794. private _progressCallback;
  78795. private _additionalRenderLoopLogicCallback;
  78796. private _textureLoadingCallback;
  78797. private _startingProcessingFilesCallback;
  78798. private _onReloadCallback;
  78799. private _errorCallback;
  78800. private _elementToMonitor;
  78801. private _sceneFileToLoad;
  78802. private _filesToLoad;
  78803. /**
  78804. * Creates a new FilesInput
  78805. * @param engine defines the rendering engine
  78806. * @param scene defines the hosting scene
  78807. * @param sceneLoadedCallback callback called when scene is loaded
  78808. * @param progressCallback callback called to track progress
  78809. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78810. * @param textureLoadingCallback callback called when a texture is loading
  78811. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78812. * @param onReloadCallback callback called when a reload is requested
  78813. * @param errorCallback callback call if an error occurs
  78814. */
  78815. 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>);
  78816. private _dragEnterHandler;
  78817. private _dragOverHandler;
  78818. private _dropHandler;
  78819. /**
  78820. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78821. * @param elementToMonitor defines the DOM element to track
  78822. */
  78823. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78824. /** Gets the current list of files to load */
  78825. get filesToLoad(): File[];
  78826. /**
  78827. * Release all associated resources
  78828. */
  78829. dispose(): void;
  78830. private renderFunction;
  78831. private drag;
  78832. private drop;
  78833. private _traverseFolder;
  78834. private _processFiles;
  78835. /**
  78836. * Load files from a drop event
  78837. * @param event defines the drop event to use as source
  78838. */
  78839. loadFiles(event: any): void;
  78840. private _processReload;
  78841. /**
  78842. * Reload the current scene from the loaded files
  78843. */
  78844. reload(): void;
  78845. }
  78846. }
  78847. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78848. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78849. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78850. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78851. }
  78852. declare module "babylonjs/Misc/sceneOptimizer" {
  78853. import { Scene, IDisposable } from "babylonjs/scene";
  78854. import { Observable } from "babylonjs/Misc/observable";
  78855. /**
  78856. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78857. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78858. */
  78859. export class SceneOptimization {
  78860. /**
  78861. * Defines the priority of this optimization (0 by default which means first in the list)
  78862. */
  78863. priority: number;
  78864. /**
  78865. * Gets a string describing the action executed by the current optimization
  78866. * @returns description string
  78867. */
  78868. getDescription(): string;
  78869. /**
  78870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78871. * @param scene defines the current scene where to apply this optimization
  78872. * @param optimizer defines the current optimizer
  78873. * @returns true if everything that can be done was applied
  78874. */
  78875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78876. /**
  78877. * Creates the SceneOptimization object
  78878. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78879. * @param desc defines the description associated with the optimization
  78880. */
  78881. constructor(
  78882. /**
  78883. * Defines the priority of this optimization (0 by default which means first in the list)
  78884. */
  78885. priority?: number);
  78886. }
  78887. /**
  78888. * Defines an optimization used to reduce the size of render target textures
  78889. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78890. */
  78891. export class TextureOptimization extends SceneOptimization {
  78892. /**
  78893. * Defines the priority of this optimization (0 by default which means first in the list)
  78894. */
  78895. priority: number;
  78896. /**
  78897. * 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
  78898. */
  78899. maximumSize: number;
  78900. /**
  78901. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78902. */
  78903. step: number;
  78904. /**
  78905. * Gets a string describing the action executed by the current optimization
  78906. * @returns description string
  78907. */
  78908. getDescription(): string;
  78909. /**
  78910. * Creates the TextureOptimization object
  78911. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78912. * @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
  78913. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78914. */
  78915. constructor(
  78916. /**
  78917. * Defines the priority of this optimization (0 by default which means first in the list)
  78918. */
  78919. priority?: number,
  78920. /**
  78921. * 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
  78922. */
  78923. maximumSize?: number,
  78924. /**
  78925. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78926. */
  78927. step?: number);
  78928. /**
  78929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78930. * @param scene defines the current scene where to apply this optimization
  78931. * @param optimizer defines the current optimizer
  78932. * @returns true if everything that can be done was applied
  78933. */
  78934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78935. }
  78936. /**
  78937. * Defines an optimization used to increase or decrease the rendering resolution
  78938. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78939. */
  78940. export class HardwareScalingOptimization extends SceneOptimization {
  78941. /**
  78942. * Defines the priority of this optimization (0 by default which means first in the list)
  78943. */
  78944. priority: number;
  78945. /**
  78946. * Defines the maximum scale to use (2 by default)
  78947. */
  78948. maximumScale: number;
  78949. /**
  78950. * Defines the step to use between two passes (0.5 by default)
  78951. */
  78952. step: number;
  78953. private _currentScale;
  78954. private _directionOffset;
  78955. /**
  78956. * Gets a string describing the action executed by the current optimization
  78957. * @return description string
  78958. */
  78959. getDescription(): string;
  78960. /**
  78961. * Creates the HardwareScalingOptimization object
  78962. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78963. * @param maximumScale defines the maximum scale to use (2 by default)
  78964. * @param step defines the step to use between two passes (0.5 by default)
  78965. */
  78966. constructor(
  78967. /**
  78968. * Defines the priority of this optimization (0 by default which means first in the list)
  78969. */
  78970. priority?: number,
  78971. /**
  78972. * Defines the maximum scale to use (2 by default)
  78973. */
  78974. maximumScale?: number,
  78975. /**
  78976. * Defines the step to use between two passes (0.5 by default)
  78977. */
  78978. step?: number);
  78979. /**
  78980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78981. * @param scene defines the current scene where to apply this optimization
  78982. * @param optimizer defines the current optimizer
  78983. * @returns true if everything that can be done was applied
  78984. */
  78985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78986. }
  78987. /**
  78988. * Defines an optimization used to remove shadows
  78989. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78990. */
  78991. export class ShadowsOptimization extends SceneOptimization {
  78992. /**
  78993. * Gets a string describing the action executed by the current optimization
  78994. * @return description string
  78995. */
  78996. getDescription(): string;
  78997. /**
  78998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78999. * @param scene defines the current scene where to apply this optimization
  79000. * @param optimizer defines the current optimizer
  79001. * @returns true if everything that can be done was applied
  79002. */
  79003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79004. }
  79005. /**
  79006. * Defines an optimization used to turn post-processes off
  79007. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79008. */
  79009. export class PostProcessesOptimization extends SceneOptimization {
  79010. /**
  79011. * Gets a string describing the action executed by the current optimization
  79012. * @return description string
  79013. */
  79014. getDescription(): string;
  79015. /**
  79016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79017. * @param scene defines the current scene where to apply this optimization
  79018. * @param optimizer defines the current optimizer
  79019. * @returns true if everything that can be done was applied
  79020. */
  79021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79022. }
  79023. /**
  79024. * Defines an optimization used to turn lens flares off
  79025. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79026. */
  79027. export class LensFlaresOptimization extends SceneOptimization {
  79028. /**
  79029. * Gets a string describing the action executed by the current optimization
  79030. * @return description string
  79031. */
  79032. getDescription(): string;
  79033. /**
  79034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79035. * @param scene defines the current scene where to apply this optimization
  79036. * @param optimizer defines the current optimizer
  79037. * @returns true if everything that can be done was applied
  79038. */
  79039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79040. }
  79041. /**
  79042. * Defines an optimization based on user defined callback.
  79043. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79044. */
  79045. export class CustomOptimization extends SceneOptimization {
  79046. /**
  79047. * Callback called to apply the custom optimization.
  79048. */
  79049. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79050. /**
  79051. * Callback called to get custom description
  79052. */
  79053. onGetDescription: () => string;
  79054. /**
  79055. * Gets a string describing the action executed by the current optimization
  79056. * @returns description string
  79057. */
  79058. getDescription(): string;
  79059. /**
  79060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79061. * @param scene defines the current scene where to apply this optimization
  79062. * @param optimizer defines the current optimizer
  79063. * @returns true if everything that can be done was applied
  79064. */
  79065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79066. }
  79067. /**
  79068. * Defines an optimization used to turn particles off
  79069. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79070. */
  79071. export class ParticlesOptimization extends SceneOptimization {
  79072. /**
  79073. * Gets a string describing the action executed by the current optimization
  79074. * @return description string
  79075. */
  79076. getDescription(): string;
  79077. /**
  79078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79079. * @param scene defines the current scene where to apply this optimization
  79080. * @param optimizer defines the current optimizer
  79081. * @returns true if everything that can be done was applied
  79082. */
  79083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79084. }
  79085. /**
  79086. * Defines an optimization used to turn render targets off
  79087. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79088. */
  79089. export class RenderTargetsOptimization extends SceneOptimization {
  79090. /**
  79091. * Gets a string describing the action executed by the current optimization
  79092. * @return description string
  79093. */
  79094. getDescription(): string;
  79095. /**
  79096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79097. * @param scene defines the current scene where to apply this optimization
  79098. * @param optimizer defines the current optimizer
  79099. * @returns true if everything that can be done was applied
  79100. */
  79101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79102. }
  79103. /**
  79104. * Defines an optimization used to merge meshes with compatible materials
  79105. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79106. */
  79107. export class MergeMeshesOptimization extends SceneOptimization {
  79108. private static _UpdateSelectionTree;
  79109. /**
  79110. * Gets or sets a boolean which defines if optimization octree has to be updated
  79111. */
  79112. static get UpdateSelectionTree(): boolean;
  79113. /**
  79114. * Gets or sets a boolean which defines if optimization octree has to be updated
  79115. */
  79116. static set UpdateSelectionTree(value: boolean);
  79117. /**
  79118. * Gets a string describing the action executed by the current optimization
  79119. * @return description string
  79120. */
  79121. getDescription(): string;
  79122. private _canBeMerged;
  79123. /**
  79124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79125. * @param scene defines the current scene where to apply this optimization
  79126. * @param optimizer defines the current optimizer
  79127. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79128. * @returns true if everything that can be done was applied
  79129. */
  79130. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79131. }
  79132. /**
  79133. * Defines a list of options used by SceneOptimizer
  79134. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79135. */
  79136. export class SceneOptimizerOptions {
  79137. /**
  79138. * Defines the target frame rate to reach (60 by default)
  79139. */
  79140. targetFrameRate: number;
  79141. /**
  79142. * Defines the interval between two checkes (2000ms by default)
  79143. */
  79144. trackerDuration: number;
  79145. /**
  79146. * Gets the list of optimizations to apply
  79147. */
  79148. optimizations: SceneOptimization[];
  79149. /**
  79150. * Creates a new list of options used by SceneOptimizer
  79151. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79152. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79153. */
  79154. constructor(
  79155. /**
  79156. * Defines the target frame rate to reach (60 by default)
  79157. */
  79158. targetFrameRate?: number,
  79159. /**
  79160. * Defines the interval between two checkes (2000ms by default)
  79161. */
  79162. trackerDuration?: number);
  79163. /**
  79164. * Add a new optimization
  79165. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79166. * @returns the current SceneOptimizerOptions
  79167. */
  79168. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79169. /**
  79170. * Add a new custom optimization
  79171. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79172. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79173. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79174. * @returns the current SceneOptimizerOptions
  79175. */
  79176. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79177. /**
  79178. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79179. * @param targetFrameRate defines the target frame rate (60 by default)
  79180. * @returns a SceneOptimizerOptions object
  79181. */
  79182. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79183. /**
  79184. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79185. * @param targetFrameRate defines the target frame rate (60 by default)
  79186. * @returns a SceneOptimizerOptions object
  79187. */
  79188. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79189. /**
  79190. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79191. * @param targetFrameRate defines the target frame rate (60 by default)
  79192. * @returns a SceneOptimizerOptions object
  79193. */
  79194. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79195. }
  79196. /**
  79197. * Class used to run optimizations in order to reach a target frame rate
  79198. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79199. */
  79200. export class SceneOptimizer implements IDisposable {
  79201. private _isRunning;
  79202. private _options;
  79203. private _scene;
  79204. private _currentPriorityLevel;
  79205. private _targetFrameRate;
  79206. private _trackerDuration;
  79207. private _currentFrameRate;
  79208. private _sceneDisposeObserver;
  79209. private _improvementMode;
  79210. /**
  79211. * Defines an observable called when the optimizer reaches the target frame rate
  79212. */
  79213. onSuccessObservable: Observable<SceneOptimizer>;
  79214. /**
  79215. * Defines an observable called when the optimizer enables an optimization
  79216. */
  79217. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79218. /**
  79219. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79220. */
  79221. onFailureObservable: Observable<SceneOptimizer>;
  79222. /**
  79223. * Gets a boolean indicating if the optimizer is in improvement mode
  79224. */
  79225. get isInImprovementMode(): boolean;
  79226. /**
  79227. * Gets the current priority level (0 at start)
  79228. */
  79229. get currentPriorityLevel(): number;
  79230. /**
  79231. * Gets the current frame rate checked by the SceneOptimizer
  79232. */
  79233. get currentFrameRate(): number;
  79234. /**
  79235. * Gets or sets the current target frame rate (60 by default)
  79236. */
  79237. get targetFrameRate(): number;
  79238. /**
  79239. * Gets or sets the current target frame rate (60 by default)
  79240. */
  79241. set targetFrameRate(value: number);
  79242. /**
  79243. * Gets or sets the current interval between two checks (every 2000ms by default)
  79244. */
  79245. get trackerDuration(): number;
  79246. /**
  79247. * Gets or sets the current interval between two checks (every 2000ms by default)
  79248. */
  79249. set trackerDuration(value: number);
  79250. /**
  79251. * Gets the list of active optimizations
  79252. */
  79253. get optimizations(): SceneOptimization[];
  79254. /**
  79255. * Creates a new SceneOptimizer
  79256. * @param scene defines the scene to work on
  79257. * @param options defines the options to use with the SceneOptimizer
  79258. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79259. * @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)
  79260. */
  79261. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79262. /**
  79263. * Stops the current optimizer
  79264. */
  79265. stop(): void;
  79266. /**
  79267. * Reset the optimizer to initial step (current priority level = 0)
  79268. */
  79269. reset(): void;
  79270. /**
  79271. * Start the optimizer. By default it will try to reach a specific framerate
  79272. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79273. */
  79274. start(): void;
  79275. private _checkCurrentState;
  79276. /**
  79277. * Release all resources
  79278. */
  79279. dispose(): void;
  79280. /**
  79281. * Helper function to create a SceneOptimizer with one single line of code
  79282. * @param scene defines the scene to work on
  79283. * @param options defines the options to use with the SceneOptimizer
  79284. * @param onSuccess defines a callback to call on success
  79285. * @param onFailure defines a callback to call on failure
  79286. * @returns the new SceneOptimizer object
  79287. */
  79288. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79289. }
  79290. }
  79291. declare module "babylonjs/Misc/sceneSerializer" {
  79292. import { Scene } from "babylonjs/scene";
  79293. /**
  79294. * Class used to serialize a scene into a string
  79295. */
  79296. export class SceneSerializer {
  79297. /**
  79298. * Clear cache used by a previous serialization
  79299. */
  79300. static ClearCache(): void;
  79301. /**
  79302. * Serialize a scene into a JSON compatible object
  79303. * @param scene defines the scene to serialize
  79304. * @returns a JSON compatible object
  79305. */
  79306. static Serialize(scene: Scene): any;
  79307. /**
  79308. * Serialize a mesh into a JSON compatible object
  79309. * @param toSerialize defines the mesh to serialize
  79310. * @param withParents defines if parents must be serialized as well
  79311. * @param withChildren defines if children must be serialized as well
  79312. * @returns a JSON compatible object
  79313. */
  79314. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79315. }
  79316. }
  79317. declare module "babylonjs/Misc/textureTools" {
  79318. import { Texture } from "babylonjs/Materials/Textures/texture";
  79319. /**
  79320. * Class used to host texture specific utilities
  79321. */
  79322. export class TextureTools {
  79323. /**
  79324. * Uses the GPU to create a copy texture rescaled at a given size
  79325. * @param texture Texture to copy from
  79326. * @param width defines the desired width
  79327. * @param height defines the desired height
  79328. * @param useBilinearMode defines if bilinear mode has to be used
  79329. * @return the generated texture
  79330. */
  79331. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79332. }
  79333. }
  79334. declare module "babylonjs/Misc/videoRecorder" {
  79335. import { Nullable } from "babylonjs/types";
  79336. import { Engine } from "babylonjs/Engines/engine";
  79337. /**
  79338. * This represents the different options available for the video capture.
  79339. */
  79340. export interface VideoRecorderOptions {
  79341. /** Defines the mime type of the video. */
  79342. mimeType: string;
  79343. /** Defines the FPS the video should be recorded at. */
  79344. fps: number;
  79345. /** Defines the chunk size for the recording data. */
  79346. recordChunckSize: number;
  79347. /** The audio tracks to attach to the recording. */
  79348. audioTracks?: MediaStreamTrack[];
  79349. }
  79350. /**
  79351. * This can help with recording videos from BabylonJS.
  79352. * This is based on the available WebRTC functionalities of the browser.
  79353. *
  79354. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79355. */
  79356. export class VideoRecorder {
  79357. private static readonly _defaultOptions;
  79358. /**
  79359. * Returns whether or not the VideoRecorder is available in your browser.
  79360. * @param engine Defines the Babylon Engine.
  79361. * @returns true if supported otherwise false.
  79362. */
  79363. static IsSupported(engine: Engine): boolean;
  79364. private readonly _options;
  79365. private _canvas;
  79366. private _mediaRecorder;
  79367. private _recordedChunks;
  79368. private _fileName;
  79369. private _resolve;
  79370. private _reject;
  79371. /**
  79372. * True when a recording is already in progress.
  79373. */
  79374. get isRecording(): boolean;
  79375. /**
  79376. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79377. * @param engine Defines the BabylonJS Engine you wish to record.
  79378. * @param options Defines options that can be used to customize the capture.
  79379. */
  79380. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79381. /**
  79382. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79383. */
  79384. stopRecording(): void;
  79385. /**
  79386. * Starts recording the canvas for a max duration specified in parameters.
  79387. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79388. * If null no automatic download will start and you can rely on the promise to get the data back.
  79389. * @param maxDuration Defines the maximum recording time in seconds.
  79390. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79391. * @return A promise callback at the end of the recording with the video data in Blob.
  79392. */
  79393. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79394. /**
  79395. * Releases internal resources used during the recording.
  79396. */
  79397. dispose(): void;
  79398. private _handleDataAvailable;
  79399. private _handleError;
  79400. private _handleStop;
  79401. }
  79402. }
  79403. declare module "babylonjs/Misc/screenshotTools" {
  79404. import { Camera } from "babylonjs/Cameras/camera";
  79405. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79406. import { Engine } from "babylonjs/Engines/engine";
  79407. /**
  79408. * Class containing a set of static utilities functions for screenshots
  79409. */
  79410. export class ScreenshotTools {
  79411. /**
  79412. * Captures a screenshot of the current rendering
  79413. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79414. * @param engine defines the rendering engine
  79415. * @param camera defines the source camera
  79416. * @param size This parameter can be set to a single number or to an object with the
  79417. * following (optional) properties: precision, width, height. If a single number is passed,
  79418. * it will be used for both width and height. If an object is passed, the screenshot size
  79419. * will be derived from the parameters. The precision property is a multiplier allowing
  79420. * rendering at a higher or lower resolution
  79421. * @param successCallback defines the callback receives a single parameter which contains the
  79422. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79423. * src parameter of an <img> to display it
  79424. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79425. * Check your browser for supported MIME types
  79426. */
  79427. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79428. /**
  79429. * Captures a screenshot of the current rendering
  79430. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79431. * @param engine defines the rendering engine
  79432. * @param camera defines the source camera
  79433. * @param size This parameter can be set to a single number or to an object with the
  79434. * following (optional) properties: precision, width, height. If a single number is passed,
  79435. * it will be used for both width and height. If an object is passed, the screenshot size
  79436. * will be derived from the parameters. The precision property is a multiplier allowing
  79437. * rendering at a higher or lower resolution
  79438. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79439. * Check your browser for supported MIME types
  79440. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79441. * to the src parameter of an <img> to display it
  79442. */
  79443. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79444. /**
  79445. * Generates an image screenshot from the specified camera.
  79446. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79447. * @param engine The engine to use for rendering
  79448. * @param camera The camera to use for rendering
  79449. * @param size This parameter can be set to a single number or to an object with the
  79450. * following (optional) properties: precision, width, height. If a single number is passed,
  79451. * it will be used for both width and height. If an object is passed, the screenshot size
  79452. * will be derived from the parameters. The precision property is a multiplier allowing
  79453. * rendering at a higher or lower resolution
  79454. * @param successCallback The callback receives a single parameter which contains the
  79455. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79456. * src parameter of an <img> to display it
  79457. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79458. * Check your browser for supported MIME types
  79459. * @param samples Texture samples (default: 1)
  79460. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79461. * @param fileName A name for for the downloaded file.
  79462. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79463. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79464. */
  79465. 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;
  79466. /**
  79467. * Generates an image screenshot from the specified camera.
  79468. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79469. * @param engine The engine to use for rendering
  79470. * @param camera The camera to use for rendering
  79471. * @param size This parameter can be set to a single number or to an object with the
  79472. * following (optional) properties: precision, width, height. If a single number is passed,
  79473. * it will be used for both width and height. If an object is passed, the screenshot size
  79474. * will be derived from the parameters. The precision property is a multiplier allowing
  79475. * rendering at a higher or lower resolution
  79476. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79477. * Check your browser for supported MIME types
  79478. * @param samples Texture samples (default: 1)
  79479. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79480. * @param fileName A name for for the downloaded file.
  79481. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79482. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79483. * to the src parameter of an <img> to display it
  79484. */
  79485. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79486. /**
  79487. * Gets height and width for screenshot size
  79488. * @private
  79489. */
  79490. private static _getScreenshotSize;
  79491. }
  79492. }
  79493. declare module "babylonjs/Misc/dataReader" {
  79494. /**
  79495. * Interface for a data buffer
  79496. */
  79497. export interface IDataBuffer {
  79498. /**
  79499. * Reads bytes from the data buffer.
  79500. * @param byteOffset The byte offset to read
  79501. * @param byteLength The byte length to read
  79502. * @returns A promise that resolves when the bytes are read
  79503. */
  79504. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79505. /**
  79506. * The byte length of the buffer.
  79507. */
  79508. readonly byteLength: number;
  79509. }
  79510. /**
  79511. * Utility class for reading from a data buffer
  79512. */
  79513. export class DataReader {
  79514. /**
  79515. * The data buffer associated with this data reader.
  79516. */
  79517. readonly buffer: IDataBuffer;
  79518. /**
  79519. * The current byte offset from the beginning of the data buffer.
  79520. */
  79521. byteOffset: number;
  79522. private _dataView;
  79523. private _dataByteOffset;
  79524. /**
  79525. * Constructor
  79526. * @param buffer The buffer to read
  79527. */
  79528. constructor(buffer: IDataBuffer);
  79529. /**
  79530. * Loads the given byte length.
  79531. * @param byteLength The byte length to load
  79532. * @returns A promise that resolves when the load is complete
  79533. */
  79534. loadAsync(byteLength: number): Promise<void>;
  79535. /**
  79536. * Read a unsigned 32-bit integer from the currently loaded data range.
  79537. * @returns The 32-bit integer read
  79538. */
  79539. readUint32(): number;
  79540. /**
  79541. * Read a byte array from the currently loaded data range.
  79542. * @param byteLength The byte length to read
  79543. * @returns The byte array read
  79544. */
  79545. readUint8Array(byteLength: number): Uint8Array;
  79546. /**
  79547. * Read a string from the currently loaded data range.
  79548. * @param byteLength The byte length to read
  79549. * @returns The string read
  79550. */
  79551. readString(byteLength: number): string;
  79552. /**
  79553. * Skips the given byte length the currently loaded data range.
  79554. * @param byteLength The byte length to skip
  79555. */
  79556. skipBytes(byteLength: number): void;
  79557. }
  79558. }
  79559. declare module "babylonjs/Misc/dataStorage" {
  79560. /**
  79561. * Class for storing data to local storage if available or in-memory storage otherwise
  79562. */
  79563. export class DataStorage {
  79564. private static _Storage;
  79565. private static _GetStorage;
  79566. /**
  79567. * Reads a string from the data storage
  79568. * @param key The key to read
  79569. * @param defaultValue The value if the key doesn't exist
  79570. * @returns The string value
  79571. */
  79572. static ReadString(key: string, defaultValue: string): string;
  79573. /**
  79574. * Writes a string to the data storage
  79575. * @param key The key to write
  79576. * @param value The value to write
  79577. */
  79578. static WriteString(key: string, value: string): void;
  79579. /**
  79580. * Reads a boolean from the data storage
  79581. * @param key The key to read
  79582. * @param defaultValue The value if the key doesn't exist
  79583. * @returns The boolean value
  79584. */
  79585. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79586. /**
  79587. * Writes a boolean to the data storage
  79588. * @param key The key to write
  79589. * @param value The value to write
  79590. */
  79591. static WriteBoolean(key: string, value: boolean): void;
  79592. /**
  79593. * Reads a number from the data storage
  79594. * @param key The key to read
  79595. * @param defaultValue The value if the key doesn't exist
  79596. * @returns The number value
  79597. */
  79598. static ReadNumber(key: string, defaultValue: number): number;
  79599. /**
  79600. * Writes a number to the data storage
  79601. * @param key The key to write
  79602. * @param value The value to write
  79603. */
  79604. static WriteNumber(key: string, value: number): void;
  79605. }
  79606. }
  79607. declare module "babylonjs/Misc/sceneRecorder" {
  79608. import { Scene } from "babylonjs/scene";
  79609. /**
  79610. * Class used to record delta files between 2 scene states
  79611. */
  79612. export class SceneRecorder {
  79613. private _trackedScene;
  79614. private _savedJSON;
  79615. /**
  79616. * Track a given scene. This means the current scene state will be considered the original state
  79617. * @param scene defines the scene to track
  79618. */
  79619. track(scene: Scene): void;
  79620. /**
  79621. * Get the delta between current state and original state
  79622. * @returns a string containing the delta
  79623. */
  79624. getDelta(): any;
  79625. private _compareArray;
  79626. private _compareObjects;
  79627. private _compareCollections;
  79628. private static GetShadowGeneratorById;
  79629. /**
  79630. * Apply a given delta to a given scene
  79631. * @param deltaJSON defines the JSON containing the delta
  79632. * @param scene defines the scene to apply the delta to
  79633. */
  79634. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79635. private static _ApplyPropertiesToEntity;
  79636. private static _ApplyDeltaForEntity;
  79637. }
  79638. }
  79639. declare module "babylonjs/Misc/trajectoryClassifier" {
  79640. import { DeepImmutable, Nullable } from "babylonjs/types";
  79641. import { Vector3 } from "babylonjs/Maths/math.vector";
  79642. /**
  79643. * A 3D trajectory consisting of an order list of vectors describing a
  79644. * path of motion through 3D space.
  79645. */
  79646. export class Trajectory {
  79647. private _points;
  79648. private readonly _segmentLength;
  79649. /**
  79650. * Serialize to JSON.
  79651. * @returns serialized JSON string
  79652. */
  79653. serialize(): string;
  79654. /**
  79655. * Deserialize from JSON.
  79656. * @param json serialized JSON string
  79657. * @returns deserialized Trajectory
  79658. */
  79659. static Deserialize(json: string): Trajectory;
  79660. /**
  79661. * Create a new empty Trajectory.
  79662. * @param segmentLength radius of discretization for Trajectory points
  79663. */
  79664. constructor(segmentLength?: number);
  79665. /**
  79666. * Get the length of the Trajectory.
  79667. * @returns length of the Trajectory
  79668. */
  79669. getLength(): number;
  79670. /**
  79671. * Append a new point to the Trajectory.
  79672. * NOTE: This implementation has many allocations.
  79673. * @param point point to append to the Trajectory
  79674. */
  79675. add(point: DeepImmutable<Vector3>): void;
  79676. /**
  79677. * Create a new Trajectory with a segment length chosen to make it
  79678. * probable that the new Trajectory will have a specified number of
  79679. * segments. This operation is imprecise.
  79680. * @param targetResolution number of segments desired
  79681. * @returns new Trajectory with approximately the requested number of segments
  79682. */
  79683. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79684. /**
  79685. * Convert Trajectory segments into tokenized representation. This
  79686. * representation is an array of numbers where each nth number is the
  79687. * index of the token which is most similar to the nth segment of the
  79688. * Trajectory.
  79689. * @param tokens list of vectors which serve as discrete tokens
  79690. * @returns list of indices of most similar token per segment
  79691. */
  79692. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79693. private static _forwardDir;
  79694. private static _inverseFromVec;
  79695. private static _upDir;
  79696. private static _fromToVec;
  79697. private static _lookMatrix;
  79698. /**
  79699. * Transform the rotation (i.e., direction) of a segment to isolate
  79700. * the relative transformation represented by the segment. This operation
  79701. * may or may not succeed due to singularities in the equations that define
  79702. * motion relativity in this context.
  79703. * @param priorVec the origin of the prior segment
  79704. * @param fromVec the origin of the current segment
  79705. * @param toVec the destination of the current segment
  79706. * @param result reference to output variable
  79707. * @returns whether or not transformation was successful
  79708. */
  79709. private static _transformSegmentDirToRef;
  79710. private static _bestMatch;
  79711. private static _score;
  79712. private static _bestScore;
  79713. /**
  79714. * Determine which token vector is most similar to the
  79715. * segment vector.
  79716. * @param segment segment vector
  79717. * @param tokens token vector list
  79718. * @returns index of the most similar token to the segment
  79719. */
  79720. private static _tokenizeSegment;
  79721. }
  79722. /**
  79723. * Class representing a set of known, named trajectories to which Trajectories can be
  79724. * added and using which Trajectories can be recognized.
  79725. */
  79726. export class TrajectoryClassifier {
  79727. private _maximumAllowableMatchCost;
  79728. private _vector3Alphabet;
  79729. private _levenshteinAlphabet;
  79730. private _nameToDescribedTrajectory;
  79731. /**
  79732. * Serialize to JSON.
  79733. * @returns JSON serialization
  79734. */
  79735. serialize(): string;
  79736. /**
  79737. * Deserialize from JSON.
  79738. * @param json JSON serialization
  79739. * @returns deserialized TrajectorySet
  79740. */
  79741. static Deserialize(json: string): TrajectoryClassifier;
  79742. /**
  79743. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79744. * VERY naive, need to be generating these things from known
  79745. * sets. Better version later, probably eliminating this one.
  79746. * @returns auto-generated TrajectorySet
  79747. */
  79748. static Generate(): TrajectoryClassifier;
  79749. private constructor();
  79750. /**
  79751. * Add a new Trajectory to the set with a given name.
  79752. * @param trajectory new Trajectory to be added
  79753. * @param classification name to which to add the Trajectory
  79754. */
  79755. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79756. /**
  79757. * Remove a known named trajectory and all Trajectories associated with it.
  79758. * @param classification name to remove
  79759. * @returns whether anything was removed
  79760. */
  79761. deleteClassification(classification: string): boolean;
  79762. /**
  79763. * Attempt to recognize a Trajectory from among all the classifications
  79764. * already known to the classifier.
  79765. * @param trajectory Trajectory to be recognized
  79766. * @returns classification of Trajectory if recognized, null otherwise
  79767. */
  79768. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79769. }
  79770. }
  79771. declare module "babylonjs/Misc/index" {
  79772. export * from "babylonjs/Misc/andOrNotEvaluator";
  79773. export * from "babylonjs/Misc/assetsManager";
  79774. export * from "babylonjs/Misc/basis";
  79775. export * from "babylonjs/Misc/dds";
  79776. export * from "babylonjs/Misc/decorators";
  79777. export * from "babylonjs/Misc/deferred";
  79778. export * from "babylonjs/Misc/environmentTextureTools";
  79779. export * from "babylonjs/Misc/meshExploder";
  79780. export * from "babylonjs/Misc/filesInput";
  79781. export * from "babylonjs/Misc/HighDynamicRange/index";
  79782. export * from "babylonjs/Misc/khronosTextureContainer";
  79783. export * from "babylonjs/Misc/observable";
  79784. export * from "babylonjs/Misc/performanceMonitor";
  79785. export * from "babylonjs/Misc/promise";
  79786. export * from "babylonjs/Misc/sceneOptimizer";
  79787. export * from "babylonjs/Misc/sceneSerializer";
  79788. export * from "babylonjs/Misc/smartArray";
  79789. export * from "babylonjs/Misc/stringDictionary";
  79790. export * from "babylonjs/Misc/tags";
  79791. export * from "babylonjs/Misc/textureTools";
  79792. export * from "babylonjs/Misc/tga";
  79793. export * from "babylonjs/Misc/tools";
  79794. export * from "babylonjs/Misc/videoRecorder";
  79795. export * from "babylonjs/Misc/virtualJoystick";
  79796. export * from "babylonjs/Misc/workerPool";
  79797. export * from "babylonjs/Misc/logger";
  79798. export * from "babylonjs/Misc/typeStore";
  79799. export * from "babylonjs/Misc/filesInputStore";
  79800. export * from "babylonjs/Misc/deepCopier";
  79801. export * from "babylonjs/Misc/pivotTools";
  79802. export * from "babylonjs/Misc/precisionDate";
  79803. export * from "babylonjs/Misc/screenshotTools";
  79804. export * from "babylonjs/Misc/typeStore";
  79805. export * from "babylonjs/Misc/webRequest";
  79806. export * from "babylonjs/Misc/iInspectable";
  79807. export * from "babylonjs/Misc/brdfTextureTools";
  79808. export * from "babylonjs/Misc/rgbdTextureTools";
  79809. export * from "babylonjs/Misc/gradients";
  79810. export * from "babylonjs/Misc/perfCounter";
  79811. export * from "babylonjs/Misc/fileRequest";
  79812. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79813. export * from "babylonjs/Misc/retryStrategy";
  79814. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79815. export * from "babylonjs/Misc/canvasGenerator";
  79816. export * from "babylonjs/Misc/fileTools";
  79817. export * from "babylonjs/Misc/stringTools";
  79818. export * from "babylonjs/Misc/dataReader";
  79819. export * from "babylonjs/Misc/minMaxReducer";
  79820. export * from "babylonjs/Misc/depthReducer";
  79821. export * from "babylonjs/Misc/dataStorage";
  79822. export * from "babylonjs/Misc/sceneRecorder";
  79823. export * from "babylonjs/Misc/khronosTextureContainer2";
  79824. export * from "babylonjs/Misc/trajectoryClassifier";
  79825. export * from "babylonjs/Misc/timer";
  79826. export * from "babylonjs/Misc/copyTools";
  79827. }
  79828. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79829. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79830. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79831. import { Observable } from "babylonjs/Misc/observable";
  79832. import { Matrix } from "babylonjs/Maths/math.vector";
  79833. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79834. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79835. /**
  79836. * An interface for all Hit test features
  79837. */
  79838. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79839. /**
  79840. * Triggered when new babylon (transformed) hit test results are available
  79841. */
  79842. onHitTestResultObservable: Observable<T[]>;
  79843. }
  79844. /**
  79845. * Options used for hit testing
  79846. */
  79847. export interface IWebXRLegacyHitTestOptions {
  79848. /**
  79849. * Only test when user interacted with the scene. Default - hit test every frame
  79850. */
  79851. testOnPointerDownOnly?: boolean;
  79852. /**
  79853. * The node to use to transform the local results to world coordinates
  79854. */
  79855. worldParentNode?: TransformNode;
  79856. }
  79857. /**
  79858. * Interface defining the babylon result of raycasting/hit-test
  79859. */
  79860. export interface IWebXRLegacyHitResult {
  79861. /**
  79862. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79863. */
  79864. transformationMatrix: Matrix;
  79865. /**
  79866. * The native hit test result
  79867. */
  79868. xrHitResult: XRHitResult | XRHitTestResult;
  79869. }
  79870. /**
  79871. * The currently-working hit-test module.
  79872. * Hit test (or Ray-casting) is used to interact with the real world.
  79873. * For further information read here - https://github.com/immersive-web/hit-test
  79874. */
  79875. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79876. /**
  79877. * options to use when constructing this feature
  79878. */
  79879. readonly options: IWebXRLegacyHitTestOptions;
  79880. private _direction;
  79881. private _mat;
  79882. private _onSelectEnabled;
  79883. private _origin;
  79884. /**
  79885. * The module's name
  79886. */
  79887. static readonly Name: string;
  79888. /**
  79889. * The (Babylon) version of this module.
  79890. * This is an integer representing the implementation version.
  79891. * This number does not correspond to the WebXR specs version
  79892. */
  79893. static readonly Version: number;
  79894. /**
  79895. * Populated with the last native XR Hit Results
  79896. */
  79897. lastNativeXRHitResults: XRHitResult[];
  79898. /**
  79899. * Triggered when new babylon (transformed) hit test results are available
  79900. */
  79901. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79902. /**
  79903. * Creates a new instance of the (legacy version) hit test feature
  79904. * @param _xrSessionManager an instance of WebXRSessionManager
  79905. * @param options options to use when constructing this feature
  79906. */
  79907. constructor(_xrSessionManager: WebXRSessionManager,
  79908. /**
  79909. * options to use when constructing this feature
  79910. */
  79911. options?: IWebXRLegacyHitTestOptions);
  79912. /**
  79913. * execute a hit test with an XR Ray
  79914. *
  79915. * @param xrSession a native xrSession that will execute this hit test
  79916. * @param xrRay the ray (position and direction) to use for ray-casting
  79917. * @param referenceSpace native XR reference space to use for the hit-test
  79918. * @param filter filter function that will filter the results
  79919. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79920. */
  79921. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79922. /**
  79923. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79924. * @param event the (select) event to use to select with
  79925. * @param referenceSpace the reference space to use for this hit test
  79926. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79927. */
  79928. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79929. /**
  79930. * attach this feature
  79931. * Will usually be called by the features manager
  79932. *
  79933. * @returns true if successful.
  79934. */
  79935. attach(): boolean;
  79936. /**
  79937. * detach this feature.
  79938. * Will usually be called by the features manager
  79939. *
  79940. * @returns true if successful.
  79941. */
  79942. detach(): boolean;
  79943. /**
  79944. * Dispose this feature and all of the resources attached
  79945. */
  79946. dispose(): void;
  79947. protected _onXRFrame(frame: XRFrame): void;
  79948. private _onHitTestResults;
  79949. private _onSelect;
  79950. }
  79951. }
  79952. declare module "babylonjs/XR/features/WebXRHitTest" {
  79953. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79954. import { Observable } from "babylonjs/Misc/observable";
  79955. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79956. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79957. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79958. /**
  79959. * Options used for hit testing (version 2)
  79960. */
  79961. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79962. /**
  79963. * Do not create a permanent hit test. Will usually be used when only
  79964. * transient inputs are needed.
  79965. */
  79966. disablePermanentHitTest?: boolean;
  79967. /**
  79968. * Enable transient (for example touch-based) hit test inspections
  79969. */
  79970. enableTransientHitTest?: boolean;
  79971. /**
  79972. * Offset ray for the permanent hit test
  79973. */
  79974. offsetRay?: Vector3;
  79975. /**
  79976. * Offset ray for the transient hit test
  79977. */
  79978. transientOffsetRay?: Vector3;
  79979. /**
  79980. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79981. */
  79982. useReferenceSpace?: boolean;
  79983. /**
  79984. * Override the default entity type(s) of the hit-test result
  79985. */
  79986. entityTypes?: XRHitTestTrackableType[];
  79987. }
  79988. /**
  79989. * Interface defining the babylon result of hit-test
  79990. */
  79991. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79992. /**
  79993. * The input source that generated this hit test (if transient)
  79994. */
  79995. inputSource?: XRInputSource;
  79996. /**
  79997. * Is this a transient hit test
  79998. */
  79999. isTransient?: boolean;
  80000. /**
  80001. * Position of the hit test result
  80002. */
  80003. position: Vector3;
  80004. /**
  80005. * Rotation of the hit test result
  80006. */
  80007. rotationQuaternion: Quaternion;
  80008. /**
  80009. * The native hit test result
  80010. */
  80011. xrHitResult: XRHitTestResult;
  80012. }
  80013. /**
  80014. * The currently-working hit-test module.
  80015. * Hit test (or Ray-casting) is used to interact with the real world.
  80016. * For further information read here - https://github.com/immersive-web/hit-test
  80017. *
  80018. * Tested on chrome (mobile) 80.
  80019. */
  80020. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80021. /**
  80022. * options to use when constructing this feature
  80023. */
  80024. readonly options: IWebXRHitTestOptions;
  80025. private _tmpMat;
  80026. private _tmpPos;
  80027. private _tmpQuat;
  80028. private _transientXrHitTestSource;
  80029. private _xrHitTestSource;
  80030. private initHitTestSource;
  80031. /**
  80032. * The module's name
  80033. */
  80034. static readonly Name: string;
  80035. /**
  80036. * The (Babylon) version of this module.
  80037. * This is an integer representing the implementation version.
  80038. * This number does not correspond to the WebXR specs version
  80039. */
  80040. static readonly Version: number;
  80041. /**
  80042. * When set to true, each hit test will have its own position/rotation objects
  80043. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80044. * the developers will clone them or copy them as they see fit.
  80045. */
  80046. autoCloneTransformation: boolean;
  80047. /**
  80048. * Triggered when new babylon (transformed) hit test results are available
  80049. * Note - this will be called when results come back from the device. It can be an empty array!!
  80050. */
  80051. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80052. /**
  80053. * Use this to temporarily pause hit test checks.
  80054. */
  80055. paused: boolean;
  80056. /**
  80057. * Creates a new instance of the hit test feature
  80058. * @param _xrSessionManager an instance of WebXRSessionManager
  80059. * @param options options to use when constructing this feature
  80060. */
  80061. constructor(_xrSessionManager: WebXRSessionManager,
  80062. /**
  80063. * options to use when constructing this feature
  80064. */
  80065. options?: IWebXRHitTestOptions);
  80066. /**
  80067. * attach this feature
  80068. * Will usually be called by the features manager
  80069. *
  80070. * @returns true if successful.
  80071. */
  80072. attach(): boolean;
  80073. /**
  80074. * detach this feature.
  80075. * Will usually be called by the features manager
  80076. *
  80077. * @returns true if successful.
  80078. */
  80079. detach(): boolean;
  80080. /**
  80081. * Dispose this feature and all of the resources attached
  80082. */
  80083. dispose(): void;
  80084. protected _onXRFrame(frame: XRFrame): void;
  80085. private _processWebXRHitTestResult;
  80086. }
  80087. }
  80088. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80089. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80090. import { Observable } from "babylonjs/Misc/observable";
  80091. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80092. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80093. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80094. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80095. /**
  80096. * Configuration options of the anchor system
  80097. */
  80098. export interface IWebXRAnchorSystemOptions {
  80099. /**
  80100. * a node that will be used to convert local to world coordinates
  80101. */
  80102. worldParentNode?: TransformNode;
  80103. /**
  80104. * If set to true a reference of the created anchors will be kept until the next session starts
  80105. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80106. */
  80107. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80108. }
  80109. /**
  80110. * A babylon container for an XR Anchor
  80111. */
  80112. export interface IWebXRAnchor {
  80113. /**
  80114. * A babylon-assigned ID for this anchor
  80115. */
  80116. id: number;
  80117. /**
  80118. * Transformation matrix to apply to an object attached to this anchor
  80119. */
  80120. transformationMatrix: Matrix;
  80121. /**
  80122. * The native anchor object
  80123. */
  80124. xrAnchor: XRAnchor;
  80125. /**
  80126. * if defined, this object will be constantly updated by the anchor's position and rotation
  80127. */
  80128. attachedNode?: TransformNode;
  80129. }
  80130. /**
  80131. * An implementation of the anchor system for WebXR.
  80132. * For further information see https://github.com/immersive-web/anchors/
  80133. */
  80134. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80135. private _options;
  80136. private _lastFrameDetected;
  80137. private _trackedAnchors;
  80138. private _referenceSpaceForFrameAnchors;
  80139. private _futureAnchors;
  80140. /**
  80141. * The module's name
  80142. */
  80143. static readonly Name: string;
  80144. /**
  80145. * The (Babylon) version of this module.
  80146. * This is an integer representing the implementation version.
  80147. * This number does not correspond to the WebXR specs version
  80148. */
  80149. static readonly Version: number;
  80150. /**
  80151. * Observers registered here will be executed when a new anchor was added to the session
  80152. */
  80153. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80154. /**
  80155. * Observers registered here will be executed when an anchor was removed from the session
  80156. */
  80157. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80158. /**
  80159. * Observers registered here will be executed when an existing anchor updates
  80160. * This can execute N times every frame
  80161. */
  80162. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80163. /**
  80164. * Set the reference space to use for anchor creation, when not using a hit test.
  80165. * Will default to the session's reference space if not defined
  80166. */
  80167. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80168. /**
  80169. * constructs a new anchor system
  80170. * @param _xrSessionManager an instance of WebXRSessionManager
  80171. * @param _options configuration object for this feature
  80172. */
  80173. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80174. private _tmpVector;
  80175. private _tmpQuaternion;
  80176. private _populateTmpTransformation;
  80177. /**
  80178. * Create a new anchor point using a hit test result at a specific point in the scene
  80179. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80180. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80181. *
  80182. * @param hitTestResult The hit test result to use for this anchor creation
  80183. * @param position an optional position offset for this anchor
  80184. * @param rotationQuaternion an optional rotation offset for this anchor
  80185. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80186. */
  80187. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  80188. /**
  80189. * Add a new anchor at a specific position and rotation
  80190. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80191. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80192. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80193. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80194. *
  80195. * @param position the position in which to add an anchor
  80196. * @param rotationQuaternion an optional rotation for the anchor transformation
  80197. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80198. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80199. */
  80200. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  80201. /**
  80202. * detach this feature.
  80203. * Will usually be called by the features manager
  80204. *
  80205. * @returns true if successful.
  80206. */
  80207. detach(): boolean;
  80208. /**
  80209. * Dispose this feature and all of the resources attached
  80210. */
  80211. dispose(): void;
  80212. protected _onXRFrame(frame: XRFrame): void;
  80213. /**
  80214. * avoiding using Array.find for global support.
  80215. * @param xrAnchor the plane to find in the array
  80216. */
  80217. private _findIndexInAnchorArray;
  80218. private _updateAnchorWithXRFrame;
  80219. private _createAnchorAtTransformation;
  80220. }
  80221. }
  80222. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80223. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80224. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80225. import { Observable } from "babylonjs/Misc/observable";
  80226. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80227. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80228. /**
  80229. * Options used in the plane detector module
  80230. */
  80231. export interface IWebXRPlaneDetectorOptions {
  80232. /**
  80233. * The node to use to transform the local results to world coordinates
  80234. */
  80235. worldParentNode?: TransformNode;
  80236. /**
  80237. * If set to true a reference of the created planes will be kept until the next session starts
  80238. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80239. */
  80240. doNotRemovePlanesOnSessionEnded?: boolean;
  80241. }
  80242. /**
  80243. * A babylon interface for a WebXR plane.
  80244. * A Plane is actually a polygon, built from N points in space
  80245. *
  80246. * Supported in chrome 79, not supported in canary 81 ATM
  80247. */
  80248. export interface IWebXRPlane {
  80249. /**
  80250. * a babylon-assigned ID for this polygon
  80251. */
  80252. id: number;
  80253. /**
  80254. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80255. */
  80256. polygonDefinition: Array<Vector3>;
  80257. /**
  80258. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80259. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80260. */
  80261. transformationMatrix: Matrix;
  80262. /**
  80263. * the native xr-plane object
  80264. */
  80265. xrPlane: XRPlane;
  80266. }
  80267. /**
  80268. * The plane detector is used to detect planes in the real world when in AR
  80269. * For more information see https://github.com/immersive-web/real-world-geometry/
  80270. */
  80271. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80272. private _options;
  80273. private _detectedPlanes;
  80274. private _enabled;
  80275. private _lastFrameDetected;
  80276. /**
  80277. * The module's name
  80278. */
  80279. static readonly Name: string;
  80280. /**
  80281. * The (Babylon) version of this module.
  80282. * This is an integer representing the implementation version.
  80283. * This number does not correspond to the WebXR specs version
  80284. */
  80285. static readonly Version: number;
  80286. /**
  80287. * Observers registered here will be executed when a new plane was added to the session
  80288. */
  80289. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80290. /**
  80291. * Observers registered here will be executed when a plane is no longer detected in the session
  80292. */
  80293. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80294. /**
  80295. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80296. * This can execute N times every frame
  80297. */
  80298. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80299. /**
  80300. * construct a new Plane Detector
  80301. * @param _xrSessionManager an instance of xr Session manager
  80302. * @param _options configuration to use when constructing this feature
  80303. */
  80304. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80305. /**
  80306. * detach this feature.
  80307. * Will usually be called by the features manager
  80308. *
  80309. * @returns true if successful.
  80310. */
  80311. detach(): boolean;
  80312. /**
  80313. * Dispose this feature and all of the resources attached
  80314. */
  80315. dispose(): void;
  80316. /**
  80317. * Check if the needed objects are defined.
  80318. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80319. */
  80320. isCompatible(): boolean;
  80321. protected _onXRFrame(frame: XRFrame): void;
  80322. private _init;
  80323. private _updatePlaneWithXRPlane;
  80324. /**
  80325. * avoiding using Array.find for global support.
  80326. * @param xrPlane the plane to find in the array
  80327. */
  80328. private findIndexInPlaneArray;
  80329. }
  80330. }
  80331. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80332. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80334. import { Observable } from "babylonjs/Misc/observable";
  80335. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80336. /**
  80337. * Options interface for the background remover plugin
  80338. */
  80339. export interface IWebXRBackgroundRemoverOptions {
  80340. /**
  80341. * Further background meshes to disable when entering AR
  80342. */
  80343. backgroundMeshes?: AbstractMesh[];
  80344. /**
  80345. * flags to configure the removal of the environment helper.
  80346. * If not set, the entire background will be removed. If set, flags should be set as well.
  80347. */
  80348. environmentHelperRemovalFlags?: {
  80349. /**
  80350. * Should the skybox be removed (default false)
  80351. */
  80352. skyBox?: boolean;
  80353. /**
  80354. * Should the ground be removed (default false)
  80355. */
  80356. ground?: boolean;
  80357. };
  80358. /**
  80359. * don't disable the environment helper
  80360. */
  80361. ignoreEnvironmentHelper?: boolean;
  80362. }
  80363. /**
  80364. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80365. */
  80366. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80367. /**
  80368. * read-only options to be used in this module
  80369. */
  80370. readonly options: IWebXRBackgroundRemoverOptions;
  80371. /**
  80372. * The module's name
  80373. */
  80374. static readonly Name: string;
  80375. /**
  80376. * The (Babylon) version of this module.
  80377. * This is an integer representing the implementation version.
  80378. * This number does not correspond to the WebXR specs version
  80379. */
  80380. static readonly Version: number;
  80381. /**
  80382. * registered observers will be triggered when the background state changes
  80383. */
  80384. onBackgroundStateChangedObservable: Observable<boolean>;
  80385. /**
  80386. * constructs a new background remover module
  80387. * @param _xrSessionManager the session manager for this module
  80388. * @param options read-only options to be used in this module
  80389. */
  80390. constructor(_xrSessionManager: WebXRSessionManager,
  80391. /**
  80392. * read-only options to be used in this module
  80393. */
  80394. options?: IWebXRBackgroundRemoverOptions);
  80395. /**
  80396. * attach this feature
  80397. * Will usually be called by the features manager
  80398. *
  80399. * @returns true if successful.
  80400. */
  80401. attach(): boolean;
  80402. /**
  80403. * detach this feature.
  80404. * Will usually be called by the features manager
  80405. *
  80406. * @returns true if successful.
  80407. */
  80408. detach(): boolean;
  80409. /**
  80410. * Dispose this feature and all of the resources attached
  80411. */
  80412. dispose(): void;
  80413. protected _onXRFrame(_xrFrame: XRFrame): void;
  80414. private _setBackgroundState;
  80415. }
  80416. }
  80417. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80418. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80419. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80420. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80421. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80422. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80423. import { Nullable } from "babylonjs/types";
  80424. /**
  80425. * Options for the controller physics feature
  80426. */
  80427. export class IWebXRControllerPhysicsOptions {
  80428. /**
  80429. * Should the headset get its own impostor
  80430. */
  80431. enableHeadsetImpostor?: boolean;
  80432. /**
  80433. * Optional parameters for the headset impostor
  80434. */
  80435. headsetImpostorParams?: {
  80436. /**
  80437. * The type of impostor to create. Default is sphere
  80438. */
  80439. impostorType: number;
  80440. /**
  80441. * the size of the impostor. Defaults to 10cm
  80442. */
  80443. impostorSize?: number | {
  80444. width: number;
  80445. height: number;
  80446. depth: number;
  80447. };
  80448. /**
  80449. * Friction definitions
  80450. */
  80451. friction?: number;
  80452. /**
  80453. * Restitution
  80454. */
  80455. restitution?: number;
  80456. };
  80457. /**
  80458. * The physics properties of the future impostors
  80459. */
  80460. physicsProperties?: {
  80461. /**
  80462. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80463. * Note that this requires a physics engine that supports mesh impostors!
  80464. */
  80465. useControllerMesh?: boolean;
  80466. /**
  80467. * The type of impostor to create. Default is sphere
  80468. */
  80469. impostorType?: number;
  80470. /**
  80471. * the size of the impostor. Defaults to 10cm
  80472. */
  80473. impostorSize?: number | {
  80474. width: number;
  80475. height: number;
  80476. depth: number;
  80477. };
  80478. /**
  80479. * Friction definitions
  80480. */
  80481. friction?: number;
  80482. /**
  80483. * Restitution
  80484. */
  80485. restitution?: number;
  80486. };
  80487. /**
  80488. * the xr input to use with this pointer selection
  80489. */
  80490. xrInput: WebXRInput;
  80491. }
  80492. /**
  80493. * Add physics impostor to your webxr controllers,
  80494. * including naive calculation of their linear and angular velocity
  80495. */
  80496. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80497. private readonly _options;
  80498. private _attachController;
  80499. private _controllers;
  80500. private _debugMode;
  80501. private _delta;
  80502. private _headsetImpostor?;
  80503. private _headsetMesh?;
  80504. private _lastTimestamp;
  80505. private _tmpQuaternion;
  80506. private _tmpVector;
  80507. /**
  80508. * The module's name
  80509. */
  80510. static readonly Name: string;
  80511. /**
  80512. * The (Babylon) version of this module.
  80513. * This is an integer representing the implementation version.
  80514. * This number does not correspond to the webxr specs version
  80515. */
  80516. static readonly Version: number;
  80517. /**
  80518. * Construct a new Controller Physics Feature
  80519. * @param _xrSessionManager the corresponding xr session manager
  80520. * @param _options options to create this feature with
  80521. */
  80522. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80523. /**
  80524. * @hidden
  80525. * enable debugging - will show console outputs and the impostor mesh
  80526. */
  80527. _enablePhysicsDebug(): void;
  80528. /**
  80529. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80530. * @param xrController the controller to add
  80531. */
  80532. addController(xrController: WebXRInputSource): void;
  80533. /**
  80534. * attach this feature
  80535. * Will usually be called by the features manager
  80536. *
  80537. * @returns true if successful.
  80538. */
  80539. attach(): boolean;
  80540. /**
  80541. * detach this feature.
  80542. * Will usually be called by the features manager
  80543. *
  80544. * @returns true if successful.
  80545. */
  80546. detach(): boolean;
  80547. /**
  80548. * Get the headset impostor, if enabled
  80549. * @returns the impostor
  80550. */
  80551. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80552. /**
  80553. * Get the physics impostor of a specific controller.
  80554. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80555. * @param controller the controller or the controller id of which to get the impostor
  80556. * @returns the impostor or null
  80557. */
  80558. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80559. /**
  80560. * Update the physics properties provided in the constructor
  80561. * @param newProperties the new properties object
  80562. */
  80563. setPhysicsProperties(newProperties: {
  80564. impostorType?: number;
  80565. impostorSize?: number | {
  80566. width: number;
  80567. height: number;
  80568. depth: number;
  80569. };
  80570. friction?: number;
  80571. restitution?: number;
  80572. }): void;
  80573. protected _onXRFrame(_xrFrame: any): void;
  80574. private _detachController;
  80575. }
  80576. }
  80577. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80578. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80579. import { Observable } from "babylonjs/Misc/observable";
  80580. import { Vector3 } from "babylonjs/Maths/math.vector";
  80581. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80582. /**
  80583. * A babylon interface for a "WebXR" feature point.
  80584. * Represents the position and confidence value of a given feature point.
  80585. */
  80586. export interface IWebXRFeaturePoint {
  80587. /**
  80588. * Represents the position of the feature point in world space.
  80589. */
  80590. position: Vector3;
  80591. /**
  80592. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80593. */
  80594. confidenceValue: number;
  80595. }
  80596. /**
  80597. * The feature point system is used to detect feature points from real world geometry.
  80598. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80599. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80600. */
  80601. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80602. private _enabled;
  80603. private _featurePointCloud;
  80604. /**
  80605. * The module's name
  80606. */
  80607. static readonly Name: string;
  80608. /**
  80609. * The (Babylon) version of this module.
  80610. * This is an integer representing the implementation version.
  80611. * This number does not correspond to the WebXR specs version
  80612. */
  80613. static readonly Version: number;
  80614. /**
  80615. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80616. * Will notify the observers about which feature points have been added.
  80617. */
  80618. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80619. /**
  80620. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80621. * Will notify the observers about which feature points have been updated.
  80622. */
  80623. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80624. /**
  80625. * The current feature point cloud maintained across frames.
  80626. */
  80627. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80628. /**
  80629. * construct the feature point system
  80630. * @param _xrSessionManager an instance of xr Session manager
  80631. */
  80632. constructor(_xrSessionManager: WebXRSessionManager);
  80633. /**
  80634. * Detach this feature.
  80635. * Will usually be called by the features manager
  80636. *
  80637. * @returns true if successful.
  80638. */
  80639. detach(): boolean;
  80640. /**
  80641. * Dispose this feature and all of the resources attached
  80642. */
  80643. dispose(): void;
  80644. /**
  80645. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80646. */
  80647. protected _onXRFrame(frame: XRFrame): void;
  80648. /**
  80649. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80650. */
  80651. private _init;
  80652. }
  80653. }
  80654. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80655. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80656. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80658. import { Mesh } from "babylonjs/Meshes/mesh";
  80659. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80660. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80661. import { Nullable } from "babylonjs/types";
  80662. import { IDisposable } from "babylonjs/scene";
  80663. import { Observable } from "babylonjs/Misc/observable";
  80664. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80665. /**
  80666. * Configuration interface for the hand tracking feature
  80667. */
  80668. export interface IWebXRHandTrackingOptions {
  80669. /**
  80670. * The xrInput that will be used as source for new hands
  80671. */
  80672. xrInput: WebXRInput;
  80673. /**
  80674. * Configuration object for the joint meshes
  80675. */
  80676. jointMeshes?: {
  80677. /**
  80678. * Should the meshes created be invisible (defaults to false)
  80679. */
  80680. invisible?: boolean;
  80681. /**
  80682. * A source mesh to be used to create instances. Defaults to a sphere.
  80683. * This mesh will be the source for all other (25) meshes.
  80684. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80685. */
  80686. sourceMesh?: Mesh;
  80687. /**
  80688. * This function will be called after a mesh was created for a specific joint.
  80689. * Using this function you can either manipulate the instance or return a new mesh.
  80690. * When returning a new mesh the instance created before will be disposed
  80691. */
  80692. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80693. /**
  80694. * Should the source mesh stay visible. Defaults to false
  80695. */
  80696. keepOriginalVisible?: boolean;
  80697. /**
  80698. * Scale factor for all instances (defaults to 2)
  80699. */
  80700. scaleFactor?: number;
  80701. /**
  80702. * Should each instance have its own physics impostor
  80703. */
  80704. enablePhysics?: boolean;
  80705. /**
  80706. * If enabled, override default physics properties
  80707. */
  80708. physicsProps?: {
  80709. friction?: number;
  80710. restitution?: number;
  80711. impostorType?: number;
  80712. };
  80713. /**
  80714. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80715. */
  80716. handMesh?: AbstractMesh;
  80717. };
  80718. }
  80719. /**
  80720. * Parts of the hands divided to writs and finger names
  80721. */
  80722. export const enum HandPart {
  80723. /**
  80724. * HandPart - Wrist
  80725. */
  80726. WRIST = "wrist",
  80727. /**
  80728. * HandPart - The THumb
  80729. */
  80730. THUMB = "thumb",
  80731. /**
  80732. * HandPart - Index finger
  80733. */
  80734. INDEX = "index",
  80735. /**
  80736. * HandPart - Middle finger
  80737. */
  80738. MIDDLE = "middle",
  80739. /**
  80740. * HandPart - Ring finger
  80741. */
  80742. RING = "ring",
  80743. /**
  80744. * HandPart - Little finger
  80745. */
  80746. LITTLE = "little"
  80747. }
  80748. /**
  80749. * Representing a single hand (with its corresponding native XRHand object)
  80750. */
  80751. export class WebXRHand implements IDisposable {
  80752. /** the controller to which the hand correlates */
  80753. readonly xrController: WebXRInputSource;
  80754. /** the meshes to be used to track the hand joints */
  80755. readonly trackedMeshes: AbstractMesh[];
  80756. /**
  80757. * Hand-parts definition (key is HandPart)
  80758. */
  80759. handPartsDefinition: {
  80760. [key: string]: number[];
  80761. };
  80762. /**
  80763. * Populate the HandPartsDefinition object.
  80764. * This is called as a side effect since certain browsers don't have XRHand defined.
  80765. */
  80766. private generateHandPartsDefinition;
  80767. /**
  80768. * Construct a new hand object
  80769. * @param xrController the controller to which the hand correlates
  80770. * @param trackedMeshes the meshes to be used to track the hand joints
  80771. */
  80772. constructor(
  80773. /** the controller to which the hand correlates */
  80774. xrController: WebXRInputSource,
  80775. /** the meshes to be used to track the hand joints */
  80776. trackedMeshes: AbstractMesh[]);
  80777. /**
  80778. * Update this hand from the latest xr frame
  80779. * @param xrFrame xrFrame to update from
  80780. * @param referenceSpace The current viewer reference space
  80781. * @param scaleFactor optional scale factor for the meshes
  80782. */
  80783. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80784. /**
  80785. * Get meshes of part of the hand
  80786. * @param part the part of hand to get
  80787. * @returns An array of meshes that correlate to the hand part requested
  80788. */
  80789. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80790. /**
  80791. * Dispose this Hand object
  80792. */
  80793. dispose(): void;
  80794. }
  80795. /**
  80796. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80797. */
  80798. export class WebXRHandTracking extends WebXRAbstractFeature {
  80799. /**
  80800. * options to use when constructing this feature
  80801. */
  80802. readonly options: IWebXRHandTrackingOptions;
  80803. private static _idCounter;
  80804. /**
  80805. * The module's name
  80806. */
  80807. static readonly Name: string;
  80808. /**
  80809. * The (Babylon) version of this module.
  80810. * This is an integer representing the implementation version.
  80811. * This number does not correspond to the WebXR specs version
  80812. */
  80813. static readonly Version: number;
  80814. /**
  80815. * This observable will notify registered observers when a new hand object was added and initialized
  80816. */
  80817. onHandAddedObservable: Observable<WebXRHand>;
  80818. /**
  80819. * This observable will notify its observers right before the hand object is disposed
  80820. */
  80821. onHandRemovedObservable: Observable<WebXRHand>;
  80822. private _hands;
  80823. /**
  80824. * Creates a new instance of the hit test feature
  80825. * @param _xrSessionManager an instance of WebXRSessionManager
  80826. * @param options options to use when constructing this feature
  80827. */
  80828. constructor(_xrSessionManager: WebXRSessionManager,
  80829. /**
  80830. * options to use when constructing this feature
  80831. */
  80832. options: IWebXRHandTrackingOptions);
  80833. /**
  80834. * Check if the needed objects are defined.
  80835. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80836. */
  80837. isCompatible(): boolean;
  80838. /**
  80839. * attach this feature
  80840. * Will usually be called by the features manager
  80841. *
  80842. * @returns true if successful.
  80843. */
  80844. attach(): boolean;
  80845. /**
  80846. * detach this feature.
  80847. * Will usually be called by the features manager
  80848. *
  80849. * @returns true if successful.
  80850. */
  80851. detach(): boolean;
  80852. /**
  80853. * Dispose this feature and all of the resources attached
  80854. */
  80855. dispose(): void;
  80856. /**
  80857. * Get the hand object according to the controller id
  80858. * @param controllerId the controller id to which we want to get the hand
  80859. * @returns null if not found or the WebXRHand object if found
  80860. */
  80861. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80862. /**
  80863. * Get a hand object according to the requested handedness
  80864. * @param handedness the handedness to request
  80865. * @returns null if not found or the WebXRHand object if found
  80866. */
  80867. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80868. protected _onXRFrame(_xrFrame: XRFrame): void;
  80869. private _attachHand;
  80870. private _detachHand;
  80871. }
  80872. }
  80873. declare module "babylonjs/XR/features/index" {
  80874. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  80875. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80876. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80877. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80878. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80879. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80880. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80881. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80882. export * from "babylonjs/XR/features/WebXRHitTest";
  80883. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80884. export * from "babylonjs/XR/features/WebXRHandTracking";
  80885. }
  80886. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80887. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80889. import { Scene } from "babylonjs/scene";
  80890. /**
  80891. * The motion controller class for all microsoft mixed reality controllers
  80892. */
  80893. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80894. protected readonly _mapping: {
  80895. defaultButton: {
  80896. valueNodeName: string;
  80897. unpressedNodeName: string;
  80898. pressedNodeName: string;
  80899. };
  80900. defaultAxis: {
  80901. valueNodeName: string;
  80902. minNodeName: string;
  80903. maxNodeName: string;
  80904. };
  80905. buttons: {
  80906. "xr-standard-trigger": {
  80907. rootNodeName: string;
  80908. componentProperty: string;
  80909. states: string[];
  80910. };
  80911. "xr-standard-squeeze": {
  80912. rootNodeName: string;
  80913. componentProperty: string;
  80914. states: string[];
  80915. };
  80916. "xr-standard-touchpad": {
  80917. rootNodeName: string;
  80918. labelAnchorNodeName: string;
  80919. touchPointNodeName: string;
  80920. };
  80921. "xr-standard-thumbstick": {
  80922. rootNodeName: string;
  80923. componentProperty: string;
  80924. states: string[];
  80925. };
  80926. };
  80927. axes: {
  80928. "xr-standard-touchpad": {
  80929. "x-axis": {
  80930. rootNodeName: string;
  80931. };
  80932. "y-axis": {
  80933. rootNodeName: string;
  80934. };
  80935. };
  80936. "xr-standard-thumbstick": {
  80937. "x-axis": {
  80938. rootNodeName: string;
  80939. };
  80940. "y-axis": {
  80941. rootNodeName: string;
  80942. };
  80943. };
  80944. };
  80945. };
  80946. /**
  80947. * The base url used to load the left and right controller models
  80948. */
  80949. static MODEL_BASE_URL: string;
  80950. /**
  80951. * The name of the left controller model file
  80952. */
  80953. static MODEL_LEFT_FILENAME: string;
  80954. /**
  80955. * The name of the right controller model file
  80956. */
  80957. static MODEL_RIGHT_FILENAME: string;
  80958. profileId: string;
  80959. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80960. protected _getFilenameAndPath(): {
  80961. filename: string;
  80962. path: string;
  80963. };
  80964. protected _getModelLoadingConstraints(): boolean;
  80965. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80966. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80967. protected _updateModel(): void;
  80968. }
  80969. }
  80970. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80971. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80973. import { Scene } from "babylonjs/scene";
  80974. /**
  80975. * The motion controller class for oculus touch (quest, rift).
  80976. * This class supports legacy mapping as well the standard xr mapping
  80977. */
  80978. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80979. private _forceLegacyControllers;
  80980. private _modelRootNode;
  80981. /**
  80982. * The base url used to load the left and right controller models
  80983. */
  80984. static MODEL_BASE_URL: string;
  80985. /**
  80986. * The name of the left controller model file
  80987. */
  80988. static MODEL_LEFT_FILENAME: string;
  80989. /**
  80990. * The name of the right controller model file
  80991. */
  80992. static MODEL_RIGHT_FILENAME: string;
  80993. /**
  80994. * Base Url for the Quest controller model.
  80995. */
  80996. static QUEST_MODEL_BASE_URL: string;
  80997. profileId: string;
  80998. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80999. protected _getFilenameAndPath(): {
  81000. filename: string;
  81001. path: string;
  81002. };
  81003. protected _getModelLoadingConstraints(): boolean;
  81004. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81005. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81006. protected _updateModel(): void;
  81007. /**
  81008. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81009. * between the touch and touch 2.
  81010. */
  81011. private _isQuest;
  81012. }
  81013. }
  81014. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81015. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81016. import { Scene } from "babylonjs/scene";
  81017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81018. /**
  81019. * The motion controller class for the standard HTC-Vive controllers
  81020. */
  81021. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81022. private _modelRootNode;
  81023. /**
  81024. * The base url used to load the left and right controller models
  81025. */
  81026. static MODEL_BASE_URL: string;
  81027. /**
  81028. * File name for the controller model.
  81029. */
  81030. static MODEL_FILENAME: string;
  81031. profileId: string;
  81032. /**
  81033. * Create a new Vive motion controller object
  81034. * @param scene the scene to use to create this controller
  81035. * @param gamepadObject the corresponding gamepad object
  81036. * @param handedness the handedness of the controller
  81037. */
  81038. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81039. protected _getFilenameAndPath(): {
  81040. filename: string;
  81041. path: string;
  81042. };
  81043. protected _getModelLoadingConstraints(): boolean;
  81044. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81045. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81046. protected _updateModel(): void;
  81047. }
  81048. }
  81049. declare module "babylonjs/XR/motionController/index" {
  81050. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81051. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81052. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81053. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81054. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81055. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81056. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81057. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81058. }
  81059. declare module "babylonjs/XR/index" {
  81060. export * from "babylonjs/XR/webXRCamera";
  81061. export * from "babylonjs/XR/webXREnterExitUI";
  81062. export * from "babylonjs/XR/webXRExperienceHelper";
  81063. export * from "babylonjs/XR/webXRInput";
  81064. export * from "babylonjs/XR/webXRInputSource";
  81065. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81066. export * from "babylonjs/XR/webXRTypes";
  81067. export * from "babylonjs/XR/webXRSessionManager";
  81068. export * from "babylonjs/XR/webXRDefaultExperience";
  81069. export * from "babylonjs/XR/webXRFeaturesManager";
  81070. export * from "babylonjs/XR/features/index";
  81071. export * from "babylonjs/XR/motionController/index";
  81072. }
  81073. declare module "babylonjs/index" {
  81074. export * from "babylonjs/abstractScene";
  81075. export * from "babylonjs/Actions/index";
  81076. export * from "babylonjs/Animations/index";
  81077. export * from "babylonjs/assetContainer";
  81078. export * from "babylonjs/Audio/index";
  81079. export * from "babylonjs/Behaviors/index";
  81080. export * from "babylonjs/Bones/index";
  81081. export * from "babylonjs/Cameras/index";
  81082. export * from "babylonjs/Collisions/index";
  81083. export * from "babylonjs/Culling/index";
  81084. export * from "babylonjs/Debug/index";
  81085. export * from "babylonjs/DeviceInput/index";
  81086. export * from "babylonjs/Engines/index";
  81087. export * from "babylonjs/Events/index";
  81088. export * from "babylonjs/Gamepads/index";
  81089. export * from "babylonjs/Gizmos/index";
  81090. export * from "babylonjs/Helpers/index";
  81091. export * from "babylonjs/Instrumentation/index";
  81092. export * from "babylonjs/Layers/index";
  81093. export * from "babylonjs/LensFlares/index";
  81094. export * from "babylonjs/Lights/index";
  81095. export * from "babylonjs/Loading/index";
  81096. export * from "babylonjs/Materials/index";
  81097. export * from "babylonjs/Maths/index";
  81098. export * from "babylonjs/Meshes/index";
  81099. export * from "babylonjs/Morph/index";
  81100. export * from "babylonjs/Navigation/index";
  81101. export * from "babylonjs/node";
  81102. export * from "babylonjs/Offline/index";
  81103. export * from "babylonjs/Particles/index";
  81104. export * from "babylonjs/Physics/index";
  81105. export * from "babylonjs/PostProcesses/index";
  81106. export * from "babylonjs/Probes/index";
  81107. export * from "babylonjs/Rendering/index";
  81108. export * from "babylonjs/scene";
  81109. export * from "babylonjs/sceneComponent";
  81110. export * from "babylonjs/Sprites/index";
  81111. export * from "babylonjs/States/index";
  81112. export * from "babylonjs/Misc/index";
  81113. export * from "babylonjs/XR/index";
  81114. export * from "babylonjs/types";
  81115. }
  81116. declare module "babylonjs/Animations/pathCursor" {
  81117. import { Vector3 } from "babylonjs/Maths/math.vector";
  81118. import { Path2 } from "babylonjs/Maths/math.path";
  81119. /**
  81120. * A cursor which tracks a point on a path
  81121. */
  81122. export class PathCursor {
  81123. private path;
  81124. /**
  81125. * Stores path cursor callbacks for when an onchange event is triggered
  81126. */
  81127. private _onchange;
  81128. /**
  81129. * The value of the path cursor
  81130. */
  81131. value: number;
  81132. /**
  81133. * The animation array of the path cursor
  81134. */
  81135. animations: Animation[];
  81136. /**
  81137. * Initializes the path cursor
  81138. * @param path The path to track
  81139. */
  81140. constructor(path: Path2);
  81141. /**
  81142. * Gets the cursor point on the path
  81143. * @returns A point on the path cursor at the cursor location
  81144. */
  81145. getPoint(): Vector3;
  81146. /**
  81147. * Moves the cursor ahead by the step amount
  81148. * @param step The amount to move the cursor forward
  81149. * @returns This path cursor
  81150. */
  81151. moveAhead(step?: number): PathCursor;
  81152. /**
  81153. * Moves the cursor behind by the step amount
  81154. * @param step The amount to move the cursor back
  81155. * @returns This path cursor
  81156. */
  81157. moveBack(step?: number): PathCursor;
  81158. /**
  81159. * Moves the cursor by the step amount
  81160. * If the step amount is greater than one, an exception is thrown
  81161. * @param step The amount to move the cursor
  81162. * @returns This path cursor
  81163. */
  81164. move(step: number): PathCursor;
  81165. /**
  81166. * Ensures that the value is limited between zero and one
  81167. * @returns This path cursor
  81168. */
  81169. private ensureLimits;
  81170. /**
  81171. * Runs onchange callbacks on change (used by the animation engine)
  81172. * @returns This path cursor
  81173. */
  81174. private raiseOnChange;
  81175. /**
  81176. * Executes a function on change
  81177. * @param f A path cursor onchange callback
  81178. * @returns This path cursor
  81179. */
  81180. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81181. }
  81182. }
  81183. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81184. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81185. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81186. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81187. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81188. }
  81189. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81190. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81191. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81192. }
  81193. declare module "babylonjs/Engines/Processors/index" {
  81194. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81195. export * from "babylonjs/Engines/Processors/Expressions/index";
  81196. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81197. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81198. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81199. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81200. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81201. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81202. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81203. }
  81204. declare module "babylonjs/Legacy/legacy" {
  81205. import * as Babylon from "babylonjs/index";
  81206. export * from "babylonjs/index";
  81207. }
  81208. declare module "babylonjs/Shaders/blur.fragment" {
  81209. /** @hidden */
  81210. export var blurPixelShader: {
  81211. name: string;
  81212. shader: string;
  81213. };
  81214. }
  81215. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81216. /** @hidden */
  81217. export var pointCloudVertexDeclaration: {
  81218. name: string;
  81219. shader: string;
  81220. };
  81221. }
  81222. declare module "babylonjs" {
  81223. export * from "babylonjs/Legacy/legacy";
  81224. }
  81225. declare module BABYLON {
  81226. /** Alias type for value that can be null */
  81227. export type Nullable<T> = T | null;
  81228. /**
  81229. * Alias type for number that are floats
  81230. * @ignorenaming
  81231. */
  81232. export type float = number;
  81233. /**
  81234. * Alias type for number that are doubles.
  81235. * @ignorenaming
  81236. */
  81237. export type double = number;
  81238. /**
  81239. * Alias type for number that are integer
  81240. * @ignorenaming
  81241. */
  81242. export type int = number;
  81243. /** Alias type for number array or Float32Array */
  81244. export type FloatArray = number[] | Float32Array;
  81245. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81246. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81247. /**
  81248. * Alias for types that can be used by a Buffer or VertexBuffer.
  81249. */
  81250. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81251. /**
  81252. * Alias type for primitive types
  81253. * @ignorenaming
  81254. */
  81255. type Primitive = undefined | null | boolean | string | number | Function;
  81256. /**
  81257. * Type modifier to make all the properties of an object Readonly
  81258. */
  81259. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81260. /**
  81261. * Type modifier to make all the properties of an object Readonly recursively
  81262. */
  81263. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81264. /**
  81265. * Type modifier to make object properties readonly.
  81266. */
  81267. export type DeepImmutableObject<T> = {
  81268. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81269. };
  81270. /** @hidden */
  81271. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81272. }
  81273. }
  81274. declare module BABYLON {
  81275. /**
  81276. * A class serves as a medium between the observable and its observers
  81277. */
  81278. export class EventState {
  81279. /**
  81280. * Create a new EventState
  81281. * @param mask defines the mask associated with this state
  81282. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81283. * @param target defines the original target of the state
  81284. * @param currentTarget defines the current target of the state
  81285. */
  81286. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81287. /**
  81288. * Initialize the current event state
  81289. * @param mask defines the mask associated with this state
  81290. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81291. * @param target defines the original target of the state
  81292. * @param currentTarget defines the current target of the state
  81293. * @returns the current event state
  81294. */
  81295. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81296. /**
  81297. * An Observer can set this property to true to prevent subsequent observers of being notified
  81298. */
  81299. skipNextObservers: boolean;
  81300. /**
  81301. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81302. */
  81303. mask: number;
  81304. /**
  81305. * The object that originally notified the event
  81306. */
  81307. target?: any;
  81308. /**
  81309. * The current object in the bubbling phase
  81310. */
  81311. currentTarget?: any;
  81312. /**
  81313. * This will be populated with the return value of the last function that was executed.
  81314. * If it is the first function in the callback chain it will be the event data.
  81315. */
  81316. lastReturnValue?: any;
  81317. /**
  81318. * User defined information that will be sent to observers
  81319. */
  81320. userInfo?: any;
  81321. }
  81322. /**
  81323. * Represent an Observer registered to a given Observable object.
  81324. */
  81325. export class Observer<T> {
  81326. /**
  81327. * Defines the callback to call when the observer is notified
  81328. */
  81329. callback: (eventData: T, eventState: EventState) => void;
  81330. /**
  81331. * Defines the mask of the observer (used to filter notifications)
  81332. */
  81333. mask: number;
  81334. /**
  81335. * Defines the current scope used to restore the JS context
  81336. */
  81337. scope: any;
  81338. /** @hidden */
  81339. _willBeUnregistered: boolean;
  81340. /**
  81341. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81342. */
  81343. unregisterOnNextCall: boolean;
  81344. /**
  81345. * Creates a new observer
  81346. * @param callback defines the callback to call when the observer is notified
  81347. * @param mask defines the mask of the observer (used to filter notifications)
  81348. * @param scope defines the current scope used to restore the JS context
  81349. */
  81350. constructor(
  81351. /**
  81352. * Defines the callback to call when the observer is notified
  81353. */
  81354. callback: (eventData: T, eventState: EventState) => void,
  81355. /**
  81356. * Defines the mask of the observer (used to filter notifications)
  81357. */
  81358. mask: number,
  81359. /**
  81360. * Defines the current scope used to restore the JS context
  81361. */
  81362. scope?: any);
  81363. }
  81364. /**
  81365. * Represent a list of observers registered to multiple Observables object.
  81366. */
  81367. export class MultiObserver<T> {
  81368. private _observers;
  81369. private _observables;
  81370. /**
  81371. * Release associated resources
  81372. */
  81373. dispose(): void;
  81374. /**
  81375. * Raise a callback when one of the observable will notify
  81376. * @param observables defines a list of observables to watch
  81377. * @param callback defines the callback to call on notification
  81378. * @param mask defines the mask used to filter notifications
  81379. * @param scope defines the current scope used to restore the JS context
  81380. * @returns the new MultiObserver
  81381. */
  81382. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81383. }
  81384. /**
  81385. * The Observable class is a simple implementation of the Observable pattern.
  81386. *
  81387. * 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.
  81388. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81389. * 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).
  81390. * 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.
  81391. */
  81392. export class Observable<T> {
  81393. private _observers;
  81394. private _eventState;
  81395. private _onObserverAdded;
  81396. /**
  81397. * Gets the list of observers
  81398. */
  81399. get observers(): Array<Observer<T>>;
  81400. /**
  81401. * Creates a new observable
  81402. * @param onObserverAdded defines a callback to call when a new observer is added
  81403. */
  81404. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81405. /**
  81406. * Create a new Observer with the specified callback
  81407. * @param callback the callback that will be executed for that Observer
  81408. * @param mask the mask used to filter observers
  81409. * @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.
  81410. * @param scope optional scope for the callback to be called from
  81411. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81412. * @returns the new observer created for the callback
  81413. */
  81414. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81415. /**
  81416. * Create a new Observer with the specified callback and unregisters after the next notification
  81417. * @param callback the callback that will be executed for that Observer
  81418. * @returns the new observer created for the callback
  81419. */
  81420. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81421. /**
  81422. * Remove an Observer from the Observable object
  81423. * @param observer the instance of the Observer to remove
  81424. * @returns false if it doesn't belong to this Observable
  81425. */
  81426. remove(observer: Nullable<Observer<T>>): boolean;
  81427. /**
  81428. * Remove a callback from the Observable object
  81429. * @param callback the callback to remove
  81430. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81431. * @returns false if it doesn't belong to this Observable
  81432. */
  81433. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81434. private _deferUnregister;
  81435. private _remove;
  81436. /**
  81437. * Moves the observable to the top of the observer list making it get called first when notified
  81438. * @param observer the observer to move
  81439. */
  81440. makeObserverTopPriority(observer: Observer<T>): void;
  81441. /**
  81442. * Moves the observable to the bottom of the observer list making it get called last when notified
  81443. * @param observer the observer to move
  81444. */
  81445. makeObserverBottomPriority(observer: Observer<T>): void;
  81446. /**
  81447. * Notify all Observers by calling their respective callback with the given data
  81448. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81449. * @param eventData defines the data to send to all observers
  81450. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81451. * @param target defines the original target of the state
  81452. * @param currentTarget defines the current target of the state
  81453. * @param userInfo defines any user info to send to observers
  81454. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81455. */
  81456. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81457. /**
  81458. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81459. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81460. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81461. * and it is crucial that all callbacks will be executed.
  81462. * The order of the callbacks is kept, callbacks are not executed parallel.
  81463. *
  81464. * @param eventData The data to be sent to each callback
  81465. * @param mask is used to filter observers defaults to -1
  81466. * @param target defines the callback target (see EventState)
  81467. * @param currentTarget defines he current object in the bubbling phase
  81468. * @param userInfo defines any user info to send to observers
  81469. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81470. */
  81471. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81472. /**
  81473. * Notify a specific observer
  81474. * @param observer defines the observer to notify
  81475. * @param eventData defines the data to be sent to each callback
  81476. * @param mask is used to filter observers defaults to -1
  81477. */
  81478. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81479. /**
  81480. * Gets a boolean indicating if the observable has at least one observer
  81481. * @returns true is the Observable has at least one Observer registered
  81482. */
  81483. hasObservers(): boolean;
  81484. /**
  81485. * Clear the list of observers
  81486. */
  81487. clear(): void;
  81488. /**
  81489. * Clone the current observable
  81490. * @returns a new observable
  81491. */
  81492. clone(): Observable<T>;
  81493. /**
  81494. * Does this observable handles observer registered with a given mask
  81495. * @param mask defines the mask to be tested
  81496. * @return whether or not one observer registered with the given mask is handeled
  81497. **/
  81498. hasSpecificMask(mask?: number): boolean;
  81499. }
  81500. }
  81501. declare module BABYLON {
  81502. /**
  81503. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81504. * Babylon.js
  81505. */
  81506. export class DomManagement {
  81507. /**
  81508. * Checks if the window object exists
  81509. * @returns true if the window object exists
  81510. */
  81511. static IsWindowObjectExist(): boolean;
  81512. /**
  81513. * Checks if the navigator object exists
  81514. * @returns true if the navigator object exists
  81515. */
  81516. static IsNavigatorAvailable(): boolean;
  81517. /**
  81518. * Check if the document object exists
  81519. * @returns true if the document object exists
  81520. */
  81521. static IsDocumentAvailable(): boolean;
  81522. /**
  81523. * Extracts text content from a DOM element hierarchy
  81524. * @param element defines the root element
  81525. * @returns a string
  81526. */
  81527. static GetDOMTextContent(element: HTMLElement): string;
  81528. }
  81529. }
  81530. declare module BABYLON {
  81531. /**
  81532. * Logger used througouht the application to allow configuration of
  81533. * the log level required for the messages.
  81534. */
  81535. export class Logger {
  81536. /**
  81537. * No log
  81538. */
  81539. static readonly NoneLogLevel: number;
  81540. /**
  81541. * Only message logs
  81542. */
  81543. static readonly MessageLogLevel: number;
  81544. /**
  81545. * Only warning logs
  81546. */
  81547. static readonly WarningLogLevel: number;
  81548. /**
  81549. * Only error logs
  81550. */
  81551. static readonly ErrorLogLevel: number;
  81552. /**
  81553. * All logs
  81554. */
  81555. static readonly AllLogLevel: number;
  81556. private static _LogCache;
  81557. /**
  81558. * Gets a value indicating the number of loading errors
  81559. * @ignorenaming
  81560. */
  81561. static errorsCount: number;
  81562. /**
  81563. * Callback called when a new log is added
  81564. */
  81565. static OnNewCacheEntry: (entry: string) => void;
  81566. private static _AddLogEntry;
  81567. private static _FormatMessage;
  81568. private static _LogDisabled;
  81569. private static _LogEnabled;
  81570. private static _WarnDisabled;
  81571. private static _WarnEnabled;
  81572. private static _ErrorDisabled;
  81573. private static _ErrorEnabled;
  81574. /**
  81575. * Log a message to the console
  81576. */
  81577. static Log: (message: string) => void;
  81578. /**
  81579. * Write a warning message to the console
  81580. */
  81581. static Warn: (message: string) => void;
  81582. /**
  81583. * Write an error message to the console
  81584. */
  81585. static Error: (message: string) => void;
  81586. /**
  81587. * Gets current log cache (list of logs)
  81588. */
  81589. static get LogCache(): string;
  81590. /**
  81591. * Clears the log cache
  81592. */
  81593. static ClearLogCache(): void;
  81594. /**
  81595. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81596. */
  81597. static set LogLevels(level: number);
  81598. }
  81599. }
  81600. declare module BABYLON {
  81601. /** @hidden */
  81602. export class _TypeStore {
  81603. /** @hidden */
  81604. static RegisteredTypes: {
  81605. [key: string]: Object;
  81606. };
  81607. /** @hidden */
  81608. static GetClass(fqdn: string): any;
  81609. }
  81610. }
  81611. declare module BABYLON {
  81612. /**
  81613. * Helper to manipulate strings
  81614. */
  81615. export class StringTools {
  81616. /**
  81617. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81618. * @param str Source string
  81619. * @param suffix Suffix to search for in the source string
  81620. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81621. */
  81622. static EndsWith(str: string, suffix: string): boolean;
  81623. /**
  81624. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81625. * @param str Source string
  81626. * @param suffix Suffix to search for in the source string
  81627. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81628. */
  81629. static StartsWith(str: string, suffix: string): boolean;
  81630. /**
  81631. * Decodes a buffer into a string
  81632. * @param buffer The buffer to decode
  81633. * @returns The decoded string
  81634. */
  81635. static Decode(buffer: Uint8Array | Uint16Array): string;
  81636. /**
  81637. * Encode a buffer to a base64 string
  81638. * @param buffer defines the buffer to encode
  81639. * @returns the encoded string
  81640. */
  81641. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81642. /**
  81643. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81644. * @param num the number to convert and pad
  81645. * @param length the expected length of the string
  81646. * @returns the padded string
  81647. */
  81648. static PadNumber(num: number, length: number): string;
  81649. }
  81650. }
  81651. declare module BABYLON {
  81652. /**
  81653. * Class containing a set of static utilities functions for deep copy.
  81654. */
  81655. export class DeepCopier {
  81656. /**
  81657. * Tries to copy an object by duplicating every property
  81658. * @param source defines the source object
  81659. * @param destination defines the target object
  81660. * @param doNotCopyList defines a list of properties to avoid
  81661. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81662. */
  81663. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81664. }
  81665. }
  81666. declare module BABYLON {
  81667. /**
  81668. * Class containing a set of static utilities functions for precision date
  81669. */
  81670. export class PrecisionDate {
  81671. /**
  81672. * Gets either window.performance.now() if supported or Date.now() else
  81673. */
  81674. static get Now(): number;
  81675. }
  81676. }
  81677. declare module BABYLON {
  81678. /** @hidden */
  81679. export class _DevTools {
  81680. static WarnImport(name: string): string;
  81681. }
  81682. }
  81683. declare module BABYLON {
  81684. /**
  81685. * Interface used to define the mechanism to get data from the network
  81686. */
  81687. export interface IWebRequest {
  81688. /**
  81689. * Returns client's response url
  81690. */
  81691. responseURL: string;
  81692. /**
  81693. * Returns client's status
  81694. */
  81695. status: number;
  81696. /**
  81697. * Returns client's status as a text
  81698. */
  81699. statusText: string;
  81700. }
  81701. }
  81702. declare module BABYLON {
  81703. /**
  81704. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81705. */
  81706. export class WebRequest implements IWebRequest {
  81707. private readonly _xhr;
  81708. /**
  81709. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81710. * i.e. when loading files, where the server/service expects an Authorization header
  81711. */
  81712. static CustomRequestHeaders: {
  81713. [key: string]: string;
  81714. };
  81715. /**
  81716. * Add callback functions in this array to update all the requests before they get sent to the network
  81717. */
  81718. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81719. private _injectCustomRequestHeaders;
  81720. /**
  81721. * Gets or sets a function to be called when loading progress changes
  81722. */
  81723. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81724. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81725. /**
  81726. * Returns client's state
  81727. */
  81728. get readyState(): number;
  81729. /**
  81730. * Returns client's status
  81731. */
  81732. get status(): number;
  81733. /**
  81734. * Returns client's status as a text
  81735. */
  81736. get statusText(): string;
  81737. /**
  81738. * Returns client's response
  81739. */
  81740. get response(): any;
  81741. /**
  81742. * Returns client's response url
  81743. */
  81744. get responseURL(): string;
  81745. /**
  81746. * Returns client's response as text
  81747. */
  81748. get responseText(): string;
  81749. /**
  81750. * Gets or sets the expected response type
  81751. */
  81752. get responseType(): XMLHttpRequestResponseType;
  81753. set responseType(value: XMLHttpRequestResponseType);
  81754. /** @hidden */
  81755. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81756. /** @hidden */
  81757. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81758. /**
  81759. * Cancels any network activity
  81760. */
  81761. abort(): void;
  81762. /**
  81763. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81764. * @param body defines an optional request body
  81765. */
  81766. send(body?: Document | BodyInit | null): void;
  81767. /**
  81768. * Sets the request method, request URL
  81769. * @param method defines the method to use (GET, POST, etc..)
  81770. * @param url defines the url to connect with
  81771. */
  81772. open(method: string, url: string): void;
  81773. /**
  81774. * Sets the value of a request header.
  81775. * @param name The name of the header whose value is to be set
  81776. * @param value The value to set as the body of the header
  81777. */
  81778. setRequestHeader(name: string, value: string): void;
  81779. /**
  81780. * Get the string containing the text of a particular header's value.
  81781. * @param name The name of the header
  81782. * @returns The string containing the text of the given header name
  81783. */
  81784. getResponseHeader(name: string): Nullable<string>;
  81785. }
  81786. }
  81787. declare module BABYLON {
  81788. /**
  81789. * File request interface
  81790. */
  81791. export interface IFileRequest {
  81792. /**
  81793. * Raised when the request is complete (success or error).
  81794. */
  81795. onCompleteObservable: Observable<IFileRequest>;
  81796. /**
  81797. * Aborts the request for a file.
  81798. */
  81799. abort: () => void;
  81800. }
  81801. }
  81802. declare module BABYLON {
  81803. /**
  81804. * Define options used to create a render target texture
  81805. */
  81806. export class RenderTargetCreationOptions {
  81807. /**
  81808. * Specifies is mipmaps must be generated
  81809. */
  81810. generateMipMaps?: boolean;
  81811. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81812. generateDepthBuffer?: boolean;
  81813. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81814. generateStencilBuffer?: boolean;
  81815. /** Defines texture type (int by default) */
  81816. type?: number;
  81817. /** Defines sampling mode (trilinear by default) */
  81818. samplingMode?: number;
  81819. /** Defines format (RGBA by default) */
  81820. format?: number;
  81821. }
  81822. }
  81823. declare module BABYLON {
  81824. /** Defines the cross module used constants to avoid circular dependncies */
  81825. export class Constants {
  81826. /** Defines that alpha blending is disabled */
  81827. static readonly ALPHA_DISABLE: number;
  81828. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81829. static readonly ALPHA_ADD: number;
  81830. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81831. static readonly ALPHA_COMBINE: number;
  81832. /** Defines that alpha blending is DEST - SRC * DEST */
  81833. static readonly ALPHA_SUBTRACT: number;
  81834. /** Defines that alpha blending is SRC * DEST */
  81835. static readonly ALPHA_MULTIPLY: number;
  81836. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81837. static readonly ALPHA_MAXIMIZED: number;
  81838. /** Defines that alpha blending is SRC + DEST */
  81839. static readonly ALPHA_ONEONE: number;
  81840. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81841. static readonly ALPHA_PREMULTIPLIED: number;
  81842. /**
  81843. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81844. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81845. */
  81846. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81847. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81848. static readonly ALPHA_INTERPOLATE: number;
  81849. /**
  81850. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81851. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81852. */
  81853. static readonly ALPHA_SCREENMODE: number;
  81854. /**
  81855. * Defines that alpha blending is SRC + DST
  81856. * Alpha will be set to SRC ALPHA + DST ALPHA
  81857. */
  81858. static readonly ALPHA_ONEONE_ONEONE: number;
  81859. /**
  81860. * Defines that alpha blending is SRC * DST ALPHA + DST
  81861. * Alpha will be set to 0
  81862. */
  81863. static readonly ALPHA_ALPHATOCOLOR: number;
  81864. /**
  81865. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81866. */
  81867. static readonly ALPHA_REVERSEONEMINUS: number;
  81868. /**
  81869. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81870. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81871. */
  81872. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81873. /**
  81874. * Defines that alpha blending is SRC + DST
  81875. * Alpha will be set to SRC ALPHA
  81876. */
  81877. static readonly ALPHA_ONEONE_ONEZERO: number;
  81878. /**
  81879. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81880. * Alpha will be set to DST ALPHA
  81881. */
  81882. static readonly ALPHA_EXCLUSION: number;
  81883. /** Defines that alpha blending equation a SUM */
  81884. static readonly ALPHA_EQUATION_ADD: number;
  81885. /** Defines that alpha blending equation a SUBSTRACTION */
  81886. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81887. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81888. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81889. /** Defines that alpha blending equation a MAX operation */
  81890. static readonly ALPHA_EQUATION_MAX: number;
  81891. /** Defines that alpha blending equation a MIN operation */
  81892. static readonly ALPHA_EQUATION_MIN: number;
  81893. /**
  81894. * Defines that alpha blending equation a DARKEN operation:
  81895. * It takes the min of the src and sums the alpha channels.
  81896. */
  81897. static readonly ALPHA_EQUATION_DARKEN: number;
  81898. /** Defines that the ressource is not delayed*/
  81899. static readonly DELAYLOADSTATE_NONE: number;
  81900. /** Defines that the ressource was successfully delay loaded */
  81901. static readonly DELAYLOADSTATE_LOADED: number;
  81902. /** Defines that the ressource is currently delay loading */
  81903. static readonly DELAYLOADSTATE_LOADING: number;
  81904. /** Defines that the ressource is delayed and has not started loading */
  81905. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81907. static readonly NEVER: number;
  81908. /** 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 */
  81909. static readonly ALWAYS: number;
  81910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81911. static readonly LESS: number;
  81912. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81913. static readonly EQUAL: number;
  81914. /** 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 */
  81915. static readonly LEQUAL: number;
  81916. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81917. static readonly GREATER: number;
  81918. /** 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 */
  81919. static readonly GEQUAL: number;
  81920. /** 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 */
  81921. static readonly NOTEQUAL: number;
  81922. /** Passed to stencilOperation to specify that stencil value must be kept */
  81923. static readonly KEEP: number;
  81924. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81925. static readonly REPLACE: number;
  81926. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81927. static readonly INCR: number;
  81928. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81929. static readonly DECR: number;
  81930. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81931. static readonly INVERT: number;
  81932. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81933. static readonly INCR_WRAP: number;
  81934. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81935. static readonly DECR_WRAP: number;
  81936. /** Texture is not repeating outside of 0..1 UVs */
  81937. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81938. /** Texture is repeating outside of 0..1 UVs */
  81939. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81940. /** Texture is repeating and mirrored */
  81941. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81942. /** ALPHA */
  81943. static readonly TEXTUREFORMAT_ALPHA: number;
  81944. /** LUMINANCE */
  81945. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81946. /** LUMINANCE_ALPHA */
  81947. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81948. /** RGB */
  81949. static readonly TEXTUREFORMAT_RGB: number;
  81950. /** RGBA */
  81951. static readonly TEXTUREFORMAT_RGBA: number;
  81952. /** RED */
  81953. static readonly TEXTUREFORMAT_RED: number;
  81954. /** RED (2nd reference) */
  81955. static readonly TEXTUREFORMAT_R: number;
  81956. /** RG */
  81957. static readonly TEXTUREFORMAT_RG: number;
  81958. /** RED_INTEGER */
  81959. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81960. /** RED_INTEGER (2nd reference) */
  81961. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81962. /** RG_INTEGER */
  81963. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81964. /** RGB_INTEGER */
  81965. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81966. /** RGBA_INTEGER */
  81967. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81968. /** UNSIGNED_BYTE */
  81969. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81970. /** UNSIGNED_BYTE (2nd reference) */
  81971. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81972. /** FLOAT */
  81973. static readonly TEXTURETYPE_FLOAT: number;
  81974. /** HALF_FLOAT */
  81975. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81976. /** BYTE */
  81977. static readonly TEXTURETYPE_BYTE: number;
  81978. /** SHORT */
  81979. static readonly TEXTURETYPE_SHORT: number;
  81980. /** UNSIGNED_SHORT */
  81981. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81982. /** INT */
  81983. static readonly TEXTURETYPE_INT: number;
  81984. /** UNSIGNED_INT */
  81985. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81986. /** UNSIGNED_SHORT_4_4_4_4 */
  81987. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81988. /** UNSIGNED_SHORT_5_5_5_1 */
  81989. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81990. /** UNSIGNED_SHORT_5_6_5 */
  81991. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81992. /** UNSIGNED_INT_2_10_10_10_REV */
  81993. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81994. /** UNSIGNED_INT_24_8 */
  81995. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81996. /** UNSIGNED_INT_10F_11F_11F_REV */
  81997. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81998. /** UNSIGNED_INT_5_9_9_9_REV */
  81999. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82000. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82001. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82002. /** nearest is mag = nearest and min = nearest and no mip */
  82003. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82004. /** mag = nearest and min = nearest and mip = none */
  82005. static readonly TEXTURE_NEAREST_NEAREST: number;
  82006. /** Bilinear is mag = linear and min = linear and no mip */
  82007. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82008. /** mag = linear and min = linear and mip = none */
  82009. static readonly TEXTURE_LINEAR_LINEAR: number;
  82010. /** Trilinear is mag = linear and min = linear and mip = linear */
  82011. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82012. /** Trilinear is mag = linear and min = linear and mip = linear */
  82013. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82014. /** mag = nearest and min = nearest and mip = nearest */
  82015. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82016. /** mag = nearest and min = linear and mip = nearest */
  82017. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82018. /** mag = nearest and min = linear and mip = linear */
  82019. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82020. /** mag = nearest and min = linear and mip = none */
  82021. static readonly TEXTURE_NEAREST_LINEAR: number;
  82022. /** nearest is mag = nearest and min = nearest and mip = linear */
  82023. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82024. /** mag = linear and min = nearest and mip = nearest */
  82025. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82026. /** mag = linear and min = nearest and mip = linear */
  82027. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82028. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82029. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82030. /** mag = linear and min = nearest and mip = none */
  82031. static readonly TEXTURE_LINEAR_NEAREST: number;
  82032. /** Explicit coordinates mode */
  82033. static readonly TEXTURE_EXPLICIT_MODE: number;
  82034. /** Spherical coordinates mode */
  82035. static readonly TEXTURE_SPHERICAL_MODE: number;
  82036. /** Planar coordinates mode */
  82037. static readonly TEXTURE_PLANAR_MODE: number;
  82038. /** Cubic coordinates mode */
  82039. static readonly TEXTURE_CUBIC_MODE: number;
  82040. /** Projection coordinates mode */
  82041. static readonly TEXTURE_PROJECTION_MODE: number;
  82042. /** Skybox coordinates mode */
  82043. static readonly TEXTURE_SKYBOX_MODE: number;
  82044. /** Inverse Cubic coordinates mode */
  82045. static readonly TEXTURE_INVCUBIC_MODE: number;
  82046. /** Equirectangular coordinates mode */
  82047. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82048. /** Equirectangular Fixed coordinates mode */
  82049. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82050. /** Equirectangular Fixed Mirrored coordinates mode */
  82051. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82052. /** Offline (baking) quality for texture filtering */
  82053. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82054. /** High quality for texture filtering */
  82055. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82056. /** Medium quality for texture filtering */
  82057. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82058. /** Low quality for texture filtering */
  82059. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82060. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82061. static readonly SCALEMODE_FLOOR: number;
  82062. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82063. static readonly SCALEMODE_NEAREST: number;
  82064. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82065. static readonly SCALEMODE_CEILING: number;
  82066. /**
  82067. * The dirty texture flag value
  82068. */
  82069. static readonly MATERIAL_TextureDirtyFlag: number;
  82070. /**
  82071. * The dirty light flag value
  82072. */
  82073. static readonly MATERIAL_LightDirtyFlag: number;
  82074. /**
  82075. * The dirty fresnel flag value
  82076. */
  82077. static readonly MATERIAL_FresnelDirtyFlag: number;
  82078. /**
  82079. * The dirty attribute flag value
  82080. */
  82081. static readonly MATERIAL_AttributesDirtyFlag: number;
  82082. /**
  82083. * The dirty misc flag value
  82084. */
  82085. static readonly MATERIAL_MiscDirtyFlag: number;
  82086. /**
  82087. * The dirty prepass flag value
  82088. */
  82089. static readonly MATERIAL_PrePassDirtyFlag: number;
  82090. /**
  82091. * The all dirty flag value
  82092. */
  82093. static readonly MATERIAL_AllDirtyFlag: number;
  82094. /**
  82095. * Returns the triangle fill mode
  82096. */
  82097. static readonly MATERIAL_TriangleFillMode: number;
  82098. /**
  82099. * Returns the wireframe mode
  82100. */
  82101. static readonly MATERIAL_WireFrameFillMode: number;
  82102. /**
  82103. * Returns the point fill mode
  82104. */
  82105. static readonly MATERIAL_PointFillMode: number;
  82106. /**
  82107. * Returns the point list draw mode
  82108. */
  82109. static readonly MATERIAL_PointListDrawMode: number;
  82110. /**
  82111. * Returns the line list draw mode
  82112. */
  82113. static readonly MATERIAL_LineListDrawMode: number;
  82114. /**
  82115. * Returns the line loop draw mode
  82116. */
  82117. static readonly MATERIAL_LineLoopDrawMode: number;
  82118. /**
  82119. * Returns the line strip draw mode
  82120. */
  82121. static readonly MATERIAL_LineStripDrawMode: number;
  82122. /**
  82123. * Returns the triangle strip draw mode
  82124. */
  82125. static readonly MATERIAL_TriangleStripDrawMode: number;
  82126. /**
  82127. * Returns the triangle fan draw mode
  82128. */
  82129. static readonly MATERIAL_TriangleFanDrawMode: number;
  82130. /**
  82131. * Stores the clock-wise side orientation
  82132. */
  82133. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82134. /**
  82135. * Stores the counter clock-wise side orientation
  82136. */
  82137. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82138. /**
  82139. * Nothing
  82140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82141. */
  82142. static readonly ACTION_NothingTrigger: number;
  82143. /**
  82144. * On pick
  82145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82146. */
  82147. static readonly ACTION_OnPickTrigger: number;
  82148. /**
  82149. * On left pick
  82150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82151. */
  82152. static readonly ACTION_OnLeftPickTrigger: number;
  82153. /**
  82154. * On right pick
  82155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82156. */
  82157. static readonly ACTION_OnRightPickTrigger: number;
  82158. /**
  82159. * On center pick
  82160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82161. */
  82162. static readonly ACTION_OnCenterPickTrigger: number;
  82163. /**
  82164. * On pick down
  82165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82166. */
  82167. static readonly ACTION_OnPickDownTrigger: number;
  82168. /**
  82169. * On double pick
  82170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82171. */
  82172. static readonly ACTION_OnDoublePickTrigger: number;
  82173. /**
  82174. * On pick up
  82175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82176. */
  82177. static readonly ACTION_OnPickUpTrigger: number;
  82178. /**
  82179. * On pick out.
  82180. * This trigger will only be raised if you also declared a OnPickDown
  82181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82182. */
  82183. static readonly ACTION_OnPickOutTrigger: number;
  82184. /**
  82185. * On long press
  82186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82187. */
  82188. static readonly ACTION_OnLongPressTrigger: number;
  82189. /**
  82190. * On pointer over
  82191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82192. */
  82193. static readonly ACTION_OnPointerOverTrigger: number;
  82194. /**
  82195. * On pointer out
  82196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82197. */
  82198. static readonly ACTION_OnPointerOutTrigger: number;
  82199. /**
  82200. * On every frame
  82201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82202. */
  82203. static readonly ACTION_OnEveryFrameTrigger: number;
  82204. /**
  82205. * On intersection enter
  82206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82207. */
  82208. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82209. /**
  82210. * On intersection exit
  82211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82212. */
  82213. static readonly ACTION_OnIntersectionExitTrigger: number;
  82214. /**
  82215. * On key down
  82216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82217. */
  82218. static readonly ACTION_OnKeyDownTrigger: number;
  82219. /**
  82220. * On key up
  82221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82222. */
  82223. static readonly ACTION_OnKeyUpTrigger: number;
  82224. /**
  82225. * Billboard mode will only apply to Y axis
  82226. */
  82227. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82228. /**
  82229. * Billboard mode will apply to all axes
  82230. */
  82231. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82232. /**
  82233. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82234. */
  82235. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82236. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82237. * Test order :
  82238. * Is the bounding sphere outside the frustum ?
  82239. * If not, are the bounding box vertices outside the frustum ?
  82240. * It not, then the cullable object is in the frustum.
  82241. */
  82242. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82243. /** Culling strategy : Bounding Sphere Only.
  82244. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82245. * It's also less accurate than the standard because some not visible objects can still be selected.
  82246. * Test : is the bounding sphere outside the frustum ?
  82247. * If not, then the cullable object is in the frustum.
  82248. */
  82249. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82250. /** Culling strategy : Optimistic Inclusion.
  82251. * This in an inclusion test first, then the standard exclusion test.
  82252. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82253. * 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.
  82254. * Anyway, it's as accurate as the standard strategy.
  82255. * Test :
  82256. * Is the cullable object bounding sphere center in the frustum ?
  82257. * If not, apply the default culling strategy.
  82258. */
  82259. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82260. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82261. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82262. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82263. * 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.
  82264. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82265. * Test :
  82266. * Is the cullable object bounding sphere center in the frustum ?
  82267. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82268. */
  82269. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82270. /**
  82271. * No logging while loading
  82272. */
  82273. static readonly SCENELOADER_NO_LOGGING: number;
  82274. /**
  82275. * Minimal logging while loading
  82276. */
  82277. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82278. /**
  82279. * Summary logging while loading
  82280. */
  82281. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82282. /**
  82283. * Detailled logging while loading
  82284. */
  82285. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82286. /**
  82287. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82288. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82289. */
  82290. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82291. /**
  82292. * Constant used to retrieve the position texture index in the textures array in the prepass
  82293. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82294. */
  82295. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82296. /**
  82297. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82298. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82299. */
  82300. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82301. /**
  82302. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82303. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82304. */
  82305. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82306. /**
  82307. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82308. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82309. */
  82310. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82311. /**
  82312. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82313. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82314. */
  82315. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82316. /**
  82317. * Constant used to retrieve albedo index in the textures array in the prepass
  82318. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82319. */
  82320. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82321. }
  82322. }
  82323. declare module BABYLON {
  82324. /**
  82325. * This represents the required contract to create a new type of texture loader.
  82326. */
  82327. export interface IInternalTextureLoader {
  82328. /**
  82329. * Defines wether the loader supports cascade loading the different faces.
  82330. */
  82331. supportCascades: boolean;
  82332. /**
  82333. * This returns if the loader support the current file information.
  82334. * @param extension defines the file extension of the file being loaded
  82335. * @param mimeType defines the optional mime type of the file being loaded
  82336. * @returns true if the loader can load the specified file
  82337. */
  82338. canLoad(extension: string, mimeType?: string): boolean;
  82339. /**
  82340. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82341. * @param data contains the texture data
  82342. * @param texture defines the BabylonJS internal texture
  82343. * @param createPolynomials will be true if polynomials have been requested
  82344. * @param onLoad defines the callback to trigger once the texture is ready
  82345. * @param onError defines the callback to trigger in case of error
  82346. * @param options options to be passed to the loader
  82347. */
  82348. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82349. /**
  82350. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82351. * @param data contains the texture data
  82352. * @param texture defines the BabylonJS internal texture
  82353. * @param callback defines the method to call once ready to upload
  82354. * @param options options to be passed to the loader
  82355. */
  82356. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82357. }
  82358. }
  82359. declare module BABYLON {
  82360. /**
  82361. * Class used to store and describe the pipeline context associated with an effect
  82362. */
  82363. export interface IPipelineContext {
  82364. /**
  82365. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82366. */
  82367. isAsync: boolean;
  82368. /**
  82369. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82370. */
  82371. isReady: boolean;
  82372. /** @hidden */
  82373. _getVertexShaderCode(): string | null;
  82374. /** @hidden */
  82375. _getFragmentShaderCode(): string | null;
  82376. /** @hidden */
  82377. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82378. }
  82379. }
  82380. declare module BABYLON {
  82381. /**
  82382. * Class used to store gfx data (like WebGLBuffer)
  82383. */
  82384. export class DataBuffer {
  82385. /**
  82386. * Gets or sets the number of objects referencing this buffer
  82387. */
  82388. references: number;
  82389. /** Gets or sets the size of the underlying buffer */
  82390. capacity: number;
  82391. /**
  82392. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82393. */
  82394. is32Bits: boolean;
  82395. /**
  82396. * Gets the underlying buffer
  82397. */
  82398. get underlyingResource(): any;
  82399. }
  82400. }
  82401. declare module BABYLON {
  82402. /** @hidden */
  82403. export interface IShaderProcessor {
  82404. attributeProcessor?: (attribute: string) => string;
  82405. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82406. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82407. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82408. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82409. lineProcessor?: (line: string, isFragment: boolean) => string;
  82410. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82411. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82412. }
  82413. }
  82414. declare module BABYLON {
  82415. /** @hidden */
  82416. export interface ProcessingOptions {
  82417. defines: string[];
  82418. indexParameters: any;
  82419. isFragment: boolean;
  82420. shouldUseHighPrecisionShader: boolean;
  82421. supportsUniformBuffers: boolean;
  82422. shadersRepository: string;
  82423. includesShadersStore: {
  82424. [key: string]: string;
  82425. };
  82426. processor?: IShaderProcessor;
  82427. version: string;
  82428. platformName: string;
  82429. lookForClosingBracketForUniformBuffer?: boolean;
  82430. }
  82431. }
  82432. declare module BABYLON {
  82433. /** @hidden */
  82434. export class ShaderCodeNode {
  82435. line: string;
  82436. children: ShaderCodeNode[];
  82437. additionalDefineKey?: string;
  82438. additionalDefineValue?: string;
  82439. isValid(preprocessors: {
  82440. [key: string]: string;
  82441. }): boolean;
  82442. process(preprocessors: {
  82443. [key: string]: string;
  82444. }, options: ProcessingOptions): string;
  82445. }
  82446. }
  82447. declare module BABYLON {
  82448. /** @hidden */
  82449. export class ShaderCodeCursor {
  82450. private _lines;
  82451. lineIndex: number;
  82452. get currentLine(): string;
  82453. get canRead(): boolean;
  82454. set lines(value: string[]);
  82455. }
  82456. }
  82457. declare module BABYLON {
  82458. /** @hidden */
  82459. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82460. process(preprocessors: {
  82461. [key: string]: string;
  82462. }, options: ProcessingOptions): string;
  82463. }
  82464. }
  82465. declare module BABYLON {
  82466. /** @hidden */
  82467. export class ShaderDefineExpression {
  82468. isTrue(preprocessors: {
  82469. [key: string]: string;
  82470. }): boolean;
  82471. private static _OperatorPriority;
  82472. private static _Stack;
  82473. static postfixToInfix(postfix: string[]): string;
  82474. static infixToPostfix(infix: string): string[];
  82475. }
  82476. }
  82477. declare module BABYLON {
  82478. /** @hidden */
  82479. export class ShaderCodeTestNode extends ShaderCodeNode {
  82480. testExpression: ShaderDefineExpression;
  82481. isValid(preprocessors: {
  82482. [key: string]: string;
  82483. }): boolean;
  82484. }
  82485. }
  82486. declare module BABYLON {
  82487. /** @hidden */
  82488. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82489. define: string;
  82490. not: boolean;
  82491. constructor(define: string, not?: boolean);
  82492. isTrue(preprocessors: {
  82493. [key: string]: string;
  82494. }): boolean;
  82495. }
  82496. }
  82497. declare module BABYLON {
  82498. /** @hidden */
  82499. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82500. leftOperand: ShaderDefineExpression;
  82501. rightOperand: ShaderDefineExpression;
  82502. isTrue(preprocessors: {
  82503. [key: string]: string;
  82504. }): boolean;
  82505. }
  82506. }
  82507. declare module BABYLON {
  82508. /** @hidden */
  82509. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82510. leftOperand: ShaderDefineExpression;
  82511. rightOperand: ShaderDefineExpression;
  82512. isTrue(preprocessors: {
  82513. [key: string]: string;
  82514. }): boolean;
  82515. }
  82516. }
  82517. declare module BABYLON {
  82518. /** @hidden */
  82519. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82520. define: string;
  82521. operand: string;
  82522. testValue: string;
  82523. constructor(define: string, operand: string, testValue: string);
  82524. isTrue(preprocessors: {
  82525. [key: string]: string;
  82526. }): boolean;
  82527. }
  82528. }
  82529. declare module BABYLON {
  82530. /**
  82531. * Class used to enable access to offline support
  82532. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82533. */
  82534. export interface IOfflineProvider {
  82535. /**
  82536. * Gets a boolean indicating if scene must be saved in the database
  82537. */
  82538. enableSceneOffline: boolean;
  82539. /**
  82540. * Gets a boolean indicating if textures must be saved in the database
  82541. */
  82542. enableTexturesOffline: boolean;
  82543. /**
  82544. * Open the offline support and make it available
  82545. * @param successCallback defines the callback to call on success
  82546. * @param errorCallback defines the callback to call on error
  82547. */
  82548. open(successCallback: () => void, errorCallback: () => void): void;
  82549. /**
  82550. * Loads an image from the offline support
  82551. * @param url defines the url to load from
  82552. * @param image defines the target DOM image
  82553. */
  82554. loadImage(url: string, image: HTMLImageElement): void;
  82555. /**
  82556. * Loads a file from offline support
  82557. * @param url defines the URL to load from
  82558. * @param sceneLoaded defines a callback to call on success
  82559. * @param progressCallBack defines a callback to call when progress changed
  82560. * @param errorCallback defines a callback to call on error
  82561. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82562. */
  82563. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82564. }
  82565. }
  82566. declare module BABYLON {
  82567. /**
  82568. * Class used to help managing file picking and drag'n'drop
  82569. * File Storage
  82570. */
  82571. export class FilesInputStore {
  82572. /**
  82573. * List of files ready to be loaded
  82574. */
  82575. static FilesToLoad: {
  82576. [key: string]: File;
  82577. };
  82578. }
  82579. }
  82580. declare module BABYLON {
  82581. /**
  82582. * Class used to define a retry strategy when error happens while loading assets
  82583. */
  82584. export class RetryStrategy {
  82585. /**
  82586. * Function used to defines an exponential back off strategy
  82587. * @param maxRetries defines the maximum number of retries (3 by default)
  82588. * @param baseInterval defines the interval between retries
  82589. * @returns the strategy function to use
  82590. */
  82591. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82592. }
  82593. }
  82594. declare module BABYLON {
  82595. /**
  82596. * @ignore
  82597. * Application error to support additional information when loading a file
  82598. */
  82599. export abstract class BaseError extends Error {
  82600. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82601. }
  82602. }
  82603. declare module BABYLON {
  82604. /** @ignore */
  82605. export class LoadFileError extends BaseError {
  82606. request?: WebRequest;
  82607. file?: File;
  82608. /**
  82609. * Creates a new LoadFileError
  82610. * @param message defines the message of the error
  82611. * @param request defines the optional web request
  82612. * @param file defines the optional file
  82613. */
  82614. constructor(message: string, object?: WebRequest | File);
  82615. }
  82616. /** @ignore */
  82617. export class RequestFileError extends BaseError {
  82618. request: WebRequest;
  82619. /**
  82620. * Creates a new LoadFileError
  82621. * @param message defines the message of the error
  82622. * @param request defines the optional web request
  82623. */
  82624. constructor(message: string, request: WebRequest);
  82625. }
  82626. /** @ignore */
  82627. export class ReadFileError extends BaseError {
  82628. file: File;
  82629. /**
  82630. * Creates a new ReadFileError
  82631. * @param message defines the message of the error
  82632. * @param file defines the optional file
  82633. */
  82634. constructor(message: string, file: File);
  82635. }
  82636. /**
  82637. * @hidden
  82638. */
  82639. export class FileTools {
  82640. /**
  82641. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82642. */
  82643. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82644. /**
  82645. * Gets or sets the base URL to use to load assets
  82646. */
  82647. static BaseUrl: string;
  82648. /**
  82649. * Default behaviour for cors in the application.
  82650. * It can be a string if the expected behavior is identical in the entire app.
  82651. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82652. */
  82653. static CorsBehavior: string | ((url: string | string[]) => string);
  82654. /**
  82655. * Gets or sets a function used to pre-process url before using them to load assets
  82656. */
  82657. static PreprocessUrl: (url: string) => string;
  82658. /**
  82659. * Removes unwanted characters from an url
  82660. * @param url defines the url to clean
  82661. * @returns the cleaned url
  82662. */
  82663. private static _CleanUrl;
  82664. /**
  82665. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82666. * @param url define the url we are trying
  82667. * @param element define the dom element where to configure the cors policy
  82668. */
  82669. static SetCorsBehavior(url: string | string[], element: {
  82670. crossOrigin: string | null;
  82671. }): void;
  82672. /**
  82673. * Loads an image as an HTMLImageElement.
  82674. * @param input url string, ArrayBuffer, or Blob to load
  82675. * @param onLoad callback called when the image successfully loads
  82676. * @param onError callback called when the image fails to load
  82677. * @param offlineProvider offline provider for caching
  82678. * @param mimeType optional mime type
  82679. * @returns the HTMLImageElement of the loaded image
  82680. */
  82681. 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>;
  82682. /**
  82683. * Reads a file from a File object
  82684. * @param file defines the file to load
  82685. * @param onSuccess defines the callback to call when data is loaded
  82686. * @param onProgress defines the callback to call during loading process
  82687. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82688. * @param onError defines the callback to call when an error occurs
  82689. * @returns a file request object
  82690. */
  82691. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82692. /**
  82693. * Loads a file from a url
  82694. * @param url url to load
  82695. * @param onSuccess callback called when the file successfully loads
  82696. * @param onProgress callback called while file is loading (if the server supports this mode)
  82697. * @param offlineProvider defines the offline provider for caching
  82698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82699. * @param onError callback called when the file fails to load
  82700. * @returns a file request object
  82701. */
  82702. 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;
  82703. /**
  82704. * Loads a file
  82705. * @param url url to load
  82706. * @param onSuccess callback called when the file successfully loads
  82707. * @param onProgress callback called while file is loading (if the server supports this mode)
  82708. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82709. * @param onError callback called when the file fails to load
  82710. * @param onOpened callback called when the web request is opened
  82711. * @returns a file request object
  82712. */
  82713. 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;
  82714. /**
  82715. * Checks if the loaded document was accessed via `file:`-Protocol.
  82716. * @returns boolean
  82717. */
  82718. static IsFileURL(): boolean;
  82719. }
  82720. }
  82721. declare module BABYLON {
  82722. /** @hidden */
  82723. export class ShaderProcessor {
  82724. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  82725. private static _ProcessPrecision;
  82726. private static _ExtractOperation;
  82727. private static _BuildSubExpression;
  82728. private static _BuildExpression;
  82729. private static _MoveCursorWithinIf;
  82730. private static _MoveCursor;
  82731. private static _EvaluatePreProcessors;
  82732. private static _PreparePreProcessors;
  82733. private static _ProcessShaderConversion;
  82734. private static _ProcessIncludes;
  82735. /**
  82736. * Loads a file from a url
  82737. * @param url url to load
  82738. * @param onSuccess callback called when the file successfully loads
  82739. * @param onProgress callback called while file is loading (if the server supports this mode)
  82740. * @param offlineProvider defines the offline provider for caching
  82741. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82742. * @param onError callback called when the file fails to load
  82743. * @returns a file request object
  82744. * @hidden
  82745. */
  82746. 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;
  82747. }
  82748. }
  82749. declare module BABYLON {
  82750. /**
  82751. * @hidden
  82752. */
  82753. export interface IColor4Like {
  82754. r: float;
  82755. g: float;
  82756. b: float;
  82757. a: float;
  82758. }
  82759. /**
  82760. * @hidden
  82761. */
  82762. export interface IColor3Like {
  82763. r: float;
  82764. g: float;
  82765. b: float;
  82766. }
  82767. /**
  82768. * @hidden
  82769. */
  82770. export interface IVector4Like {
  82771. x: float;
  82772. y: float;
  82773. z: float;
  82774. w: float;
  82775. }
  82776. /**
  82777. * @hidden
  82778. */
  82779. export interface IVector3Like {
  82780. x: float;
  82781. y: float;
  82782. z: float;
  82783. }
  82784. /**
  82785. * @hidden
  82786. */
  82787. export interface IVector2Like {
  82788. x: float;
  82789. y: float;
  82790. }
  82791. /**
  82792. * @hidden
  82793. */
  82794. export interface IMatrixLike {
  82795. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82796. updateFlag: int;
  82797. }
  82798. /**
  82799. * @hidden
  82800. */
  82801. export interface IViewportLike {
  82802. x: float;
  82803. y: float;
  82804. width: float;
  82805. height: float;
  82806. }
  82807. /**
  82808. * @hidden
  82809. */
  82810. export interface IPlaneLike {
  82811. normal: IVector3Like;
  82812. d: float;
  82813. normalize(): void;
  82814. }
  82815. }
  82816. declare module BABYLON {
  82817. /**
  82818. * Interface used to define common properties for effect fallbacks
  82819. */
  82820. export interface IEffectFallbacks {
  82821. /**
  82822. * Removes the defines that should be removed when falling back.
  82823. * @param currentDefines defines the current define statements for the shader.
  82824. * @param effect defines the current effect we try to compile
  82825. * @returns The resulting defines with defines of the current rank removed.
  82826. */
  82827. reduce(currentDefines: string, effect: Effect): string;
  82828. /**
  82829. * Removes the fallback from the bound mesh.
  82830. */
  82831. unBindMesh(): void;
  82832. /**
  82833. * Checks to see if more fallbacks are still availible.
  82834. */
  82835. hasMoreFallbacks: boolean;
  82836. }
  82837. }
  82838. declare module BABYLON {
  82839. /**
  82840. * Class used to evalaute queries containing `and` and `or` operators
  82841. */
  82842. export class AndOrNotEvaluator {
  82843. /**
  82844. * Evaluate a query
  82845. * @param query defines the query to evaluate
  82846. * @param evaluateCallback defines the callback used to filter result
  82847. * @returns true if the query matches
  82848. */
  82849. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82850. private static _HandleParenthesisContent;
  82851. private static _SimplifyNegation;
  82852. }
  82853. }
  82854. declare module BABYLON {
  82855. /**
  82856. * Class used to store custom tags
  82857. */
  82858. export class Tags {
  82859. /**
  82860. * Adds support for tags on the given object
  82861. * @param obj defines the object to use
  82862. */
  82863. static EnableFor(obj: any): void;
  82864. /**
  82865. * Removes tags support
  82866. * @param obj defines the object to use
  82867. */
  82868. static DisableFor(obj: any): void;
  82869. /**
  82870. * Gets a boolean indicating if the given object has tags
  82871. * @param obj defines the object to use
  82872. * @returns a boolean
  82873. */
  82874. static HasTags(obj: any): boolean;
  82875. /**
  82876. * Gets the tags available on a given object
  82877. * @param obj defines the object to use
  82878. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82879. * @returns the tags
  82880. */
  82881. static GetTags(obj: any, asString?: boolean): any;
  82882. /**
  82883. * Adds tags to an object
  82884. * @param obj defines the object to use
  82885. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82886. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82887. */
  82888. static AddTagsTo(obj: any, tagsString: string): void;
  82889. /**
  82890. * @hidden
  82891. */
  82892. static _AddTagTo(obj: any, tag: string): void;
  82893. /**
  82894. * Removes specific tags from a specific object
  82895. * @param obj defines the object to use
  82896. * @param tagsString defines the tags to remove
  82897. */
  82898. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82899. /**
  82900. * @hidden
  82901. */
  82902. static _RemoveTagFrom(obj: any, tag: string): void;
  82903. /**
  82904. * Defines if tags hosted on an object match a given query
  82905. * @param obj defines the object to use
  82906. * @param tagsQuery defines the tag query
  82907. * @returns a boolean
  82908. */
  82909. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82910. }
  82911. }
  82912. declare module BABYLON {
  82913. /**
  82914. * Scalar computation library
  82915. */
  82916. export class Scalar {
  82917. /**
  82918. * Two pi constants convenient for computation.
  82919. */
  82920. static TwoPi: number;
  82921. /**
  82922. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82923. * @param a number
  82924. * @param b number
  82925. * @param epsilon (default = 1.401298E-45)
  82926. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82927. */
  82928. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82929. /**
  82930. * Returns a string : the upper case translation of the number i to hexadecimal.
  82931. * @param i number
  82932. * @returns the upper case translation of the number i to hexadecimal.
  82933. */
  82934. static ToHex(i: number): string;
  82935. /**
  82936. * Returns -1 if value is negative and +1 is value is positive.
  82937. * @param value the value
  82938. * @returns the value itself if it's equal to zero.
  82939. */
  82940. static Sign(value: number): number;
  82941. /**
  82942. * Returns the value itself if it's between min and max.
  82943. * Returns min if the value is lower than min.
  82944. * Returns max if the value is greater than max.
  82945. * @param value the value to clmap
  82946. * @param min the min value to clamp to (default: 0)
  82947. * @param max the max value to clamp to (default: 1)
  82948. * @returns the clamped value
  82949. */
  82950. static Clamp(value: number, min?: number, max?: number): number;
  82951. /**
  82952. * the log2 of value.
  82953. * @param value the value to compute log2 of
  82954. * @returns the log2 of value.
  82955. */
  82956. static Log2(value: number): number;
  82957. /**
  82958. * Loops the value, so that it is never larger than length and never smaller than 0.
  82959. *
  82960. * This is similar to the modulo operator but it works with floating point numbers.
  82961. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82962. * With t = 5 and length = 2.5, the result would be 0.0.
  82963. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82964. * @param value the value
  82965. * @param length the length
  82966. * @returns the looped value
  82967. */
  82968. static Repeat(value: number, length: number): number;
  82969. /**
  82970. * Normalize the value between 0.0 and 1.0 using min and max values
  82971. * @param value value to normalize
  82972. * @param min max to normalize between
  82973. * @param max min to normalize between
  82974. * @returns the normalized value
  82975. */
  82976. static Normalize(value: number, min: number, max: number): number;
  82977. /**
  82978. * Denormalize the value from 0.0 and 1.0 using min and max values
  82979. * @param normalized value to denormalize
  82980. * @param min max to denormalize between
  82981. * @param max min to denormalize between
  82982. * @returns the denormalized value
  82983. */
  82984. static Denormalize(normalized: number, min: number, max: number): number;
  82985. /**
  82986. * Calculates the shortest difference between two given angles given in degrees.
  82987. * @param current current angle in degrees
  82988. * @param target target angle in degrees
  82989. * @returns the delta
  82990. */
  82991. static DeltaAngle(current: number, target: number): number;
  82992. /**
  82993. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82994. * @param tx value
  82995. * @param length length
  82996. * @returns The returned value will move back and forth between 0 and length
  82997. */
  82998. static PingPong(tx: number, length: number): number;
  82999. /**
  83000. * Interpolates between min and max with smoothing at the limits.
  83001. *
  83002. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  83003. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  83004. * @param from from
  83005. * @param to to
  83006. * @param tx value
  83007. * @returns the smooth stepped value
  83008. */
  83009. static SmoothStep(from: number, to: number, tx: number): number;
  83010. /**
  83011. * Moves a value current towards target.
  83012. *
  83013. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83014. * Negative values of maxDelta pushes the value away from target.
  83015. * @param current current value
  83016. * @param target target value
  83017. * @param maxDelta max distance to move
  83018. * @returns resulting value
  83019. */
  83020. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83021. /**
  83022. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83023. *
  83024. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83025. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83026. * @param current current value
  83027. * @param target target value
  83028. * @param maxDelta max distance to move
  83029. * @returns resulting angle
  83030. */
  83031. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83032. /**
  83033. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83034. * @param start start value
  83035. * @param end target value
  83036. * @param amount amount to lerp between
  83037. * @returns the lerped value
  83038. */
  83039. static Lerp(start: number, end: number, amount: number): number;
  83040. /**
  83041. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83042. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83043. * @param start start value
  83044. * @param end target value
  83045. * @param amount amount to lerp between
  83046. * @returns the lerped value
  83047. */
  83048. static LerpAngle(start: number, end: number, amount: number): number;
  83049. /**
  83050. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83051. * @param a start value
  83052. * @param b target value
  83053. * @param value value between a and b
  83054. * @returns the inverseLerp value
  83055. */
  83056. static InverseLerp(a: number, b: number, value: number): number;
  83057. /**
  83058. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83059. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83060. * @param value1 spline value
  83061. * @param tangent1 spline value
  83062. * @param value2 spline value
  83063. * @param tangent2 spline value
  83064. * @param amount input value
  83065. * @returns hermite result
  83066. */
  83067. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83068. /**
  83069. * Returns a random float number between and min and max values
  83070. * @param min min value of random
  83071. * @param max max value of random
  83072. * @returns random value
  83073. */
  83074. static RandomRange(min: number, max: number): number;
  83075. /**
  83076. * This function returns percentage of a number in a given range.
  83077. *
  83078. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83079. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83080. * @param number to convert to percentage
  83081. * @param min min range
  83082. * @param max max range
  83083. * @returns the percentage
  83084. */
  83085. static RangeToPercent(number: number, min: number, max: number): number;
  83086. /**
  83087. * This function returns number that corresponds to the percentage in a given range.
  83088. *
  83089. * PercentToRange(0.34,0,100) will return 34.
  83090. * @param percent to convert to number
  83091. * @param min min range
  83092. * @param max max range
  83093. * @returns the number
  83094. */
  83095. static PercentToRange(percent: number, min: number, max: number): number;
  83096. /**
  83097. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83098. * @param angle The angle to normalize in radian.
  83099. * @return The converted angle.
  83100. */
  83101. static NormalizeRadians(angle: number): number;
  83102. }
  83103. }
  83104. declare module BABYLON {
  83105. /**
  83106. * Constant used to convert a value to gamma space
  83107. * @ignorenaming
  83108. */
  83109. export const ToGammaSpace: number;
  83110. /**
  83111. * Constant used to convert a value to linear space
  83112. * @ignorenaming
  83113. */
  83114. export const ToLinearSpace = 2.2;
  83115. /**
  83116. * Constant used to define the minimal number value in Babylon.js
  83117. * @ignorenaming
  83118. */
  83119. let Epsilon: number;
  83120. }
  83121. declare module BABYLON {
  83122. /**
  83123. * Class used to represent a viewport on screen
  83124. */
  83125. export class Viewport {
  83126. /** viewport left coordinate */
  83127. x: number;
  83128. /** viewport top coordinate */
  83129. y: number;
  83130. /**viewport width */
  83131. width: number;
  83132. /** viewport height */
  83133. height: number;
  83134. /**
  83135. * Creates a Viewport object located at (x, y) and sized (width, height)
  83136. * @param x defines viewport left coordinate
  83137. * @param y defines viewport top coordinate
  83138. * @param width defines the viewport width
  83139. * @param height defines the viewport height
  83140. */
  83141. constructor(
  83142. /** viewport left coordinate */
  83143. x: number,
  83144. /** viewport top coordinate */
  83145. y: number,
  83146. /**viewport width */
  83147. width: number,
  83148. /** viewport height */
  83149. height: number);
  83150. /**
  83151. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83152. * @param renderWidth defines the rendering width
  83153. * @param renderHeight defines the rendering height
  83154. * @returns a new Viewport
  83155. */
  83156. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83157. /**
  83158. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83159. * @param renderWidth defines the rendering width
  83160. * @param renderHeight defines the rendering height
  83161. * @param ref defines the target viewport
  83162. * @returns the current viewport
  83163. */
  83164. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83165. /**
  83166. * Returns a new Viewport copied from the current one
  83167. * @returns a new Viewport
  83168. */
  83169. clone(): Viewport;
  83170. }
  83171. }
  83172. declare module BABYLON {
  83173. /**
  83174. * Class containing a set of static utilities functions for arrays.
  83175. */
  83176. export class ArrayTools {
  83177. /**
  83178. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83179. * @param size the number of element to construct and put in the array
  83180. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83181. * @returns a new array filled with new objects
  83182. */
  83183. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83184. }
  83185. }
  83186. declare module BABYLON {
  83187. /**
  83188. * Represents a plane by the equation ax + by + cz + d = 0
  83189. */
  83190. export class Plane {
  83191. private static _TmpMatrix;
  83192. /**
  83193. * Normal of the plane (a,b,c)
  83194. */
  83195. normal: Vector3;
  83196. /**
  83197. * d component of the plane
  83198. */
  83199. d: number;
  83200. /**
  83201. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83202. * @param a a component of the plane
  83203. * @param b b component of the plane
  83204. * @param c c component of the plane
  83205. * @param d d component of the plane
  83206. */
  83207. constructor(a: number, b: number, c: number, d: number);
  83208. /**
  83209. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83210. */
  83211. asArray(): number[];
  83212. /**
  83213. * @returns a new plane copied from the current Plane.
  83214. */
  83215. clone(): Plane;
  83216. /**
  83217. * @returns the string "Plane".
  83218. */
  83219. getClassName(): string;
  83220. /**
  83221. * @returns the Plane hash code.
  83222. */
  83223. getHashCode(): number;
  83224. /**
  83225. * Normalize the current Plane in place.
  83226. * @returns the updated Plane.
  83227. */
  83228. normalize(): Plane;
  83229. /**
  83230. * Applies a transformation the plane and returns the result
  83231. * @param transformation the transformation matrix to be applied to the plane
  83232. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83233. */
  83234. transform(transformation: DeepImmutable<Matrix>): Plane;
  83235. /**
  83236. * Compute the dot product between the point and the plane normal
  83237. * @param point point to calculate the dot product with
  83238. * @returns the dot product (float) of the point coordinates and the plane normal.
  83239. */
  83240. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83241. /**
  83242. * Updates the current Plane from the plane defined by the three given points.
  83243. * @param point1 one of the points used to contruct the plane
  83244. * @param point2 one of the points used to contruct the plane
  83245. * @param point3 one of the points used to contruct the plane
  83246. * @returns the updated Plane.
  83247. */
  83248. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83249. /**
  83250. * Checks if the plane is facing a given direction
  83251. * @param direction the direction to check if the plane is facing
  83252. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  83253. * @returns True is the vector "direction" is the same side than the plane normal.
  83254. */
  83255. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  83256. /**
  83257. * Calculates the distance to a point
  83258. * @param point point to calculate distance to
  83259. * @returns the signed distance (float) from the given point to the Plane.
  83260. */
  83261. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  83262. /**
  83263. * Creates a plane from an array
  83264. * @param array the array to create a plane from
  83265. * @returns a new Plane from the given array.
  83266. */
  83267. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  83268. /**
  83269. * Creates a plane from three points
  83270. * @param point1 point used to create the plane
  83271. * @param point2 point used to create the plane
  83272. * @param point3 point used to create the plane
  83273. * @returns a new Plane defined by the three given points.
  83274. */
  83275. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83276. /**
  83277. * Creates a plane from an origin point and a normal
  83278. * @param origin origin of the plane to be constructed
  83279. * @param normal normal of the plane to be constructed
  83280. * @returns a new Plane the normal vector to this plane at the given origin point.
  83281. * Note : the vector "normal" is updated because normalized.
  83282. */
  83283. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  83284. /**
  83285. * Calculates the distance from a plane and a point
  83286. * @param origin origin of the plane to be constructed
  83287. * @param normal normal of the plane to be constructed
  83288. * @param point point to calculate distance to
  83289. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  83290. */
  83291. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  83292. }
  83293. }
  83294. declare module BABYLON {
  83295. /** @hidden */
  83296. export class PerformanceConfigurator {
  83297. /** @hidden */
  83298. static MatrixUse64Bits: boolean;
  83299. /** @hidden */
  83300. static MatrixTrackPrecisionChange: boolean;
  83301. /** @hidden */
  83302. static MatrixCurrentType: any;
  83303. /** @hidden */
  83304. static MatrixTrackedMatrices: Array<any> | null;
  83305. /** @hidden */
  83306. static SetMatrixPrecision(use64bits: boolean): void;
  83307. }
  83308. }
  83309. declare module BABYLON {
  83310. /**
  83311. * Class representing a vector containing 2 coordinates
  83312. */
  83313. export class Vector2 {
  83314. /** defines the first coordinate */
  83315. x: number;
  83316. /** defines the second coordinate */
  83317. y: number;
  83318. /**
  83319. * Creates a new Vector2 from the given x and y coordinates
  83320. * @param x defines the first coordinate
  83321. * @param y defines the second coordinate
  83322. */
  83323. constructor(
  83324. /** defines the first coordinate */
  83325. x?: number,
  83326. /** defines the second coordinate */
  83327. y?: number);
  83328. /**
  83329. * Gets a string with the Vector2 coordinates
  83330. * @returns a string with the Vector2 coordinates
  83331. */
  83332. toString(): string;
  83333. /**
  83334. * Gets class name
  83335. * @returns the string "Vector2"
  83336. */
  83337. getClassName(): string;
  83338. /**
  83339. * Gets current vector hash code
  83340. * @returns the Vector2 hash code as a number
  83341. */
  83342. getHashCode(): number;
  83343. /**
  83344. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  83345. * @param array defines the source array
  83346. * @param index defines the offset in source array
  83347. * @returns the current Vector2
  83348. */
  83349. toArray(array: FloatArray, index?: number): Vector2;
  83350. /**
  83351. * Update the current vector from an array
  83352. * @param array defines the destination array
  83353. * @param index defines the offset in the destination array
  83354. * @returns the current Vector3
  83355. */
  83356. fromArray(array: FloatArray, index?: number): Vector2;
  83357. /**
  83358. * Copy the current vector to an array
  83359. * @returns a new array with 2 elements: the Vector2 coordinates.
  83360. */
  83361. asArray(): number[];
  83362. /**
  83363. * Sets the Vector2 coordinates with the given Vector2 coordinates
  83364. * @param source defines the source Vector2
  83365. * @returns the current updated Vector2
  83366. */
  83367. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  83368. /**
  83369. * Sets the Vector2 coordinates with the given floats
  83370. * @param x defines the first coordinate
  83371. * @param y defines the second coordinate
  83372. * @returns the current updated Vector2
  83373. */
  83374. copyFromFloats(x: number, y: number): Vector2;
  83375. /**
  83376. * Sets the Vector2 coordinates with the given floats
  83377. * @param x defines the first coordinate
  83378. * @param y defines the second coordinate
  83379. * @returns the current updated Vector2
  83380. */
  83381. set(x: number, y: number): Vector2;
  83382. /**
  83383. * Add another vector with the current one
  83384. * @param otherVector defines the other vector
  83385. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  83386. */
  83387. add(otherVector: DeepImmutable<Vector2>): Vector2;
  83388. /**
  83389. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  83390. * @param otherVector defines the other vector
  83391. * @param result defines the target vector
  83392. * @returns the unmodified current Vector2
  83393. */
  83394. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83395. /**
  83396. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  83397. * @param otherVector defines the other vector
  83398. * @returns the current updated Vector2
  83399. */
  83400. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83401. /**
  83402. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  83403. * @param otherVector defines the other vector
  83404. * @returns a new Vector2
  83405. */
  83406. addVector3(otherVector: Vector3): Vector2;
  83407. /**
  83408. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  83409. * @param otherVector defines the other vector
  83410. * @returns a new Vector2
  83411. */
  83412. subtract(otherVector: Vector2): Vector2;
  83413. /**
  83414. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  83415. * @param otherVector defines the other vector
  83416. * @param result defines the target vector
  83417. * @returns the unmodified current Vector2
  83418. */
  83419. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83420. /**
  83421. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  83422. * @param otherVector defines the other vector
  83423. * @returns the current updated Vector2
  83424. */
  83425. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83426. /**
  83427. * Multiplies in place the current Vector2 coordinates by the given ones
  83428. * @param otherVector defines the other vector
  83429. * @returns the current updated Vector2
  83430. */
  83431. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83432. /**
  83433. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  83434. * @param otherVector defines the other vector
  83435. * @returns a new Vector2
  83436. */
  83437. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  83438. /**
  83439. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83440. * @param otherVector defines the other vector
  83441. * @param result defines the target vector
  83442. * @returns the unmodified current Vector2
  83443. */
  83444. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83445. /**
  83446. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83447. * @param x defines the first coordinate
  83448. * @param y defines the second coordinate
  83449. * @returns a new Vector2
  83450. */
  83451. multiplyByFloats(x: number, y: number): Vector2;
  83452. /**
  83453. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83454. * @param otherVector defines the other vector
  83455. * @returns a new Vector2
  83456. */
  83457. divide(otherVector: Vector2): Vector2;
  83458. /**
  83459. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83460. * @param otherVector defines the other vector
  83461. * @param result defines the target vector
  83462. * @returns the unmodified current Vector2
  83463. */
  83464. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83465. /**
  83466. * Divides the current Vector2 coordinates by the given ones
  83467. * @param otherVector defines the other vector
  83468. * @returns the current updated Vector2
  83469. */
  83470. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83471. /**
  83472. * Gets a new Vector2 with current Vector2 negated coordinates
  83473. * @returns a new Vector2
  83474. */
  83475. negate(): Vector2;
  83476. /**
  83477. * Negate this vector in place
  83478. * @returns this
  83479. */
  83480. negateInPlace(): Vector2;
  83481. /**
  83482. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83483. * @param result defines the Vector3 object where to store the result
  83484. * @returns the current Vector2
  83485. */
  83486. negateToRef(result: Vector2): Vector2;
  83487. /**
  83488. * Multiply the Vector2 coordinates by scale
  83489. * @param scale defines the scaling factor
  83490. * @returns the current updated Vector2
  83491. */
  83492. scaleInPlace(scale: number): Vector2;
  83493. /**
  83494. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83495. * @param scale defines the scaling factor
  83496. * @returns a new Vector2
  83497. */
  83498. scale(scale: number): Vector2;
  83499. /**
  83500. * Scale the current Vector2 values by a factor to a given Vector2
  83501. * @param scale defines the scale factor
  83502. * @param result defines the Vector2 object where to store the result
  83503. * @returns the unmodified current Vector2
  83504. */
  83505. scaleToRef(scale: number, result: Vector2): Vector2;
  83506. /**
  83507. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83508. * @param scale defines the scale factor
  83509. * @param result defines the Vector2 object where to store the result
  83510. * @returns the unmodified current Vector2
  83511. */
  83512. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83513. /**
  83514. * Gets a boolean if two vectors are equals
  83515. * @param otherVector defines the other vector
  83516. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83517. */
  83518. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83519. /**
  83520. * Gets a boolean if two vectors are equals (using an epsilon value)
  83521. * @param otherVector defines the other vector
  83522. * @param epsilon defines the minimal distance to consider equality
  83523. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83524. */
  83525. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83526. /**
  83527. * Gets a new Vector2 from current Vector2 floored values
  83528. * @returns a new Vector2
  83529. */
  83530. floor(): Vector2;
  83531. /**
  83532. * Gets a new Vector2 from current Vector2 floored values
  83533. * @returns a new Vector2
  83534. */
  83535. fract(): Vector2;
  83536. /**
  83537. * Gets the length of the vector
  83538. * @returns the vector length (float)
  83539. */
  83540. length(): number;
  83541. /**
  83542. * Gets the vector squared length
  83543. * @returns the vector squared length (float)
  83544. */
  83545. lengthSquared(): number;
  83546. /**
  83547. * Normalize the vector
  83548. * @returns the current updated Vector2
  83549. */
  83550. normalize(): Vector2;
  83551. /**
  83552. * Gets a new Vector2 copied from the Vector2
  83553. * @returns a new Vector2
  83554. */
  83555. clone(): Vector2;
  83556. /**
  83557. * Gets a new Vector2(0, 0)
  83558. * @returns a new Vector2
  83559. */
  83560. static Zero(): Vector2;
  83561. /**
  83562. * Gets a new Vector2(1, 1)
  83563. * @returns a new Vector2
  83564. */
  83565. static One(): Vector2;
  83566. /**
  83567. * Gets a new Vector2 set from the given index element of the given array
  83568. * @param array defines the data source
  83569. * @param offset defines the offset in the data source
  83570. * @returns a new Vector2
  83571. */
  83572. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83573. /**
  83574. * Sets "result" from the given index element of the given array
  83575. * @param array defines the data source
  83576. * @param offset defines the offset in the data source
  83577. * @param result defines the target vector
  83578. */
  83579. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83580. /**
  83581. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83582. * @param value1 defines 1st point of control
  83583. * @param value2 defines 2nd point of control
  83584. * @param value3 defines 3rd point of control
  83585. * @param value4 defines 4th point of control
  83586. * @param amount defines the interpolation factor
  83587. * @returns a new Vector2
  83588. */
  83589. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83590. /**
  83591. * 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".
  83592. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83593. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83594. * @param value defines the value to clamp
  83595. * @param min defines the lower limit
  83596. * @param max defines the upper limit
  83597. * @returns a new Vector2
  83598. */
  83599. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83600. /**
  83601. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83602. * @param value1 defines the 1st control point
  83603. * @param tangent1 defines the outgoing tangent
  83604. * @param value2 defines the 2nd control point
  83605. * @param tangent2 defines the incoming tangent
  83606. * @param amount defines the interpolation factor
  83607. * @returns a new Vector2
  83608. */
  83609. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83610. /**
  83611. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83612. * @param start defines the start vector
  83613. * @param end defines the end vector
  83614. * @param amount defines the interpolation factor
  83615. * @returns a new Vector2
  83616. */
  83617. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83618. /**
  83619. * Gets the dot product of the vector "left" and the vector "right"
  83620. * @param left defines first vector
  83621. * @param right defines second vector
  83622. * @returns the dot product (float)
  83623. */
  83624. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83625. /**
  83626. * Returns a new Vector2 equal to the normalized given vector
  83627. * @param vector defines the vector to normalize
  83628. * @returns a new Vector2
  83629. */
  83630. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83631. /**
  83632. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83633. * @param left defines 1st vector
  83634. * @param right defines 2nd vector
  83635. * @returns a new Vector2
  83636. */
  83637. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83638. /**
  83639. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83640. * @param left defines 1st vector
  83641. * @param right defines 2nd vector
  83642. * @returns a new Vector2
  83643. */
  83644. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83645. /**
  83646. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83647. * @param vector defines the vector to transform
  83648. * @param transformation defines the matrix to apply
  83649. * @returns a new Vector2
  83650. */
  83651. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83652. /**
  83653. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83654. * @param vector defines the vector to transform
  83655. * @param transformation defines the matrix to apply
  83656. * @param result defines the target vector
  83657. */
  83658. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83659. /**
  83660. * Determines if a given vector is included in a triangle
  83661. * @param p defines the vector to test
  83662. * @param p0 defines 1st triangle point
  83663. * @param p1 defines 2nd triangle point
  83664. * @param p2 defines 3rd triangle point
  83665. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83666. */
  83667. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83668. /**
  83669. * Gets the distance between the vectors "value1" and "value2"
  83670. * @param value1 defines first vector
  83671. * @param value2 defines second vector
  83672. * @returns the distance between vectors
  83673. */
  83674. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83675. /**
  83676. * Returns the squared distance between the vectors "value1" and "value2"
  83677. * @param value1 defines first vector
  83678. * @param value2 defines second vector
  83679. * @returns the squared distance between vectors
  83680. */
  83681. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83682. /**
  83683. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83684. * @param value1 defines first vector
  83685. * @param value2 defines second vector
  83686. * @returns a new Vector2
  83687. */
  83688. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83689. /**
  83690. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83691. * @param p defines the middle point
  83692. * @param segA defines one point of the segment
  83693. * @param segB defines the other point of the segment
  83694. * @returns the shortest distance
  83695. */
  83696. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83697. }
  83698. /**
  83699. * Class used to store (x,y,z) vector representation
  83700. * A Vector3 is the main object used in 3D geometry
  83701. * It can represent etiher the coordinates of a point the space, either a direction
  83702. * Reminder: js uses a left handed forward facing system
  83703. */
  83704. export class Vector3 {
  83705. private static _UpReadOnly;
  83706. private static _ZeroReadOnly;
  83707. /** @hidden */
  83708. _x: number;
  83709. /** @hidden */
  83710. _y: number;
  83711. /** @hidden */
  83712. _z: number;
  83713. /** @hidden */
  83714. _isDirty: boolean;
  83715. /** Gets or sets the x coordinate */
  83716. get x(): number;
  83717. set x(value: number);
  83718. /** Gets or sets the y coordinate */
  83719. get y(): number;
  83720. set y(value: number);
  83721. /** Gets or sets the z coordinate */
  83722. get z(): number;
  83723. set z(value: number);
  83724. /**
  83725. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83726. * @param x defines the first coordinates (on X axis)
  83727. * @param y defines the second coordinates (on Y axis)
  83728. * @param z defines the third coordinates (on Z axis)
  83729. */
  83730. constructor(x?: number, y?: number, z?: number);
  83731. /**
  83732. * Creates a string representation of the Vector3
  83733. * @returns a string with the Vector3 coordinates.
  83734. */
  83735. toString(): string;
  83736. /**
  83737. * Gets the class name
  83738. * @returns the string "Vector3"
  83739. */
  83740. getClassName(): string;
  83741. /**
  83742. * Creates the Vector3 hash code
  83743. * @returns a number which tends to be unique between Vector3 instances
  83744. */
  83745. getHashCode(): number;
  83746. /**
  83747. * Creates an array containing three elements : the coordinates of the Vector3
  83748. * @returns a new array of numbers
  83749. */
  83750. asArray(): number[];
  83751. /**
  83752. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83753. * @param array defines the destination array
  83754. * @param index defines the offset in the destination array
  83755. * @returns the current Vector3
  83756. */
  83757. toArray(array: FloatArray, index?: number): Vector3;
  83758. /**
  83759. * Update the current vector from an array
  83760. * @param array defines the destination array
  83761. * @param index defines the offset in the destination array
  83762. * @returns the current Vector3
  83763. */
  83764. fromArray(array: FloatArray, index?: number): Vector3;
  83765. /**
  83766. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83767. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83768. */
  83769. toQuaternion(): Quaternion;
  83770. /**
  83771. * Adds the given vector to the current Vector3
  83772. * @param otherVector defines the second operand
  83773. * @returns the current updated Vector3
  83774. */
  83775. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83776. /**
  83777. * Adds the given coordinates to the current Vector3
  83778. * @param x defines the x coordinate of the operand
  83779. * @param y defines the y coordinate of the operand
  83780. * @param z defines the z coordinate of the operand
  83781. * @returns the current updated Vector3
  83782. */
  83783. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83784. /**
  83785. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83786. * @param otherVector defines the second operand
  83787. * @returns the resulting Vector3
  83788. */
  83789. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83790. /**
  83791. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83792. * @param otherVector defines the second operand
  83793. * @param result defines the Vector3 object where to store the result
  83794. * @returns the current Vector3
  83795. */
  83796. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83797. /**
  83798. * Subtract the given vector from the current Vector3
  83799. * @param otherVector defines the second operand
  83800. * @returns the current updated Vector3
  83801. */
  83802. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83803. /**
  83804. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83805. * @param otherVector defines the second operand
  83806. * @returns the resulting Vector3
  83807. */
  83808. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83809. /**
  83810. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83811. * @param otherVector defines the second operand
  83812. * @param result defines the Vector3 object where to store the result
  83813. * @returns the current Vector3
  83814. */
  83815. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83816. /**
  83817. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83818. * @param x defines the x coordinate of the operand
  83819. * @param y defines the y coordinate of the operand
  83820. * @param z defines the z coordinate of the operand
  83821. * @returns the resulting Vector3
  83822. */
  83823. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83824. /**
  83825. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83826. * @param x defines the x coordinate of the operand
  83827. * @param y defines the y coordinate of the operand
  83828. * @param z defines the z coordinate of the operand
  83829. * @param result defines the Vector3 object where to store the result
  83830. * @returns the current Vector3
  83831. */
  83832. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83833. /**
  83834. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83835. * @returns a new Vector3
  83836. */
  83837. negate(): Vector3;
  83838. /**
  83839. * Negate this vector in place
  83840. * @returns this
  83841. */
  83842. negateInPlace(): Vector3;
  83843. /**
  83844. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83845. * @param result defines the Vector3 object where to store the result
  83846. * @returns the current Vector3
  83847. */
  83848. negateToRef(result: Vector3): Vector3;
  83849. /**
  83850. * Multiplies the Vector3 coordinates by the float "scale"
  83851. * @param scale defines the multiplier factor
  83852. * @returns the current updated Vector3
  83853. */
  83854. scaleInPlace(scale: number): Vector3;
  83855. /**
  83856. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83857. * @param scale defines the multiplier factor
  83858. * @returns a new Vector3
  83859. */
  83860. scale(scale: number): Vector3;
  83861. /**
  83862. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83863. * @param scale defines the multiplier factor
  83864. * @param result defines the Vector3 object where to store the result
  83865. * @returns the current Vector3
  83866. */
  83867. scaleToRef(scale: number, result: Vector3): Vector3;
  83868. /**
  83869. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83870. * @param scale defines the scale factor
  83871. * @param result defines the Vector3 object where to store the result
  83872. * @returns the unmodified current Vector3
  83873. */
  83874. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83875. /**
  83876. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83877. * @param origin defines the origin of the projection ray
  83878. * @param plane defines the plane to project to
  83879. * @returns the projected vector3
  83880. */
  83881. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83882. /**
  83883. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83884. * @param origin defines the origin of the projection ray
  83885. * @param plane defines the plane to project to
  83886. * @param result defines the Vector3 where to store the result
  83887. */
  83888. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83889. /**
  83890. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83891. * @param otherVector defines the second operand
  83892. * @returns true if both vectors are equals
  83893. */
  83894. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83895. /**
  83896. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83897. * @param otherVector defines the second operand
  83898. * @param epsilon defines the minimal distance to define values as equals
  83899. * @returns true if both vectors are distant less than epsilon
  83900. */
  83901. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83902. /**
  83903. * Returns true if the current Vector3 coordinates equals the given floats
  83904. * @param x defines the x coordinate of the operand
  83905. * @param y defines the y coordinate of the operand
  83906. * @param z defines the z coordinate of the operand
  83907. * @returns true if both vectors are equals
  83908. */
  83909. equalsToFloats(x: number, y: number, z: number): boolean;
  83910. /**
  83911. * Multiplies the current Vector3 coordinates by the given ones
  83912. * @param otherVector defines the second operand
  83913. * @returns the current updated Vector3
  83914. */
  83915. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83916. /**
  83917. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83918. * @param otherVector defines the second operand
  83919. * @returns the new Vector3
  83920. */
  83921. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83922. /**
  83923. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83924. * @param otherVector defines the second operand
  83925. * @param result defines the Vector3 object where to store the result
  83926. * @returns the current Vector3
  83927. */
  83928. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83929. /**
  83930. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83931. * @param x defines the x coordinate of the operand
  83932. * @param y defines the y coordinate of the operand
  83933. * @param z defines the z coordinate of the operand
  83934. * @returns the new Vector3
  83935. */
  83936. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83937. /**
  83938. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83939. * @param otherVector defines the second operand
  83940. * @returns the new Vector3
  83941. */
  83942. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83943. /**
  83944. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83945. * @param otherVector defines the second operand
  83946. * @param result defines the Vector3 object where to store the result
  83947. * @returns the current Vector3
  83948. */
  83949. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83950. /**
  83951. * Divides the current Vector3 coordinates by the given ones.
  83952. * @param otherVector defines the second operand
  83953. * @returns the current updated Vector3
  83954. */
  83955. divideInPlace(otherVector: Vector3): Vector3;
  83956. /**
  83957. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83958. * @param other defines the second operand
  83959. * @returns the current updated Vector3
  83960. */
  83961. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83962. /**
  83963. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83964. * @param other defines the second operand
  83965. * @returns the current updated Vector3
  83966. */
  83967. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83968. /**
  83969. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83970. * @param x defines the x coordinate of the operand
  83971. * @param y defines the y coordinate of the operand
  83972. * @param z defines the z coordinate of the operand
  83973. * @returns the current updated Vector3
  83974. */
  83975. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83976. /**
  83977. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83978. * @param x defines the x coordinate of the operand
  83979. * @param y defines the y coordinate of the operand
  83980. * @param z defines the z coordinate of the operand
  83981. * @returns the current updated Vector3
  83982. */
  83983. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83984. /**
  83985. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83986. * Check if is non uniform within a certain amount of decimal places to account for this
  83987. * @param epsilon the amount the values can differ
  83988. * @returns if the the vector is non uniform to a certain number of decimal places
  83989. */
  83990. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83991. /**
  83992. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83993. */
  83994. get isNonUniform(): boolean;
  83995. /**
  83996. * Gets a new Vector3 from current Vector3 floored values
  83997. * @returns a new Vector3
  83998. */
  83999. floor(): Vector3;
  84000. /**
  84001. * Gets a new Vector3 from current Vector3 floored values
  84002. * @returns a new Vector3
  84003. */
  84004. fract(): Vector3;
  84005. /**
  84006. * Gets the length of the Vector3
  84007. * @returns the length of the Vector3
  84008. */
  84009. length(): number;
  84010. /**
  84011. * Gets the squared length of the Vector3
  84012. * @returns squared length of the Vector3
  84013. */
  84014. lengthSquared(): number;
  84015. /**
  84016. * Normalize the current Vector3.
  84017. * Please note that this is an in place operation.
  84018. * @returns the current updated Vector3
  84019. */
  84020. normalize(): Vector3;
  84021. /**
  84022. * Reorders the x y z properties of the vector in place
  84023. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84024. * @returns the current updated vector
  84025. */
  84026. reorderInPlace(order: string): this;
  84027. /**
  84028. * Rotates the vector around 0,0,0 by a quaternion
  84029. * @param quaternion the rotation quaternion
  84030. * @param result vector to store the result
  84031. * @returns the resulting vector
  84032. */
  84033. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84034. /**
  84035. * Rotates a vector around a given point
  84036. * @param quaternion the rotation quaternion
  84037. * @param point the point to rotate around
  84038. * @param result vector to store the result
  84039. * @returns the resulting vector
  84040. */
  84041. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84042. /**
  84043. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84044. * The cross product is then orthogonal to both current and "other"
  84045. * @param other defines the right operand
  84046. * @returns the cross product
  84047. */
  84048. cross(other: Vector3): Vector3;
  84049. /**
  84050. * Normalize the current Vector3 with the given input length.
  84051. * Please note that this is an in place operation.
  84052. * @param len the length of the vector
  84053. * @returns the current updated Vector3
  84054. */
  84055. normalizeFromLength(len: number): Vector3;
  84056. /**
  84057. * Normalize the current Vector3 to a new vector
  84058. * @returns the new Vector3
  84059. */
  84060. normalizeToNew(): Vector3;
  84061. /**
  84062. * Normalize the current Vector3 to the reference
  84063. * @param reference define the Vector3 to update
  84064. * @returns the updated Vector3
  84065. */
  84066. normalizeToRef(reference: Vector3): Vector3;
  84067. /**
  84068. * Creates a new Vector3 copied from the current Vector3
  84069. * @returns the new Vector3
  84070. */
  84071. clone(): Vector3;
  84072. /**
  84073. * Copies the given vector coordinates to the current Vector3 ones
  84074. * @param source defines the source Vector3
  84075. * @returns the current updated Vector3
  84076. */
  84077. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84078. /**
  84079. * Copies the given floats to the current Vector3 coordinates
  84080. * @param x defines the x coordinate of the operand
  84081. * @param y defines the y coordinate of the operand
  84082. * @param z defines the z coordinate of the operand
  84083. * @returns the current updated Vector3
  84084. */
  84085. copyFromFloats(x: number, y: number, z: number): Vector3;
  84086. /**
  84087. * Copies the given floats to the current Vector3 coordinates
  84088. * @param x defines the x coordinate of the operand
  84089. * @param y defines the y coordinate of the operand
  84090. * @param z defines the z coordinate of the operand
  84091. * @returns the current updated Vector3
  84092. */
  84093. set(x: number, y: number, z: number): Vector3;
  84094. /**
  84095. * Copies the given float to the current Vector3 coordinates
  84096. * @param v defines the x, y and z coordinates of the operand
  84097. * @returns the current updated Vector3
  84098. */
  84099. setAll(v: number): Vector3;
  84100. /**
  84101. * Get the clip factor between two vectors
  84102. * @param vector0 defines the first operand
  84103. * @param vector1 defines the second operand
  84104. * @param axis defines the axis to use
  84105. * @param size defines the size along the axis
  84106. * @returns the clip factor
  84107. */
  84108. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84109. /**
  84110. * Get angle between two vectors
  84111. * @param vector0 angle between vector0 and vector1
  84112. * @param vector1 angle between vector0 and vector1
  84113. * @param normal direction of the normal
  84114. * @return the angle between vector0 and vector1
  84115. */
  84116. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84117. /**
  84118. * Returns a new Vector3 set from the index "offset" of the given array
  84119. * @param array defines the source array
  84120. * @param offset defines the offset in the source array
  84121. * @returns the new Vector3
  84122. */
  84123. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84124. /**
  84125. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84126. * @param array defines the source array
  84127. * @param offset defines the offset in the source array
  84128. * @returns the new Vector3
  84129. * @deprecated Please use FromArray instead.
  84130. */
  84131. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84132. /**
  84133. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84134. * @param array defines the source array
  84135. * @param offset defines the offset in the source array
  84136. * @param result defines the Vector3 where to store the result
  84137. */
  84138. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84139. /**
  84140. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84141. * @param array defines the source array
  84142. * @param offset defines the offset in the source array
  84143. * @param result defines the Vector3 where to store the result
  84144. * @deprecated Please use FromArrayToRef instead.
  84145. */
  84146. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84147. /**
  84148. * Sets the given vector "result" with the given floats.
  84149. * @param x defines the x coordinate of the source
  84150. * @param y defines the y coordinate of the source
  84151. * @param z defines the z coordinate of the source
  84152. * @param result defines the Vector3 where to store the result
  84153. */
  84154. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84155. /**
  84156. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84157. * @returns a new empty Vector3
  84158. */
  84159. static Zero(): Vector3;
  84160. /**
  84161. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84162. * @returns a new unit Vector3
  84163. */
  84164. static One(): Vector3;
  84165. /**
  84166. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84167. * @returns a new up Vector3
  84168. */
  84169. static Up(): Vector3;
  84170. /**
  84171. * Gets a up Vector3 that must not be updated
  84172. */
  84173. static get UpReadOnly(): DeepImmutable<Vector3>;
  84174. /**
  84175. * Gets a zero Vector3 that must not be updated
  84176. */
  84177. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84178. /**
  84179. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84180. * @returns a new down Vector3
  84181. */
  84182. static Down(): Vector3;
  84183. /**
  84184. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84185. * @param rightHandedSystem is the scene right-handed (negative z)
  84186. * @returns a new forward Vector3
  84187. */
  84188. static Forward(rightHandedSystem?: boolean): Vector3;
  84189. /**
  84190. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84191. * @param rightHandedSystem is the scene right-handed (negative-z)
  84192. * @returns a new forward Vector3
  84193. */
  84194. static Backward(rightHandedSystem?: boolean): Vector3;
  84195. /**
  84196. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84197. * @returns a new right Vector3
  84198. */
  84199. static Right(): Vector3;
  84200. /**
  84201. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84202. * @returns a new left Vector3
  84203. */
  84204. static Left(): Vector3;
  84205. /**
  84206. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84207. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84208. * @param vector defines the Vector3 to transform
  84209. * @param transformation defines the transformation matrix
  84210. * @returns the transformed Vector3
  84211. */
  84212. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84213. /**
  84214. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84215. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84216. * @param vector defines the Vector3 to transform
  84217. * @param transformation defines the transformation matrix
  84218. * @param result defines the Vector3 where to store the result
  84219. */
  84220. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84221. /**
  84222. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84223. * This method computes tranformed coordinates only, not transformed direction vectors
  84224. * @param x define the x coordinate of the source vector
  84225. * @param y define the y coordinate of the source vector
  84226. * @param z define the z coordinate of the source vector
  84227. * @param transformation defines the transformation matrix
  84228. * @param result defines the Vector3 where to store the result
  84229. */
  84230. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84231. /**
  84232. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84233. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84234. * @param vector defines the Vector3 to transform
  84235. * @param transformation defines the transformation matrix
  84236. * @returns the new Vector3
  84237. */
  84238. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84239. /**
  84240. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84241. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84242. * @param vector defines the Vector3 to transform
  84243. * @param transformation defines the transformation matrix
  84244. * @param result defines the Vector3 where to store the result
  84245. */
  84246. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84247. /**
  84248. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84249. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84250. * @param x define the x coordinate of the source vector
  84251. * @param y define the y coordinate of the source vector
  84252. * @param z define the z coordinate of the source vector
  84253. * @param transformation defines the transformation matrix
  84254. * @param result defines the Vector3 where to store the result
  84255. */
  84256. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84257. /**
  84258. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84259. * @param value1 defines the first control point
  84260. * @param value2 defines the second control point
  84261. * @param value3 defines the third control point
  84262. * @param value4 defines the fourth control point
  84263. * @param amount defines the amount on the spline to use
  84264. * @returns the new Vector3
  84265. */
  84266. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  84267. /**
  84268. * 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"
  84269. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84270. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84271. * @param value defines the current value
  84272. * @param min defines the lower range value
  84273. * @param max defines the upper range value
  84274. * @returns the new Vector3
  84275. */
  84276. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  84277. /**
  84278. * 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"
  84279. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84280. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84281. * @param value defines the current value
  84282. * @param min defines the lower range value
  84283. * @param max defines the upper range value
  84284. * @param result defines the Vector3 where to store the result
  84285. */
  84286. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  84287. /**
  84288. * Checks if a given vector is inside a specific range
  84289. * @param v defines the vector to test
  84290. * @param min defines the minimum range
  84291. * @param max defines the maximum range
  84292. */
  84293. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  84294. /**
  84295. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84296. * @param value1 defines the first control point
  84297. * @param tangent1 defines the first tangent vector
  84298. * @param value2 defines the second control point
  84299. * @param tangent2 defines the second tangent vector
  84300. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84301. * @returns the new Vector3
  84302. */
  84303. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  84304. /**
  84305. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84306. * @param start defines the start value
  84307. * @param end defines the end value
  84308. * @param amount max defines amount between both (between 0 and 1)
  84309. * @returns the new Vector3
  84310. */
  84311. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  84312. /**
  84313. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84314. * @param start defines the start value
  84315. * @param end defines the end value
  84316. * @param amount max defines amount between both (between 0 and 1)
  84317. * @param result defines the Vector3 where to store the result
  84318. */
  84319. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  84320. /**
  84321. * Returns the dot product (float) between the vectors "left" and "right"
  84322. * @param left defines the left operand
  84323. * @param right defines the right operand
  84324. * @returns the dot product
  84325. */
  84326. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  84327. /**
  84328. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84329. * The cross product is then orthogonal to both "left" and "right"
  84330. * @param left defines the left operand
  84331. * @param right defines the right operand
  84332. * @returns the cross product
  84333. */
  84334. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84335. /**
  84336. * Sets the given vector "result" with the cross product of "left" and "right"
  84337. * The cross product is then orthogonal to both "left" and "right"
  84338. * @param left defines the left operand
  84339. * @param right defines the right operand
  84340. * @param result defines the Vector3 where to store the result
  84341. */
  84342. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  84343. /**
  84344. * Returns a new Vector3 as the normalization of the given vector
  84345. * @param vector defines the Vector3 to normalize
  84346. * @returns the new Vector3
  84347. */
  84348. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  84349. /**
  84350. * Sets the given vector "result" with the normalization of the given first vector
  84351. * @param vector defines the Vector3 to normalize
  84352. * @param result defines the Vector3 where to store the result
  84353. */
  84354. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  84355. /**
  84356. * Project a Vector3 onto screen space
  84357. * @param vector defines the Vector3 to project
  84358. * @param world defines the world matrix to use
  84359. * @param transform defines the transform (view x projection) matrix to use
  84360. * @param viewport defines the screen viewport to use
  84361. * @returns the new Vector3
  84362. */
  84363. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  84364. /**
  84365. * Project a Vector3 onto screen space to reference
  84366. * @param vector defines the Vector3 to project
  84367. * @param world defines the world matrix to use
  84368. * @param transform defines the transform (view x projection) matrix to use
  84369. * @param viewport defines the screen viewport to use
  84370. * @param result the vector in which the screen space will be stored
  84371. * @returns the new Vector3
  84372. */
  84373. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  84374. /** @hidden */
  84375. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  84376. /**
  84377. * Unproject from screen space to object space
  84378. * @param source defines the screen space Vector3 to use
  84379. * @param viewportWidth defines the current width of the viewport
  84380. * @param viewportHeight defines the current height of the viewport
  84381. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84382. * @param transform defines the transform (view x projection) matrix to use
  84383. * @returns the new Vector3
  84384. */
  84385. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  84386. /**
  84387. * Unproject from screen space to object space
  84388. * @param source defines the screen space Vector3 to use
  84389. * @param viewportWidth defines the current width of the viewport
  84390. * @param viewportHeight defines the current height of the viewport
  84391. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84392. * @param view defines the view matrix to use
  84393. * @param projection defines the projection matrix to use
  84394. * @returns the new Vector3
  84395. */
  84396. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  84397. /**
  84398. * Unproject from screen space to object space
  84399. * @param source defines the screen space Vector3 to use
  84400. * @param viewportWidth defines the current width of the viewport
  84401. * @param viewportHeight defines the current height of the viewport
  84402. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84403. * @param view defines the view matrix to use
  84404. * @param projection defines the projection matrix to use
  84405. * @param result defines the Vector3 where to store the result
  84406. */
  84407. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84408. /**
  84409. * Unproject from screen space to object space
  84410. * @param sourceX defines the screen space x coordinate to use
  84411. * @param sourceY defines the screen space y coordinate to use
  84412. * @param sourceZ defines the screen space z coordinate to use
  84413. * @param viewportWidth defines the current width of the viewport
  84414. * @param viewportHeight defines the current height of the viewport
  84415. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84416. * @param view defines the view matrix to use
  84417. * @param projection defines the projection matrix to use
  84418. * @param result defines the Vector3 where to store the result
  84419. */
  84420. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84421. /**
  84422. * Gets the minimal coordinate values between two Vector3
  84423. * @param left defines the first operand
  84424. * @param right defines the second operand
  84425. * @returns the new Vector3
  84426. */
  84427. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84428. /**
  84429. * Gets the maximal coordinate values between two Vector3
  84430. * @param left defines the first operand
  84431. * @param right defines the second operand
  84432. * @returns the new Vector3
  84433. */
  84434. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84435. /**
  84436. * Returns the distance between the vectors "value1" and "value2"
  84437. * @param value1 defines the first operand
  84438. * @param value2 defines the second operand
  84439. * @returns the distance
  84440. */
  84441. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84442. /**
  84443. * Returns the squared distance between the vectors "value1" and "value2"
  84444. * @param value1 defines the first operand
  84445. * @param value2 defines the second operand
  84446. * @returns the squared distance
  84447. */
  84448. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84449. /**
  84450. * Returns a new Vector3 located at the center between "value1" and "value2"
  84451. * @param value1 defines the first operand
  84452. * @param value2 defines the second operand
  84453. * @returns the new Vector3
  84454. */
  84455. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84456. /**
  84457. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84458. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84459. * to something in order to rotate it from its local system to the given target system
  84460. * Note: axis1, axis2 and axis3 are normalized during this operation
  84461. * @param axis1 defines the first axis
  84462. * @param axis2 defines the second axis
  84463. * @param axis3 defines the third axis
  84464. * @returns a new Vector3
  84465. */
  84466. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84467. /**
  84468. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84469. * @param axis1 defines the first axis
  84470. * @param axis2 defines the second axis
  84471. * @param axis3 defines the third axis
  84472. * @param ref defines the Vector3 where to store the result
  84473. */
  84474. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84475. }
  84476. /**
  84477. * Vector4 class created for EulerAngle class conversion to Quaternion
  84478. */
  84479. export class Vector4 {
  84480. /** x value of the vector */
  84481. x: number;
  84482. /** y value of the vector */
  84483. y: number;
  84484. /** z value of the vector */
  84485. z: number;
  84486. /** w value of the vector */
  84487. w: number;
  84488. /**
  84489. * Creates a Vector4 object from the given floats.
  84490. * @param x x value of the vector
  84491. * @param y y value of the vector
  84492. * @param z z value of the vector
  84493. * @param w w value of the vector
  84494. */
  84495. constructor(
  84496. /** x value of the vector */
  84497. x: number,
  84498. /** y value of the vector */
  84499. y: number,
  84500. /** z value of the vector */
  84501. z: number,
  84502. /** w value of the vector */
  84503. w: number);
  84504. /**
  84505. * Returns the string with the Vector4 coordinates.
  84506. * @returns a string containing all the vector values
  84507. */
  84508. toString(): string;
  84509. /**
  84510. * Returns the string "Vector4".
  84511. * @returns "Vector4"
  84512. */
  84513. getClassName(): string;
  84514. /**
  84515. * Returns the Vector4 hash code.
  84516. * @returns a unique hash code
  84517. */
  84518. getHashCode(): number;
  84519. /**
  84520. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84521. * @returns the resulting array
  84522. */
  84523. asArray(): number[];
  84524. /**
  84525. * Populates the given array from the given index with the Vector4 coordinates.
  84526. * @param array array to populate
  84527. * @param index index of the array to start at (default: 0)
  84528. * @returns the Vector4.
  84529. */
  84530. toArray(array: FloatArray, index?: number): Vector4;
  84531. /**
  84532. * Update the current vector from an array
  84533. * @param array defines the destination array
  84534. * @param index defines the offset in the destination array
  84535. * @returns the current Vector3
  84536. */
  84537. fromArray(array: FloatArray, index?: number): Vector4;
  84538. /**
  84539. * Adds the given vector to the current Vector4.
  84540. * @param otherVector the vector to add
  84541. * @returns the updated Vector4.
  84542. */
  84543. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84544. /**
  84545. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84546. * @param otherVector the vector to add
  84547. * @returns the resulting vector
  84548. */
  84549. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84550. /**
  84551. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84552. * @param otherVector the vector to add
  84553. * @param result the vector to store the result
  84554. * @returns the current Vector4.
  84555. */
  84556. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84557. /**
  84558. * Subtract in place the given vector from the current Vector4.
  84559. * @param otherVector the vector to subtract
  84560. * @returns the updated Vector4.
  84561. */
  84562. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84563. /**
  84564. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84565. * @param otherVector the vector to add
  84566. * @returns the new vector with the result
  84567. */
  84568. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84569. /**
  84570. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84571. * @param otherVector the vector to subtract
  84572. * @param result the vector to store the result
  84573. * @returns the current Vector4.
  84574. */
  84575. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84576. /**
  84577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84578. */
  84579. /**
  84580. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84581. * @param x value to subtract
  84582. * @param y value to subtract
  84583. * @param z value to subtract
  84584. * @param w value to subtract
  84585. * @returns new vector containing the result
  84586. */
  84587. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84588. /**
  84589. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84590. * @param x value to subtract
  84591. * @param y value to subtract
  84592. * @param z value to subtract
  84593. * @param w value to subtract
  84594. * @param result the vector to store the result in
  84595. * @returns the current Vector4.
  84596. */
  84597. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84598. /**
  84599. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84600. * @returns a new vector with the negated values
  84601. */
  84602. negate(): Vector4;
  84603. /**
  84604. * Negate this vector in place
  84605. * @returns this
  84606. */
  84607. negateInPlace(): Vector4;
  84608. /**
  84609. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84610. * @param result defines the Vector3 object where to store the result
  84611. * @returns the current Vector4
  84612. */
  84613. negateToRef(result: Vector4): Vector4;
  84614. /**
  84615. * Multiplies the current Vector4 coordinates by scale (float).
  84616. * @param scale the number to scale with
  84617. * @returns the updated Vector4.
  84618. */
  84619. scaleInPlace(scale: number): Vector4;
  84620. /**
  84621. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84622. * @param scale the number to scale with
  84623. * @returns a new vector with the result
  84624. */
  84625. scale(scale: number): Vector4;
  84626. /**
  84627. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84628. * @param scale the number to scale with
  84629. * @param result a vector to store the result in
  84630. * @returns the current Vector4.
  84631. */
  84632. scaleToRef(scale: number, result: Vector4): Vector4;
  84633. /**
  84634. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84635. * @param scale defines the scale factor
  84636. * @param result defines the Vector4 object where to store the result
  84637. * @returns the unmodified current Vector4
  84638. */
  84639. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84640. /**
  84641. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84642. * @param otherVector the vector to compare against
  84643. * @returns true if they are equal
  84644. */
  84645. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84646. /**
  84647. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84648. * @param otherVector vector to compare against
  84649. * @param epsilon (Default: very small number)
  84650. * @returns true if they are equal
  84651. */
  84652. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84653. /**
  84654. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84655. * @param x x value to compare against
  84656. * @param y y value to compare against
  84657. * @param z z value to compare against
  84658. * @param w w value to compare against
  84659. * @returns true if equal
  84660. */
  84661. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84662. /**
  84663. * Multiplies in place the current Vector4 by the given one.
  84664. * @param otherVector vector to multiple with
  84665. * @returns the updated Vector4.
  84666. */
  84667. multiplyInPlace(otherVector: Vector4): Vector4;
  84668. /**
  84669. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84670. * @param otherVector vector to multiple with
  84671. * @returns resulting new vector
  84672. */
  84673. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84674. /**
  84675. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84676. * @param otherVector vector to multiple with
  84677. * @param result vector to store the result
  84678. * @returns the current Vector4.
  84679. */
  84680. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84681. /**
  84682. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84683. * @param x x value multiply with
  84684. * @param y y value multiply with
  84685. * @param z z value multiply with
  84686. * @param w w value multiply with
  84687. * @returns resulting new vector
  84688. */
  84689. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84690. /**
  84691. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84692. * @param otherVector vector to devide with
  84693. * @returns resulting new vector
  84694. */
  84695. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84696. /**
  84697. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84698. * @param otherVector vector to devide with
  84699. * @param result vector to store the result
  84700. * @returns the current Vector4.
  84701. */
  84702. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84703. /**
  84704. * Divides the current Vector3 coordinates by the given ones.
  84705. * @param otherVector vector to devide with
  84706. * @returns the updated Vector3.
  84707. */
  84708. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84709. /**
  84710. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84711. * @param other defines the second operand
  84712. * @returns the current updated Vector4
  84713. */
  84714. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84715. /**
  84716. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84717. * @param other defines the second operand
  84718. * @returns the current updated Vector4
  84719. */
  84720. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84721. /**
  84722. * Gets a new Vector4 from current Vector4 floored values
  84723. * @returns a new Vector4
  84724. */
  84725. floor(): Vector4;
  84726. /**
  84727. * Gets a new Vector4 from current Vector3 floored values
  84728. * @returns a new Vector4
  84729. */
  84730. fract(): Vector4;
  84731. /**
  84732. * Returns the Vector4 length (float).
  84733. * @returns the length
  84734. */
  84735. length(): number;
  84736. /**
  84737. * Returns the Vector4 squared length (float).
  84738. * @returns the length squared
  84739. */
  84740. lengthSquared(): number;
  84741. /**
  84742. * Normalizes in place the Vector4.
  84743. * @returns the updated Vector4.
  84744. */
  84745. normalize(): Vector4;
  84746. /**
  84747. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84748. * @returns this converted to a new vector3
  84749. */
  84750. toVector3(): Vector3;
  84751. /**
  84752. * Returns a new Vector4 copied from the current one.
  84753. * @returns the new cloned vector
  84754. */
  84755. clone(): Vector4;
  84756. /**
  84757. * Updates the current Vector4 with the given one coordinates.
  84758. * @param source the source vector to copy from
  84759. * @returns the updated Vector4.
  84760. */
  84761. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84762. /**
  84763. * Updates the current Vector4 coordinates with the given floats.
  84764. * @param x float to copy from
  84765. * @param y float to copy from
  84766. * @param z float to copy from
  84767. * @param w float to copy from
  84768. * @returns the updated Vector4.
  84769. */
  84770. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84771. /**
  84772. * Updates the current Vector4 coordinates with the given floats.
  84773. * @param x float to set from
  84774. * @param y float to set from
  84775. * @param z float to set from
  84776. * @param w float to set from
  84777. * @returns the updated Vector4.
  84778. */
  84779. set(x: number, y: number, z: number, w: number): Vector4;
  84780. /**
  84781. * Copies the given float to the current Vector3 coordinates
  84782. * @param v defines the x, y, z and w coordinates of the operand
  84783. * @returns the current updated Vector3
  84784. */
  84785. setAll(v: number): Vector4;
  84786. /**
  84787. * Returns a new Vector4 set from the starting index of the given array.
  84788. * @param array the array to pull values from
  84789. * @param offset the offset into the array to start at
  84790. * @returns the new vector
  84791. */
  84792. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84793. /**
  84794. * Updates the given vector "result" from the starting index of the given array.
  84795. * @param array the array to pull values from
  84796. * @param offset the offset into the array to start at
  84797. * @param result the vector to store the result in
  84798. */
  84799. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84800. /**
  84801. * Updates the given vector "result" from the starting index of the given Float32Array.
  84802. * @param array the array to pull values from
  84803. * @param offset the offset into the array to start at
  84804. * @param result the vector to store the result in
  84805. */
  84806. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84807. /**
  84808. * Updates the given vector "result" coordinates from the given floats.
  84809. * @param x float to set from
  84810. * @param y float to set from
  84811. * @param z float to set from
  84812. * @param w float to set from
  84813. * @param result the vector to the floats in
  84814. */
  84815. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84816. /**
  84817. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84818. * @returns the new vector
  84819. */
  84820. static Zero(): Vector4;
  84821. /**
  84822. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84823. * @returns the new vector
  84824. */
  84825. static One(): Vector4;
  84826. /**
  84827. * Returns a new normalized Vector4 from the given one.
  84828. * @param vector the vector to normalize
  84829. * @returns the vector
  84830. */
  84831. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84832. /**
  84833. * Updates the given vector "result" from the normalization of the given one.
  84834. * @param vector the vector to normalize
  84835. * @param result the vector to store the result in
  84836. */
  84837. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84838. /**
  84839. * Returns a vector with the minimum values from the left and right vectors
  84840. * @param left left vector to minimize
  84841. * @param right right vector to minimize
  84842. * @returns a new vector with the minimum of the left and right vector values
  84843. */
  84844. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84845. /**
  84846. * Returns a vector with the maximum values from the left and right vectors
  84847. * @param left left vector to maximize
  84848. * @param right right vector to maximize
  84849. * @returns a new vector with the maximum of the left and right vector values
  84850. */
  84851. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84852. /**
  84853. * Returns the distance (float) between the vectors "value1" and "value2".
  84854. * @param value1 value to calulate the distance between
  84855. * @param value2 value to calulate the distance between
  84856. * @return the distance between the two vectors
  84857. */
  84858. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84859. /**
  84860. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84861. * @param value1 value to calulate the distance between
  84862. * @param value2 value to calulate the distance between
  84863. * @return the distance between the two vectors squared
  84864. */
  84865. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84866. /**
  84867. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84868. * @param value1 value to calulate the center between
  84869. * @param value2 value to calulate the center between
  84870. * @return the center between the two vectors
  84871. */
  84872. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84873. /**
  84874. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84875. * This methods computes transformed normalized direction vectors only.
  84876. * @param vector the vector to transform
  84877. * @param transformation the transformation matrix to apply
  84878. * @returns the new vector
  84879. */
  84880. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84881. /**
  84882. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84883. * This methods computes transformed normalized direction vectors only.
  84884. * @param vector the vector to transform
  84885. * @param transformation the transformation matrix to apply
  84886. * @param result the vector to store the result in
  84887. */
  84888. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84889. /**
  84890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84891. * This methods computes transformed normalized direction vectors only.
  84892. * @param x value to transform
  84893. * @param y value to transform
  84894. * @param z value to transform
  84895. * @param w value to transform
  84896. * @param transformation the transformation matrix to apply
  84897. * @param result the vector to store the results in
  84898. */
  84899. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84900. /**
  84901. * Creates a new Vector4 from a Vector3
  84902. * @param source defines the source data
  84903. * @param w defines the 4th component (default is 0)
  84904. * @returns a new Vector4
  84905. */
  84906. static FromVector3(source: Vector3, w?: number): Vector4;
  84907. }
  84908. /**
  84909. * Class used to store quaternion data
  84910. * @see https://en.wikipedia.org/wiki/Quaternion
  84911. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84912. */
  84913. export class Quaternion {
  84914. /** @hidden */
  84915. _x: number;
  84916. /** @hidden */
  84917. _y: number;
  84918. /** @hidden */
  84919. _z: number;
  84920. /** @hidden */
  84921. _w: number;
  84922. /** @hidden */
  84923. _isDirty: boolean;
  84924. /** Gets or sets the x coordinate */
  84925. get x(): number;
  84926. set x(value: number);
  84927. /** Gets or sets the y coordinate */
  84928. get y(): number;
  84929. set y(value: number);
  84930. /** Gets or sets the z coordinate */
  84931. get z(): number;
  84932. set z(value: number);
  84933. /** Gets or sets the w coordinate */
  84934. get w(): number;
  84935. set w(value: number);
  84936. /**
  84937. * Creates a new Quaternion from the given floats
  84938. * @param x defines the first component (0 by default)
  84939. * @param y defines the second component (0 by default)
  84940. * @param z defines the third component (0 by default)
  84941. * @param w defines the fourth component (1.0 by default)
  84942. */
  84943. constructor(x?: number, y?: number, z?: number, w?: number);
  84944. /**
  84945. * Gets a string representation for the current quaternion
  84946. * @returns a string with the Quaternion coordinates
  84947. */
  84948. toString(): string;
  84949. /**
  84950. * Gets the class name of the quaternion
  84951. * @returns the string "Quaternion"
  84952. */
  84953. getClassName(): string;
  84954. /**
  84955. * Gets a hash code for this quaternion
  84956. * @returns the quaternion hash code
  84957. */
  84958. getHashCode(): number;
  84959. /**
  84960. * Copy the quaternion to an array
  84961. * @returns a new array populated with 4 elements from the quaternion coordinates
  84962. */
  84963. asArray(): number[];
  84964. /**
  84965. * Check if two quaternions are equals
  84966. * @param otherQuaternion defines the second operand
  84967. * @return true if the current quaternion and the given one coordinates are strictly equals
  84968. */
  84969. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84970. /**
  84971. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84972. * @param otherQuaternion defines the other quaternion
  84973. * @param epsilon defines the minimal distance to consider equality
  84974. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84975. */
  84976. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84977. /**
  84978. * Clone the current quaternion
  84979. * @returns a new quaternion copied from the current one
  84980. */
  84981. clone(): Quaternion;
  84982. /**
  84983. * Copy a quaternion to the current one
  84984. * @param other defines the other quaternion
  84985. * @returns the updated current quaternion
  84986. */
  84987. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84988. /**
  84989. * Updates the current quaternion with the given float coordinates
  84990. * @param x defines the x coordinate
  84991. * @param y defines the y coordinate
  84992. * @param z defines the z coordinate
  84993. * @param w defines the w coordinate
  84994. * @returns the updated current quaternion
  84995. */
  84996. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84997. /**
  84998. * Updates the current quaternion from the given float coordinates
  84999. * @param x defines the x coordinate
  85000. * @param y defines the y coordinate
  85001. * @param z defines the z coordinate
  85002. * @param w defines the w coordinate
  85003. * @returns the updated current quaternion
  85004. */
  85005. set(x: number, y: number, z: number, w: number): Quaternion;
  85006. /**
  85007. * Adds two quaternions
  85008. * @param other defines the second operand
  85009. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85010. */
  85011. add(other: DeepImmutable<Quaternion>): Quaternion;
  85012. /**
  85013. * Add a quaternion to the current one
  85014. * @param other defines the quaternion to add
  85015. * @returns the current quaternion
  85016. */
  85017. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85018. /**
  85019. * Subtract two quaternions
  85020. * @param other defines the second operand
  85021. * @returns a new quaternion as the subtraction result of the given one from the current one
  85022. */
  85023. subtract(other: Quaternion): Quaternion;
  85024. /**
  85025. * Multiplies the current quaternion by a scale factor
  85026. * @param value defines the scale factor
  85027. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85028. */
  85029. scale(value: number): Quaternion;
  85030. /**
  85031. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85032. * @param scale defines the scale factor
  85033. * @param result defines the Quaternion object where to store the result
  85034. * @returns the unmodified current quaternion
  85035. */
  85036. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85037. /**
  85038. * Multiplies in place the current quaternion by a scale factor
  85039. * @param value defines the scale factor
  85040. * @returns the current modified quaternion
  85041. */
  85042. scaleInPlace(value: number): Quaternion;
  85043. /**
  85044. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85045. * @param scale defines the scale factor
  85046. * @param result defines the Quaternion object where to store the result
  85047. * @returns the unmodified current quaternion
  85048. */
  85049. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85050. /**
  85051. * Multiplies two quaternions
  85052. * @param q1 defines the second operand
  85053. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85054. */
  85055. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85056. /**
  85057. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85058. * @param q1 defines the second operand
  85059. * @param result defines the target quaternion
  85060. * @returns the current quaternion
  85061. */
  85062. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85063. /**
  85064. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85065. * @param q1 defines the second operand
  85066. * @returns the currentupdated quaternion
  85067. */
  85068. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85069. /**
  85070. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85071. * @param ref defines the target quaternion
  85072. * @returns the current quaternion
  85073. */
  85074. conjugateToRef(ref: Quaternion): Quaternion;
  85075. /**
  85076. * Conjugates in place (1-q) the current quaternion
  85077. * @returns the current updated quaternion
  85078. */
  85079. conjugateInPlace(): Quaternion;
  85080. /**
  85081. * Conjugates in place (1-q) the current quaternion
  85082. * @returns a new quaternion
  85083. */
  85084. conjugate(): Quaternion;
  85085. /**
  85086. * Gets length of current quaternion
  85087. * @returns the quaternion length (float)
  85088. */
  85089. length(): number;
  85090. /**
  85091. * Normalize in place the current quaternion
  85092. * @returns the current updated quaternion
  85093. */
  85094. normalize(): Quaternion;
  85095. /**
  85096. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85097. * @param order is a reserved parameter and is ignored for now
  85098. * @returns a new Vector3 containing the Euler angles
  85099. */
  85100. toEulerAngles(order?: string): Vector3;
  85101. /**
  85102. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85103. * @param result defines the vector which will be filled with the Euler angles
  85104. * @returns the current unchanged quaternion
  85105. */
  85106. toEulerAnglesToRef(result: Vector3): Quaternion;
  85107. /**
  85108. * Updates the given rotation matrix with the current quaternion values
  85109. * @param result defines the target matrix
  85110. * @returns the current unchanged quaternion
  85111. */
  85112. toRotationMatrix(result: Matrix): Quaternion;
  85113. /**
  85114. * Updates the current quaternion from the given rotation matrix values
  85115. * @param matrix defines the source matrix
  85116. * @returns the current updated quaternion
  85117. */
  85118. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85119. /**
  85120. * Creates a new quaternion from a rotation matrix
  85121. * @param matrix defines the source matrix
  85122. * @returns a new quaternion created from the given rotation matrix values
  85123. */
  85124. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85125. /**
  85126. * Updates the given quaternion with the given rotation matrix values
  85127. * @param matrix defines the source matrix
  85128. * @param result defines the target quaternion
  85129. */
  85130. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85131. /**
  85132. * Returns the dot product (float) between the quaternions "left" and "right"
  85133. * @param left defines the left operand
  85134. * @param right defines the right operand
  85135. * @returns the dot product
  85136. */
  85137. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85138. /**
  85139. * Checks if the two quaternions are close to each other
  85140. * @param quat0 defines the first quaternion to check
  85141. * @param quat1 defines the second quaternion to check
  85142. * @returns true if the two quaternions are close to each other
  85143. */
  85144. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85145. /**
  85146. * Creates an empty quaternion
  85147. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85148. */
  85149. static Zero(): Quaternion;
  85150. /**
  85151. * Inverse a given quaternion
  85152. * @param q defines the source quaternion
  85153. * @returns a new quaternion as the inverted current quaternion
  85154. */
  85155. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85156. /**
  85157. * Inverse a given quaternion
  85158. * @param q defines the source quaternion
  85159. * @param result the quaternion the result will be stored in
  85160. * @returns the result quaternion
  85161. */
  85162. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85163. /**
  85164. * Creates an identity quaternion
  85165. * @returns the identity quaternion
  85166. */
  85167. static Identity(): Quaternion;
  85168. /**
  85169. * Gets a boolean indicating if the given quaternion is identity
  85170. * @param quaternion defines the quaternion to check
  85171. * @returns true if the quaternion is identity
  85172. */
  85173. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85174. /**
  85175. * Creates a quaternion from a rotation around an axis
  85176. * @param axis defines the axis to use
  85177. * @param angle defines the angle to use
  85178. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85179. */
  85180. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85181. /**
  85182. * Creates a rotation around an axis and stores it into the given quaternion
  85183. * @param axis defines the axis to use
  85184. * @param angle defines the angle to use
  85185. * @param result defines the target quaternion
  85186. * @returns the target quaternion
  85187. */
  85188. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85189. /**
  85190. * Creates a new quaternion from data stored into an array
  85191. * @param array defines the data source
  85192. * @param offset defines the offset in the source array where the data starts
  85193. * @returns a new quaternion
  85194. */
  85195. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85196. /**
  85197. * Updates the given quaternion "result" from the starting index of the given array.
  85198. * @param array the array to pull values from
  85199. * @param offset the offset into the array to start at
  85200. * @param result the quaternion to store the result in
  85201. */
  85202. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85203. /**
  85204. * Create a quaternion from Euler rotation angles
  85205. * @param x Pitch
  85206. * @param y Yaw
  85207. * @param z Roll
  85208. * @returns the new Quaternion
  85209. */
  85210. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85211. /**
  85212. * Updates a quaternion from Euler rotation angles
  85213. * @param x Pitch
  85214. * @param y Yaw
  85215. * @param z Roll
  85216. * @param result the quaternion to store the result
  85217. * @returns the updated quaternion
  85218. */
  85219. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85220. /**
  85221. * Create a quaternion from Euler rotation vector
  85222. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85223. * @returns the new Quaternion
  85224. */
  85225. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85226. /**
  85227. * Updates a quaternion from Euler rotation vector
  85228. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85229. * @param result the quaternion to store the result
  85230. * @returns the updated quaternion
  85231. */
  85232. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85233. /**
  85234. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85235. * @param yaw defines the rotation around Y axis
  85236. * @param pitch defines the rotation around X axis
  85237. * @param roll defines the rotation around Z axis
  85238. * @returns the new quaternion
  85239. */
  85240. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  85241. /**
  85242. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85243. * @param yaw defines the rotation around Y axis
  85244. * @param pitch defines the rotation around X axis
  85245. * @param roll defines the rotation around Z axis
  85246. * @param result defines the target quaternion
  85247. */
  85248. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  85249. /**
  85250. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85251. * @param alpha defines the rotation around first axis
  85252. * @param beta defines the rotation around second axis
  85253. * @param gamma defines the rotation around third axis
  85254. * @returns the new quaternion
  85255. */
  85256. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  85257. /**
  85258. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85259. * @param alpha defines the rotation around first axis
  85260. * @param beta defines the rotation around second axis
  85261. * @param gamma defines the rotation around third axis
  85262. * @param result defines the target quaternion
  85263. */
  85264. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  85265. /**
  85266. * 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)
  85267. * @param axis1 defines the first axis
  85268. * @param axis2 defines the second axis
  85269. * @param axis3 defines the third axis
  85270. * @returns the new quaternion
  85271. */
  85272. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  85273. /**
  85274. * 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
  85275. * @param axis1 defines the first axis
  85276. * @param axis2 defines the second axis
  85277. * @param axis3 defines the third axis
  85278. * @param ref defines the target quaternion
  85279. */
  85280. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  85281. /**
  85282. * Interpolates between two quaternions
  85283. * @param left defines first quaternion
  85284. * @param right defines second quaternion
  85285. * @param amount defines the gradient to use
  85286. * @returns the new interpolated quaternion
  85287. */
  85288. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85289. /**
  85290. * Interpolates between two quaternions and stores it into a target quaternion
  85291. * @param left defines first quaternion
  85292. * @param right defines second quaternion
  85293. * @param amount defines the gradient to use
  85294. * @param result defines the target quaternion
  85295. */
  85296. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  85297. /**
  85298. * Interpolate between two quaternions using Hermite interpolation
  85299. * @param value1 defines first quaternion
  85300. * @param tangent1 defines the incoming tangent
  85301. * @param value2 defines second quaternion
  85302. * @param tangent2 defines the outgoing tangent
  85303. * @param amount defines the target quaternion
  85304. * @returns the new interpolated quaternion
  85305. */
  85306. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85307. }
  85308. /**
  85309. * Class used to store matrix data (4x4)
  85310. */
  85311. export class Matrix {
  85312. /**
  85313. * Gets the precision of matrix computations
  85314. */
  85315. static get Use64Bits(): boolean;
  85316. private static _updateFlagSeed;
  85317. private static _identityReadOnly;
  85318. private _isIdentity;
  85319. private _isIdentityDirty;
  85320. private _isIdentity3x2;
  85321. private _isIdentity3x2Dirty;
  85322. /**
  85323. * Gets the update flag of the matrix which is an unique number for the matrix.
  85324. * It will be incremented every time the matrix data change.
  85325. * You can use it to speed the comparison between two versions of the same matrix.
  85326. */
  85327. updateFlag: number;
  85328. private readonly _m;
  85329. /**
  85330. * Gets the internal data of the matrix
  85331. */
  85332. get m(): DeepImmutable<Float32Array | Array<number>>;
  85333. /** @hidden */
  85334. _markAsUpdated(): void;
  85335. /** @hidden */
  85336. private _updateIdentityStatus;
  85337. /**
  85338. * Creates an empty matrix (filled with zeros)
  85339. */
  85340. constructor();
  85341. /**
  85342. * Check if the current matrix is identity
  85343. * @returns true is the matrix is the identity matrix
  85344. */
  85345. isIdentity(): boolean;
  85346. /**
  85347. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  85348. * @returns true is the matrix is the identity matrix
  85349. */
  85350. isIdentityAs3x2(): boolean;
  85351. /**
  85352. * Gets the determinant of the matrix
  85353. * @returns the matrix determinant
  85354. */
  85355. determinant(): number;
  85356. /**
  85357. * Returns the matrix as a Float32Array or Array<number>
  85358. * @returns the matrix underlying array
  85359. */
  85360. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85361. /**
  85362. * Returns the matrix as a Float32Array or Array<number>
  85363. * @returns the matrix underlying array.
  85364. */
  85365. asArray(): DeepImmutable<Float32Array | Array<number>>;
  85366. /**
  85367. * Inverts the current matrix in place
  85368. * @returns the current inverted matrix
  85369. */
  85370. invert(): Matrix;
  85371. /**
  85372. * Sets all the matrix elements to zero
  85373. * @returns the current matrix
  85374. */
  85375. reset(): Matrix;
  85376. /**
  85377. * Adds the current matrix with a second one
  85378. * @param other defines the matrix to add
  85379. * @returns a new matrix as the addition of the current matrix and the given one
  85380. */
  85381. add(other: DeepImmutable<Matrix>): Matrix;
  85382. /**
  85383. * Sets the given matrix "result" to the addition of the current matrix and the given one
  85384. * @param other defines the matrix to add
  85385. * @param result defines the target matrix
  85386. * @returns the current matrix
  85387. */
  85388. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85389. /**
  85390. * Adds in place the given matrix to the current matrix
  85391. * @param other defines the second operand
  85392. * @returns the current updated matrix
  85393. */
  85394. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  85395. /**
  85396. * Sets the given matrix to the current inverted Matrix
  85397. * @param other defines the target matrix
  85398. * @returns the unmodified current matrix
  85399. */
  85400. invertToRef(other: Matrix): Matrix;
  85401. /**
  85402. * add a value at the specified position in the current Matrix
  85403. * @param index the index of the value within the matrix. between 0 and 15.
  85404. * @param value the value to be added
  85405. * @returns the current updated matrix
  85406. */
  85407. addAtIndex(index: number, value: number): Matrix;
  85408. /**
  85409. * mutiply the specified position in the current Matrix by a value
  85410. * @param index the index of the value within the matrix. between 0 and 15.
  85411. * @param value the value to be added
  85412. * @returns the current updated matrix
  85413. */
  85414. multiplyAtIndex(index: number, value: number): Matrix;
  85415. /**
  85416. * Inserts the translation vector (using 3 floats) in the current matrix
  85417. * @param x defines the 1st component of the translation
  85418. * @param y defines the 2nd component of the translation
  85419. * @param z defines the 3rd component of the translation
  85420. * @returns the current updated matrix
  85421. */
  85422. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85423. /**
  85424. * Adds the translation vector (using 3 floats) in the current matrix
  85425. * @param x defines the 1st component of the translation
  85426. * @param y defines the 2nd component of the translation
  85427. * @param z defines the 3rd component of the translation
  85428. * @returns the current updated matrix
  85429. */
  85430. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85431. /**
  85432. * Inserts the translation vector in the current matrix
  85433. * @param vector3 defines the translation to insert
  85434. * @returns the current updated matrix
  85435. */
  85436. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  85437. /**
  85438. * Gets the translation value of the current matrix
  85439. * @returns a new Vector3 as the extracted translation from the matrix
  85440. */
  85441. getTranslation(): Vector3;
  85442. /**
  85443. * Fill a Vector3 with the extracted translation from the matrix
  85444. * @param result defines the Vector3 where to store the translation
  85445. * @returns the current matrix
  85446. */
  85447. getTranslationToRef(result: Vector3): Matrix;
  85448. /**
  85449. * Remove rotation and scaling part from the matrix
  85450. * @returns the updated matrix
  85451. */
  85452. removeRotationAndScaling(): Matrix;
  85453. /**
  85454. * Multiply two matrices
  85455. * @param other defines the second operand
  85456. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85457. */
  85458. multiply(other: DeepImmutable<Matrix>): Matrix;
  85459. /**
  85460. * Copy the current matrix from the given one
  85461. * @param other defines the source matrix
  85462. * @returns the current updated matrix
  85463. */
  85464. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85465. /**
  85466. * Populates the given array from the starting index with the current matrix values
  85467. * @param array defines the target array
  85468. * @param offset defines the offset in the target array where to start storing values
  85469. * @returns the current matrix
  85470. */
  85471. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85472. /**
  85473. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85474. * @param other defines the second operand
  85475. * @param result defines the matrix where to store the multiplication
  85476. * @returns the current matrix
  85477. */
  85478. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85479. /**
  85480. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85481. * @param other defines the second operand
  85482. * @param result defines the array where to store the multiplication
  85483. * @param offset defines the offset in the target array where to start storing values
  85484. * @returns the current matrix
  85485. */
  85486. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85487. /**
  85488. * Check equality between this matrix and a second one
  85489. * @param value defines the second matrix to compare
  85490. * @returns true is the current matrix and the given one values are strictly equal
  85491. */
  85492. equals(value: DeepImmutable<Matrix>): boolean;
  85493. /**
  85494. * Clone the current matrix
  85495. * @returns a new matrix from the current matrix
  85496. */
  85497. clone(): Matrix;
  85498. /**
  85499. * Returns the name of the current matrix class
  85500. * @returns the string "Matrix"
  85501. */
  85502. getClassName(): string;
  85503. /**
  85504. * Gets the hash code of the current matrix
  85505. * @returns the hash code
  85506. */
  85507. getHashCode(): number;
  85508. /**
  85509. * Decomposes the current Matrix into a translation, rotation and scaling components
  85510. * @param scale defines the scale vector3 given as a reference to update
  85511. * @param rotation defines the rotation quaternion given as a reference to update
  85512. * @param translation defines the translation vector3 given as a reference to update
  85513. * @returns true if operation was successful
  85514. */
  85515. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85516. /**
  85517. * Gets specific row of the matrix
  85518. * @param index defines the number of the row to get
  85519. * @returns the index-th row of the current matrix as a new Vector4
  85520. */
  85521. getRow(index: number): Nullable<Vector4>;
  85522. /**
  85523. * Sets the index-th row of the current matrix to the vector4 values
  85524. * @param index defines the number of the row to set
  85525. * @param row defines the target vector4
  85526. * @returns the updated current matrix
  85527. */
  85528. setRow(index: number, row: Vector4): Matrix;
  85529. /**
  85530. * Compute the transpose of the matrix
  85531. * @returns the new transposed matrix
  85532. */
  85533. transpose(): Matrix;
  85534. /**
  85535. * Compute the transpose of the matrix and store it in a given matrix
  85536. * @param result defines the target matrix
  85537. * @returns the current matrix
  85538. */
  85539. transposeToRef(result: Matrix): Matrix;
  85540. /**
  85541. * Sets the index-th row of the current matrix with the given 4 x float values
  85542. * @param index defines the row index
  85543. * @param x defines the x component to set
  85544. * @param y defines the y component to set
  85545. * @param z defines the z component to set
  85546. * @param w defines the w component to set
  85547. * @returns the updated current matrix
  85548. */
  85549. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85550. /**
  85551. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85552. * @param scale defines the scale factor
  85553. * @returns a new matrix
  85554. */
  85555. scale(scale: number): Matrix;
  85556. /**
  85557. * Scale the current matrix values by a factor to a given result matrix
  85558. * @param scale defines the scale factor
  85559. * @param result defines the matrix to store the result
  85560. * @returns the current matrix
  85561. */
  85562. scaleToRef(scale: number, result: Matrix): Matrix;
  85563. /**
  85564. * Scale the current matrix values by a factor and add the result to a given matrix
  85565. * @param scale defines the scale factor
  85566. * @param result defines the Matrix to store the result
  85567. * @returns the current matrix
  85568. */
  85569. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85570. /**
  85571. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85572. * @param ref matrix to store the result
  85573. */
  85574. toNormalMatrix(ref: Matrix): void;
  85575. /**
  85576. * Gets only rotation part of the current matrix
  85577. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85578. */
  85579. getRotationMatrix(): Matrix;
  85580. /**
  85581. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85582. * @param result defines the target matrix to store data to
  85583. * @returns the current matrix
  85584. */
  85585. getRotationMatrixToRef(result: Matrix): Matrix;
  85586. /**
  85587. * Toggles model matrix from being right handed to left handed in place and vice versa
  85588. */
  85589. toggleModelMatrixHandInPlace(): void;
  85590. /**
  85591. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85592. */
  85593. toggleProjectionMatrixHandInPlace(): void;
  85594. /**
  85595. * Creates a matrix from an array
  85596. * @param array defines the source array
  85597. * @param offset defines an offset in the source array
  85598. * @returns a new Matrix set from the starting index of the given array
  85599. */
  85600. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85601. /**
  85602. * Copy the content of an array into a given matrix
  85603. * @param array defines the source array
  85604. * @param offset defines an offset in the source array
  85605. * @param result defines the target matrix
  85606. */
  85607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85608. /**
  85609. * Stores an array into a matrix after having multiplied each component by a given factor
  85610. * @param array defines the source array
  85611. * @param offset defines the offset in the source array
  85612. * @param scale defines the scaling factor
  85613. * @param result defines the target matrix
  85614. */
  85615. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85616. /**
  85617. * Gets an identity matrix that must not be updated
  85618. */
  85619. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85620. /**
  85621. * Stores a list of values (16) inside a given matrix
  85622. * @param initialM11 defines 1st value of 1st row
  85623. * @param initialM12 defines 2nd value of 1st row
  85624. * @param initialM13 defines 3rd value of 1st row
  85625. * @param initialM14 defines 4th value of 1st row
  85626. * @param initialM21 defines 1st value of 2nd row
  85627. * @param initialM22 defines 2nd value of 2nd row
  85628. * @param initialM23 defines 3rd value of 2nd row
  85629. * @param initialM24 defines 4th value of 2nd row
  85630. * @param initialM31 defines 1st value of 3rd row
  85631. * @param initialM32 defines 2nd value of 3rd row
  85632. * @param initialM33 defines 3rd value of 3rd row
  85633. * @param initialM34 defines 4th value of 3rd row
  85634. * @param initialM41 defines 1st value of 4th row
  85635. * @param initialM42 defines 2nd value of 4th row
  85636. * @param initialM43 defines 3rd value of 4th row
  85637. * @param initialM44 defines 4th value of 4th row
  85638. * @param result defines the target matrix
  85639. */
  85640. 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;
  85641. /**
  85642. * Creates new matrix from a list of values (16)
  85643. * @param initialM11 defines 1st value of 1st row
  85644. * @param initialM12 defines 2nd value of 1st row
  85645. * @param initialM13 defines 3rd value of 1st row
  85646. * @param initialM14 defines 4th value of 1st row
  85647. * @param initialM21 defines 1st value of 2nd row
  85648. * @param initialM22 defines 2nd value of 2nd row
  85649. * @param initialM23 defines 3rd value of 2nd row
  85650. * @param initialM24 defines 4th value of 2nd row
  85651. * @param initialM31 defines 1st value of 3rd row
  85652. * @param initialM32 defines 2nd value of 3rd row
  85653. * @param initialM33 defines 3rd value of 3rd row
  85654. * @param initialM34 defines 4th value of 3rd row
  85655. * @param initialM41 defines 1st value of 4th row
  85656. * @param initialM42 defines 2nd value of 4th row
  85657. * @param initialM43 defines 3rd value of 4th row
  85658. * @param initialM44 defines 4th value of 4th row
  85659. * @returns the new matrix
  85660. */
  85661. 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;
  85662. /**
  85663. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85664. * @param scale defines the scale vector3
  85665. * @param rotation defines the rotation quaternion
  85666. * @param translation defines the translation vector3
  85667. * @returns a new matrix
  85668. */
  85669. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85670. /**
  85671. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85672. * @param scale defines the scale vector3
  85673. * @param rotation defines the rotation quaternion
  85674. * @param translation defines the translation vector3
  85675. * @param result defines the target matrix
  85676. */
  85677. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85678. /**
  85679. * Creates a new identity matrix
  85680. * @returns a new identity matrix
  85681. */
  85682. static Identity(): Matrix;
  85683. /**
  85684. * Creates a new identity matrix and stores the result in a given matrix
  85685. * @param result defines the target matrix
  85686. */
  85687. static IdentityToRef(result: Matrix): void;
  85688. /**
  85689. * Creates a new zero matrix
  85690. * @returns a new zero matrix
  85691. */
  85692. static Zero(): Matrix;
  85693. /**
  85694. * Creates a new rotation matrix for "angle" radians around the X axis
  85695. * @param angle defines the angle (in radians) to use
  85696. * @return the new matrix
  85697. */
  85698. static RotationX(angle: number): Matrix;
  85699. /**
  85700. * Creates a new matrix as the invert of a given matrix
  85701. * @param source defines the source matrix
  85702. * @returns the new matrix
  85703. */
  85704. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85705. /**
  85706. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85707. * @param angle defines the angle (in radians) to use
  85708. * @param result defines the target matrix
  85709. */
  85710. static RotationXToRef(angle: number, result: Matrix): void;
  85711. /**
  85712. * Creates a new rotation matrix for "angle" radians around the Y axis
  85713. * @param angle defines the angle (in radians) to use
  85714. * @return the new matrix
  85715. */
  85716. static RotationY(angle: number): Matrix;
  85717. /**
  85718. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85719. * @param angle defines the angle (in radians) to use
  85720. * @param result defines the target matrix
  85721. */
  85722. static RotationYToRef(angle: number, result: Matrix): void;
  85723. /**
  85724. * Creates a new rotation matrix for "angle" radians around the Z axis
  85725. * @param angle defines the angle (in radians) to use
  85726. * @return the new matrix
  85727. */
  85728. static RotationZ(angle: number): Matrix;
  85729. /**
  85730. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85731. * @param angle defines the angle (in radians) to use
  85732. * @param result defines the target matrix
  85733. */
  85734. static RotationZToRef(angle: number, result: Matrix): void;
  85735. /**
  85736. * Creates a new rotation matrix for "angle" radians around the given axis
  85737. * @param axis defines the axis to use
  85738. * @param angle defines the angle (in radians) to use
  85739. * @return the new matrix
  85740. */
  85741. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85742. /**
  85743. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85744. * @param axis defines the axis to use
  85745. * @param angle defines the angle (in radians) to use
  85746. * @param result defines the target matrix
  85747. */
  85748. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85749. /**
  85750. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85751. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85752. * @param from defines the vector to align
  85753. * @param to defines the vector to align to
  85754. * @param result defines the target matrix
  85755. */
  85756. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85757. /**
  85758. * Creates a rotation matrix
  85759. * @param yaw defines the yaw angle in radians (Y axis)
  85760. * @param pitch defines the pitch angle in radians (X axis)
  85761. * @param roll defines the roll angle in radians (Z axis)
  85762. * @returns the new rotation matrix
  85763. */
  85764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85765. /**
  85766. * Creates a rotation matrix and stores it in a given matrix
  85767. * @param yaw defines the yaw angle in radians (Y axis)
  85768. * @param pitch defines the pitch angle in radians (X axis)
  85769. * @param roll defines the roll angle in radians (Z axis)
  85770. * @param result defines the target matrix
  85771. */
  85772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85773. /**
  85774. * Creates a scaling matrix
  85775. * @param x defines the scale factor on X axis
  85776. * @param y defines the scale factor on Y axis
  85777. * @param z defines the scale factor on Z axis
  85778. * @returns the new matrix
  85779. */
  85780. static Scaling(x: number, y: number, z: number): Matrix;
  85781. /**
  85782. * Creates a scaling matrix and stores it in a given matrix
  85783. * @param x defines the scale factor on X axis
  85784. * @param y defines the scale factor on Y axis
  85785. * @param z defines the scale factor on Z axis
  85786. * @param result defines the target matrix
  85787. */
  85788. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85789. /**
  85790. * Creates a translation matrix
  85791. * @param x defines the translation on X axis
  85792. * @param y defines the translation on Y axis
  85793. * @param z defines the translationon Z axis
  85794. * @returns the new matrix
  85795. */
  85796. static Translation(x: number, y: number, z: number): Matrix;
  85797. /**
  85798. * Creates a translation matrix and stores it in a given matrix
  85799. * @param x defines the translation on X axis
  85800. * @param y defines the translation on Y axis
  85801. * @param z defines the translationon Z axis
  85802. * @param result defines the target matrix
  85803. */
  85804. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85805. /**
  85806. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85807. * @param startValue defines the start value
  85808. * @param endValue defines the end value
  85809. * @param gradient defines the gradient factor
  85810. * @returns the new matrix
  85811. */
  85812. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85813. /**
  85814. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85815. * @param startValue defines the start value
  85816. * @param endValue defines the end value
  85817. * @param gradient defines the gradient factor
  85818. * @param result defines the Matrix object where to store data
  85819. */
  85820. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85821. /**
  85822. * Builds a new matrix whose values are computed by:
  85823. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85824. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85825. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85826. * @param startValue defines the first matrix
  85827. * @param endValue defines the second matrix
  85828. * @param gradient defines the gradient between the two matrices
  85829. * @returns the new matrix
  85830. */
  85831. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85832. /**
  85833. * Update a matrix to values which are computed by:
  85834. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85835. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85836. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85837. * @param startValue defines the first matrix
  85838. * @param endValue defines the second matrix
  85839. * @param gradient defines the gradient between the two matrices
  85840. * @param result defines the target matrix
  85841. */
  85842. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85843. /**
  85844. * 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"
  85845. * This function works in left handed mode
  85846. * @param eye defines the final position of the entity
  85847. * @param target defines where the entity should look at
  85848. * @param up defines the up vector for the entity
  85849. * @returns the new matrix
  85850. */
  85851. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85852. /**
  85853. * 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".
  85854. * This function works in left handed mode
  85855. * @param eye defines the final position of the entity
  85856. * @param target defines where the entity should look at
  85857. * @param up defines the up vector for the entity
  85858. * @param result defines the target matrix
  85859. */
  85860. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85861. /**
  85862. * 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"
  85863. * This function works in right handed mode
  85864. * @param eye defines the final position of the entity
  85865. * @param target defines where the entity should look at
  85866. * @param up defines the up vector for the entity
  85867. * @returns the new matrix
  85868. */
  85869. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85870. /**
  85871. * 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".
  85872. * This function works in right handed mode
  85873. * @param eye defines the final position of the entity
  85874. * @param target defines where the entity should look at
  85875. * @param up defines the up vector for the entity
  85876. * @param result defines the target matrix
  85877. */
  85878. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85879. /**
  85880. * Create a left-handed orthographic projection matrix
  85881. * @param width defines the viewport width
  85882. * @param height defines the viewport height
  85883. * @param znear defines the near clip plane
  85884. * @param zfar defines the far clip plane
  85885. * @returns a new matrix as a left-handed orthographic projection matrix
  85886. */
  85887. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85888. /**
  85889. * Store a left-handed orthographic projection to a given matrix
  85890. * @param width defines the viewport width
  85891. * @param height defines the viewport height
  85892. * @param znear defines the near clip plane
  85893. * @param zfar defines the far clip plane
  85894. * @param result defines the target matrix
  85895. */
  85896. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85897. /**
  85898. * Create a left-handed orthographic projection matrix
  85899. * @param left defines the viewport left coordinate
  85900. * @param right defines the viewport right coordinate
  85901. * @param bottom defines the viewport bottom coordinate
  85902. * @param top defines the viewport top coordinate
  85903. * @param znear defines the near clip plane
  85904. * @param zfar defines the far clip plane
  85905. * @returns a new matrix as a left-handed orthographic projection matrix
  85906. */
  85907. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85908. /**
  85909. * Stores a left-handed orthographic projection into a given matrix
  85910. * @param left defines the viewport left coordinate
  85911. * @param right defines the viewport right coordinate
  85912. * @param bottom defines the viewport bottom coordinate
  85913. * @param top defines the viewport top coordinate
  85914. * @param znear defines the near clip plane
  85915. * @param zfar defines the far clip plane
  85916. * @param result defines the target matrix
  85917. */
  85918. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85919. /**
  85920. * Creates a right-handed orthographic projection matrix
  85921. * @param left defines the viewport left coordinate
  85922. * @param right defines the viewport right coordinate
  85923. * @param bottom defines the viewport bottom coordinate
  85924. * @param top defines the viewport top coordinate
  85925. * @param znear defines the near clip plane
  85926. * @param zfar defines the far clip plane
  85927. * @returns a new matrix as a right-handed orthographic projection matrix
  85928. */
  85929. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85930. /**
  85931. * Stores a right-handed orthographic projection into a given matrix
  85932. * @param left defines the viewport left coordinate
  85933. * @param right defines the viewport right coordinate
  85934. * @param bottom defines the viewport bottom coordinate
  85935. * @param top defines the viewport top coordinate
  85936. * @param znear defines the near clip plane
  85937. * @param zfar defines the far clip plane
  85938. * @param result defines the target matrix
  85939. */
  85940. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85941. /**
  85942. * Creates a left-handed perspective projection matrix
  85943. * @param width defines the viewport width
  85944. * @param height defines the viewport height
  85945. * @param znear defines the near clip plane
  85946. * @param zfar defines the far clip plane
  85947. * @returns a new matrix as a left-handed perspective projection matrix
  85948. */
  85949. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85950. /**
  85951. * Creates a left-handed perspective projection matrix
  85952. * @param fov defines the horizontal field of view
  85953. * @param aspect defines the aspect ratio
  85954. * @param znear defines the near clip plane
  85955. * @param zfar defines the far clip plane
  85956. * @returns a new matrix as a left-handed perspective projection matrix
  85957. */
  85958. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85959. /**
  85960. * Stores a left-handed perspective projection into a given matrix
  85961. * @param fov defines the horizontal field of view
  85962. * @param aspect defines the aspect ratio
  85963. * @param znear defines the near clip plane
  85964. * @param zfar defines the far clip plane
  85965. * @param result defines the target matrix
  85966. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85967. */
  85968. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85969. /**
  85970. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85971. * @param fov defines the horizontal field of view
  85972. * @param aspect defines the aspect ratio
  85973. * @param znear defines the near clip plane
  85974. * @param zfar not used as infinity is used as far clip
  85975. * @param result defines the target matrix
  85976. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85977. */
  85978. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85979. /**
  85980. * Creates a right-handed perspective projection matrix
  85981. * @param fov defines the horizontal field of view
  85982. * @param aspect defines the aspect ratio
  85983. * @param znear defines the near clip plane
  85984. * @param zfar defines the far clip plane
  85985. * @returns a new matrix as a right-handed perspective projection matrix
  85986. */
  85987. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85988. /**
  85989. * Stores a right-handed perspective projection into a given matrix
  85990. * @param fov defines the horizontal field of view
  85991. * @param aspect defines the aspect ratio
  85992. * @param znear defines the near clip plane
  85993. * @param zfar defines the far clip plane
  85994. * @param result defines the target matrix
  85995. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85996. */
  85997. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85998. /**
  85999. * Stores a right-handed perspective projection into a given matrix
  86000. * @param fov defines the horizontal field of view
  86001. * @param aspect defines the aspect ratio
  86002. * @param znear defines the near clip plane
  86003. * @param zfar not used as infinity is used as far clip
  86004. * @param result defines the target matrix
  86005. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86006. */
  86007. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86008. /**
  86009. * Stores a perspective projection for WebVR info a given matrix
  86010. * @param fov defines the field of view
  86011. * @param znear defines the near clip plane
  86012. * @param zfar defines the far clip plane
  86013. * @param result defines the target matrix
  86014. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86015. */
  86016. static PerspectiveFovWebVRToRef(fov: {
  86017. upDegrees: number;
  86018. downDegrees: number;
  86019. leftDegrees: number;
  86020. rightDegrees: number;
  86021. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86022. /**
  86023. * Computes a complete transformation matrix
  86024. * @param viewport defines the viewport to use
  86025. * @param world defines the world matrix
  86026. * @param view defines the view matrix
  86027. * @param projection defines the projection matrix
  86028. * @param zmin defines the near clip plane
  86029. * @param zmax defines the far clip plane
  86030. * @returns the transformation matrix
  86031. */
  86032. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86033. /**
  86034. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86035. * @param matrix defines the matrix to use
  86036. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86037. */
  86038. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86039. /**
  86040. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86041. * @param matrix defines the matrix to use
  86042. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86043. */
  86044. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86045. /**
  86046. * Compute the transpose of a given matrix
  86047. * @param matrix defines the matrix to transpose
  86048. * @returns the new matrix
  86049. */
  86050. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86051. /**
  86052. * Compute the transpose of a matrix and store it in a target matrix
  86053. * @param matrix defines the matrix to transpose
  86054. * @param result defines the target matrix
  86055. */
  86056. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86057. /**
  86058. * Computes a reflection matrix from a plane
  86059. * @param plane defines the reflection plane
  86060. * @returns a new matrix
  86061. */
  86062. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86063. /**
  86064. * Computes a reflection matrix from a plane
  86065. * @param plane defines the reflection plane
  86066. * @param result defines the target matrix
  86067. */
  86068. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86069. /**
  86070. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86071. * @param xaxis defines the value of the 1st axis
  86072. * @param yaxis defines the value of the 2nd axis
  86073. * @param zaxis defines the value of the 3rd axis
  86074. * @param result defines the target matrix
  86075. */
  86076. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86077. /**
  86078. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86079. * @param quat defines the quaternion to use
  86080. * @param result defines the target matrix
  86081. */
  86082. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86083. }
  86084. /**
  86085. * @hidden
  86086. */
  86087. export class TmpVectors {
  86088. static Vector2: Vector2[];
  86089. static Vector3: Vector3[];
  86090. static Vector4: Vector4[];
  86091. static Quaternion: Quaternion[];
  86092. static Matrix: Matrix[];
  86093. }
  86094. }
  86095. declare module BABYLON {
  86096. /**
  86097. * Defines potential orientation for back face culling
  86098. */
  86099. export enum Orientation {
  86100. /**
  86101. * Clockwise
  86102. */
  86103. CW = 0,
  86104. /** Counter clockwise */
  86105. CCW = 1
  86106. }
  86107. /** Class used to represent a Bezier curve */
  86108. export class BezierCurve {
  86109. /**
  86110. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86111. * @param t defines the time
  86112. * @param x1 defines the left coordinate on X axis
  86113. * @param y1 defines the left coordinate on Y axis
  86114. * @param x2 defines the right coordinate on X axis
  86115. * @param y2 defines the right coordinate on Y axis
  86116. * @returns the interpolated value
  86117. */
  86118. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86119. }
  86120. /**
  86121. * Defines angle representation
  86122. */
  86123. export class Angle {
  86124. private _radians;
  86125. /**
  86126. * Creates an Angle object of "radians" radians (float).
  86127. * @param radians the angle in radians
  86128. */
  86129. constructor(radians: number);
  86130. /**
  86131. * Get value in degrees
  86132. * @returns the Angle value in degrees (float)
  86133. */
  86134. degrees(): number;
  86135. /**
  86136. * Get value in radians
  86137. * @returns the Angle value in radians (float)
  86138. */
  86139. radians(): number;
  86140. /**
  86141. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86142. * @param a defines first point as the origin
  86143. * @param b defines point
  86144. * @returns a new Angle
  86145. */
  86146. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86147. /**
  86148. * Gets a new Angle object from the given float in radians
  86149. * @param radians defines the angle value in radians
  86150. * @returns a new Angle
  86151. */
  86152. static FromRadians(radians: number): Angle;
  86153. /**
  86154. * Gets a new Angle object from the given float in degrees
  86155. * @param degrees defines the angle value in degrees
  86156. * @returns a new Angle
  86157. */
  86158. static FromDegrees(degrees: number): Angle;
  86159. }
  86160. /**
  86161. * This represents an arc in a 2d space.
  86162. */
  86163. export class Arc2 {
  86164. /** Defines the start point of the arc */
  86165. startPoint: Vector2;
  86166. /** Defines the mid point of the arc */
  86167. midPoint: Vector2;
  86168. /** Defines the end point of the arc */
  86169. endPoint: Vector2;
  86170. /**
  86171. * Defines the center point of the arc.
  86172. */
  86173. centerPoint: Vector2;
  86174. /**
  86175. * Defines the radius of the arc.
  86176. */
  86177. radius: number;
  86178. /**
  86179. * Defines the angle of the arc (from mid point to end point).
  86180. */
  86181. angle: Angle;
  86182. /**
  86183. * Defines the start angle of the arc (from start point to middle point).
  86184. */
  86185. startAngle: Angle;
  86186. /**
  86187. * Defines the orientation of the arc (clock wise/counter clock wise).
  86188. */
  86189. orientation: Orientation;
  86190. /**
  86191. * Creates an Arc object from the three given points : start, middle and end.
  86192. * @param startPoint Defines the start point of the arc
  86193. * @param midPoint Defines the midlle point of the arc
  86194. * @param endPoint Defines the end point of the arc
  86195. */
  86196. constructor(
  86197. /** Defines the start point of the arc */
  86198. startPoint: Vector2,
  86199. /** Defines the mid point of the arc */
  86200. midPoint: Vector2,
  86201. /** Defines the end point of the arc */
  86202. endPoint: Vector2);
  86203. }
  86204. /**
  86205. * Represents a 2D path made up of multiple 2D points
  86206. */
  86207. export class Path2 {
  86208. private _points;
  86209. private _length;
  86210. /**
  86211. * If the path start and end point are the same
  86212. */
  86213. closed: boolean;
  86214. /**
  86215. * Creates a Path2 object from the starting 2D coordinates x and y.
  86216. * @param x the starting points x value
  86217. * @param y the starting points y value
  86218. */
  86219. constructor(x: number, y: number);
  86220. /**
  86221. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86222. * @param x the added points x value
  86223. * @param y the added points y value
  86224. * @returns the updated Path2.
  86225. */
  86226. addLineTo(x: number, y: number): Path2;
  86227. /**
  86228. * 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.
  86229. * @param midX middle point x value
  86230. * @param midY middle point y value
  86231. * @param endX end point x value
  86232. * @param endY end point y value
  86233. * @param numberOfSegments (default: 36)
  86234. * @returns the updated Path2.
  86235. */
  86236. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86237. /**
  86238. * Closes the Path2.
  86239. * @returns the Path2.
  86240. */
  86241. close(): Path2;
  86242. /**
  86243. * Gets the sum of the distance between each sequential point in the path
  86244. * @returns the Path2 total length (float).
  86245. */
  86246. length(): number;
  86247. /**
  86248. * Gets the points which construct the path
  86249. * @returns the Path2 internal array of points.
  86250. */
  86251. getPoints(): Vector2[];
  86252. /**
  86253. * Retreives the point at the distance aways from the starting point
  86254. * @param normalizedLengthPosition the length along the path to retreive the point from
  86255. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  86256. */
  86257. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  86258. /**
  86259. * Creates a new path starting from an x and y position
  86260. * @param x starting x value
  86261. * @param y starting y value
  86262. * @returns a new Path2 starting at the coordinates (x, y).
  86263. */
  86264. static StartingAt(x: number, y: number): Path2;
  86265. }
  86266. /**
  86267. * Represents a 3D path made up of multiple 3D points
  86268. */
  86269. export class Path3D {
  86270. /**
  86271. * an array of Vector3, the curve axis of the Path3D
  86272. */
  86273. path: Vector3[];
  86274. private _curve;
  86275. private _distances;
  86276. private _tangents;
  86277. private _normals;
  86278. private _binormals;
  86279. private _raw;
  86280. private _alignTangentsWithPath;
  86281. private readonly _pointAtData;
  86282. /**
  86283. * new Path3D(path, normal, raw)
  86284. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  86285. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  86286. * @param path an array of Vector3, the curve axis of the Path3D
  86287. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  86288. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  86289. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  86290. */
  86291. constructor(
  86292. /**
  86293. * an array of Vector3, the curve axis of the Path3D
  86294. */
  86295. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  86296. /**
  86297. * Returns the Path3D array of successive Vector3 designing its curve.
  86298. * @returns the Path3D array of successive Vector3 designing its curve.
  86299. */
  86300. getCurve(): Vector3[];
  86301. /**
  86302. * Returns the Path3D array of successive Vector3 designing its curve.
  86303. * @returns the Path3D array of successive Vector3 designing its curve.
  86304. */
  86305. getPoints(): Vector3[];
  86306. /**
  86307. * @returns the computed length (float) of the path.
  86308. */
  86309. length(): number;
  86310. /**
  86311. * Returns an array populated with tangent vectors on each Path3D curve point.
  86312. * @returns an array populated with tangent vectors on each Path3D curve point.
  86313. */
  86314. getTangents(): Vector3[];
  86315. /**
  86316. * Returns an array populated with normal vectors on each Path3D curve point.
  86317. * @returns an array populated with normal vectors on each Path3D curve point.
  86318. */
  86319. getNormals(): Vector3[];
  86320. /**
  86321. * Returns an array populated with binormal vectors on each Path3D curve point.
  86322. * @returns an array populated with binormal vectors on each Path3D curve point.
  86323. */
  86324. getBinormals(): Vector3[];
  86325. /**
  86326. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  86327. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  86328. */
  86329. getDistances(): number[];
  86330. /**
  86331. * Returns an interpolated point along this path
  86332. * @param position the position of the point along this path, from 0.0 to 1.0
  86333. * @returns a new Vector3 as the point
  86334. */
  86335. getPointAt(position: number): Vector3;
  86336. /**
  86337. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86338. * @param position the position of the point along this path, from 0.0 to 1.0
  86339. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  86340. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  86341. */
  86342. getTangentAt(position: number, interpolated?: boolean): Vector3;
  86343. /**
  86344. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86345. * @param position the position of the point along this path, from 0.0 to 1.0
  86346. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  86347. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  86348. */
  86349. getNormalAt(position: number, interpolated?: boolean): Vector3;
  86350. /**
  86351. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  86352. * @param position the position of the point along this path, from 0.0 to 1.0
  86353. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  86354. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  86355. */
  86356. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  86357. /**
  86358. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  86359. * @param position the position of the point along this path, from 0.0 to 1.0
  86360. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  86361. */
  86362. getDistanceAt(position: number): number;
  86363. /**
  86364. * Returns the array index of the previous point of an interpolated point along this path
  86365. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86366. * @returns the array index
  86367. */
  86368. getPreviousPointIndexAt(position: number): number;
  86369. /**
  86370. * 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)
  86371. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86372. * @returns the sub position
  86373. */
  86374. getSubPositionAt(position: number): number;
  86375. /**
  86376. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  86377. * @param target the vector of which to get the closest position to
  86378. * @returns the position of the closest virtual point on this path to the target vector
  86379. */
  86380. getClosestPositionTo(target: Vector3): number;
  86381. /**
  86382. * Returns a sub path (slice) of this path
  86383. * @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
  86384. * @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
  86385. * @returns a sub path (slice) of this path
  86386. */
  86387. slice(start?: number, end?: number): Path3D;
  86388. /**
  86389. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  86390. * @param path path which all values are copied into the curves points
  86391. * @param firstNormal which should be projected onto the curve
  86392. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  86393. * @returns the same object updated.
  86394. */
  86395. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  86396. private _compute;
  86397. private _getFirstNonNullVector;
  86398. private _getLastNonNullVector;
  86399. private _normalVector;
  86400. /**
  86401. * Updates the point at data for an interpolated point along this curve
  86402. * @param position the position of the point along this curve, from 0.0 to 1.0
  86403. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  86404. * @returns the (updated) point at data
  86405. */
  86406. private _updatePointAtData;
  86407. /**
  86408. * Updates the point at data from the specified parameters
  86409. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  86410. * @param point the interpolated point
  86411. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  86412. */
  86413. private _setPointAtData;
  86414. /**
  86415. * Updates the point at interpolation matrix for the tangents, normals and binormals
  86416. */
  86417. private _updateInterpolationMatrix;
  86418. }
  86419. /**
  86420. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86421. * A Curve3 is designed from a series of successive Vector3.
  86422. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  86423. */
  86424. export class Curve3 {
  86425. private _points;
  86426. private _length;
  86427. /**
  86428. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  86429. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  86430. * @param v1 (Vector3) the control point
  86431. * @param v2 (Vector3) the end point of the Quadratic Bezier
  86432. * @param nbPoints (integer) the wanted number of points in the curve
  86433. * @returns the created Curve3
  86434. */
  86435. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86436. /**
  86437. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  86438. * @param v0 (Vector3) the origin point of the Cubic Bezier
  86439. * @param v1 (Vector3) the first control point
  86440. * @param v2 (Vector3) the second control point
  86441. * @param v3 (Vector3) the end point of the Cubic Bezier
  86442. * @param nbPoints (integer) the wanted number of points in the curve
  86443. * @returns the created Curve3
  86444. */
  86445. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86446. /**
  86447. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86448. * @param p1 (Vector3) the origin point of the Hermite Spline
  86449. * @param t1 (Vector3) the tangent vector at the origin point
  86450. * @param p2 (Vector3) the end point of the Hermite Spline
  86451. * @param t2 (Vector3) the tangent vector at the end point
  86452. * @param nbPoints (integer) the wanted number of points in the curve
  86453. * @returns the created Curve3
  86454. */
  86455. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86456. /**
  86457. * Returns a Curve3 object along a CatmullRom Spline curve :
  86458. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86459. * @param nbPoints (integer) the wanted number of points between each curve control points
  86460. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86461. * @returns the created Curve3
  86462. */
  86463. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86464. /**
  86465. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86466. * A Curve3 is designed from a series of successive Vector3.
  86467. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86468. * @param points points which make up the curve
  86469. */
  86470. constructor(points: Vector3[]);
  86471. /**
  86472. * @returns the Curve3 stored array of successive Vector3
  86473. */
  86474. getPoints(): Vector3[];
  86475. /**
  86476. * @returns the computed length (float) of the curve.
  86477. */
  86478. length(): number;
  86479. /**
  86480. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86481. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86482. * curveA and curveB keep unchanged.
  86483. * @param curve the curve to continue from this curve
  86484. * @returns the newly constructed curve
  86485. */
  86486. continue(curve: DeepImmutable<Curve3>): Curve3;
  86487. private _computeLength;
  86488. }
  86489. }
  86490. declare module BABYLON {
  86491. /**
  86492. * This represents the main contract an easing function should follow.
  86493. * Easing functions are used throughout the animation system.
  86494. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86495. */
  86496. export interface IEasingFunction {
  86497. /**
  86498. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86499. * of the easing function.
  86500. * The link below provides some of the most common examples of easing functions.
  86501. * @see https://easings.net/
  86502. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86503. * @returns the corresponding value on the curve defined by the easing function
  86504. */
  86505. ease(gradient: number): number;
  86506. }
  86507. /**
  86508. * Base class used for every default easing function.
  86509. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86510. */
  86511. export class EasingFunction implements IEasingFunction {
  86512. /**
  86513. * Interpolation follows the mathematical formula associated with the easing function.
  86514. */
  86515. static readonly EASINGMODE_EASEIN: number;
  86516. /**
  86517. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86518. */
  86519. static readonly EASINGMODE_EASEOUT: number;
  86520. /**
  86521. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86522. */
  86523. static readonly EASINGMODE_EASEINOUT: number;
  86524. private _easingMode;
  86525. /**
  86526. * Sets the easing mode of the current function.
  86527. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86528. */
  86529. setEasingMode(easingMode: number): void;
  86530. /**
  86531. * Gets the current easing mode.
  86532. * @returns the easing mode
  86533. */
  86534. getEasingMode(): number;
  86535. /**
  86536. * @hidden
  86537. */
  86538. easeInCore(gradient: number): number;
  86539. /**
  86540. * Given an input gradient between 0 and 1, this returns the corresponding value
  86541. * of the easing function.
  86542. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86543. * @returns the corresponding value on the curve defined by the easing function
  86544. */
  86545. ease(gradient: number): number;
  86546. }
  86547. /**
  86548. * Easing function with a circle shape (see link below).
  86549. * @see https://easings.net/#easeInCirc
  86550. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86551. */
  86552. export class CircleEase extends EasingFunction implements IEasingFunction {
  86553. /** @hidden */
  86554. easeInCore(gradient: number): number;
  86555. }
  86556. /**
  86557. * Easing function with a ease back shape (see link below).
  86558. * @see https://easings.net/#easeInBack
  86559. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86560. */
  86561. export class BackEase extends EasingFunction implements IEasingFunction {
  86562. /** Defines the amplitude of the function */
  86563. amplitude: number;
  86564. /**
  86565. * Instantiates a back ease easing
  86566. * @see https://easings.net/#easeInBack
  86567. * @param amplitude Defines the amplitude of the function
  86568. */
  86569. constructor(
  86570. /** Defines the amplitude of the function */
  86571. amplitude?: number);
  86572. /** @hidden */
  86573. easeInCore(gradient: number): number;
  86574. }
  86575. /**
  86576. * Easing function with a bouncing shape (see link below).
  86577. * @see https://easings.net/#easeInBounce
  86578. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86579. */
  86580. export class BounceEase extends EasingFunction implements IEasingFunction {
  86581. /** Defines the number of bounces */
  86582. bounces: number;
  86583. /** Defines the amplitude of the bounce */
  86584. bounciness: number;
  86585. /**
  86586. * Instantiates a bounce easing
  86587. * @see https://easings.net/#easeInBounce
  86588. * @param bounces Defines the number of bounces
  86589. * @param bounciness Defines the amplitude of the bounce
  86590. */
  86591. constructor(
  86592. /** Defines the number of bounces */
  86593. bounces?: number,
  86594. /** Defines the amplitude of the bounce */
  86595. bounciness?: number);
  86596. /** @hidden */
  86597. easeInCore(gradient: number): number;
  86598. }
  86599. /**
  86600. * Easing function with a power of 3 shape (see link below).
  86601. * @see https://easings.net/#easeInCubic
  86602. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86603. */
  86604. export class CubicEase extends EasingFunction implements IEasingFunction {
  86605. /** @hidden */
  86606. easeInCore(gradient: number): number;
  86607. }
  86608. /**
  86609. * Easing function with an elastic shape (see link below).
  86610. * @see https://easings.net/#easeInElastic
  86611. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86612. */
  86613. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86614. /** Defines the number of oscillations*/
  86615. oscillations: number;
  86616. /** Defines the amplitude of the oscillations*/
  86617. springiness: number;
  86618. /**
  86619. * Instantiates an elastic easing function
  86620. * @see https://easings.net/#easeInElastic
  86621. * @param oscillations Defines the number of oscillations
  86622. * @param springiness Defines the amplitude of the oscillations
  86623. */
  86624. constructor(
  86625. /** Defines the number of oscillations*/
  86626. oscillations?: number,
  86627. /** Defines the amplitude of the oscillations*/
  86628. springiness?: number);
  86629. /** @hidden */
  86630. easeInCore(gradient: number): number;
  86631. }
  86632. /**
  86633. * Easing function with an exponential shape (see link below).
  86634. * @see https://easings.net/#easeInExpo
  86635. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86636. */
  86637. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86638. /** Defines the exponent of the function */
  86639. exponent: number;
  86640. /**
  86641. * Instantiates an exponential easing function
  86642. * @see https://easings.net/#easeInExpo
  86643. * @param exponent Defines the exponent of the function
  86644. */
  86645. constructor(
  86646. /** Defines the exponent of the function */
  86647. exponent?: number);
  86648. /** @hidden */
  86649. easeInCore(gradient: number): number;
  86650. }
  86651. /**
  86652. * Easing function with a power shape (see link below).
  86653. * @see https://easings.net/#easeInQuad
  86654. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86655. */
  86656. export class PowerEase extends EasingFunction implements IEasingFunction {
  86657. /** Defines the power of the function */
  86658. power: number;
  86659. /**
  86660. * Instantiates an power base easing function
  86661. * @see https://easings.net/#easeInQuad
  86662. * @param power Defines the power of the function
  86663. */
  86664. constructor(
  86665. /** Defines the power of the function */
  86666. power?: number);
  86667. /** @hidden */
  86668. easeInCore(gradient: number): number;
  86669. }
  86670. /**
  86671. * Easing function with a power of 2 shape (see link below).
  86672. * @see https://easings.net/#easeInQuad
  86673. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86674. */
  86675. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86676. /** @hidden */
  86677. easeInCore(gradient: number): number;
  86678. }
  86679. /**
  86680. * Easing function with a power of 4 shape (see link below).
  86681. * @see https://easings.net/#easeInQuart
  86682. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86683. */
  86684. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86685. /** @hidden */
  86686. easeInCore(gradient: number): number;
  86687. }
  86688. /**
  86689. * Easing function with a power of 5 shape (see link below).
  86690. * @see https://easings.net/#easeInQuint
  86691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86692. */
  86693. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86694. /** @hidden */
  86695. easeInCore(gradient: number): number;
  86696. }
  86697. /**
  86698. * Easing function with a sin shape (see link below).
  86699. * @see https://easings.net/#easeInSine
  86700. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86701. */
  86702. export class SineEase extends EasingFunction implements IEasingFunction {
  86703. /** @hidden */
  86704. easeInCore(gradient: number): number;
  86705. }
  86706. /**
  86707. * Easing function with a bezier shape (see link below).
  86708. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86709. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86710. */
  86711. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86712. /** Defines the x component of the start tangent in the bezier curve */
  86713. x1: number;
  86714. /** Defines the y component of the start tangent in the bezier curve */
  86715. y1: number;
  86716. /** Defines the x component of the end tangent in the bezier curve */
  86717. x2: number;
  86718. /** Defines the y component of the end tangent in the bezier curve */
  86719. y2: number;
  86720. /**
  86721. * Instantiates a bezier function
  86722. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86723. * @param x1 Defines the x component of the start tangent in the bezier curve
  86724. * @param y1 Defines the y component of the start tangent in the bezier curve
  86725. * @param x2 Defines the x component of the end tangent in the bezier curve
  86726. * @param y2 Defines the y component of the end tangent in the bezier curve
  86727. */
  86728. constructor(
  86729. /** Defines the x component of the start tangent in the bezier curve */
  86730. x1?: number,
  86731. /** Defines the y component of the start tangent in the bezier curve */
  86732. y1?: number,
  86733. /** Defines the x component of the end tangent in the bezier curve */
  86734. x2?: number,
  86735. /** Defines the y component of the end tangent in the bezier curve */
  86736. y2?: number);
  86737. /** @hidden */
  86738. easeInCore(gradient: number): number;
  86739. }
  86740. }
  86741. declare module BABYLON {
  86742. /**
  86743. * Class used to hold a RBG color
  86744. */
  86745. export class Color3 {
  86746. /**
  86747. * Defines the red component (between 0 and 1, default is 0)
  86748. */
  86749. r: number;
  86750. /**
  86751. * Defines the green component (between 0 and 1, default is 0)
  86752. */
  86753. g: number;
  86754. /**
  86755. * Defines the blue component (between 0 and 1, default is 0)
  86756. */
  86757. b: number;
  86758. /**
  86759. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86760. * @param r defines the red component (between 0 and 1, default is 0)
  86761. * @param g defines the green component (between 0 and 1, default is 0)
  86762. * @param b defines the blue component (between 0 and 1, default is 0)
  86763. */
  86764. constructor(
  86765. /**
  86766. * Defines the red component (between 0 and 1, default is 0)
  86767. */
  86768. r?: number,
  86769. /**
  86770. * Defines the green component (between 0 and 1, default is 0)
  86771. */
  86772. g?: number,
  86773. /**
  86774. * Defines the blue component (between 0 and 1, default is 0)
  86775. */
  86776. b?: number);
  86777. /**
  86778. * Creates a string with the Color3 current values
  86779. * @returns the string representation of the Color3 object
  86780. */
  86781. toString(): string;
  86782. /**
  86783. * Returns the string "Color3"
  86784. * @returns "Color3"
  86785. */
  86786. getClassName(): string;
  86787. /**
  86788. * Compute the Color3 hash code
  86789. * @returns an unique number that can be used to hash Color3 objects
  86790. */
  86791. getHashCode(): number;
  86792. /**
  86793. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86794. * @param array defines the array where to store the r,g,b components
  86795. * @param index defines an optional index in the target array to define where to start storing values
  86796. * @returns the current Color3 object
  86797. */
  86798. toArray(array: FloatArray, index?: number): Color3;
  86799. /**
  86800. * Update the current color with values stored in an array from the starting index of the given array
  86801. * @param array defines the source array
  86802. * @param offset defines an offset in the source array
  86803. * @returns the current Color3 object
  86804. */
  86805. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86806. /**
  86807. * Returns a new Color4 object from the current Color3 and the given alpha
  86808. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86809. * @returns a new Color4 object
  86810. */
  86811. toColor4(alpha?: number): Color4;
  86812. /**
  86813. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86814. * @returns the new array
  86815. */
  86816. asArray(): number[];
  86817. /**
  86818. * Returns the luminance value
  86819. * @returns a float value
  86820. */
  86821. toLuminance(): number;
  86822. /**
  86823. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86824. * @param otherColor defines the second operand
  86825. * @returns the new Color3 object
  86826. */
  86827. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86828. /**
  86829. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86830. * @param otherColor defines the second operand
  86831. * @param result defines the Color3 object where to store the result
  86832. * @returns the current Color3
  86833. */
  86834. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86835. /**
  86836. * Determines equality between Color3 objects
  86837. * @param otherColor defines the second operand
  86838. * @returns true if the rgb values are equal to the given ones
  86839. */
  86840. equals(otherColor: DeepImmutable<Color3>): boolean;
  86841. /**
  86842. * Determines equality between the current Color3 object and a set of r,b,g values
  86843. * @param r defines the red component to check
  86844. * @param g defines the green component to check
  86845. * @param b defines the blue component to check
  86846. * @returns true if the rgb values are equal to the given ones
  86847. */
  86848. equalsFloats(r: number, g: number, b: number): boolean;
  86849. /**
  86850. * Multiplies in place each rgb value by scale
  86851. * @param scale defines the scaling factor
  86852. * @returns the updated Color3
  86853. */
  86854. scale(scale: number): Color3;
  86855. /**
  86856. * Multiplies the rgb values by scale and stores the result into "result"
  86857. * @param scale defines the scaling factor
  86858. * @param result defines the Color3 object where to store the result
  86859. * @returns the unmodified current Color3
  86860. */
  86861. scaleToRef(scale: number, result: Color3): Color3;
  86862. /**
  86863. * Scale the current Color3 values by a factor and add the result to a given Color3
  86864. * @param scale defines the scale factor
  86865. * @param result defines color to store the result into
  86866. * @returns the unmodified current Color3
  86867. */
  86868. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86869. /**
  86870. * Clamps the rgb values by the min and max values and stores the result into "result"
  86871. * @param min defines minimum clamping value (default is 0)
  86872. * @param max defines maximum clamping value (default is 1)
  86873. * @param result defines color to store the result into
  86874. * @returns the original Color3
  86875. */
  86876. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86877. /**
  86878. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86879. * @param otherColor defines the second operand
  86880. * @returns the new Color3
  86881. */
  86882. add(otherColor: DeepImmutable<Color3>): Color3;
  86883. /**
  86884. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86885. * @param otherColor defines the second operand
  86886. * @param result defines Color3 object to store the result into
  86887. * @returns the unmodified current Color3
  86888. */
  86889. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86890. /**
  86891. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86892. * @param otherColor defines the second operand
  86893. * @returns the new Color3
  86894. */
  86895. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86896. /**
  86897. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86898. * @param otherColor defines the second operand
  86899. * @param result defines Color3 object to store the result into
  86900. * @returns the unmodified current Color3
  86901. */
  86902. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86903. /**
  86904. * Copy the current object
  86905. * @returns a new Color3 copied the current one
  86906. */
  86907. clone(): Color3;
  86908. /**
  86909. * Copies the rgb values from the source in the current Color3
  86910. * @param source defines the source Color3 object
  86911. * @returns the updated Color3 object
  86912. */
  86913. copyFrom(source: DeepImmutable<Color3>): Color3;
  86914. /**
  86915. * Updates the Color3 rgb values from the given floats
  86916. * @param r defines the red component to read from
  86917. * @param g defines the green component to read from
  86918. * @param b defines the blue component to read from
  86919. * @returns the current Color3 object
  86920. */
  86921. copyFromFloats(r: number, g: number, b: number): Color3;
  86922. /**
  86923. * Updates the Color3 rgb values from the given floats
  86924. * @param r defines the red component to read from
  86925. * @param g defines the green component to read from
  86926. * @param b defines the blue component to read from
  86927. * @returns the current Color3 object
  86928. */
  86929. set(r: number, g: number, b: number): Color3;
  86930. /**
  86931. * Compute the Color3 hexadecimal code as a string
  86932. * @returns a string containing the hexadecimal representation of the Color3 object
  86933. */
  86934. toHexString(): string;
  86935. /**
  86936. * Computes a new Color3 converted from the current one to linear space
  86937. * @returns a new Color3 object
  86938. */
  86939. toLinearSpace(): Color3;
  86940. /**
  86941. * Converts current color in rgb space to HSV values
  86942. * @returns a new color3 representing the HSV values
  86943. */
  86944. toHSV(): Color3;
  86945. /**
  86946. * Converts current color in rgb space to HSV values
  86947. * @param result defines the Color3 where to store the HSV values
  86948. */
  86949. toHSVToRef(result: Color3): void;
  86950. /**
  86951. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86952. * @param convertedColor defines the Color3 object where to store the linear space version
  86953. * @returns the unmodified Color3
  86954. */
  86955. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86956. /**
  86957. * Computes a new Color3 converted from the current one to gamma space
  86958. * @returns a new Color3 object
  86959. */
  86960. toGammaSpace(): Color3;
  86961. /**
  86962. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86963. * @param convertedColor defines the Color3 object where to store the gamma space version
  86964. * @returns the unmodified Color3
  86965. */
  86966. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86967. private static _BlackReadOnly;
  86968. /**
  86969. * Convert Hue, saturation and value to a Color3 (RGB)
  86970. * @param hue defines the hue
  86971. * @param saturation defines the saturation
  86972. * @param value defines the value
  86973. * @param result defines the Color3 where to store the RGB values
  86974. */
  86975. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86976. /**
  86977. * Creates a new Color3 from the string containing valid hexadecimal values
  86978. * @param hex defines a string containing valid hexadecimal values
  86979. * @returns a new Color3 object
  86980. */
  86981. static FromHexString(hex: string): Color3;
  86982. /**
  86983. * Creates a new Color3 from the starting index of the given array
  86984. * @param array defines the source array
  86985. * @param offset defines an offset in the source array
  86986. * @returns a new Color3 object
  86987. */
  86988. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86989. /**
  86990. * Creates a new Color3 from the starting index element of the given array
  86991. * @param array defines the source array to read from
  86992. * @param offset defines the offset in the source array
  86993. * @param result defines the target Color3 object
  86994. */
  86995. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86996. /**
  86997. * Creates a new Color3 from integer values (< 256)
  86998. * @param r defines the red component to read from (value between 0 and 255)
  86999. * @param g defines the green component to read from (value between 0 and 255)
  87000. * @param b defines the blue component to read from (value between 0 and 255)
  87001. * @returns a new Color3 object
  87002. */
  87003. static FromInts(r: number, g: number, b: number): Color3;
  87004. /**
  87005. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87006. * @param start defines the start Color3 value
  87007. * @param end defines the end Color3 value
  87008. * @param amount defines the gradient value between start and end
  87009. * @returns a new Color3 object
  87010. */
  87011. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87012. /**
  87013. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87014. * @param left defines the start value
  87015. * @param right defines the end value
  87016. * @param amount defines the gradient factor
  87017. * @param result defines the Color3 object where to store the result
  87018. */
  87019. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87020. /**
  87021. * Returns a Color3 value containing a red color
  87022. * @returns a new Color3 object
  87023. */
  87024. static Red(): Color3;
  87025. /**
  87026. * Returns a Color3 value containing a green color
  87027. * @returns a new Color3 object
  87028. */
  87029. static Green(): Color3;
  87030. /**
  87031. * Returns a Color3 value containing a blue color
  87032. * @returns a new Color3 object
  87033. */
  87034. static Blue(): Color3;
  87035. /**
  87036. * Returns a Color3 value containing a black color
  87037. * @returns a new Color3 object
  87038. */
  87039. static Black(): Color3;
  87040. /**
  87041. * Gets a Color3 value containing a black color that must not be updated
  87042. */
  87043. static get BlackReadOnly(): DeepImmutable<Color3>;
  87044. /**
  87045. * Returns a Color3 value containing a white color
  87046. * @returns a new Color3 object
  87047. */
  87048. static White(): Color3;
  87049. /**
  87050. * Returns a Color3 value containing a purple color
  87051. * @returns a new Color3 object
  87052. */
  87053. static Purple(): Color3;
  87054. /**
  87055. * Returns a Color3 value containing a magenta color
  87056. * @returns a new Color3 object
  87057. */
  87058. static Magenta(): Color3;
  87059. /**
  87060. * Returns a Color3 value containing a yellow color
  87061. * @returns a new Color3 object
  87062. */
  87063. static Yellow(): Color3;
  87064. /**
  87065. * Returns a Color3 value containing a gray color
  87066. * @returns a new Color3 object
  87067. */
  87068. static Gray(): Color3;
  87069. /**
  87070. * Returns a Color3 value containing a teal color
  87071. * @returns a new Color3 object
  87072. */
  87073. static Teal(): Color3;
  87074. /**
  87075. * Returns a Color3 value containing a random color
  87076. * @returns a new Color3 object
  87077. */
  87078. static Random(): Color3;
  87079. }
  87080. /**
  87081. * Class used to hold a RBGA color
  87082. */
  87083. export class Color4 {
  87084. /**
  87085. * Defines the red component (between 0 and 1, default is 0)
  87086. */
  87087. r: number;
  87088. /**
  87089. * Defines the green component (between 0 and 1, default is 0)
  87090. */
  87091. g: number;
  87092. /**
  87093. * Defines the blue component (between 0 and 1, default is 0)
  87094. */
  87095. b: number;
  87096. /**
  87097. * Defines the alpha component (between 0 and 1, default is 1)
  87098. */
  87099. a: number;
  87100. /**
  87101. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87102. * @param r defines the red component (between 0 and 1, default is 0)
  87103. * @param g defines the green component (between 0 and 1, default is 0)
  87104. * @param b defines the blue component (between 0 and 1, default is 0)
  87105. * @param a defines the alpha component (between 0 and 1, default is 1)
  87106. */
  87107. constructor(
  87108. /**
  87109. * Defines the red component (between 0 and 1, default is 0)
  87110. */
  87111. r?: number,
  87112. /**
  87113. * Defines the green component (between 0 and 1, default is 0)
  87114. */
  87115. g?: number,
  87116. /**
  87117. * Defines the blue component (between 0 and 1, default is 0)
  87118. */
  87119. b?: number,
  87120. /**
  87121. * Defines the alpha component (between 0 and 1, default is 1)
  87122. */
  87123. a?: number);
  87124. /**
  87125. * Adds in place the given Color4 values to the current Color4 object
  87126. * @param right defines the second operand
  87127. * @returns the current updated Color4 object
  87128. */
  87129. addInPlace(right: DeepImmutable<Color4>): Color4;
  87130. /**
  87131. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87132. * @returns the new array
  87133. */
  87134. asArray(): number[];
  87135. /**
  87136. * Stores from the starting index in the given array the Color4 successive values
  87137. * @param array defines the array where to store the r,g,b components
  87138. * @param index defines an optional index in the target array to define where to start storing values
  87139. * @returns the current Color4 object
  87140. */
  87141. toArray(array: number[], index?: number): Color4;
  87142. /**
  87143. * Update the current color with values stored in an array from the starting index of the given array
  87144. * @param array defines the source array
  87145. * @param offset defines an offset in the source array
  87146. * @returns the current Color4 object
  87147. */
  87148. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87149. /**
  87150. * Determines equality between Color4 objects
  87151. * @param otherColor defines the second operand
  87152. * @returns true if the rgba values are equal to the given ones
  87153. */
  87154. equals(otherColor: DeepImmutable<Color4>): boolean;
  87155. /**
  87156. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87157. * @param right defines the second operand
  87158. * @returns a new Color4 object
  87159. */
  87160. add(right: DeepImmutable<Color4>): Color4;
  87161. /**
  87162. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87163. * @param right defines the second operand
  87164. * @returns a new Color4 object
  87165. */
  87166. subtract(right: DeepImmutable<Color4>): Color4;
  87167. /**
  87168. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87169. * @param right defines the second operand
  87170. * @param result defines the Color4 object where to store the result
  87171. * @returns the current Color4 object
  87172. */
  87173. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87174. /**
  87175. * Creates a new Color4 with the current Color4 values multiplied by scale
  87176. * @param scale defines the scaling factor to apply
  87177. * @returns a new Color4 object
  87178. */
  87179. scale(scale: number): Color4;
  87180. /**
  87181. * Multiplies the current Color4 values by scale and stores the result in "result"
  87182. * @param scale defines the scaling factor to apply
  87183. * @param result defines the Color4 object where to store the result
  87184. * @returns the current unmodified Color4
  87185. */
  87186. scaleToRef(scale: number, result: Color4): Color4;
  87187. /**
  87188. * Scale the current Color4 values by a factor and add the result to a given Color4
  87189. * @param scale defines the scale factor
  87190. * @param result defines the Color4 object where to store the result
  87191. * @returns the unmodified current Color4
  87192. */
  87193. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87194. /**
  87195. * Clamps the rgb values by the min and max values and stores the result into "result"
  87196. * @param min defines minimum clamping value (default is 0)
  87197. * @param max defines maximum clamping value (default is 1)
  87198. * @param result defines color to store the result into.
  87199. * @returns the cuurent Color4
  87200. */
  87201. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87202. /**
  87203. * Multipy an Color4 value by another and return a new Color4 object
  87204. * @param color defines the Color4 value to multiply by
  87205. * @returns a new Color4 object
  87206. */
  87207. multiply(color: Color4): Color4;
  87208. /**
  87209. * Multipy a Color4 value by another and push the result in a reference value
  87210. * @param color defines the Color4 value to multiply by
  87211. * @param result defines the Color4 to fill the result in
  87212. * @returns the result Color4
  87213. */
  87214. multiplyToRef(color: Color4, result: Color4): Color4;
  87215. /**
  87216. * Creates a string with the Color4 current values
  87217. * @returns the string representation of the Color4 object
  87218. */
  87219. toString(): string;
  87220. /**
  87221. * Returns the string "Color4"
  87222. * @returns "Color4"
  87223. */
  87224. getClassName(): string;
  87225. /**
  87226. * Compute the Color4 hash code
  87227. * @returns an unique number that can be used to hash Color4 objects
  87228. */
  87229. getHashCode(): number;
  87230. /**
  87231. * Creates a new Color4 copied from the current one
  87232. * @returns a new Color4 object
  87233. */
  87234. clone(): Color4;
  87235. /**
  87236. * Copies the given Color4 values into the current one
  87237. * @param source defines the source Color4 object
  87238. * @returns the current updated Color4 object
  87239. */
  87240. copyFrom(source: Color4): Color4;
  87241. /**
  87242. * Copies the given float values into the current one
  87243. * @param r defines the red component to read from
  87244. * @param g defines the green component to read from
  87245. * @param b defines the blue component to read from
  87246. * @param a defines the alpha component to read from
  87247. * @returns the current updated Color4 object
  87248. */
  87249. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  87250. /**
  87251. * Copies the given float values into the current one
  87252. * @param r defines the red component to read from
  87253. * @param g defines the green component to read from
  87254. * @param b defines the blue component to read from
  87255. * @param a defines the alpha component to read from
  87256. * @returns the current updated Color4 object
  87257. */
  87258. set(r: number, g: number, b: number, a: number): Color4;
  87259. /**
  87260. * Compute the Color4 hexadecimal code as a string
  87261. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  87262. * @returns a string containing the hexadecimal representation of the Color4 object
  87263. */
  87264. toHexString(returnAsColor3?: boolean): string;
  87265. /**
  87266. * Computes a new Color4 converted from the current one to linear space
  87267. * @returns a new Color4 object
  87268. */
  87269. toLinearSpace(): Color4;
  87270. /**
  87271. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  87272. * @param convertedColor defines the Color4 object where to store the linear space version
  87273. * @returns the unmodified Color4
  87274. */
  87275. toLinearSpaceToRef(convertedColor: Color4): Color4;
  87276. /**
  87277. * Computes a new Color4 converted from the current one to gamma space
  87278. * @returns a new Color4 object
  87279. */
  87280. toGammaSpace(): Color4;
  87281. /**
  87282. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  87283. * @param convertedColor defines the Color4 object where to store the gamma space version
  87284. * @returns the unmodified Color4
  87285. */
  87286. toGammaSpaceToRef(convertedColor: Color4): Color4;
  87287. /**
  87288. * Creates a new Color4 from the string containing valid hexadecimal values
  87289. * @param hex defines a string containing valid hexadecimal values
  87290. * @returns a new Color4 object
  87291. */
  87292. static FromHexString(hex: string): Color4;
  87293. /**
  87294. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87295. * @param left defines the start value
  87296. * @param right defines the end value
  87297. * @param amount defines the gradient factor
  87298. * @returns a new Color4 object
  87299. */
  87300. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  87301. /**
  87302. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87303. * @param left defines the start value
  87304. * @param right defines the end value
  87305. * @param amount defines the gradient factor
  87306. * @param result defines the Color4 object where to store data
  87307. */
  87308. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  87309. /**
  87310. * Creates a new Color4 from a Color3 and an alpha value
  87311. * @param color3 defines the source Color3 to read from
  87312. * @param alpha defines the alpha component (1.0 by default)
  87313. * @returns a new Color4 object
  87314. */
  87315. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  87316. /**
  87317. * Creates a new Color4 from the starting index element of the given array
  87318. * @param array defines the source array to read from
  87319. * @param offset defines the offset in the source array
  87320. * @returns a new Color4 object
  87321. */
  87322. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87323. /**
  87324. * Creates a new Color4 from the starting index element of the given array
  87325. * @param array defines the source array to read from
  87326. * @param offset defines the offset in the source array
  87327. * @param result defines the target Color4 object
  87328. */
  87329. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  87330. /**
  87331. * Creates a new Color3 from integer values (< 256)
  87332. * @param r defines the red component to read from (value between 0 and 255)
  87333. * @param g defines the green component to read from (value between 0 and 255)
  87334. * @param b defines the blue component to read from (value between 0 and 255)
  87335. * @param a defines the alpha component to read from (value between 0 and 255)
  87336. * @returns a new Color3 object
  87337. */
  87338. static FromInts(r: number, g: number, b: number, a: number): Color4;
  87339. /**
  87340. * Check the content of a given array and convert it to an array containing RGBA data
  87341. * If the original array was already containing count * 4 values then it is returned directly
  87342. * @param colors defines the array to check
  87343. * @param count defines the number of RGBA data to expect
  87344. * @returns an array containing count * 4 values (RGBA)
  87345. */
  87346. static CheckColors4(colors: number[], count: number): number[];
  87347. }
  87348. /**
  87349. * @hidden
  87350. */
  87351. export class TmpColors {
  87352. static Color3: Color3[];
  87353. static Color4: Color4[];
  87354. }
  87355. }
  87356. declare module BABYLON {
  87357. /**
  87358. * Defines an interface which represents an animation key frame
  87359. */
  87360. export interface IAnimationKey {
  87361. /**
  87362. * Frame of the key frame
  87363. */
  87364. frame: number;
  87365. /**
  87366. * Value at the specifies key frame
  87367. */
  87368. value: any;
  87369. /**
  87370. * The input tangent for the cubic hermite spline
  87371. */
  87372. inTangent?: any;
  87373. /**
  87374. * The output tangent for the cubic hermite spline
  87375. */
  87376. outTangent?: any;
  87377. /**
  87378. * The animation interpolation type
  87379. */
  87380. interpolation?: AnimationKeyInterpolation;
  87381. }
  87382. /**
  87383. * Enum for the animation key frame interpolation type
  87384. */
  87385. export enum AnimationKeyInterpolation {
  87386. /**
  87387. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  87388. */
  87389. STEP = 1
  87390. }
  87391. }
  87392. declare module BABYLON {
  87393. /**
  87394. * Represents the range of an animation
  87395. */
  87396. export class AnimationRange {
  87397. /**The name of the animation range**/
  87398. name: string;
  87399. /**The starting frame of the animation */
  87400. from: number;
  87401. /**The ending frame of the animation*/
  87402. to: number;
  87403. /**
  87404. * Initializes the range of an animation
  87405. * @param name The name of the animation range
  87406. * @param from The starting frame of the animation
  87407. * @param to The ending frame of the animation
  87408. */
  87409. constructor(
  87410. /**The name of the animation range**/
  87411. name: string,
  87412. /**The starting frame of the animation */
  87413. from: number,
  87414. /**The ending frame of the animation*/
  87415. to: number);
  87416. /**
  87417. * Makes a copy of the animation range
  87418. * @returns A copy of the animation range
  87419. */
  87420. clone(): AnimationRange;
  87421. }
  87422. }
  87423. declare module BABYLON {
  87424. /**
  87425. * Composed of a frame, and an action function
  87426. */
  87427. export class AnimationEvent {
  87428. /** The frame for which the event is triggered **/
  87429. frame: number;
  87430. /** The event to perform when triggered **/
  87431. action: (currentFrame: number) => void;
  87432. /** Specifies if the event should be triggered only once**/
  87433. onlyOnce?: boolean | undefined;
  87434. /**
  87435. * Specifies if the animation event is done
  87436. */
  87437. isDone: boolean;
  87438. /**
  87439. * Initializes the animation event
  87440. * @param frame The frame for which the event is triggered
  87441. * @param action The event to perform when triggered
  87442. * @param onlyOnce Specifies if the event should be triggered only once
  87443. */
  87444. constructor(
  87445. /** The frame for which the event is triggered **/
  87446. frame: number,
  87447. /** The event to perform when triggered **/
  87448. action: (currentFrame: number) => void,
  87449. /** Specifies if the event should be triggered only once**/
  87450. onlyOnce?: boolean | undefined);
  87451. /** @hidden */
  87452. _clone(): AnimationEvent;
  87453. }
  87454. }
  87455. declare module BABYLON {
  87456. /**
  87457. * Interface used to define a behavior
  87458. */
  87459. export interface Behavior<T> {
  87460. /** gets or sets behavior's name */
  87461. name: string;
  87462. /**
  87463. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87464. */
  87465. init(): void;
  87466. /**
  87467. * Called when the behavior is attached to a target
  87468. * @param target defines the target where the behavior is attached to
  87469. */
  87470. attach(target: T): void;
  87471. /**
  87472. * Called when the behavior is detached from its target
  87473. */
  87474. detach(): void;
  87475. }
  87476. /**
  87477. * Interface implemented by classes supporting behaviors
  87478. */
  87479. export interface IBehaviorAware<T> {
  87480. /**
  87481. * Attach a behavior
  87482. * @param behavior defines the behavior to attach
  87483. * @returns the current host
  87484. */
  87485. addBehavior(behavior: Behavior<T>): T;
  87486. /**
  87487. * Remove a behavior from the current object
  87488. * @param behavior defines the behavior to detach
  87489. * @returns the current host
  87490. */
  87491. removeBehavior(behavior: Behavior<T>): T;
  87492. /**
  87493. * Gets a behavior using its name to search
  87494. * @param name defines the name to search
  87495. * @returns the behavior or null if not found
  87496. */
  87497. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87498. }
  87499. }
  87500. declare module BABYLON {
  87501. /**
  87502. * Defines an array and its length.
  87503. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87504. */
  87505. export interface ISmartArrayLike<T> {
  87506. /**
  87507. * The data of the array.
  87508. */
  87509. data: Array<T>;
  87510. /**
  87511. * The active length of the array.
  87512. */
  87513. length: number;
  87514. }
  87515. /**
  87516. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87517. */
  87518. export class SmartArray<T> implements ISmartArrayLike<T> {
  87519. /**
  87520. * The full set of data from the array.
  87521. */
  87522. data: Array<T>;
  87523. /**
  87524. * The active length of the array.
  87525. */
  87526. length: number;
  87527. protected _id: number;
  87528. /**
  87529. * Instantiates a Smart Array.
  87530. * @param capacity defines the default capacity of the array.
  87531. */
  87532. constructor(capacity: number);
  87533. /**
  87534. * Pushes a value at the end of the active data.
  87535. * @param value defines the object to push in the array.
  87536. */
  87537. push(value: T): void;
  87538. /**
  87539. * Iterates over the active data and apply the lambda to them.
  87540. * @param func defines the action to apply on each value.
  87541. */
  87542. forEach(func: (content: T) => void): void;
  87543. /**
  87544. * Sorts the full sets of data.
  87545. * @param compareFn defines the comparison function to apply.
  87546. */
  87547. sort(compareFn: (a: T, b: T) => number): void;
  87548. /**
  87549. * Resets the active data to an empty array.
  87550. */
  87551. reset(): void;
  87552. /**
  87553. * Releases all the data from the array as well as the array.
  87554. */
  87555. dispose(): void;
  87556. /**
  87557. * Concats the active data with a given array.
  87558. * @param array defines the data to concatenate with.
  87559. */
  87560. concat(array: any): void;
  87561. /**
  87562. * Returns the position of a value in the active data.
  87563. * @param value defines the value to find the index for
  87564. * @returns the index if found in the active data otherwise -1
  87565. */
  87566. indexOf(value: T): number;
  87567. /**
  87568. * Returns whether an element is part of the active data.
  87569. * @param value defines the value to look for
  87570. * @returns true if found in the active data otherwise false
  87571. */
  87572. contains(value: T): boolean;
  87573. private static _GlobalId;
  87574. }
  87575. /**
  87576. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87577. * The data in this array can only be present once
  87578. */
  87579. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87580. private _duplicateId;
  87581. /**
  87582. * Pushes a value at the end of the active data.
  87583. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87584. * @param value defines the object to push in the array.
  87585. */
  87586. push(value: T): void;
  87587. /**
  87588. * Pushes a value at the end of the active data.
  87589. * If the data is already present, it won t be added again
  87590. * @param value defines the object to push in the array.
  87591. * @returns true if added false if it was already present
  87592. */
  87593. pushNoDuplicate(value: T): boolean;
  87594. /**
  87595. * Resets the active data to an empty array.
  87596. */
  87597. reset(): void;
  87598. /**
  87599. * Concats the active data with a given array.
  87600. * This ensures no dupplicate will be present in the result.
  87601. * @param array defines the data to concatenate with.
  87602. */
  87603. concatWithNoDuplicate(array: any): void;
  87604. }
  87605. }
  87606. declare module BABYLON {
  87607. /**
  87608. * @ignore
  87609. * This is a list of all the different input types that are available in the application.
  87610. * Fo instance: ArcRotateCameraGamepadInput...
  87611. */
  87612. export var CameraInputTypes: {};
  87613. /**
  87614. * This is the contract to implement in order to create a new input class.
  87615. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87616. */
  87617. export interface ICameraInput<TCamera extends Camera> {
  87618. /**
  87619. * Defines the camera the input is attached to.
  87620. */
  87621. camera: Nullable<TCamera>;
  87622. /**
  87623. * Gets the class name of the current intput.
  87624. * @returns the class name
  87625. */
  87626. getClassName(): string;
  87627. /**
  87628. * Get the friendly name associated with the input class.
  87629. * @returns the input friendly name
  87630. */
  87631. getSimpleName(): string;
  87632. /**
  87633. * Attach the input controls to a specific dom element to get the input from.
  87634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87635. */
  87636. attachControl(noPreventDefault?: boolean): void;
  87637. /**
  87638. * Detach the current controls from the specified dom element.
  87639. */
  87640. detachControl(): void;
  87641. /**
  87642. * Update the current camera state depending on the inputs that have been used this frame.
  87643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87644. */
  87645. checkInputs?: () => void;
  87646. }
  87647. /**
  87648. * Represents a map of input types to input instance or input index to input instance.
  87649. */
  87650. export interface CameraInputsMap<TCamera extends Camera> {
  87651. /**
  87652. * Accessor to the input by input type.
  87653. */
  87654. [name: string]: ICameraInput<TCamera>;
  87655. /**
  87656. * Accessor to the input by input index.
  87657. */
  87658. [idx: number]: ICameraInput<TCamera>;
  87659. }
  87660. /**
  87661. * This represents the input manager used within a camera.
  87662. * It helps dealing with all the different kind of input attached to a camera.
  87663. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87664. */
  87665. export class CameraInputsManager<TCamera extends Camera> {
  87666. /**
  87667. * Defines the list of inputs attahed to the camera.
  87668. */
  87669. attached: CameraInputsMap<TCamera>;
  87670. /**
  87671. * Defines the dom element the camera is collecting inputs from.
  87672. * This is null if the controls have not been attached.
  87673. */
  87674. attachedToElement: boolean;
  87675. /**
  87676. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87677. */
  87678. noPreventDefault: boolean;
  87679. /**
  87680. * Defined the camera the input manager belongs to.
  87681. */
  87682. camera: TCamera;
  87683. /**
  87684. * Update the current camera state depending on the inputs that have been used this frame.
  87685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87686. */
  87687. checkInputs: () => void;
  87688. /**
  87689. * Instantiate a new Camera Input Manager.
  87690. * @param camera Defines the camera the input manager blongs to
  87691. */
  87692. constructor(camera: TCamera);
  87693. /**
  87694. * Add an input method to a camera
  87695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87696. * @param input camera input method
  87697. */
  87698. add(input: ICameraInput<TCamera>): void;
  87699. /**
  87700. * Remove a specific input method from a camera
  87701. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87702. * @param inputToRemove camera input method
  87703. */
  87704. remove(inputToRemove: ICameraInput<TCamera>): void;
  87705. /**
  87706. * Remove a specific input type from a camera
  87707. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87708. * @param inputType the type of the input to remove
  87709. */
  87710. removeByType(inputType: string): void;
  87711. private _addCheckInputs;
  87712. /**
  87713. * Attach the input controls to the currently attached dom element to listen the events from.
  87714. * @param input Defines the input to attach
  87715. */
  87716. attachInput(input: ICameraInput<TCamera>): void;
  87717. /**
  87718. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87719. * @param element Defines the dom element to collect the events from
  87720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87721. */
  87722. attachElement(noPreventDefault?: boolean): void;
  87723. /**
  87724. * Detach the current manager inputs controls from a specific dom element.
  87725. * @param element Defines the dom element to collect the events from
  87726. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87727. */
  87728. detachElement(disconnect?: boolean): void;
  87729. /**
  87730. * Rebuild the dynamic inputCheck function from the current list of
  87731. * defined inputs in the manager.
  87732. */
  87733. rebuildInputCheck(): void;
  87734. /**
  87735. * Remove all attached input methods from a camera
  87736. */
  87737. clear(): void;
  87738. /**
  87739. * Serialize the current input manager attached to a camera.
  87740. * This ensures than once parsed,
  87741. * the input associated to the camera will be identical to the current ones
  87742. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87743. */
  87744. serialize(serializedCamera: any): void;
  87745. /**
  87746. * Parses an input manager serialized JSON to restore the previous list of inputs
  87747. * and states associated to a camera.
  87748. * @param parsedCamera Defines the JSON to parse
  87749. */
  87750. parse(parsedCamera: any): void;
  87751. }
  87752. }
  87753. declare module BABYLON {
  87754. /**
  87755. * Class used to store data that will be store in GPU memory
  87756. */
  87757. export class Buffer {
  87758. private _engine;
  87759. private _buffer;
  87760. /** @hidden */
  87761. _data: Nullable<DataArray>;
  87762. private _updatable;
  87763. private _instanced;
  87764. private _divisor;
  87765. /**
  87766. * Gets the byte stride.
  87767. */
  87768. readonly byteStride: number;
  87769. /**
  87770. * Constructor
  87771. * @param engine the engine
  87772. * @param data the data to use for this buffer
  87773. * @param updatable whether the data is updatable
  87774. * @param stride the stride (optional)
  87775. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87776. * @param instanced whether the buffer is instanced (optional)
  87777. * @param useBytes set to true if the stride in in bytes (optional)
  87778. * @param divisor sets an optional divisor for instances (1 by default)
  87779. */
  87780. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87781. /**
  87782. * Create a new VertexBuffer based on the current buffer
  87783. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87784. * @param offset defines offset in the buffer (0 by default)
  87785. * @param size defines the size in floats of attributes (position is 3 for instance)
  87786. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87787. * @param instanced defines if the vertex buffer contains indexed data
  87788. * @param useBytes defines if the offset and stride are in bytes *
  87789. * @param divisor sets an optional divisor for instances (1 by default)
  87790. * @returns the new vertex buffer
  87791. */
  87792. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87793. /**
  87794. * Gets a boolean indicating if the Buffer is updatable?
  87795. * @returns true if the buffer is updatable
  87796. */
  87797. isUpdatable(): boolean;
  87798. /**
  87799. * Gets current buffer's data
  87800. * @returns a DataArray or null
  87801. */
  87802. getData(): Nullable<DataArray>;
  87803. /**
  87804. * Gets underlying native buffer
  87805. * @returns underlying native buffer
  87806. */
  87807. getBuffer(): Nullable<DataBuffer>;
  87808. /**
  87809. * Gets the stride in float32 units (i.e. byte stride / 4).
  87810. * May not be an integer if the byte stride is not divisible by 4.
  87811. * @returns the stride in float32 units
  87812. * @deprecated Please use byteStride instead.
  87813. */
  87814. getStrideSize(): number;
  87815. /**
  87816. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87817. * @param data defines the data to store
  87818. */
  87819. create(data?: Nullable<DataArray>): void;
  87820. /** @hidden */
  87821. _rebuild(): void;
  87822. /**
  87823. * Update current buffer data
  87824. * @param data defines the data to store
  87825. */
  87826. update(data: DataArray): void;
  87827. /**
  87828. * Updates the data directly.
  87829. * @param data the new data
  87830. * @param offset the new offset
  87831. * @param vertexCount the vertex count (optional)
  87832. * @param useBytes set to true if the offset is in bytes
  87833. */
  87834. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87835. /**
  87836. * Release all resources
  87837. */
  87838. dispose(): void;
  87839. }
  87840. /**
  87841. * Specialized buffer used to store vertex data
  87842. */
  87843. export class VertexBuffer {
  87844. /** @hidden */
  87845. _buffer: Buffer;
  87846. private _kind;
  87847. private _size;
  87848. private _ownsBuffer;
  87849. private _instanced;
  87850. private _instanceDivisor;
  87851. /**
  87852. * The byte type.
  87853. */
  87854. static readonly BYTE: number;
  87855. /**
  87856. * The unsigned byte type.
  87857. */
  87858. static readonly UNSIGNED_BYTE: number;
  87859. /**
  87860. * The short type.
  87861. */
  87862. static readonly SHORT: number;
  87863. /**
  87864. * The unsigned short type.
  87865. */
  87866. static readonly UNSIGNED_SHORT: number;
  87867. /**
  87868. * The integer type.
  87869. */
  87870. static readonly INT: number;
  87871. /**
  87872. * The unsigned integer type.
  87873. */
  87874. static readonly UNSIGNED_INT: number;
  87875. /**
  87876. * The float type.
  87877. */
  87878. static readonly FLOAT: number;
  87879. /**
  87880. * Gets or sets the instance divisor when in instanced mode
  87881. */
  87882. get instanceDivisor(): number;
  87883. set instanceDivisor(value: number);
  87884. /**
  87885. * Gets the byte stride.
  87886. */
  87887. readonly byteStride: number;
  87888. /**
  87889. * Gets the byte offset.
  87890. */
  87891. readonly byteOffset: number;
  87892. /**
  87893. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87894. */
  87895. readonly normalized: boolean;
  87896. /**
  87897. * Gets the data type of each component in the array.
  87898. */
  87899. readonly type: number;
  87900. /**
  87901. * Constructor
  87902. * @param engine the engine
  87903. * @param data the data to use for this vertex buffer
  87904. * @param kind the vertex buffer kind
  87905. * @param updatable whether the data is updatable
  87906. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87907. * @param stride the stride (optional)
  87908. * @param instanced whether the buffer is instanced (optional)
  87909. * @param offset the offset of the data (optional)
  87910. * @param size the number of components (optional)
  87911. * @param type the type of the component (optional)
  87912. * @param normalized whether the data contains normalized data (optional)
  87913. * @param useBytes set to true if stride and offset are in bytes (optional)
  87914. * @param divisor defines the instance divisor to use (1 by default)
  87915. */
  87916. 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);
  87917. /** @hidden */
  87918. _rebuild(): void;
  87919. /**
  87920. * Returns the kind of the VertexBuffer (string)
  87921. * @returns a string
  87922. */
  87923. getKind(): string;
  87924. /**
  87925. * Gets a boolean indicating if the VertexBuffer is updatable?
  87926. * @returns true if the buffer is updatable
  87927. */
  87928. isUpdatable(): boolean;
  87929. /**
  87930. * Gets current buffer's data
  87931. * @returns a DataArray or null
  87932. */
  87933. getData(): Nullable<DataArray>;
  87934. /**
  87935. * Gets underlying native buffer
  87936. * @returns underlying native buffer
  87937. */
  87938. getBuffer(): Nullable<DataBuffer>;
  87939. /**
  87940. * Gets the stride in float32 units (i.e. byte stride / 4).
  87941. * May not be an integer if the byte stride is not divisible by 4.
  87942. * @returns the stride in float32 units
  87943. * @deprecated Please use byteStride instead.
  87944. */
  87945. getStrideSize(): number;
  87946. /**
  87947. * Returns the offset as a multiple of the type byte length.
  87948. * @returns the offset in bytes
  87949. * @deprecated Please use byteOffset instead.
  87950. */
  87951. getOffset(): number;
  87952. /**
  87953. * Returns the number of components per vertex attribute (integer)
  87954. * @returns the size in float
  87955. */
  87956. getSize(): number;
  87957. /**
  87958. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87959. * @returns true if this buffer is instanced
  87960. */
  87961. getIsInstanced(): boolean;
  87962. /**
  87963. * Returns the instancing divisor, zero for non-instanced (integer).
  87964. * @returns a number
  87965. */
  87966. getInstanceDivisor(): number;
  87967. /**
  87968. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87969. * @param data defines the data to store
  87970. */
  87971. create(data?: DataArray): void;
  87972. /**
  87973. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87974. * This function will create a new buffer if the current one is not updatable
  87975. * @param data defines the data to store
  87976. */
  87977. update(data: DataArray): void;
  87978. /**
  87979. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87980. * Returns the directly updated WebGLBuffer.
  87981. * @param data the new data
  87982. * @param offset the new offset
  87983. * @param useBytes set to true if the offset is in bytes
  87984. */
  87985. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87986. /**
  87987. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87988. */
  87989. dispose(): void;
  87990. /**
  87991. * Enumerates each value of this vertex buffer as numbers.
  87992. * @param count the number of values to enumerate
  87993. * @param callback the callback function called for each value
  87994. */
  87995. forEach(count: number, callback: (value: number, index: number) => void): void;
  87996. /**
  87997. * Positions
  87998. */
  87999. static readonly PositionKind: string;
  88000. /**
  88001. * Normals
  88002. */
  88003. static readonly NormalKind: string;
  88004. /**
  88005. * Tangents
  88006. */
  88007. static readonly TangentKind: string;
  88008. /**
  88009. * Texture coordinates
  88010. */
  88011. static readonly UVKind: string;
  88012. /**
  88013. * Texture coordinates 2
  88014. */
  88015. static readonly UV2Kind: string;
  88016. /**
  88017. * Texture coordinates 3
  88018. */
  88019. static readonly UV3Kind: string;
  88020. /**
  88021. * Texture coordinates 4
  88022. */
  88023. static readonly UV4Kind: string;
  88024. /**
  88025. * Texture coordinates 5
  88026. */
  88027. static readonly UV5Kind: string;
  88028. /**
  88029. * Texture coordinates 6
  88030. */
  88031. static readonly UV6Kind: string;
  88032. /**
  88033. * Colors
  88034. */
  88035. static readonly ColorKind: string;
  88036. /**
  88037. * Matrix indices (for bones)
  88038. */
  88039. static readonly MatricesIndicesKind: string;
  88040. /**
  88041. * Matrix weights (for bones)
  88042. */
  88043. static readonly MatricesWeightsKind: string;
  88044. /**
  88045. * Additional matrix indices (for bones)
  88046. */
  88047. static readonly MatricesIndicesExtraKind: string;
  88048. /**
  88049. * Additional matrix weights (for bones)
  88050. */
  88051. static readonly MatricesWeightsExtraKind: string;
  88052. /**
  88053. * Deduces the stride given a kind.
  88054. * @param kind The kind string to deduce
  88055. * @returns The deduced stride
  88056. */
  88057. static DeduceStride(kind: string): number;
  88058. /**
  88059. * Gets the byte length of the given type.
  88060. * @param type the type
  88061. * @returns the number of bytes
  88062. */
  88063. static GetTypeByteLength(type: number): number;
  88064. /**
  88065. * Enumerates each value of the given parameters as numbers.
  88066. * @param data the data to enumerate
  88067. * @param byteOffset the byte offset of the data
  88068. * @param byteStride the byte stride of the data
  88069. * @param componentCount the number of components per element
  88070. * @param componentType the type of the component
  88071. * @param count the number of values to enumerate
  88072. * @param normalized whether the data is normalized
  88073. * @param callback the callback function called for each value
  88074. */
  88075. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88076. private static _GetFloatValue;
  88077. }
  88078. }
  88079. declare module BABYLON {
  88080. /**
  88081. * The options Interface for creating a Capsule Mesh
  88082. */
  88083. export interface ICreateCapsuleOptions {
  88084. /** The Orientation of the capsule. Default : Vector3.Up() */
  88085. orientation?: Vector3;
  88086. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  88087. subdivisions: number;
  88088. /** Number of cylindrical segments on the capsule. */
  88089. tessellation: number;
  88090. /** Height or Length of the capsule. */
  88091. height: number;
  88092. /** Radius of the capsule. */
  88093. radius: number;
  88094. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  88095. capSubdivisions: number;
  88096. /** Overwrite for the top radius. */
  88097. radiusTop?: number;
  88098. /** Overwrite for the bottom radius. */
  88099. radiusBottom?: number;
  88100. /** Overwrite for the top capSubdivisions. */
  88101. topCapSubdivisions?: number;
  88102. /** Overwrite for the bottom capSubdivisions. */
  88103. bottomCapSubdivisions?: number;
  88104. }
  88105. /**
  88106. * Class containing static functions to help procedurally build meshes
  88107. */
  88108. export class CapsuleBuilder {
  88109. /**
  88110. * Creates a capsule or a pill mesh
  88111. * @param name defines the name of the mesh
  88112. * @param options The constructors options.
  88113. * @param scene The scene the mesh is scoped to.
  88114. * @returns Capsule Mesh
  88115. */
  88116. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  88117. }
  88118. }
  88119. declare module BABYLON {
  88120. /**
  88121. * @hidden
  88122. */
  88123. export class IntersectionInfo {
  88124. bu: Nullable<number>;
  88125. bv: Nullable<number>;
  88126. distance: number;
  88127. faceId: number;
  88128. subMeshId: number;
  88129. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88130. }
  88131. }
  88132. declare module BABYLON {
  88133. /**
  88134. * Class used to store bounding sphere information
  88135. */
  88136. export class BoundingSphere {
  88137. /**
  88138. * Gets the center of the bounding sphere in local space
  88139. */
  88140. readonly center: Vector3;
  88141. /**
  88142. * Radius of the bounding sphere in local space
  88143. */
  88144. radius: number;
  88145. /**
  88146. * Gets the center of the bounding sphere in world space
  88147. */
  88148. readonly centerWorld: Vector3;
  88149. /**
  88150. * Radius of the bounding sphere in world space
  88151. */
  88152. radiusWorld: number;
  88153. /**
  88154. * Gets the minimum vector in local space
  88155. */
  88156. readonly minimum: Vector3;
  88157. /**
  88158. * Gets the maximum vector in local space
  88159. */
  88160. readonly maximum: Vector3;
  88161. private _worldMatrix;
  88162. private static readonly TmpVector3;
  88163. /**
  88164. * Creates a new bounding sphere
  88165. * @param min defines the minimum vector (in local space)
  88166. * @param max defines the maximum vector (in local space)
  88167. * @param worldMatrix defines the new world matrix
  88168. */
  88169. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88170. /**
  88171. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88172. * @param min defines the new minimum vector (in local space)
  88173. * @param max defines the new maximum vector (in local space)
  88174. * @param worldMatrix defines the new world matrix
  88175. */
  88176. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88177. /**
  88178. * Scale the current bounding sphere by applying a scale factor
  88179. * @param factor defines the scale factor to apply
  88180. * @returns the current bounding box
  88181. */
  88182. scale(factor: number): BoundingSphere;
  88183. /**
  88184. * Gets the world matrix of the bounding box
  88185. * @returns a matrix
  88186. */
  88187. getWorldMatrix(): DeepImmutable<Matrix>;
  88188. /** @hidden */
  88189. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88190. /**
  88191. * Tests if the bounding sphere is intersecting the frustum planes
  88192. * @param frustumPlanes defines the frustum planes to test
  88193. * @returns true if there is an intersection
  88194. */
  88195. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88196. /**
  88197. * Tests if the bounding sphere center is in between the frustum planes.
  88198. * Used for optimistic fast inclusion.
  88199. * @param frustumPlanes defines the frustum planes to test
  88200. * @returns true if the sphere center is in between the frustum planes
  88201. */
  88202. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88203. /**
  88204. * Tests if a point is inside the bounding sphere
  88205. * @param point defines the point to test
  88206. * @returns true if the point is inside the bounding sphere
  88207. */
  88208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88209. /**
  88210. * Checks if two sphere intersct
  88211. * @param sphere0 sphere 0
  88212. * @param sphere1 sphere 1
  88213. * @returns true if the speres intersect
  88214. */
  88215. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88216. }
  88217. }
  88218. declare module BABYLON {
  88219. /**
  88220. * Class used to store bounding box information
  88221. */
  88222. export class BoundingBox implements ICullable {
  88223. /**
  88224. * Gets the 8 vectors representing the bounding box in local space
  88225. */
  88226. readonly vectors: Vector3[];
  88227. /**
  88228. * Gets the center of the bounding box in local space
  88229. */
  88230. readonly center: Vector3;
  88231. /**
  88232. * Gets the center of the bounding box in world space
  88233. */
  88234. readonly centerWorld: Vector3;
  88235. /**
  88236. * Gets the extend size in local space
  88237. */
  88238. readonly extendSize: Vector3;
  88239. /**
  88240. * Gets the extend size in world space
  88241. */
  88242. readonly extendSizeWorld: Vector3;
  88243. /**
  88244. * Gets the OBB (object bounding box) directions
  88245. */
  88246. readonly directions: Vector3[];
  88247. /**
  88248. * Gets the 8 vectors representing the bounding box in world space
  88249. */
  88250. readonly vectorsWorld: Vector3[];
  88251. /**
  88252. * Gets the minimum vector in world space
  88253. */
  88254. readonly minimumWorld: Vector3;
  88255. /**
  88256. * Gets the maximum vector in world space
  88257. */
  88258. readonly maximumWorld: Vector3;
  88259. /**
  88260. * Gets the minimum vector in local space
  88261. */
  88262. readonly minimum: Vector3;
  88263. /**
  88264. * Gets the maximum vector in local space
  88265. */
  88266. readonly maximum: Vector3;
  88267. private _worldMatrix;
  88268. private static readonly TmpVector3;
  88269. /**
  88270. * @hidden
  88271. */
  88272. _tag: number;
  88273. /**
  88274. * Creates a new bounding box
  88275. * @param min defines the minimum vector (in local space)
  88276. * @param max defines the maximum vector (in local space)
  88277. * @param worldMatrix defines the new world matrix
  88278. */
  88279. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88280. /**
  88281. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88282. * @param min defines the new minimum vector (in local space)
  88283. * @param max defines the new maximum vector (in local space)
  88284. * @param worldMatrix defines the new world matrix
  88285. */
  88286. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88287. /**
  88288. * Scale the current bounding box by applying a scale factor
  88289. * @param factor defines the scale factor to apply
  88290. * @returns the current bounding box
  88291. */
  88292. scale(factor: number): BoundingBox;
  88293. /**
  88294. * Gets the world matrix of the bounding box
  88295. * @returns a matrix
  88296. */
  88297. getWorldMatrix(): DeepImmutable<Matrix>;
  88298. /** @hidden */
  88299. _update(world: DeepImmutable<Matrix>): void;
  88300. /**
  88301. * Tests if the bounding box is intersecting the frustum planes
  88302. * @param frustumPlanes defines the frustum planes to test
  88303. * @returns true if there is an intersection
  88304. */
  88305. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88306. /**
  88307. * Tests if the bounding box is entirely inside the frustum planes
  88308. * @param frustumPlanes defines the frustum planes to test
  88309. * @returns true if there is an inclusion
  88310. */
  88311. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88312. /**
  88313. * Tests if a point is inside the bounding box
  88314. * @param point defines the point to test
  88315. * @returns true if the point is inside the bounding box
  88316. */
  88317. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88318. /**
  88319. * Tests if the bounding box intersects with a bounding sphere
  88320. * @param sphere defines the sphere to test
  88321. * @returns true if there is an intersection
  88322. */
  88323. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88324. /**
  88325. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88326. * @param min defines the min vector to use
  88327. * @param max defines the max vector to use
  88328. * @returns true if there is an intersection
  88329. */
  88330. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88331. /**
  88332. * Tests if two bounding boxes are intersections
  88333. * @param box0 defines the first box to test
  88334. * @param box1 defines the second box to test
  88335. * @returns true if there is an intersection
  88336. */
  88337. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88338. /**
  88339. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88340. * @param minPoint defines the minimum vector of the bounding box
  88341. * @param maxPoint defines the maximum vector of the bounding box
  88342. * @param sphereCenter defines the sphere center
  88343. * @param sphereRadius defines the sphere radius
  88344. * @returns true if there is an intersection
  88345. */
  88346. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88347. /**
  88348. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88349. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88350. * @param frustumPlanes defines the frustum planes to test
  88351. * @return true if there is an inclusion
  88352. */
  88353. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88354. /**
  88355. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88356. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88357. * @param frustumPlanes defines the frustum planes to test
  88358. * @return true if there is an intersection
  88359. */
  88360. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88361. }
  88362. }
  88363. declare module BABYLON {
  88364. /** @hidden */
  88365. export class Collider {
  88366. /** Define if a collision was found */
  88367. collisionFound: boolean;
  88368. /**
  88369. * Define last intersection point in local space
  88370. */
  88371. intersectionPoint: Vector3;
  88372. /**
  88373. * Define last collided mesh
  88374. */
  88375. collidedMesh: Nullable<AbstractMesh>;
  88376. private _collisionPoint;
  88377. private _planeIntersectionPoint;
  88378. private _tempVector;
  88379. private _tempVector2;
  88380. private _tempVector3;
  88381. private _tempVector4;
  88382. private _edge;
  88383. private _baseToVertex;
  88384. private _destinationPoint;
  88385. private _slidePlaneNormal;
  88386. private _displacementVector;
  88387. /** @hidden */
  88388. _radius: Vector3;
  88389. /** @hidden */
  88390. _retry: number;
  88391. private _velocity;
  88392. private _basePoint;
  88393. private _epsilon;
  88394. /** @hidden */
  88395. _velocityWorldLength: number;
  88396. /** @hidden */
  88397. _basePointWorld: Vector3;
  88398. private _velocityWorld;
  88399. private _normalizedVelocity;
  88400. /** @hidden */
  88401. _initialVelocity: Vector3;
  88402. /** @hidden */
  88403. _initialPosition: Vector3;
  88404. private _nearestDistance;
  88405. private _collisionMask;
  88406. get collisionMask(): number;
  88407. set collisionMask(mask: number);
  88408. /**
  88409. * Gets the plane normal used to compute the sliding response (in local space)
  88410. */
  88411. get slidePlaneNormal(): Vector3;
  88412. /** @hidden */
  88413. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88414. /** @hidden */
  88415. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88416. /** @hidden */
  88417. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88418. /** @hidden */
  88419. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88420. /** @hidden */
  88421. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88422. /** @hidden */
  88423. _getResponse(pos: Vector3, vel: Vector3): void;
  88424. }
  88425. }
  88426. declare module BABYLON {
  88427. /**
  88428. * Interface for cullable objects
  88429. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88430. */
  88431. export interface ICullable {
  88432. /**
  88433. * Checks if the object or part of the object is in the frustum
  88434. * @param frustumPlanes Camera near/planes
  88435. * @returns true if the object is in frustum otherwise false
  88436. */
  88437. isInFrustum(frustumPlanes: Plane[]): boolean;
  88438. /**
  88439. * Checks if a cullable object (mesh...) is in the camera frustum
  88440. * Unlike isInFrustum this cheks the full bounding box
  88441. * @param frustumPlanes Camera near/planes
  88442. * @returns true if the object is in frustum otherwise false
  88443. */
  88444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88445. }
  88446. /**
  88447. * Info for a bounding data of a mesh
  88448. */
  88449. export class BoundingInfo implements ICullable {
  88450. /**
  88451. * Bounding box for the mesh
  88452. */
  88453. readonly boundingBox: BoundingBox;
  88454. /**
  88455. * Bounding sphere for the mesh
  88456. */
  88457. readonly boundingSphere: BoundingSphere;
  88458. private _isLocked;
  88459. private static readonly TmpVector3;
  88460. /**
  88461. * Constructs bounding info
  88462. * @param minimum min vector of the bounding box/sphere
  88463. * @param maximum max vector of the bounding box/sphere
  88464. * @param worldMatrix defines the new world matrix
  88465. */
  88466. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88467. /**
  88468. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88469. * @param min defines the new minimum vector (in local space)
  88470. * @param max defines the new maximum vector (in local space)
  88471. * @param worldMatrix defines the new world matrix
  88472. */
  88473. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88474. /**
  88475. * min vector of the bounding box/sphere
  88476. */
  88477. get minimum(): Vector3;
  88478. /**
  88479. * max vector of the bounding box/sphere
  88480. */
  88481. get maximum(): Vector3;
  88482. /**
  88483. * If the info is locked and won't be updated to avoid perf overhead
  88484. */
  88485. get isLocked(): boolean;
  88486. set isLocked(value: boolean);
  88487. /**
  88488. * Updates the bounding sphere and box
  88489. * @param world world matrix to be used to update
  88490. */
  88491. update(world: DeepImmutable<Matrix>): void;
  88492. /**
  88493. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88494. * @param center New center of the bounding info
  88495. * @param extend New extend of the bounding info
  88496. * @returns the current bounding info
  88497. */
  88498. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88499. /**
  88500. * Scale the current bounding info by applying a scale factor
  88501. * @param factor defines the scale factor to apply
  88502. * @returns the current bounding info
  88503. */
  88504. scale(factor: number): BoundingInfo;
  88505. /**
  88506. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88507. * @param frustumPlanes defines the frustum to test
  88508. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88509. * @returns true if the bounding info is in the frustum planes
  88510. */
  88511. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88512. /**
  88513. * Gets the world distance between the min and max points of the bounding box
  88514. */
  88515. get diagonalLength(): number;
  88516. /**
  88517. * Checks if a cullable object (mesh...) is in the camera frustum
  88518. * Unlike isInFrustum this cheks the full bounding box
  88519. * @param frustumPlanes Camera near/planes
  88520. * @returns true if the object is in frustum otherwise false
  88521. */
  88522. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88523. /** @hidden */
  88524. _checkCollision(collider: Collider): boolean;
  88525. /**
  88526. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88527. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88528. * @param point the point to check intersection with
  88529. * @returns if the point intersects
  88530. */
  88531. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88532. /**
  88533. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88534. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88535. * @param boundingInfo the bounding info to check intersection with
  88536. * @param precise if the intersection should be done using OBB
  88537. * @returns if the bounding info intersects
  88538. */
  88539. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88540. }
  88541. }
  88542. declare module BABYLON {
  88543. /**
  88544. * Extracts minimum and maximum values from a list of indexed positions
  88545. * @param positions defines the positions to use
  88546. * @param indices defines the indices to the positions
  88547. * @param indexStart defines the start index
  88548. * @param indexCount defines the end index
  88549. * @param bias defines bias value to add to the result
  88550. * @return minimum and maximum values
  88551. */
  88552. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88553. minimum: Vector3;
  88554. maximum: Vector3;
  88555. };
  88556. /**
  88557. * Extracts minimum and maximum values from a list of positions
  88558. * @param positions defines the positions to use
  88559. * @param start defines the start index in the positions array
  88560. * @param count defines the number of positions to handle
  88561. * @param bias defines bias value to add to the result
  88562. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88563. * @return minimum and maximum values
  88564. */
  88565. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88566. minimum: Vector3;
  88567. maximum: Vector3;
  88568. };
  88569. }
  88570. declare module BABYLON {
  88571. /** @hidden */
  88572. export class WebGLDataBuffer extends DataBuffer {
  88573. private _buffer;
  88574. constructor(resource: WebGLBuffer);
  88575. get underlyingResource(): any;
  88576. }
  88577. }
  88578. declare module BABYLON {
  88579. /** @hidden */
  88580. export class WebGLPipelineContext implements IPipelineContext {
  88581. engine: ThinEngine;
  88582. program: Nullable<WebGLProgram>;
  88583. context?: WebGLRenderingContext;
  88584. vertexShader?: WebGLShader;
  88585. fragmentShader?: WebGLShader;
  88586. isParallelCompiled: boolean;
  88587. onCompiled?: () => void;
  88588. transformFeedback?: WebGLTransformFeedback | null;
  88589. vertexCompilationError: Nullable<string>;
  88590. fragmentCompilationError: Nullable<string>;
  88591. programLinkError: Nullable<string>;
  88592. programValidationError: Nullable<string>;
  88593. get isAsync(): boolean;
  88594. get isReady(): boolean;
  88595. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88596. _getVertexShaderCode(): string | null;
  88597. _getFragmentShaderCode(): string | null;
  88598. }
  88599. }
  88600. declare module BABYLON {
  88601. interface ThinEngine {
  88602. /**
  88603. * Create an uniform buffer
  88604. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88605. * @param elements defines the content of the uniform buffer
  88606. * @returns the webGL uniform buffer
  88607. */
  88608. createUniformBuffer(elements: FloatArray): DataBuffer;
  88609. /**
  88610. * Create a dynamic uniform buffer
  88611. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88612. * @param elements defines the content of the uniform buffer
  88613. * @returns the webGL uniform buffer
  88614. */
  88615. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88616. /**
  88617. * Update an existing uniform buffer
  88618. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88619. * @param uniformBuffer defines the target uniform buffer
  88620. * @param elements defines the content to update
  88621. * @param offset defines the offset in the uniform buffer where update should start
  88622. * @param count defines the size of the data to update
  88623. */
  88624. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88625. /**
  88626. * Bind an uniform buffer to the current webGL context
  88627. * @param buffer defines the buffer to bind
  88628. */
  88629. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88630. /**
  88631. * Bind a buffer to the current webGL context at a given location
  88632. * @param buffer defines the buffer to bind
  88633. * @param location defines the index where to bind the buffer
  88634. */
  88635. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88636. /**
  88637. * Bind a specific block at a given index in a specific shader program
  88638. * @param pipelineContext defines the pipeline context to use
  88639. * @param blockName defines the block name
  88640. * @param index defines the index where to bind the block
  88641. */
  88642. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88643. }
  88644. }
  88645. declare module BABYLON {
  88646. /**
  88647. * Uniform buffer objects.
  88648. *
  88649. * Handles blocks of uniform on the GPU.
  88650. *
  88651. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88652. *
  88653. * For more information, please refer to :
  88654. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88655. */
  88656. export class UniformBuffer {
  88657. private _engine;
  88658. private _buffer;
  88659. private _data;
  88660. private _bufferData;
  88661. private _dynamic?;
  88662. private _uniformLocations;
  88663. private _uniformSizes;
  88664. private _uniformLocationPointer;
  88665. private _needSync;
  88666. private _noUBO;
  88667. private _currentEffect;
  88668. /** @hidden */
  88669. _alreadyBound: boolean;
  88670. private static _MAX_UNIFORM_SIZE;
  88671. private static _tempBuffer;
  88672. /**
  88673. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88674. * This is dynamic to allow compat with webgl 1 and 2.
  88675. * You will need to pass the name of the uniform as well as the value.
  88676. */
  88677. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88678. /**
  88679. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88680. * This is dynamic to allow compat with webgl 1 and 2.
  88681. * You will need to pass the name of the uniform as well as the value.
  88682. */
  88683. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88684. /**
  88685. * Lambda to Update a single float in a uniform buffer.
  88686. * This is dynamic to allow compat with webgl 1 and 2.
  88687. * You will need to pass the name of the uniform as well as the value.
  88688. */
  88689. updateFloat: (name: string, x: number) => void;
  88690. /**
  88691. * Lambda to Update a vec2 of float in a uniform buffer.
  88692. * This is dynamic to allow compat with webgl 1 and 2.
  88693. * You will need to pass the name of the uniform as well as the value.
  88694. */
  88695. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88696. /**
  88697. * Lambda to Update a vec3 of float in a uniform buffer.
  88698. * This is dynamic to allow compat with webgl 1 and 2.
  88699. * You will need to pass the name of the uniform as well as the value.
  88700. */
  88701. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88702. /**
  88703. * Lambda to Update a vec4 of float in a uniform buffer.
  88704. * This is dynamic to allow compat with webgl 1 and 2.
  88705. * You will need to pass the name of the uniform as well as the value.
  88706. */
  88707. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88708. /**
  88709. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88710. * This is dynamic to allow compat with webgl 1 and 2.
  88711. * You will need to pass the name of the uniform as well as the value.
  88712. */
  88713. updateMatrix: (name: string, mat: Matrix) => void;
  88714. /**
  88715. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88716. * This is dynamic to allow compat with webgl 1 and 2.
  88717. * You will need to pass the name of the uniform as well as the value.
  88718. */
  88719. updateVector3: (name: string, vector: Vector3) => void;
  88720. /**
  88721. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88722. * This is dynamic to allow compat with webgl 1 and 2.
  88723. * You will need to pass the name of the uniform as well as the value.
  88724. */
  88725. updateVector4: (name: string, vector: Vector4) => void;
  88726. /**
  88727. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88728. * This is dynamic to allow compat with webgl 1 and 2.
  88729. * You will need to pass the name of the uniform as well as the value.
  88730. */
  88731. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88732. /**
  88733. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88734. * This is dynamic to allow compat with webgl 1 and 2.
  88735. * You will need to pass the name of the uniform as well as the value.
  88736. */
  88737. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88738. /**
  88739. * Instantiates a new Uniform buffer objects.
  88740. *
  88741. * Handles blocks of uniform on the GPU.
  88742. *
  88743. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88744. *
  88745. * For more information, please refer to :
  88746. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88747. * @param engine Define the engine the buffer is associated with
  88748. * @param data Define the data contained in the buffer
  88749. * @param dynamic Define if the buffer is updatable
  88750. */
  88751. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88752. /**
  88753. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88754. * or just falling back on setUniformXXX calls.
  88755. */
  88756. get useUbo(): boolean;
  88757. /**
  88758. * Indicates if the WebGL underlying uniform buffer is in sync
  88759. * with the javascript cache data.
  88760. */
  88761. get isSync(): boolean;
  88762. /**
  88763. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88764. * Also, a dynamic UniformBuffer will disable cache verification and always
  88765. * update the underlying WebGL uniform buffer to the GPU.
  88766. * @returns if Dynamic, otherwise false
  88767. */
  88768. isDynamic(): boolean;
  88769. /**
  88770. * The data cache on JS side.
  88771. * @returns the underlying data as a float array
  88772. */
  88773. getData(): Float32Array;
  88774. /**
  88775. * The underlying WebGL Uniform buffer.
  88776. * @returns the webgl buffer
  88777. */
  88778. getBuffer(): Nullable<DataBuffer>;
  88779. /**
  88780. * std140 layout specifies how to align data within an UBO structure.
  88781. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88782. * for specs.
  88783. */
  88784. private _fillAlignment;
  88785. /**
  88786. * Adds an uniform in the buffer.
  88787. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88788. * for the layout to be correct !
  88789. * @param name Name of the uniform, as used in the uniform block in the shader.
  88790. * @param size Data size, or data directly.
  88791. */
  88792. addUniform(name: string, size: number | number[]): void;
  88793. /**
  88794. * Adds a Matrix 4x4 to the uniform buffer.
  88795. * @param name Name of the uniform, as used in the uniform block in the shader.
  88796. * @param mat A 4x4 matrix.
  88797. */
  88798. addMatrix(name: string, mat: Matrix): void;
  88799. /**
  88800. * Adds a vec2 to the uniform buffer.
  88801. * @param name Name of the uniform, as used in the uniform block in the shader.
  88802. * @param x Define the x component value of the vec2
  88803. * @param y Define the y component value of the vec2
  88804. */
  88805. addFloat2(name: string, x: number, y: number): void;
  88806. /**
  88807. * Adds a vec3 to the uniform buffer.
  88808. * @param name Name of the uniform, as used in the uniform block in the shader.
  88809. * @param x Define the x component value of the vec3
  88810. * @param y Define the y component value of the vec3
  88811. * @param z Define the z component value of the vec3
  88812. */
  88813. addFloat3(name: string, x: number, y: number, z: number): void;
  88814. /**
  88815. * Adds a vec3 to the uniform buffer.
  88816. * @param name Name of the uniform, as used in the uniform block in the shader.
  88817. * @param color Define the vec3 from a Color
  88818. */
  88819. addColor3(name: string, color: Color3): void;
  88820. /**
  88821. * Adds a vec4 to the uniform buffer.
  88822. * @param name Name of the uniform, as used in the uniform block in the shader.
  88823. * @param color Define the rgb components from a Color
  88824. * @param alpha Define the a component of the vec4
  88825. */
  88826. addColor4(name: string, color: Color3, alpha: number): void;
  88827. /**
  88828. * Adds a vec3 to the uniform buffer.
  88829. * @param name Name of the uniform, as used in the uniform block in the shader.
  88830. * @param vector Define the vec3 components from a Vector
  88831. */
  88832. addVector3(name: string, vector: Vector3): void;
  88833. /**
  88834. * Adds a Matrix 3x3 to the uniform buffer.
  88835. * @param name Name of the uniform, as used in the uniform block in the shader.
  88836. */
  88837. addMatrix3x3(name: string): void;
  88838. /**
  88839. * Adds a Matrix 2x2 to the uniform buffer.
  88840. * @param name Name of the uniform, as used in the uniform block in the shader.
  88841. */
  88842. addMatrix2x2(name: string): void;
  88843. /**
  88844. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88845. */
  88846. create(): void;
  88847. /** @hidden */
  88848. _rebuild(): void;
  88849. /**
  88850. * Updates the WebGL Uniform Buffer on the GPU.
  88851. * If the `dynamic` flag is set to true, no cache comparison is done.
  88852. * Otherwise, the buffer will be updated only if the cache differs.
  88853. */
  88854. update(): void;
  88855. /**
  88856. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88857. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88858. * @param data Define the flattened data
  88859. * @param size Define the size of the data.
  88860. */
  88861. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88862. private _valueCache;
  88863. private _cacheMatrix;
  88864. private _updateMatrix3x3ForUniform;
  88865. private _updateMatrix3x3ForEffect;
  88866. private _updateMatrix2x2ForEffect;
  88867. private _updateMatrix2x2ForUniform;
  88868. private _updateFloatForEffect;
  88869. private _updateFloatForUniform;
  88870. private _updateFloat2ForEffect;
  88871. private _updateFloat2ForUniform;
  88872. private _updateFloat3ForEffect;
  88873. private _updateFloat3ForUniform;
  88874. private _updateFloat4ForEffect;
  88875. private _updateFloat4ForUniform;
  88876. private _updateMatrixForEffect;
  88877. private _updateMatrixForUniform;
  88878. private _updateVector3ForEffect;
  88879. private _updateVector3ForUniform;
  88880. private _updateVector4ForEffect;
  88881. private _updateVector4ForUniform;
  88882. private _updateColor3ForEffect;
  88883. private _updateColor3ForUniform;
  88884. private _updateColor4ForEffect;
  88885. private _updateColor4ForUniform;
  88886. /**
  88887. * Sets a sampler uniform on the effect.
  88888. * @param name Define the name of the sampler.
  88889. * @param texture Define the texture to set in the sampler
  88890. */
  88891. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88892. /**
  88893. * Directly updates the value of the uniform in the cache AND on the GPU.
  88894. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88895. * @param data Define the flattened data
  88896. */
  88897. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88898. /**
  88899. * Binds this uniform buffer to an effect.
  88900. * @param effect Define the effect to bind the buffer to
  88901. * @param name Name of the uniform block in the shader.
  88902. */
  88903. bindToEffect(effect: Effect, name: string): void;
  88904. /**
  88905. * Disposes the uniform buffer.
  88906. */
  88907. dispose(): void;
  88908. }
  88909. }
  88910. declare module BABYLON {
  88911. /**
  88912. * Enum that determines the text-wrapping mode to use.
  88913. */
  88914. export enum InspectableType {
  88915. /**
  88916. * Checkbox for booleans
  88917. */
  88918. Checkbox = 0,
  88919. /**
  88920. * Sliders for numbers
  88921. */
  88922. Slider = 1,
  88923. /**
  88924. * Vector3
  88925. */
  88926. Vector3 = 2,
  88927. /**
  88928. * Quaternions
  88929. */
  88930. Quaternion = 3,
  88931. /**
  88932. * Color3
  88933. */
  88934. Color3 = 4,
  88935. /**
  88936. * String
  88937. */
  88938. String = 5
  88939. }
  88940. /**
  88941. * Interface used to define custom inspectable properties.
  88942. * This interface is used by the inspector to display custom property grids
  88943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88944. */
  88945. export interface IInspectable {
  88946. /**
  88947. * Gets the label to display
  88948. */
  88949. label: string;
  88950. /**
  88951. * Gets the name of the property to edit
  88952. */
  88953. propertyName: string;
  88954. /**
  88955. * Gets the type of the editor to use
  88956. */
  88957. type: InspectableType;
  88958. /**
  88959. * Gets the minimum value of the property when using in "slider" mode
  88960. */
  88961. min?: number;
  88962. /**
  88963. * Gets the maximum value of the property when using in "slider" mode
  88964. */
  88965. max?: number;
  88966. /**
  88967. * Gets the setp to use when using in "slider" mode
  88968. */
  88969. step?: number;
  88970. }
  88971. }
  88972. declare module BABYLON {
  88973. /**
  88974. * Class used to provide helper for timing
  88975. */
  88976. export class TimingTools {
  88977. /**
  88978. * Polyfill for setImmediate
  88979. * @param action defines the action to execute after the current execution block
  88980. */
  88981. static SetImmediate(action: () => void): void;
  88982. }
  88983. }
  88984. declare module BABYLON {
  88985. /**
  88986. * Class used to enable instatition of objects by class name
  88987. */
  88988. export class InstantiationTools {
  88989. /**
  88990. * Use this object to register external classes like custom textures or material
  88991. * to allow the laoders to instantiate them
  88992. */
  88993. static RegisteredExternalClasses: {
  88994. [key: string]: Object;
  88995. };
  88996. /**
  88997. * Tries to instantiate a new object from a given class name
  88998. * @param className defines the class name to instantiate
  88999. * @returns the new object or null if the system was not able to do the instantiation
  89000. */
  89001. static Instantiate(className: string): any;
  89002. }
  89003. }
  89004. declare module BABYLON {
  89005. /**
  89006. * Class used to host copy specific utilities
  89007. */
  89008. export class CopyTools {
  89009. /**
  89010. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  89011. * @param texture defines the texture to read pixels from
  89012. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89013. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89014. * @returns The base64 encoded string or null
  89015. */
  89016. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  89017. }
  89018. }
  89019. declare module BABYLON {
  89020. /**
  89021. * Define options used to create a depth texture
  89022. */
  89023. export class DepthTextureCreationOptions {
  89024. /** Specifies whether or not a stencil should be allocated in the texture */
  89025. generateStencil?: boolean;
  89026. /** Specifies whether or not bilinear filtering is enable on the texture */
  89027. bilinearFiltering?: boolean;
  89028. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89029. comparisonFunction?: number;
  89030. /** Specifies if the created texture is a cube texture */
  89031. isCube?: boolean;
  89032. }
  89033. }
  89034. declare module BABYLON {
  89035. interface ThinEngine {
  89036. /**
  89037. * Creates a depth stencil cube texture.
  89038. * This is only available in WebGL 2.
  89039. * @param size The size of face edge in the cube texture.
  89040. * @param options The options defining the cube texture.
  89041. * @returns The cube texture
  89042. */
  89043. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  89044. /**
  89045. * Creates a cube texture
  89046. * @param rootUrl defines the url where the files to load is located
  89047. * @param scene defines the current scene
  89048. * @param files defines the list of files to load (1 per face)
  89049. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  89050. * @param onLoad defines an optional callback raised when the texture is loaded
  89051. * @param onError defines an optional callback raised if there is an issue to load the texture
  89052. * @param format defines the format of the data
  89053. * @param forcedExtension defines the extension to use to pick the right loader
  89054. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  89055. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89056. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89057. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  89058. * @param loaderOptions options to be passed to the loader
  89059. * @returns the cube texture as an InternalTexture
  89060. */
  89061. 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;
  89062. /**
  89063. * Creates a cube texture
  89064. * @param rootUrl defines the url where the files to load is located
  89065. * @param scene defines the current scene
  89066. * @param files defines the list of files to load (1 per face)
  89067. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  89068. * @param onLoad defines an optional callback raised when the texture is loaded
  89069. * @param onError defines an optional callback raised if there is an issue to load the texture
  89070. * @param format defines the format of the data
  89071. * @param forcedExtension defines the extension to use to pick the right loader
  89072. * @returns the cube texture as an InternalTexture
  89073. */
  89074. 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;
  89075. /**
  89076. * Creates a cube texture
  89077. * @param rootUrl defines the url where the files to load is located
  89078. * @param scene defines the current scene
  89079. * @param files defines the list of files to load (1 per face)
  89080. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  89081. * @param onLoad defines an optional callback raised when the texture is loaded
  89082. * @param onError defines an optional callback raised if there is an issue to load the texture
  89083. * @param format defines the format of the data
  89084. * @param forcedExtension defines the extension to use to pick the right loader
  89085. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  89086. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89087. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89088. * @returns the cube texture as an InternalTexture
  89089. */
  89090. 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;
  89091. /** @hidden */
  89092. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  89093. /** @hidden */
  89094. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  89095. /** @hidden */
  89096. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89097. /** @hidden */
  89098. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89099. /**
  89100. * @hidden
  89101. */
  89102. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  89103. }
  89104. }
  89105. declare module BABYLON {
  89106. /**
  89107. * Class for creating a cube texture
  89108. */
  89109. export class CubeTexture extends BaseTexture {
  89110. private _delayedOnLoad;
  89111. /**
  89112. * Observable triggered once the texture has been loaded.
  89113. */
  89114. onLoadObservable: Observable<CubeTexture>;
  89115. /**
  89116. * The url of the texture
  89117. */
  89118. url: string;
  89119. /**
  89120. * Gets or sets the center of the bounding box associated with the cube texture.
  89121. * It must define where the camera used to render the texture was set
  89122. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89123. */
  89124. boundingBoxPosition: Vector3;
  89125. private _boundingBoxSize;
  89126. /**
  89127. * Gets or sets the size of the bounding box associated with the cube texture
  89128. * When defined, the cubemap will switch to local mode
  89129. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89130. * @example https://www.babylonjs-playground.com/#RNASML
  89131. */
  89132. set boundingBoxSize(value: Vector3);
  89133. /**
  89134. * Returns the bounding box size
  89135. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89136. */
  89137. get boundingBoxSize(): Vector3;
  89138. protected _rotationY: number;
  89139. /**
  89140. * Sets texture matrix rotation angle around Y axis in radians.
  89141. */
  89142. set rotationY(value: number);
  89143. /**
  89144. * Gets texture matrix rotation angle around Y axis radians.
  89145. */
  89146. get rotationY(): number;
  89147. /**
  89148. * Are mip maps generated for this texture or not.
  89149. */
  89150. get noMipmap(): boolean;
  89151. private _noMipmap;
  89152. private _files;
  89153. protected _forcedExtension: Nullable<string>;
  89154. private _extensions;
  89155. private _textureMatrix;
  89156. private _format;
  89157. private _createPolynomials;
  89158. private _loaderOptions;
  89159. /**
  89160. * Creates a cube texture from an array of image urls
  89161. * @param files defines an array of image urls
  89162. * @param scene defines the hosting scene
  89163. * @param noMipmap specifies if mip maps are not used
  89164. * @returns a cube texture
  89165. */
  89166. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  89167. /**
  89168. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  89169. * @param url defines the url of the prefiltered texture
  89170. * @param scene defines the scene the texture is attached to
  89171. * @param forcedExtension defines the extension of the file if different from the url
  89172. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89173. * @return the prefiltered texture
  89174. */
  89175. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  89176. /**
  89177. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  89178. * as prefiltered data.
  89179. * @param rootUrl defines the url of the texture or the root name of the six images
  89180. * @param null defines the scene or engine the texture is attached to
  89181. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  89182. * @param noMipmap defines if mipmaps should be created or not
  89183. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  89184. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  89185. * @param onError defines a callback triggered in case of error during load
  89186. * @param format defines the internal format to use for the texture once loaded
  89187. * @param prefiltered defines whether or not the texture is created from prefiltered data
  89188. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  89189. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89190. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89191. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89192. * @param loaderOptions options to be passed to the loader
  89193. * @return the cube texture
  89194. */
  89195. 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);
  89196. /**
  89197. * Get the current class name of the texture useful for serialization or dynamic coding.
  89198. * @returns "CubeTexture"
  89199. */
  89200. getClassName(): string;
  89201. /**
  89202. * Update the url (and optional buffer) of this texture if url was null during construction.
  89203. * @param url the url of the texture
  89204. * @param forcedExtension defines the extension to use
  89205. * @param onLoad callback called when the texture is loaded (defaults to null)
  89206. * @param prefiltered Defines whether the updated texture is prefiltered or not
  89207. */
  89208. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  89209. /**
  89210. * Delays loading of the cube texture
  89211. * @param forcedExtension defines the extension to use
  89212. */
  89213. delayLoad(forcedExtension?: string): void;
  89214. /**
  89215. * Returns the reflection texture matrix
  89216. * @returns the reflection texture matrix
  89217. */
  89218. getReflectionTextureMatrix(): Matrix;
  89219. /**
  89220. * Sets the reflection texture matrix
  89221. * @param value Reflection texture matrix
  89222. */
  89223. setReflectionTextureMatrix(value: Matrix): void;
  89224. /**
  89225. * Parses text to create a cube texture
  89226. * @param parsedTexture define the serialized text to read from
  89227. * @param scene defines the hosting scene
  89228. * @param rootUrl defines the root url of the cube texture
  89229. * @returns a cube texture
  89230. */
  89231. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  89232. /**
  89233. * Makes a clone, or deep copy, of the cube texture
  89234. * @returns a new cube texture
  89235. */
  89236. clone(): CubeTexture;
  89237. }
  89238. }
  89239. declare module BABYLON {
  89240. /**
  89241. * Manages the defines for the Material
  89242. */
  89243. export class MaterialDefines {
  89244. /** @hidden */
  89245. protected _keys: string[];
  89246. private _isDirty;
  89247. /** @hidden */
  89248. _renderId: number;
  89249. /** @hidden */
  89250. _areLightsDirty: boolean;
  89251. /** @hidden */
  89252. _areLightsDisposed: boolean;
  89253. /** @hidden */
  89254. _areAttributesDirty: boolean;
  89255. /** @hidden */
  89256. _areTexturesDirty: boolean;
  89257. /** @hidden */
  89258. _areFresnelDirty: boolean;
  89259. /** @hidden */
  89260. _areMiscDirty: boolean;
  89261. /** @hidden */
  89262. _arePrePassDirty: boolean;
  89263. /** @hidden */
  89264. _areImageProcessingDirty: boolean;
  89265. /** @hidden */
  89266. _normals: boolean;
  89267. /** @hidden */
  89268. _uvs: boolean;
  89269. /** @hidden */
  89270. _needNormals: boolean;
  89271. /** @hidden */
  89272. _needUVs: boolean;
  89273. [id: string]: any;
  89274. /**
  89275. * Specifies if the material needs to be re-calculated
  89276. */
  89277. get isDirty(): boolean;
  89278. /**
  89279. * Marks the material to indicate that it has been re-calculated
  89280. */
  89281. markAsProcessed(): void;
  89282. /**
  89283. * Marks the material to indicate that it needs to be re-calculated
  89284. */
  89285. markAsUnprocessed(): void;
  89286. /**
  89287. * Marks the material to indicate all of its defines need to be re-calculated
  89288. */
  89289. markAllAsDirty(): void;
  89290. /**
  89291. * Marks the material to indicate that image processing needs to be re-calculated
  89292. */
  89293. markAsImageProcessingDirty(): void;
  89294. /**
  89295. * Marks the material to indicate the lights need to be re-calculated
  89296. * @param disposed Defines whether the light is dirty due to dispose or not
  89297. */
  89298. markAsLightDirty(disposed?: boolean): void;
  89299. /**
  89300. * Marks the attribute state as changed
  89301. */
  89302. markAsAttributesDirty(): void;
  89303. /**
  89304. * Marks the texture state as changed
  89305. */
  89306. markAsTexturesDirty(): void;
  89307. /**
  89308. * Marks the fresnel state as changed
  89309. */
  89310. markAsFresnelDirty(): void;
  89311. /**
  89312. * Marks the misc state as changed
  89313. */
  89314. markAsMiscDirty(): void;
  89315. /**
  89316. * Marks the prepass state as changed
  89317. */
  89318. markAsPrePassDirty(): void;
  89319. /**
  89320. * Rebuilds the material defines
  89321. */
  89322. rebuild(): void;
  89323. /**
  89324. * Specifies if two material defines are equal
  89325. * @param other - A material define instance to compare to
  89326. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89327. */
  89328. isEqual(other: MaterialDefines): boolean;
  89329. /**
  89330. * Clones this instance's defines to another instance
  89331. * @param other - material defines to clone values to
  89332. */
  89333. cloneTo(other: MaterialDefines): void;
  89334. /**
  89335. * Resets the material define values
  89336. */
  89337. reset(): void;
  89338. /**
  89339. * Converts the material define values to a string
  89340. * @returns - String of material define information
  89341. */
  89342. toString(): string;
  89343. }
  89344. }
  89345. declare module BABYLON {
  89346. /**
  89347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89349. * 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;
  89350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89351. */
  89352. export class ColorCurves {
  89353. private _dirty;
  89354. private _tempColor;
  89355. private _globalCurve;
  89356. private _highlightsCurve;
  89357. private _midtonesCurve;
  89358. private _shadowsCurve;
  89359. private _positiveCurve;
  89360. private _negativeCurve;
  89361. private _globalHue;
  89362. private _globalDensity;
  89363. private _globalSaturation;
  89364. private _globalExposure;
  89365. /**
  89366. * Gets the global Hue value.
  89367. * 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).
  89368. */
  89369. get globalHue(): number;
  89370. /**
  89371. * Sets the global Hue value.
  89372. * 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).
  89373. */
  89374. set globalHue(value: number);
  89375. /**
  89376. * Gets the global Density value.
  89377. * 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.
  89378. * Values less than zero provide a filter of opposite hue.
  89379. */
  89380. get globalDensity(): number;
  89381. /**
  89382. * Sets the global Density value.
  89383. * 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.
  89384. * Values less than zero provide a filter of opposite hue.
  89385. */
  89386. set globalDensity(value: number);
  89387. /**
  89388. * Gets the global Saturation value.
  89389. * 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.
  89390. */
  89391. get globalSaturation(): number;
  89392. /**
  89393. * Sets the global Saturation value.
  89394. * 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.
  89395. */
  89396. set globalSaturation(value: number);
  89397. /**
  89398. * Gets the global Exposure value.
  89399. * 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.
  89400. */
  89401. get globalExposure(): number;
  89402. /**
  89403. * Sets the global Exposure value.
  89404. * 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.
  89405. */
  89406. set globalExposure(value: number);
  89407. private _highlightsHue;
  89408. private _highlightsDensity;
  89409. private _highlightsSaturation;
  89410. private _highlightsExposure;
  89411. /**
  89412. * Gets the highlights Hue value.
  89413. * 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).
  89414. */
  89415. get highlightsHue(): number;
  89416. /**
  89417. * Sets the highlights Hue value.
  89418. * 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).
  89419. */
  89420. set highlightsHue(value: number);
  89421. /**
  89422. * Gets the highlights Density value.
  89423. * 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.
  89424. * Values less than zero provide a filter of opposite hue.
  89425. */
  89426. get highlightsDensity(): number;
  89427. /**
  89428. * Sets the highlights Density value.
  89429. * 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.
  89430. * Values less than zero provide a filter of opposite hue.
  89431. */
  89432. set highlightsDensity(value: number);
  89433. /**
  89434. * Gets the highlights Saturation value.
  89435. * 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.
  89436. */
  89437. get highlightsSaturation(): number;
  89438. /**
  89439. * Sets the highlights Saturation value.
  89440. * 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.
  89441. */
  89442. set highlightsSaturation(value: number);
  89443. /**
  89444. * Gets the highlights Exposure value.
  89445. * 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.
  89446. */
  89447. get highlightsExposure(): number;
  89448. /**
  89449. * Sets the highlights Exposure value.
  89450. * 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.
  89451. */
  89452. set highlightsExposure(value: number);
  89453. private _midtonesHue;
  89454. private _midtonesDensity;
  89455. private _midtonesSaturation;
  89456. private _midtonesExposure;
  89457. /**
  89458. * Gets the midtones Hue value.
  89459. * 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).
  89460. */
  89461. get midtonesHue(): number;
  89462. /**
  89463. * Sets the midtones Hue value.
  89464. * 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).
  89465. */
  89466. set midtonesHue(value: number);
  89467. /**
  89468. * Gets the midtones Density value.
  89469. * 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.
  89470. * Values less than zero provide a filter of opposite hue.
  89471. */
  89472. get midtonesDensity(): number;
  89473. /**
  89474. * Sets the midtones Density value.
  89475. * 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.
  89476. * Values less than zero provide a filter of opposite hue.
  89477. */
  89478. set midtonesDensity(value: number);
  89479. /**
  89480. * Gets the midtones Saturation value.
  89481. * 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.
  89482. */
  89483. get midtonesSaturation(): number;
  89484. /**
  89485. * Sets the midtones Saturation value.
  89486. * 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.
  89487. */
  89488. set midtonesSaturation(value: number);
  89489. /**
  89490. * Gets the midtones Exposure value.
  89491. * 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.
  89492. */
  89493. get midtonesExposure(): number;
  89494. /**
  89495. * Sets the midtones Exposure value.
  89496. * 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.
  89497. */
  89498. set midtonesExposure(value: number);
  89499. private _shadowsHue;
  89500. private _shadowsDensity;
  89501. private _shadowsSaturation;
  89502. private _shadowsExposure;
  89503. /**
  89504. * Gets the shadows Hue value.
  89505. * 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).
  89506. */
  89507. get shadowsHue(): number;
  89508. /**
  89509. * Sets the shadows Hue value.
  89510. * 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).
  89511. */
  89512. set shadowsHue(value: number);
  89513. /**
  89514. * Gets the shadows Density value.
  89515. * 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.
  89516. * Values less than zero provide a filter of opposite hue.
  89517. */
  89518. get shadowsDensity(): number;
  89519. /**
  89520. * Sets the shadows Density value.
  89521. * 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.
  89522. * Values less than zero provide a filter of opposite hue.
  89523. */
  89524. set shadowsDensity(value: number);
  89525. /**
  89526. * Gets the shadows Saturation value.
  89527. * 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.
  89528. */
  89529. get shadowsSaturation(): number;
  89530. /**
  89531. * Sets the shadows Saturation value.
  89532. * 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.
  89533. */
  89534. set shadowsSaturation(value: number);
  89535. /**
  89536. * Gets the shadows Exposure value.
  89537. * 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.
  89538. */
  89539. get shadowsExposure(): number;
  89540. /**
  89541. * Sets the shadows Exposure value.
  89542. * 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.
  89543. */
  89544. set shadowsExposure(value: number);
  89545. /**
  89546. * Returns the class name
  89547. * @returns The class name
  89548. */
  89549. getClassName(): string;
  89550. /**
  89551. * Binds the color curves to the shader.
  89552. * @param colorCurves The color curve to bind
  89553. * @param effect The effect to bind to
  89554. * @param positiveUniform The positive uniform shader parameter
  89555. * @param neutralUniform The neutral uniform shader parameter
  89556. * @param negativeUniform The negative uniform shader parameter
  89557. */
  89558. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89559. /**
  89560. * Prepare the list of uniforms associated with the ColorCurves effects.
  89561. * @param uniformsList The list of uniforms used in the effect
  89562. */
  89563. static PrepareUniforms(uniformsList: string[]): void;
  89564. /**
  89565. * Returns color grading data based on a hue, density, saturation and exposure value.
  89566. * @param filterHue The hue of the color filter.
  89567. * @param filterDensity The density of the color filter.
  89568. * @param saturation The saturation.
  89569. * @param exposure The exposure.
  89570. * @param result The result data container.
  89571. */
  89572. private getColorGradingDataToRef;
  89573. /**
  89574. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89575. * @param value The input slider value in range [-100,100].
  89576. * @returns Adjusted value.
  89577. */
  89578. private static applyColorGradingSliderNonlinear;
  89579. /**
  89580. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89581. * @param hue The hue (H) input.
  89582. * @param saturation The saturation (S) input.
  89583. * @param brightness The brightness (B) input.
  89584. * @result An RGBA color represented as Vector4.
  89585. */
  89586. private static fromHSBToRef;
  89587. /**
  89588. * Returns a value clamped between min and max
  89589. * @param value The value to clamp
  89590. * @param min The minimum of value
  89591. * @param max The maximum of value
  89592. * @returns The clamped value.
  89593. */
  89594. private static clamp;
  89595. /**
  89596. * Clones the current color curve instance.
  89597. * @return The cloned curves
  89598. */
  89599. clone(): ColorCurves;
  89600. /**
  89601. * Serializes the current color curve instance to a json representation.
  89602. * @return a JSON representation
  89603. */
  89604. serialize(): any;
  89605. /**
  89606. * Parses the color curve from a json representation.
  89607. * @param source the JSON source to parse
  89608. * @return The parsed curves
  89609. */
  89610. static Parse(source: any): ColorCurves;
  89611. }
  89612. }
  89613. declare module BABYLON {
  89614. /**
  89615. * Interface to follow in your material defines to integrate easily the
  89616. * Image proccessing functions.
  89617. * @hidden
  89618. */
  89619. export interface IImageProcessingConfigurationDefines {
  89620. IMAGEPROCESSING: boolean;
  89621. VIGNETTE: boolean;
  89622. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89623. VIGNETTEBLENDMODEOPAQUE: boolean;
  89624. TONEMAPPING: boolean;
  89625. TONEMAPPING_ACES: boolean;
  89626. CONTRAST: boolean;
  89627. EXPOSURE: boolean;
  89628. COLORCURVES: boolean;
  89629. COLORGRADING: boolean;
  89630. COLORGRADING3D: boolean;
  89631. SAMPLER3DGREENDEPTH: boolean;
  89632. SAMPLER3DBGRMAP: boolean;
  89633. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89634. }
  89635. /**
  89636. * @hidden
  89637. */
  89638. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89639. IMAGEPROCESSING: boolean;
  89640. VIGNETTE: boolean;
  89641. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89642. VIGNETTEBLENDMODEOPAQUE: boolean;
  89643. TONEMAPPING: boolean;
  89644. TONEMAPPING_ACES: boolean;
  89645. CONTRAST: boolean;
  89646. COLORCURVES: boolean;
  89647. COLORGRADING: boolean;
  89648. COLORGRADING3D: boolean;
  89649. SAMPLER3DGREENDEPTH: boolean;
  89650. SAMPLER3DBGRMAP: boolean;
  89651. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89652. EXPOSURE: boolean;
  89653. constructor();
  89654. }
  89655. /**
  89656. * This groups together the common properties used for image processing either in direct forward pass
  89657. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89658. * or not.
  89659. */
  89660. export class ImageProcessingConfiguration {
  89661. /**
  89662. * Default tone mapping applied in BabylonJS.
  89663. */
  89664. static readonly TONEMAPPING_STANDARD: number;
  89665. /**
  89666. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89667. * to other engines rendering to increase portability.
  89668. */
  89669. static readonly TONEMAPPING_ACES: number;
  89670. /**
  89671. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89672. */
  89673. colorCurves: Nullable<ColorCurves>;
  89674. private _colorCurvesEnabled;
  89675. /**
  89676. * Gets wether the color curves effect is enabled.
  89677. */
  89678. get colorCurvesEnabled(): boolean;
  89679. /**
  89680. * Sets wether the color curves effect is enabled.
  89681. */
  89682. set colorCurvesEnabled(value: boolean);
  89683. private _colorGradingTexture;
  89684. /**
  89685. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89686. */
  89687. get colorGradingTexture(): Nullable<BaseTexture>;
  89688. /**
  89689. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89690. */
  89691. set colorGradingTexture(value: Nullable<BaseTexture>);
  89692. private _colorGradingEnabled;
  89693. /**
  89694. * Gets wether the color grading effect is enabled.
  89695. */
  89696. get colorGradingEnabled(): boolean;
  89697. /**
  89698. * Sets wether the color grading effect is enabled.
  89699. */
  89700. set colorGradingEnabled(value: boolean);
  89701. private _colorGradingWithGreenDepth;
  89702. /**
  89703. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89704. */
  89705. get colorGradingWithGreenDepth(): boolean;
  89706. /**
  89707. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89708. */
  89709. set colorGradingWithGreenDepth(value: boolean);
  89710. private _colorGradingBGR;
  89711. /**
  89712. * Gets wether the color grading texture contains BGR values.
  89713. */
  89714. get colorGradingBGR(): boolean;
  89715. /**
  89716. * Sets wether the color grading texture contains BGR values.
  89717. */
  89718. set colorGradingBGR(value: boolean);
  89719. /** @hidden */
  89720. _exposure: number;
  89721. /**
  89722. * Gets the Exposure used in the effect.
  89723. */
  89724. get exposure(): number;
  89725. /**
  89726. * Sets the Exposure used in the effect.
  89727. */
  89728. set exposure(value: number);
  89729. private _toneMappingEnabled;
  89730. /**
  89731. * Gets wether the tone mapping effect is enabled.
  89732. */
  89733. get toneMappingEnabled(): boolean;
  89734. /**
  89735. * Sets wether the tone mapping effect is enabled.
  89736. */
  89737. set toneMappingEnabled(value: boolean);
  89738. private _toneMappingType;
  89739. /**
  89740. * Gets the type of tone mapping effect.
  89741. */
  89742. get toneMappingType(): number;
  89743. /**
  89744. * Sets the type of tone mapping effect used in BabylonJS.
  89745. */
  89746. set toneMappingType(value: number);
  89747. protected _contrast: number;
  89748. /**
  89749. * Gets the contrast used in the effect.
  89750. */
  89751. get contrast(): number;
  89752. /**
  89753. * Sets the contrast used in the effect.
  89754. */
  89755. set contrast(value: number);
  89756. /**
  89757. * Vignette stretch size.
  89758. */
  89759. vignetteStretch: number;
  89760. /**
  89761. * Vignette centre X Offset.
  89762. */
  89763. vignetteCentreX: number;
  89764. /**
  89765. * Vignette centre Y Offset.
  89766. */
  89767. vignetteCentreY: number;
  89768. /**
  89769. * Vignette weight or intensity of the vignette effect.
  89770. */
  89771. vignetteWeight: number;
  89772. /**
  89773. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89774. * if vignetteEnabled is set to true.
  89775. */
  89776. vignetteColor: Color4;
  89777. /**
  89778. * Camera field of view used by the Vignette effect.
  89779. */
  89780. vignetteCameraFov: number;
  89781. private _vignetteBlendMode;
  89782. /**
  89783. * Gets the vignette blend mode allowing different kind of effect.
  89784. */
  89785. get vignetteBlendMode(): number;
  89786. /**
  89787. * Sets the vignette blend mode allowing different kind of effect.
  89788. */
  89789. set vignetteBlendMode(value: number);
  89790. private _vignetteEnabled;
  89791. /**
  89792. * Gets wether the vignette effect is enabled.
  89793. */
  89794. get vignetteEnabled(): boolean;
  89795. /**
  89796. * Sets wether the vignette effect is enabled.
  89797. */
  89798. set vignetteEnabled(value: boolean);
  89799. private _applyByPostProcess;
  89800. /**
  89801. * Gets wether the image processing is applied through a post process or not.
  89802. */
  89803. get applyByPostProcess(): boolean;
  89804. /**
  89805. * Sets wether the image processing is applied through a post process or not.
  89806. */
  89807. set applyByPostProcess(value: boolean);
  89808. private _isEnabled;
  89809. /**
  89810. * Gets wether the image processing is enabled or not.
  89811. */
  89812. get isEnabled(): boolean;
  89813. /**
  89814. * Sets wether the image processing is enabled or not.
  89815. */
  89816. set isEnabled(value: boolean);
  89817. /**
  89818. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89819. */
  89820. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89821. /**
  89822. * Method called each time the image processing information changes requires to recompile the effect.
  89823. */
  89824. protected _updateParameters(): void;
  89825. /**
  89826. * Gets the current class name.
  89827. * @return "ImageProcessingConfiguration"
  89828. */
  89829. getClassName(): string;
  89830. /**
  89831. * Prepare the list of uniforms associated with the Image Processing effects.
  89832. * @param uniforms The list of uniforms used in the effect
  89833. * @param defines the list of defines currently in use
  89834. */
  89835. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89836. /**
  89837. * Prepare the list of samplers associated with the Image Processing effects.
  89838. * @param samplersList The list of uniforms used in the effect
  89839. * @param defines the list of defines currently in use
  89840. */
  89841. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89842. /**
  89843. * Prepare the list of defines associated to the shader.
  89844. * @param defines the list of defines to complete
  89845. * @param forPostProcess Define if we are currently in post process mode or not
  89846. */
  89847. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89848. /**
  89849. * Returns true if all the image processing information are ready.
  89850. * @returns True if ready, otherwise, false
  89851. */
  89852. isReady(): boolean;
  89853. /**
  89854. * Binds the image processing to the shader.
  89855. * @param effect The effect to bind to
  89856. * @param overrideAspectRatio Override the aspect ratio of the effect
  89857. */
  89858. bind(effect: Effect, overrideAspectRatio?: number): void;
  89859. /**
  89860. * Clones the current image processing instance.
  89861. * @return The cloned image processing
  89862. */
  89863. clone(): ImageProcessingConfiguration;
  89864. /**
  89865. * Serializes the current image processing instance to a json representation.
  89866. * @return a JSON representation
  89867. */
  89868. serialize(): any;
  89869. /**
  89870. * Parses the image processing from a json representation.
  89871. * @param source the JSON source to parse
  89872. * @return The parsed image processing
  89873. */
  89874. static Parse(source: any): ImageProcessingConfiguration;
  89875. private static _VIGNETTEMODE_MULTIPLY;
  89876. private static _VIGNETTEMODE_OPAQUE;
  89877. /**
  89878. * Used to apply the vignette as a mix with the pixel color.
  89879. */
  89880. static get VIGNETTEMODE_MULTIPLY(): number;
  89881. /**
  89882. * Used to apply the vignette as a replacement of the pixel color.
  89883. */
  89884. static get VIGNETTEMODE_OPAQUE(): number;
  89885. }
  89886. }
  89887. declare module BABYLON {
  89888. /** @hidden */
  89889. export var postprocessVertexShader: {
  89890. name: string;
  89891. shader: string;
  89892. };
  89893. }
  89894. declare module BABYLON {
  89895. /**
  89896. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89897. */
  89898. export type RenderTargetTextureSize = number | {
  89899. width: number;
  89900. height: number;
  89901. layers?: number;
  89902. };
  89903. interface ThinEngine {
  89904. /**
  89905. * Creates a new render target texture
  89906. * @param size defines the size of the texture
  89907. * @param options defines the options used to create the texture
  89908. * @returns a new render target texture stored in an InternalTexture
  89909. */
  89910. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89911. /**
  89912. * Creates a depth stencil texture.
  89913. * This is only available in WebGL 2 or with the depth texture extension available.
  89914. * @param size The size of face edge in the texture.
  89915. * @param options The options defining the texture.
  89916. * @returns The texture
  89917. */
  89918. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89919. /** @hidden */
  89920. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89921. }
  89922. }
  89923. declare module BABYLON {
  89924. /**
  89925. * Defines the kind of connection point for node based material
  89926. */
  89927. export enum NodeMaterialBlockConnectionPointTypes {
  89928. /** Float */
  89929. Float = 1,
  89930. /** Int */
  89931. Int = 2,
  89932. /** Vector2 */
  89933. Vector2 = 4,
  89934. /** Vector3 */
  89935. Vector3 = 8,
  89936. /** Vector4 */
  89937. Vector4 = 16,
  89938. /** Color3 */
  89939. Color3 = 32,
  89940. /** Color4 */
  89941. Color4 = 64,
  89942. /** Matrix */
  89943. Matrix = 128,
  89944. /** Custom object */
  89945. Object = 256,
  89946. /** Detect type based on connection */
  89947. AutoDetect = 1024,
  89948. /** Output type that will be defined by input type */
  89949. BasedOnInput = 2048
  89950. }
  89951. }
  89952. declare module BABYLON {
  89953. /**
  89954. * Enum used to define the target of a block
  89955. */
  89956. export enum NodeMaterialBlockTargets {
  89957. /** Vertex shader */
  89958. Vertex = 1,
  89959. /** Fragment shader */
  89960. Fragment = 2,
  89961. /** Neutral */
  89962. Neutral = 4,
  89963. /** Vertex and Fragment */
  89964. VertexAndFragment = 3
  89965. }
  89966. }
  89967. declare module BABYLON {
  89968. /**
  89969. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89970. */
  89971. export enum NodeMaterialBlockConnectionPointMode {
  89972. /** Value is an uniform */
  89973. Uniform = 0,
  89974. /** Value is a mesh attribute */
  89975. Attribute = 1,
  89976. /** Value is a varying between vertex and fragment shaders */
  89977. Varying = 2,
  89978. /** Mode is undefined */
  89979. Undefined = 3
  89980. }
  89981. }
  89982. declare module BABYLON {
  89983. /**
  89984. * Enum used to define system values e.g. values automatically provided by the system
  89985. */
  89986. export enum NodeMaterialSystemValues {
  89987. /** World */
  89988. World = 1,
  89989. /** View */
  89990. View = 2,
  89991. /** Projection */
  89992. Projection = 3,
  89993. /** ViewProjection */
  89994. ViewProjection = 4,
  89995. /** WorldView */
  89996. WorldView = 5,
  89997. /** WorldViewProjection */
  89998. WorldViewProjection = 6,
  89999. /** CameraPosition */
  90000. CameraPosition = 7,
  90001. /** Fog Color */
  90002. FogColor = 8,
  90003. /** Delta time */
  90004. DeltaTime = 9
  90005. }
  90006. }
  90007. declare module BABYLON {
  90008. /** Defines supported spaces */
  90009. export enum Space {
  90010. /** Local (object) space */
  90011. LOCAL = 0,
  90012. /** World space */
  90013. WORLD = 1,
  90014. /** Bone space */
  90015. BONE = 2
  90016. }
  90017. /** Defines the 3 main axes */
  90018. export class Axis {
  90019. /** X axis */
  90020. static X: Vector3;
  90021. /** Y axis */
  90022. static Y: Vector3;
  90023. /** Z axis */
  90024. static Z: Vector3;
  90025. }
  90026. /**
  90027. * Defines cartesian components.
  90028. */
  90029. export enum Coordinate {
  90030. /** X axis */
  90031. X = 0,
  90032. /** Y axis */
  90033. Y = 1,
  90034. /** Z axis */
  90035. Z = 2
  90036. }
  90037. }
  90038. declare module BABYLON {
  90039. /**
  90040. * Represents a camera frustum
  90041. */
  90042. export class Frustum {
  90043. /**
  90044. * Gets the planes representing the frustum
  90045. * @param transform matrix to be applied to the returned planes
  90046. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  90047. */
  90048. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  90049. /**
  90050. * Gets the near frustum plane transformed by the transform matrix
  90051. * @param transform transformation matrix to be applied to the resulting frustum plane
  90052. * @param frustumPlane the resuling frustum plane
  90053. */
  90054. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90055. /**
  90056. * Gets the far frustum plane transformed by the transform matrix
  90057. * @param transform transformation matrix to be applied to the resulting frustum plane
  90058. * @param frustumPlane the resuling frustum plane
  90059. */
  90060. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90061. /**
  90062. * Gets the left frustum plane transformed by the transform matrix
  90063. * @param transform transformation matrix to be applied to the resulting frustum plane
  90064. * @param frustumPlane the resuling frustum plane
  90065. */
  90066. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90067. /**
  90068. * Gets the right frustum plane transformed by the transform matrix
  90069. * @param transform transformation matrix to be applied to the resulting frustum plane
  90070. * @param frustumPlane the resuling frustum plane
  90071. */
  90072. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90073. /**
  90074. * Gets the top frustum plane transformed by the transform matrix
  90075. * @param transform transformation matrix to be applied to the resulting frustum plane
  90076. * @param frustumPlane the resuling frustum plane
  90077. */
  90078. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90079. /**
  90080. * Gets the bottom frustum plane transformed by the transform matrix
  90081. * @param transform transformation matrix to be applied to the resulting frustum plane
  90082. * @param frustumPlane the resuling frustum plane
  90083. */
  90084. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90085. /**
  90086. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  90087. * @param transform transformation matrix to be applied to the resulting frustum planes
  90088. * @param frustumPlanes the resuling frustum planes
  90089. */
  90090. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  90091. }
  90092. }
  90093. declare module BABYLON {
  90094. /**
  90095. * Interface for the size containing width and height
  90096. */
  90097. export interface ISize {
  90098. /**
  90099. * Width
  90100. */
  90101. width: number;
  90102. /**
  90103. * Heighht
  90104. */
  90105. height: number;
  90106. }
  90107. /**
  90108. * Size containing widht and height
  90109. */
  90110. export class Size implements ISize {
  90111. /**
  90112. * Width
  90113. */
  90114. width: number;
  90115. /**
  90116. * Height
  90117. */
  90118. height: number;
  90119. /**
  90120. * Creates a Size object from the given width and height (floats).
  90121. * @param width width of the new size
  90122. * @param height height of the new size
  90123. */
  90124. constructor(width: number, height: number);
  90125. /**
  90126. * Returns a string with the Size width and height
  90127. * @returns a string with the Size width and height
  90128. */
  90129. toString(): string;
  90130. /**
  90131. * "Size"
  90132. * @returns the string "Size"
  90133. */
  90134. getClassName(): string;
  90135. /**
  90136. * Returns the Size hash code.
  90137. * @returns a hash code for a unique width and height
  90138. */
  90139. getHashCode(): number;
  90140. /**
  90141. * Updates the current size from the given one.
  90142. * @param src the given size
  90143. */
  90144. copyFrom(src: Size): void;
  90145. /**
  90146. * Updates in place the current Size from the given floats.
  90147. * @param width width of the new size
  90148. * @param height height of the new size
  90149. * @returns the updated Size.
  90150. */
  90151. copyFromFloats(width: number, height: number): Size;
  90152. /**
  90153. * Updates in place the current Size from the given floats.
  90154. * @param width width to set
  90155. * @param height height to set
  90156. * @returns the updated Size.
  90157. */
  90158. set(width: number, height: number): Size;
  90159. /**
  90160. * Multiplies the width and height by numbers
  90161. * @param w factor to multiple the width by
  90162. * @param h factor to multiple the height by
  90163. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  90164. */
  90165. multiplyByFloats(w: number, h: number): Size;
  90166. /**
  90167. * Clones the size
  90168. * @returns a new Size copied from the given one.
  90169. */
  90170. clone(): Size;
  90171. /**
  90172. * True if the current Size and the given one width and height are strictly equal.
  90173. * @param other the other size to compare against
  90174. * @returns True if the current Size and the given one width and height are strictly equal.
  90175. */
  90176. equals(other: Size): boolean;
  90177. /**
  90178. * The surface of the Size : width * height (float).
  90179. */
  90180. get surface(): number;
  90181. /**
  90182. * Create a new size of zero
  90183. * @returns a new Size set to (0.0, 0.0)
  90184. */
  90185. static Zero(): Size;
  90186. /**
  90187. * Sums the width and height of two sizes
  90188. * @param otherSize size to add to this size
  90189. * @returns a new Size set as the addition result of the current Size and the given one.
  90190. */
  90191. add(otherSize: Size): Size;
  90192. /**
  90193. * Subtracts the width and height of two
  90194. * @param otherSize size to subtract to this size
  90195. * @returns a new Size set as the subtraction result of the given one from the current Size.
  90196. */
  90197. subtract(otherSize: Size): Size;
  90198. /**
  90199. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  90200. * @param start starting size to lerp between
  90201. * @param end end size to lerp between
  90202. * @param amount amount to lerp between the start and end values
  90203. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  90204. */
  90205. static Lerp(start: Size, end: Size, amount: number): Size;
  90206. }
  90207. }
  90208. declare module BABYLON {
  90209. /**
  90210. * Contains position and normal vectors for a vertex
  90211. */
  90212. export class PositionNormalVertex {
  90213. /** the position of the vertex (defaut: 0,0,0) */
  90214. position: Vector3;
  90215. /** the normal of the vertex (defaut: 0,1,0) */
  90216. normal: Vector3;
  90217. /**
  90218. * Creates a PositionNormalVertex
  90219. * @param position the position of the vertex (defaut: 0,0,0)
  90220. * @param normal the normal of the vertex (defaut: 0,1,0)
  90221. */
  90222. constructor(
  90223. /** the position of the vertex (defaut: 0,0,0) */
  90224. position?: Vector3,
  90225. /** the normal of the vertex (defaut: 0,1,0) */
  90226. normal?: Vector3);
  90227. /**
  90228. * Clones the PositionNormalVertex
  90229. * @returns the cloned PositionNormalVertex
  90230. */
  90231. clone(): PositionNormalVertex;
  90232. }
  90233. /**
  90234. * Contains position, normal and uv vectors for a vertex
  90235. */
  90236. export class PositionNormalTextureVertex {
  90237. /** the position of the vertex (defaut: 0,0,0) */
  90238. position: Vector3;
  90239. /** the normal of the vertex (defaut: 0,1,0) */
  90240. normal: Vector3;
  90241. /** the uv of the vertex (default: 0,0) */
  90242. uv: Vector2;
  90243. /**
  90244. * Creates a PositionNormalTextureVertex
  90245. * @param position the position of the vertex (defaut: 0,0,0)
  90246. * @param normal the normal of the vertex (defaut: 0,1,0)
  90247. * @param uv the uv of the vertex (default: 0,0)
  90248. */
  90249. constructor(
  90250. /** the position of the vertex (defaut: 0,0,0) */
  90251. position?: Vector3,
  90252. /** the normal of the vertex (defaut: 0,1,0) */
  90253. normal?: Vector3,
  90254. /** the uv of the vertex (default: 0,0) */
  90255. uv?: Vector2);
  90256. /**
  90257. * Clones the PositionNormalTextureVertex
  90258. * @returns the cloned PositionNormalTextureVertex
  90259. */
  90260. clone(): PositionNormalTextureVertex;
  90261. }
  90262. }
  90263. declare module BABYLON {
  90264. /**
  90265. * Enum defining the type of animations supported by InputBlock
  90266. */
  90267. export enum AnimatedInputBlockTypes {
  90268. /** No animation */
  90269. None = 0,
  90270. /** Time based animation. Will only work for floats */
  90271. Time = 1
  90272. }
  90273. }
  90274. declare module BABYLON {
  90275. /**
  90276. * Interface describing all the common properties and methods a shadow light needs to implement.
  90277. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90278. * as well as binding the different shadow properties to the effects.
  90279. */
  90280. export interface IShadowLight extends Light {
  90281. /**
  90282. * The light id in the scene (used in scene.findLighById for instance)
  90283. */
  90284. id: string;
  90285. /**
  90286. * The position the shdow will be casted from.
  90287. */
  90288. position: Vector3;
  90289. /**
  90290. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90291. */
  90292. direction: Vector3;
  90293. /**
  90294. * The transformed position. Position of the light in world space taking parenting in account.
  90295. */
  90296. transformedPosition: Vector3;
  90297. /**
  90298. * The transformed direction. Direction of the light in world space taking parenting in account.
  90299. */
  90300. transformedDirection: Vector3;
  90301. /**
  90302. * The friendly name of the light in the scene.
  90303. */
  90304. name: string;
  90305. /**
  90306. * Defines the shadow projection clipping minimum z value.
  90307. */
  90308. shadowMinZ: number;
  90309. /**
  90310. * Defines the shadow projection clipping maximum z value.
  90311. */
  90312. shadowMaxZ: number;
  90313. /**
  90314. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90315. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90316. */
  90317. computeTransformedInformation(): boolean;
  90318. /**
  90319. * Gets the scene the light belongs to.
  90320. * @returns The scene
  90321. */
  90322. getScene(): Scene;
  90323. /**
  90324. * Callback defining a custom Projection Matrix Builder.
  90325. * This can be used to override the default projection matrix computation.
  90326. */
  90327. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90328. /**
  90329. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90330. * @param matrix The materix to updated with the projection information
  90331. * @param viewMatrix The transform matrix of the light
  90332. * @param renderList The list of mesh to render in the map
  90333. * @returns The current light
  90334. */
  90335. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90336. /**
  90337. * Gets the current depth scale used in ESM.
  90338. * @returns The scale
  90339. */
  90340. getDepthScale(): number;
  90341. /**
  90342. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90343. * @returns true if a cube texture needs to be use
  90344. */
  90345. needCube(): boolean;
  90346. /**
  90347. * Detects if the projection matrix requires to be recomputed this frame.
  90348. * @returns true if it requires to be recomputed otherwise, false.
  90349. */
  90350. needProjectionMatrixCompute(): boolean;
  90351. /**
  90352. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90353. */
  90354. forceProjectionMatrixCompute(): void;
  90355. /**
  90356. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90357. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90358. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90359. */
  90360. getShadowDirection(faceIndex?: number): Vector3;
  90361. /**
  90362. * Gets the minZ used for shadow according to both the scene and the light.
  90363. * @param activeCamera The camera we are returning the min for
  90364. * @returns the depth min z
  90365. */
  90366. getDepthMinZ(activeCamera: Camera): number;
  90367. /**
  90368. * Gets the maxZ used for shadow according to both the scene and the light.
  90369. * @param activeCamera The camera we are returning the max for
  90370. * @returns the depth max z
  90371. */
  90372. getDepthMaxZ(activeCamera: Camera): number;
  90373. }
  90374. /**
  90375. * Base implementation IShadowLight
  90376. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90377. */
  90378. export abstract class ShadowLight extends Light implements IShadowLight {
  90379. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90380. protected _position: Vector3;
  90381. protected _setPosition(value: Vector3): void;
  90382. /**
  90383. * Sets the position the shadow will be casted from. Also use as the light position for both
  90384. * point and spot lights.
  90385. */
  90386. get position(): Vector3;
  90387. /**
  90388. * Sets the position the shadow will be casted from. Also use as the light position for both
  90389. * point and spot lights.
  90390. */
  90391. set position(value: Vector3);
  90392. protected _direction: Vector3;
  90393. protected _setDirection(value: Vector3): void;
  90394. /**
  90395. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90396. * Also use as the light direction on spot and directional lights.
  90397. */
  90398. get direction(): Vector3;
  90399. /**
  90400. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90401. * Also use as the light direction on spot and directional lights.
  90402. */
  90403. set direction(value: Vector3);
  90404. protected _shadowMinZ: number;
  90405. /**
  90406. * Gets the shadow projection clipping minimum z value.
  90407. */
  90408. get shadowMinZ(): number;
  90409. /**
  90410. * Sets the shadow projection clipping minimum z value.
  90411. */
  90412. set shadowMinZ(value: number);
  90413. protected _shadowMaxZ: number;
  90414. /**
  90415. * Sets the shadow projection clipping maximum z value.
  90416. */
  90417. get shadowMaxZ(): number;
  90418. /**
  90419. * Gets the shadow projection clipping maximum z value.
  90420. */
  90421. set shadowMaxZ(value: number);
  90422. /**
  90423. * Callback defining a custom Projection Matrix Builder.
  90424. * This can be used to override the default projection matrix computation.
  90425. */
  90426. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90427. /**
  90428. * The transformed position. Position of the light in world space taking parenting in account.
  90429. */
  90430. transformedPosition: Vector3;
  90431. /**
  90432. * The transformed direction. Direction of the light in world space taking parenting in account.
  90433. */
  90434. transformedDirection: Vector3;
  90435. private _needProjectionMatrixCompute;
  90436. /**
  90437. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90438. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90439. */
  90440. computeTransformedInformation(): boolean;
  90441. /**
  90442. * Return the depth scale used for the shadow map.
  90443. * @returns the depth scale.
  90444. */
  90445. getDepthScale(): number;
  90446. /**
  90447. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90448. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90449. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90450. */
  90451. getShadowDirection(faceIndex?: number): Vector3;
  90452. /**
  90453. * Returns the ShadowLight absolute position in the World.
  90454. * @returns the position vector in world space
  90455. */
  90456. getAbsolutePosition(): Vector3;
  90457. /**
  90458. * Sets the ShadowLight direction toward the passed target.
  90459. * @param target The point to target in local space
  90460. * @returns the updated ShadowLight direction
  90461. */
  90462. setDirectionToTarget(target: Vector3): Vector3;
  90463. /**
  90464. * Returns the light rotation in euler definition.
  90465. * @returns the x y z rotation in local space.
  90466. */
  90467. getRotation(): Vector3;
  90468. /**
  90469. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90470. * @returns true if a cube texture needs to be use
  90471. */
  90472. needCube(): boolean;
  90473. /**
  90474. * Detects if the projection matrix requires to be recomputed this frame.
  90475. * @returns true if it requires to be recomputed otherwise, false.
  90476. */
  90477. needProjectionMatrixCompute(): boolean;
  90478. /**
  90479. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90480. */
  90481. forceProjectionMatrixCompute(): void;
  90482. /** @hidden */
  90483. _initCache(): void;
  90484. /** @hidden */
  90485. _isSynchronized(): boolean;
  90486. /**
  90487. * Computes the world matrix of the node
  90488. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90489. * @returns the world matrix
  90490. */
  90491. computeWorldMatrix(force?: boolean): Matrix;
  90492. /**
  90493. * Gets the minZ used for shadow according to both the scene and the light.
  90494. * @param activeCamera The camera we are returning the min for
  90495. * @returns the depth min z
  90496. */
  90497. getDepthMinZ(activeCamera: Camera): number;
  90498. /**
  90499. * Gets the maxZ used for shadow according to both the scene and the light.
  90500. * @param activeCamera The camera we are returning the max for
  90501. * @returns the depth max z
  90502. */
  90503. getDepthMaxZ(activeCamera: Camera): number;
  90504. /**
  90505. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90506. * @param matrix The materix to updated with the projection information
  90507. * @param viewMatrix The transform matrix of the light
  90508. * @param renderList The list of mesh to render in the map
  90509. * @returns The current light
  90510. */
  90511. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90512. }
  90513. }
  90514. declare module BABYLON {
  90515. /** @hidden */
  90516. export var packingFunctions: {
  90517. name: string;
  90518. shader: string;
  90519. };
  90520. }
  90521. declare module BABYLON {
  90522. /** @hidden */
  90523. export var bayerDitherFunctions: {
  90524. name: string;
  90525. shader: string;
  90526. };
  90527. }
  90528. declare module BABYLON {
  90529. /** @hidden */
  90530. export var shadowMapFragmentDeclaration: {
  90531. name: string;
  90532. shader: string;
  90533. };
  90534. }
  90535. declare module BABYLON {
  90536. /** @hidden */
  90537. export var clipPlaneFragmentDeclaration: {
  90538. name: string;
  90539. shader: string;
  90540. };
  90541. }
  90542. declare module BABYLON {
  90543. /** @hidden */
  90544. export var clipPlaneFragment: {
  90545. name: string;
  90546. shader: string;
  90547. };
  90548. }
  90549. declare module BABYLON {
  90550. /** @hidden */
  90551. export var shadowMapFragment: {
  90552. name: string;
  90553. shader: string;
  90554. };
  90555. }
  90556. declare module BABYLON {
  90557. /** @hidden */
  90558. export var shadowMapPixelShader: {
  90559. name: string;
  90560. shader: string;
  90561. };
  90562. }
  90563. declare module BABYLON {
  90564. /** @hidden */
  90565. export var bonesDeclaration: {
  90566. name: string;
  90567. shader: string;
  90568. };
  90569. }
  90570. declare module BABYLON {
  90571. /** @hidden */
  90572. export var morphTargetsVertexGlobalDeclaration: {
  90573. name: string;
  90574. shader: string;
  90575. };
  90576. }
  90577. declare module BABYLON {
  90578. /** @hidden */
  90579. export var morphTargetsVertexDeclaration: {
  90580. name: string;
  90581. shader: string;
  90582. };
  90583. }
  90584. declare module BABYLON {
  90585. /** @hidden */
  90586. export var instancesDeclaration: {
  90587. name: string;
  90588. shader: string;
  90589. };
  90590. }
  90591. declare module BABYLON {
  90592. /** @hidden */
  90593. export var helperFunctions: {
  90594. name: string;
  90595. shader: string;
  90596. };
  90597. }
  90598. declare module BABYLON {
  90599. /** @hidden */
  90600. export var shadowMapVertexDeclaration: {
  90601. name: string;
  90602. shader: string;
  90603. };
  90604. }
  90605. declare module BABYLON {
  90606. /** @hidden */
  90607. export var clipPlaneVertexDeclaration: {
  90608. name: string;
  90609. shader: string;
  90610. };
  90611. }
  90612. declare module BABYLON {
  90613. /** @hidden */
  90614. export var morphTargetsVertex: {
  90615. name: string;
  90616. shader: string;
  90617. };
  90618. }
  90619. declare module BABYLON {
  90620. /** @hidden */
  90621. export var instancesVertex: {
  90622. name: string;
  90623. shader: string;
  90624. };
  90625. }
  90626. declare module BABYLON {
  90627. /** @hidden */
  90628. export var bonesVertex: {
  90629. name: string;
  90630. shader: string;
  90631. };
  90632. }
  90633. declare module BABYLON {
  90634. /** @hidden */
  90635. export var shadowMapVertexNormalBias: {
  90636. name: string;
  90637. shader: string;
  90638. };
  90639. }
  90640. declare module BABYLON {
  90641. /** @hidden */
  90642. export var shadowMapVertexMetric: {
  90643. name: string;
  90644. shader: string;
  90645. };
  90646. }
  90647. declare module BABYLON {
  90648. /** @hidden */
  90649. export var clipPlaneVertex: {
  90650. name: string;
  90651. shader: string;
  90652. };
  90653. }
  90654. declare module BABYLON {
  90655. /** @hidden */
  90656. export var shadowMapVertexShader: {
  90657. name: string;
  90658. shader: string;
  90659. };
  90660. }
  90661. declare module BABYLON {
  90662. /** @hidden */
  90663. export var depthBoxBlurPixelShader: {
  90664. name: string;
  90665. shader: string;
  90666. };
  90667. }
  90668. declare module BABYLON {
  90669. /** @hidden */
  90670. export var shadowMapFragmentSoftTransparentShadow: {
  90671. name: string;
  90672. shader: string;
  90673. };
  90674. }
  90675. declare module BABYLON {
  90676. /**
  90677. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90678. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90679. */
  90680. export class EffectFallbacks implements IEffectFallbacks {
  90681. private _defines;
  90682. private _currentRank;
  90683. private _maxRank;
  90684. private _mesh;
  90685. /**
  90686. * Removes the fallback from the bound mesh.
  90687. */
  90688. unBindMesh(): void;
  90689. /**
  90690. * Adds a fallback on the specified property.
  90691. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90692. * @param define The name of the define in the shader
  90693. */
  90694. addFallback(rank: number, define: string): void;
  90695. /**
  90696. * Sets the mesh to use CPU skinning when needing to fallback.
  90697. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90698. * @param mesh The mesh to use the fallbacks.
  90699. */
  90700. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90701. /**
  90702. * Checks to see if more fallbacks are still availible.
  90703. */
  90704. get hasMoreFallbacks(): boolean;
  90705. /**
  90706. * Removes the defines that should be removed when falling back.
  90707. * @param currentDefines defines the current define statements for the shader.
  90708. * @param effect defines the current effect we try to compile
  90709. * @returns The resulting defines with defines of the current rank removed.
  90710. */
  90711. reduce(currentDefines: string, effect: Effect): string;
  90712. }
  90713. }
  90714. declare module BABYLON {
  90715. /**
  90716. * Interface used to define Action
  90717. */
  90718. export interface IAction {
  90719. /**
  90720. * Trigger for the action
  90721. */
  90722. trigger: number;
  90723. /** Options of the trigger */
  90724. triggerOptions: any;
  90725. /**
  90726. * Gets the trigger parameters
  90727. * @returns the trigger parameters
  90728. */
  90729. getTriggerParameter(): any;
  90730. /**
  90731. * Internal only - executes current action event
  90732. * @hidden
  90733. */
  90734. _executeCurrent(evt?: ActionEvent): void;
  90735. /**
  90736. * Serialize placeholder for child classes
  90737. * @param parent of child
  90738. * @returns the serialized object
  90739. */
  90740. serialize(parent: any): any;
  90741. /**
  90742. * Internal only
  90743. * @hidden
  90744. */
  90745. _prepare(): void;
  90746. /**
  90747. * Internal only - manager for action
  90748. * @hidden
  90749. */
  90750. _actionManager: Nullable<AbstractActionManager>;
  90751. /**
  90752. * Adds action to chain of actions, may be a DoNothingAction
  90753. * @param action defines the next action to execute
  90754. * @returns The action passed in
  90755. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90756. */
  90757. then(action: IAction): IAction;
  90758. }
  90759. /**
  90760. * The action to be carried out following a trigger
  90761. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90762. */
  90763. export class Action implements IAction {
  90764. /** the trigger, with or without parameters, for the action */
  90765. triggerOptions: any;
  90766. /**
  90767. * Trigger for the action
  90768. */
  90769. trigger: number;
  90770. /**
  90771. * Internal only - manager for action
  90772. * @hidden
  90773. */
  90774. _actionManager: ActionManager;
  90775. private _nextActiveAction;
  90776. private _child;
  90777. private _condition?;
  90778. private _triggerParameter;
  90779. /**
  90780. * An event triggered prior to action being executed.
  90781. */
  90782. onBeforeExecuteObservable: Observable<Action>;
  90783. /**
  90784. * Creates a new Action
  90785. * @param triggerOptions the trigger, with or without parameters, for the action
  90786. * @param condition an optional determinant of action
  90787. */
  90788. constructor(
  90789. /** the trigger, with or without parameters, for the action */
  90790. triggerOptions: any, condition?: Condition);
  90791. /**
  90792. * Internal only
  90793. * @hidden
  90794. */
  90795. _prepare(): void;
  90796. /**
  90797. * Gets the trigger parameters
  90798. * @returns the trigger parameters
  90799. */
  90800. getTriggerParameter(): any;
  90801. /**
  90802. * Internal only - executes current action event
  90803. * @hidden
  90804. */
  90805. _executeCurrent(evt?: ActionEvent): void;
  90806. /**
  90807. * Execute placeholder for child classes
  90808. * @param evt optional action event
  90809. */
  90810. execute(evt?: ActionEvent): void;
  90811. /**
  90812. * Skips to next active action
  90813. */
  90814. skipToNextActiveAction(): void;
  90815. /**
  90816. * Adds action to chain of actions, may be a DoNothingAction
  90817. * @param action defines the next action to execute
  90818. * @returns The action passed in
  90819. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90820. */
  90821. then(action: Action): Action;
  90822. /**
  90823. * Internal only
  90824. * @hidden
  90825. */
  90826. _getProperty(propertyPath: string): string;
  90827. /**
  90828. * Internal only
  90829. * @hidden
  90830. */
  90831. _getEffectiveTarget(target: any, propertyPath: string): any;
  90832. /**
  90833. * Serialize placeholder for child classes
  90834. * @param parent of child
  90835. * @returns the serialized object
  90836. */
  90837. serialize(parent: any): any;
  90838. /**
  90839. * Internal only called by serialize
  90840. * @hidden
  90841. */
  90842. protected _serialize(serializedAction: any, parent?: any): any;
  90843. /**
  90844. * Internal only
  90845. * @hidden
  90846. */
  90847. static _SerializeValueAsString: (value: any) => string;
  90848. /**
  90849. * Internal only
  90850. * @hidden
  90851. */
  90852. static _GetTargetProperty: (target: Scene | Node) => {
  90853. name: string;
  90854. targetType: string;
  90855. value: string;
  90856. };
  90857. }
  90858. }
  90859. declare module BABYLON {
  90860. /**
  90861. * A Condition applied to an Action
  90862. */
  90863. export class Condition {
  90864. /**
  90865. * Internal only - manager for action
  90866. * @hidden
  90867. */
  90868. _actionManager: ActionManager;
  90869. /**
  90870. * Internal only
  90871. * @hidden
  90872. */
  90873. _evaluationId: number;
  90874. /**
  90875. * Internal only
  90876. * @hidden
  90877. */
  90878. _currentResult: boolean;
  90879. /**
  90880. * Creates a new Condition
  90881. * @param actionManager the manager of the action the condition is applied to
  90882. */
  90883. constructor(actionManager: ActionManager);
  90884. /**
  90885. * Check if the current condition is valid
  90886. * @returns a boolean
  90887. */
  90888. isValid(): boolean;
  90889. /**
  90890. * Internal only
  90891. * @hidden
  90892. */
  90893. _getProperty(propertyPath: string): string;
  90894. /**
  90895. * Internal only
  90896. * @hidden
  90897. */
  90898. _getEffectiveTarget(target: any, propertyPath: string): any;
  90899. /**
  90900. * Serialize placeholder for child classes
  90901. * @returns the serialized object
  90902. */
  90903. serialize(): any;
  90904. /**
  90905. * Internal only
  90906. * @hidden
  90907. */
  90908. protected _serialize(serializedCondition: any): any;
  90909. }
  90910. /**
  90911. * Defines specific conditional operators as extensions of Condition
  90912. */
  90913. export class ValueCondition extends Condition {
  90914. /** path to specify the property of the target the conditional operator uses */
  90915. propertyPath: string;
  90916. /** the value compared by the conditional operator against the current value of the property */
  90917. value: any;
  90918. /** the conditional operator, default ValueCondition.IsEqual */
  90919. operator: number;
  90920. /**
  90921. * Internal only
  90922. * @hidden
  90923. */
  90924. private static _IsEqual;
  90925. /**
  90926. * Internal only
  90927. * @hidden
  90928. */
  90929. private static _IsDifferent;
  90930. /**
  90931. * Internal only
  90932. * @hidden
  90933. */
  90934. private static _IsGreater;
  90935. /**
  90936. * Internal only
  90937. * @hidden
  90938. */
  90939. private static _IsLesser;
  90940. /**
  90941. * returns the number for IsEqual
  90942. */
  90943. static get IsEqual(): number;
  90944. /**
  90945. * Returns the number for IsDifferent
  90946. */
  90947. static get IsDifferent(): number;
  90948. /**
  90949. * Returns the number for IsGreater
  90950. */
  90951. static get IsGreater(): number;
  90952. /**
  90953. * Returns the number for IsLesser
  90954. */
  90955. static get IsLesser(): number;
  90956. /**
  90957. * Internal only The action manager for the condition
  90958. * @hidden
  90959. */
  90960. _actionManager: ActionManager;
  90961. /**
  90962. * Internal only
  90963. * @hidden
  90964. */
  90965. private _target;
  90966. /**
  90967. * Internal only
  90968. * @hidden
  90969. */
  90970. private _effectiveTarget;
  90971. /**
  90972. * Internal only
  90973. * @hidden
  90974. */
  90975. private _property;
  90976. /**
  90977. * Creates a new ValueCondition
  90978. * @param actionManager manager for the action the condition applies to
  90979. * @param target for the action
  90980. * @param propertyPath path to specify the property of the target the conditional operator uses
  90981. * @param value the value compared by the conditional operator against the current value of the property
  90982. * @param operator the conditional operator, default ValueCondition.IsEqual
  90983. */
  90984. constructor(actionManager: ActionManager, target: any,
  90985. /** path to specify the property of the target the conditional operator uses */
  90986. propertyPath: string,
  90987. /** the value compared by the conditional operator against the current value of the property */
  90988. value: any,
  90989. /** the conditional operator, default ValueCondition.IsEqual */
  90990. operator?: number);
  90991. /**
  90992. * Compares the given value with the property value for the specified conditional operator
  90993. * @returns the result of the comparison
  90994. */
  90995. isValid(): boolean;
  90996. /**
  90997. * Serialize the ValueCondition into a JSON compatible object
  90998. * @returns serialization object
  90999. */
  91000. serialize(): any;
  91001. /**
  91002. * Gets the name of the conditional operator for the ValueCondition
  91003. * @param operator the conditional operator
  91004. * @returns the name
  91005. */
  91006. static GetOperatorName(operator: number): string;
  91007. }
  91008. /**
  91009. * Defines a predicate condition as an extension of Condition
  91010. */
  91011. export class PredicateCondition extends Condition {
  91012. /** defines the predicate function used to validate the condition */
  91013. predicate: () => boolean;
  91014. /**
  91015. * Internal only - manager for action
  91016. * @hidden
  91017. */
  91018. _actionManager: ActionManager;
  91019. /**
  91020. * Creates a new PredicateCondition
  91021. * @param actionManager manager for the action the condition applies to
  91022. * @param predicate defines the predicate function used to validate the condition
  91023. */
  91024. constructor(actionManager: ActionManager,
  91025. /** defines the predicate function used to validate the condition */
  91026. predicate: () => boolean);
  91027. /**
  91028. * @returns the validity of the predicate condition
  91029. */
  91030. isValid(): boolean;
  91031. }
  91032. /**
  91033. * Defines a state condition as an extension of Condition
  91034. */
  91035. export class StateCondition extends Condition {
  91036. /** Value to compare with target state */
  91037. value: string;
  91038. /**
  91039. * Internal only - manager for action
  91040. * @hidden
  91041. */
  91042. _actionManager: ActionManager;
  91043. /**
  91044. * Internal only
  91045. * @hidden
  91046. */
  91047. private _target;
  91048. /**
  91049. * Creates a new StateCondition
  91050. * @param actionManager manager for the action the condition applies to
  91051. * @param target of the condition
  91052. * @param value to compare with target state
  91053. */
  91054. constructor(actionManager: ActionManager, target: any,
  91055. /** Value to compare with target state */
  91056. value: string);
  91057. /**
  91058. * Gets a boolean indicating if the current condition is met
  91059. * @returns the validity of the state
  91060. */
  91061. isValid(): boolean;
  91062. /**
  91063. * Serialize the StateCondition into a JSON compatible object
  91064. * @returns serialization object
  91065. */
  91066. serialize(): any;
  91067. }
  91068. }
  91069. declare module BABYLON {
  91070. /**
  91071. * This defines an action responsible to toggle a boolean once triggered.
  91072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91073. */
  91074. export class SwitchBooleanAction extends Action {
  91075. /**
  91076. * The path to the boolean property in the target object
  91077. */
  91078. propertyPath: string;
  91079. private _target;
  91080. private _effectiveTarget;
  91081. private _property;
  91082. /**
  91083. * Instantiate the action
  91084. * @param triggerOptions defines the trigger options
  91085. * @param target defines the object containing the boolean
  91086. * @param propertyPath defines the path to the boolean property in the target object
  91087. * @param condition defines the trigger related conditions
  91088. */
  91089. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91090. /** @hidden */
  91091. _prepare(): void;
  91092. /**
  91093. * Execute the action toggle the boolean value.
  91094. */
  91095. execute(): void;
  91096. /**
  91097. * Serializes the actions and its related information.
  91098. * @param parent defines the object to serialize in
  91099. * @returns the serialized object
  91100. */
  91101. serialize(parent: any): any;
  91102. }
  91103. /**
  91104. * This defines an action responsible to set a the state field of the target
  91105. * to a desired value once triggered.
  91106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91107. */
  91108. export class SetStateAction extends Action {
  91109. /**
  91110. * The value to store in the state field.
  91111. */
  91112. value: string;
  91113. private _target;
  91114. /**
  91115. * Instantiate the action
  91116. * @param triggerOptions defines the trigger options
  91117. * @param target defines the object containing the state property
  91118. * @param value defines the value to store in the state field
  91119. * @param condition defines the trigger related conditions
  91120. */
  91121. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91122. /**
  91123. * Execute the action and store the value on the target state property.
  91124. */
  91125. execute(): void;
  91126. /**
  91127. * Serializes the actions and its related information.
  91128. * @param parent defines the object to serialize in
  91129. * @returns the serialized object
  91130. */
  91131. serialize(parent: any): any;
  91132. }
  91133. /**
  91134. * This defines an action responsible to set a property of the target
  91135. * to a desired value once triggered.
  91136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91137. */
  91138. export class SetValueAction extends Action {
  91139. /**
  91140. * The path of the property to set in the target.
  91141. */
  91142. propertyPath: string;
  91143. /**
  91144. * The value to set in the property
  91145. */
  91146. value: any;
  91147. private _target;
  91148. private _effectiveTarget;
  91149. private _property;
  91150. /**
  91151. * Instantiate the action
  91152. * @param triggerOptions defines the trigger options
  91153. * @param target defines the object containing the property
  91154. * @param propertyPath defines the path of the property to set in the target
  91155. * @param value defines the value to set in the property
  91156. * @param condition defines the trigger related conditions
  91157. */
  91158. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91159. /** @hidden */
  91160. _prepare(): void;
  91161. /**
  91162. * Execute the action and set the targetted property to the desired value.
  91163. */
  91164. execute(): void;
  91165. /**
  91166. * Serializes the actions and its related information.
  91167. * @param parent defines the object to serialize in
  91168. * @returns the serialized object
  91169. */
  91170. serialize(parent: any): any;
  91171. }
  91172. /**
  91173. * This defines an action responsible to increment the target value
  91174. * to a desired value once triggered.
  91175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91176. */
  91177. export class IncrementValueAction extends Action {
  91178. /**
  91179. * The path of the property to increment in the target.
  91180. */
  91181. propertyPath: string;
  91182. /**
  91183. * The value we should increment the property by.
  91184. */
  91185. value: any;
  91186. private _target;
  91187. private _effectiveTarget;
  91188. private _property;
  91189. /**
  91190. * Instantiate the action
  91191. * @param triggerOptions defines the trigger options
  91192. * @param target defines the object containing the property
  91193. * @param propertyPath defines the path of the property to increment in the target
  91194. * @param value defines the value value we should increment the property by
  91195. * @param condition defines the trigger related conditions
  91196. */
  91197. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91198. /** @hidden */
  91199. _prepare(): void;
  91200. /**
  91201. * Execute the action and increment the target of the value amount.
  91202. */
  91203. execute(): void;
  91204. /**
  91205. * Serializes the actions and its related information.
  91206. * @param parent defines the object to serialize in
  91207. * @returns the serialized object
  91208. */
  91209. serialize(parent: any): any;
  91210. }
  91211. /**
  91212. * This defines an action responsible to start an animation once triggered.
  91213. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91214. */
  91215. export class PlayAnimationAction extends Action {
  91216. /**
  91217. * Where the animation should start (animation frame)
  91218. */
  91219. from: number;
  91220. /**
  91221. * Where the animation should stop (animation frame)
  91222. */
  91223. to: number;
  91224. /**
  91225. * Define if the animation should loop or stop after the first play.
  91226. */
  91227. loop?: boolean;
  91228. private _target;
  91229. /**
  91230. * Instantiate the action
  91231. * @param triggerOptions defines the trigger options
  91232. * @param target defines the target animation or animation name
  91233. * @param from defines from where the animation should start (animation frame)
  91234. * @param end defines where the animation should stop (animation frame)
  91235. * @param loop defines if the animation should loop or stop after the first play
  91236. * @param condition defines the trigger related conditions
  91237. */
  91238. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91239. /** @hidden */
  91240. _prepare(): void;
  91241. /**
  91242. * Execute the action and play the animation.
  91243. */
  91244. execute(): void;
  91245. /**
  91246. * Serializes the actions and its related information.
  91247. * @param parent defines the object to serialize in
  91248. * @returns the serialized object
  91249. */
  91250. serialize(parent: any): any;
  91251. }
  91252. /**
  91253. * This defines an action responsible to stop an animation once triggered.
  91254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91255. */
  91256. export class StopAnimationAction extends Action {
  91257. private _target;
  91258. /**
  91259. * Instantiate the action
  91260. * @param triggerOptions defines the trigger options
  91261. * @param target defines the target animation or animation name
  91262. * @param condition defines the trigger related conditions
  91263. */
  91264. constructor(triggerOptions: any, target: any, condition?: Condition);
  91265. /** @hidden */
  91266. _prepare(): void;
  91267. /**
  91268. * Execute the action and stop the animation.
  91269. */
  91270. execute(): void;
  91271. /**
  91272. * Serializes the actions and its related information.
  91273. * @param parent defines the object to serialize in
  91274. * @returns the serialized object
  91275. */
  91276. serialize(parent: any): any;
  91277. }
  91278. /**
  91279. * This defines an action responsible that does nothing once triggered.
  91280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91281. */
  91282. export class DoNothingAction extends Action {
  91283. /**
  91284. * Instantiate the action
  91285. * @param triggerOptions defines the trigger options
  91286. * @param condition defines the trigger related conditions
  91287. */
  91288. constructor(triggerOptions?: any, condition?: Condition);
  91289. /**
  91290. * Execute the action and do nothing.
  91291. */
  91292. execute(): void;
  91293. /**
  91294. * Serializes the actions and its related information.
  91295. * @param parent defines the object to serialize in
  91296. * @returns the serialized object
  91297. */
  91298. serialize(parent: any): any;
  91299. }
  91300. /**
  91301. * This defines an action responsible to trigger several actions once triggered.
  91302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91303. */
  91304. export class CombineAction extends Action {
  91305. /**
  91306. * The list of aggregated animations to run.
  91307. */
  91308. children: Action[];
  91309. /**
  91310. * Instantiate the action
  91311. * @param triggerOptions defines the trigger options
  91312. * @param children defines the list of aggregated animations to run
  91313. * @param condition defines the trigger related conditions
  91314. */
  91315. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91316. /** @hidden */
  91317. _prepare(): void;
  91318. /**
  91319. * Execute the action and executes all the aggregated actions.
  91320. */
  91321. execute(evt: ActionEvent): void;
  91322. /**
  91323. * Serializes the actions and its related information.
  91324. * @param parent defines the object to serialize in
  91325. * @returns the serialized object
  91326. */
  91327. serialize(parent: any): any;
  91328. }
  91329. /**
  91330. * This defines an action responsible to run code (external event) once triggered.
  91331. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91332. */
  91333. export class ExecuteCodeAction extends Action {
  91334. /**
  91335. * The callback function to run.
  91336. */
  91337. func: (evt: ActionEvent) => void;
  91338. /**
  91339. * Instantiate the action
  91340. * @param triggerOptions defines the trigger options
  91341. * @param func defines the callback function to run
  91342. * @param condition defines the trigger related conditions
  91343. */
  91344. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91345. /**
  91346. * Execute the action and run the attached code.
  91347. */
  91348. execute(evt: ActionEvent): void;
  91349. }
  91350. /**
  91351. * This defines an action responsible to set the parent property of the target once triggered.
  91352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91353. */
  91354. export class SetParentAction extends Action {
  91355. private _parent;
  91356. private _target;
  91357. /**
  91358. * Instantiate the action
  91359. * @param triggerOptions defines the trigger options
  91360. * @param target defines the target containing the parent property
  91361. * @param parent defines from where the animation should start (animation frame)
  91362. * @param condition defines the trigger related conditions
  91363. */
  91364. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91365. /** @hidden */
  91366. _prepare(): void;
  91367. /**
  91368. * Execute the action and set the parent property.
  91369. */
  91370. execute(): void;
  91371. /**
  91372. * Serializes the actions and its related information.
  91373. * @param parent defines the object to serialize in
  91374. * @returns the serialized object
  91375. */
  91376. serialize(parent: any): any;
  91377. }
  91378. }
  91379. declare module BABYLON {
  91380. /**
  91381. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91382. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91383. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91384. */
  91385. export class ActionManager extends AbstractActionManager {
  91386. /**
  91387. * Nothing
  91388. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91389. */
  91390. static readonly NothingTrigger: number;
  91391. /**
  91392. * On pick
  91393. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91394. */
  91395. static readonly OnPickTrigger: number;
  91396. /**
  91397. * On left pick
  91398. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91399. */
  91400. static readonly OnLeftPickTrigger: number;
  91401. /**
  91402. * On right pick
  91403. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91404. */
  91405. static readonly OnRightPickTrigger: number;
  91406. /**
  91407. * On center pick
  91408. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91409. */
  91410. static readonly OnCenterPickTrigger: number;
  91411. /**
  91412. * On pick down
  91413. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91414. */
  91415. static readonly OnPickDownTrigger: number;
  91416. /**
  91417. * On double pick
  91418. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91419. */
  91420. static readonly OnDoublePickTrigger: number;
  91421. /**
  91422. * On pick up
  91423. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91424. */
  91425. static readonly OnPickUpTrigger: number;
  91426. /**
  91427. * On pick out.
  91428. * This trigger will only be raised if you also declared a OnPickDown
  91429. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91430. */
  91431. static readonly OnPickOutTrigger: number;
  91432. /**
  91433. * On long press
  91434. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91435. */
  91436. static readonly OnLongPressTrigger: number;
  91437. /**
  91438. * On pointer over
  91439. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91440. */
  91441. static readonly OnPointerOverTrigger: number;
  91442. /**
  91443. * On pointer out
  91444. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91445. */
  91446. static readonly OnPointerOutTrigger: number;
  91447. /**
  91448. * On every frame
  91449. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91450. */
  91451. static readonly OnEveryFrameTrigger: number;
  91452. /**
  91453. * On intersection enter
  91454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91455. */
  91456. static readonly OnIntersectionEnterTrigger: number;
  91457. /**
  91458. * On intersection exit
  91459. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91460. */
  91461. static readonly OnIntersectionExitTrigger: number;
  91462. /**
  91463. * On key down
  91464. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91465. */
  91466. static readonly OnKeyDownTrigger: number;
  91467. /**
  91468. * On key up
  91469. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91470. */
  91471. static readonly OnKeyUpTrigger: number;
  91472. private _scene;
  91473. /**
  91474. * Creates a new action manager
  91475. * @param scene defines the hosting scene
  91476. */
  91477. constructor(scene: Scene);
  91478. /**
  91479. * Releases all associated resources
  91480. */
  91481. dispose(): void;
  91482. /**
  91483. * Gets hosting scene
  91484. * @returns the hosting scene
  91485. */
  91486. getScene(): Scene;
  91487. /**
  91488. * Does this action manager handles actions of any of the given triggers
  91489. * @param triggers defines the triggers to be tested
  91490. * @return a boolean indicating whether one (or more) of the triggers is handled
  91491. */
  91492. hasSpecificTriggers(triggers: number[]): boolean;
  91493. /**
  91494. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91495. * speed.
  91496. * @param triggerA defines the trigger to be tested
  91497. * @param triggerB defines the trigger to be tested
  91498. * @return a boolean indicating whether one (or more) of the triggers is handled
  91499. */
  91500. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91501. /**
  91502. * Does this action manager handles actions of a given trigger
  91503. * @param trigger defines the trigger to be tested
  91504. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91505. * @return whether the trigger is handled
  91506. */
  91507. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91508. /**
  91509. * Does this action manager has pointer triggers
  91510. */
  91511. get hasPointerTriggers(): boolean;
  91512. /**
  91513. * Does this action manager has pick triggers
  91514. */
  91515. get hasPickTriggers(): boolean;
  91516. /**
  91517. * Registers an action to this action manager
  91518. * @param action defines the action to be registered
  91519. * @return the action amended (prepared) after registration
  91520. */
  91521. registerAction(action: IAction): Nullable<IAction>;
  91522. /**
  91523. * Unregisters an action to this action manager
  91524. * @param action defines the action to be unregistered
  91525. * @return a boolean indicating whether the action has been unregistered
  91526. */
  91527. unregisterAction(action: IAction): Boolean;
  91528. /**
  91529. * Process a specific trigger
  91530. * @param trigger defines the trigger to process
  91531. * @param evt defines the event details to be processed
  91532. */
  91533. processTrigger(trigger: number, evt?: IActionEvent): void;
  91534. /** @hidden */
  91535. _getEffectiveTarget(target: any, propertyPath: string): any;
  91536. /** @hidden */
  91537. _getProperty(propertyPath: string): string;
  91538. /**
  91539. * Serialize this manager to a JSON object
  91540. * @param name defines the property name to store this manager
  91541. * @returns a JSON representation of this manager
  91542. */
  91543. serialize(name: string): any;
  91544. /**
  91545. * Creates a new ActionManager from a JSON data
  91546. * @param parsedActions defines the JSON data to read from
  91547. * @param object defines the hosting mesh
  91548. * @param scene defines the hosting scene
  91549. */
  91550. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91551. /**
  91552. * Get a trigger name by index
  91553. * @param trigger defines the trigger index
  91554. * @returns a trigger name
  91555. */
  91556. static GetTriggerName(trigger: number): string;
  91557. }
  91558. }
  91559. declare module BABYLON {
  91560. /**
  91561. * Class used to represent a sprite
  91562. * @see https://doc.babylonjs.com/babylon101/sprites
  91563. */
  91564. export class Sprite implements IAnimatable {
  91565. /** defines the name */
  91566. name: string;
  91567. /** Gets or sets the current world position */
  91568. position: Vector3;
  91569. /** Gets or sets the main color */
  91570. color: Color4;
  91571. /** Gets or sets the width */
  91572. width: number;
  91573. /** Gets or sets the height */
  91574. height: number;
  91575. /** Gets or sets rotation angle */
  91576. angle: number;
  91577. /** Gets or sets the cell index in the sprite sheet */
  91578. cellIndex: number;
  91579. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91580. cellRef: string;
  91581. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91582. invertU: boolean;
  91583. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91584. invertV: boolean;
  91585. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91586. disposeWhenFinishedAnimating: boolean;
  91587. /** Gets the list of attached animations */
  91588. animations: Nullable<Array<Animation>>;
  91589. /** Gets or sets a boolean indicating if the sprite can be picked */
  91590. isPickable: boolean;
  91591. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91592. useAlphaForPicking: boolean;
  91593. /** @hidden */
  91594. _xOffset: number;
  91595. /** @hidden */
  91596. _yOffset: number;
  91597. /** @hidden */
  91598. _xSize: number;
  91599. /** @hidden */
  91600. _ySize: number;
  91601. /**
  91602. * Gets or sets the associated action manager
  91603. */
  91604. actionManager: Nullable<ActionManager>;
  91605. /**
  91606. * An event triggered when the control has been disposed
  91607. */
  91608. onDisposeObservable: Observable<Sprite>;
  91609. private _animationStarted;
  91610. private _loopAnimation;
  91611. private _fromIndex;
  91612. private _toIndex;
  91613. private _delay;
  91614. private _direction;
  91615. private _manager;
  91616. private _time;
  91617. private _onAnimationEnd;
  91618. /**
  91619. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91620. */
  91621. isVisible: boolean;
  91622. /**
  91623. * Gets or sets the sprite size
  91624. */
  91625. get size(): number;
  91626. set size(value: number);
  91627. /**
  91628. * Returns a boolean indicating if the animation is started
  91629. */
  91630. get animationStarted(): boolean;
  91631. /**
  91632. * Gets or sets the unique id of the sprite
  91633. */
  91634. uniqueId: number;
  91635. /**
  91636. * Gets the manager of this sprite
  91637. */
  91638. get manager(): ISpriteManager;
  91639. /**
  91640. * Creates a new Sprite
  91641. * @param name defines the name
  91642. * @param manager defines the manager
  91643. */
  91644. constructor(
  91645. /** defines the name */
  91646. name: string, manager: ISpriteManager);
  91647. /**
  91648. * Returns the string "Sprite"
  91649. * @returns "Sprite"
  91650. */
  91651. getClassName(): string;
  91652. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91653. get fromIndex(): number;
  91654. set fromIndex(value: number);
  91655. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91656. get toIndex(): number;
  91657. set toIndex(value: number);
  91658. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91659. get loopAnimation(): boolean;
  91660. set loopAnimation(value: boolean);
  91661. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91662. get delay(): number;
  91663. set delay(value: number);
  91664. /**
  91665. * Starts an animation
  91666. * @param from defines the initial key
  91667. * @param to defines the end key
  91668. * @param loop defines if the animation must loop
  91669. * @param delay defines the start delay (in ms)
  91670. * @param onAnimationEnd defines a callback to call when animation ends
  91671. */
  91672. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91673. /** Stops current animation (if any) */
  91674. stopAnimation(): void;
  91675. /** @hidden */
  91676. _animate(deltaTime: number): void;
  91677. /** Release associated resources */
  91678. dispose(): void;
  91679. /**
  91680. * Serializes the sprite to a JSON object
  91681. * @returns the JSON object
  91682. */
  91683. serialize(): any;
  91684. /**
  91685. * Parses a JSON object to create a new sprite
  91686. * @param parsedSprite The JSON object to parse
  91687. * @param manager defines the hosting manager
  91688. * @returns the new sprite
  91689. */
  91690. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91691. }
  91692. }
  91693. declare module BABYLON {
  91694. /**
  91695. * Information about the result of picking within a scene
  91696. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91697. */
  91698. export class PickingInfo {
  91699. /** @hidden */
  91700. _pickingUnavailable: boolean;
  91701. /**
  91702. * If the pick collided with an object
  91703. */
  91704. hit: boolean;
  91705. /**
  91706. * Distance away where the pick collided
  91707. */
  91708. distance: number;
  91709. /**
  91710. * The location of pick collision
  91711. */
  91712. pickedPoint: Nullable<Vector3>;
  91713. /**
  91714. * The mesh corresponding the the pick collision
  91715. */
  91716. pickedMesh: Nullable<AbstractMesh>;
  91717. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91718. bu: number;
  91719. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91720. bv: number;
  91721. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91722. faceId: number;
  91723. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91724. subMeshFaceId: number;
  91725. /** Id of the the submesh that was picked */
  91726. subMeshId: number;
  91727. /** If a sprite was picked, this will be the sprite the pick collided with */
  91728. pickedSprite: Nullable<Sprite>;
  91729. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91730. thinInstanceIndex: number;
  91731. /**
  91732. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91733. */
  91734. originMesh: Nullable<AbstractMesh>;
  91735. /**
  91736. * The ray that was used to perform the picking.
  91737. */
  91738. ray: Nullable<Ray>;
  91739. /**
  91740. * Gets the normal correspodning to the face the pick collided with
  91741. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91742. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91743. * @returns The normal correspodning to the face the pick collided with
  91744. */
  91745. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91746. /**
  91747. * Gets the texture coordinates of where the pick occured
  91748. * @returns the vector containing the coordnates of the texture
  91749. */
  91750. getTextureCoordinates(): Nullable<Vector2>;
  91751. }
  91752. }
  91753. declare module BABYLON {
  91754. /**
  91755. * Class representing a ray with position and direction
  91756. */
  91757. export class Ray {
  91758. /** origin point */
  91759. origin: Vector3;
  91760. /** direction */
  91761. direction: Vector3;
  91762. /** length of the ray */
  91763. length: number;
  91764. private static readonly _TmpVector3;
  91765. private _tmpRay;
  91766. /**
  91767. * Creates a new ray
  91768. * @param origin origin point
  91769. * @param direction direction
  91770. * @param length length of the ray
  91771. */
  91772. constructor(
  91773. /** origin point */
  91774. origin: Vector3,
  91775. /** direction */
  91776. direction: Vector3,
  91777. /** length of the ray */
  91778. length?: number);
  91779. /**
  91780. * Checks if the ray intersects a box
  91781. * This does not account for the ray lenght by design to improve perfs.
  91782. * @param minimum bound of the box
  91783. * @param maximum bound of the box
  91784. * @param intersectionTreshold extra extend to be added to the box in all direction
  91785. * @returns if the box was hit
  91786. */
  91787. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91788. /**
  91789. * Checks if the ray intersects a box
  91790. * This does not account for the ray lenght by design to improve perfs.
  91791. * @param box the bounding box to check
  91792. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91793. * @returns if the box was hit
  91794. */
  91795. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91796. /**
  91797. * If the ray hits a sphere
  91798. * @param sphere the bounding sphere to check
  91799. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91800. * @returns true if it hits the sphere
  91801. */
  91802. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91803. /**
  91804. * If the ray hits a triange
  91805. * @param vertex0 triangle vertex
  91806. * @param vertex1 triangle vertex
  91807. * @param vertex2 triangle vertex
  91808. * @returns intersection information if hit
  91809. */
  91810. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91811. /**
  91812. * Checks if ray intersects a plane
  91813. * @param plane the plane to check
  91814. * @returns the distance away it was hit
  91815. */
  91816. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91817. /**
  91818. * Calculate the intercept of a ray on a given axis
  91819. * @param axis to check 'x' | 'y' | 'z'
  91820. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91821. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91822. */
  91823. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91824. /**
  91825. * Checks if ray intersects a mesh
  91826. * @param mesh the mesh to check
  91827. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91828. * @returns picking info of the intersecton
  91829. */
  91830. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91831. /**
  91832. * Checks if ray intersects a mesh
  91833. * @param meshes the meshes to check
  91834. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91835. * @param results array to store result in
  91836. * @returns Array of picking infos
  91837. */
  91838. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91839. private _comparePickingInfo;
  91840. private static smallnum;
  91841. private static rayl;
  91842. /**
  91843. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91844. * @param sega the first point of the segment to test the intersection against
  91845. * @param segb the second point of the segment to test the intersection against
  91846. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91847. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91848. */
  91849. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91850. /**
  91851. * Update the ray from viewport position
  91852. * @param x position
  91853. * @param y y position
  91854. * @param viewportWidth viewport width
  91855. * @param viewportHeight viewport height
  91856. * @param world world matrix
  91857. * @param view view matrix
  91858. * @param projection projection matrix
  91859. * @returns this ray updated
  91860. */
  91861. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91862. /**
  91863. * Creates a ray with origin and direction of 0,0,0
  91864. * @returns the new ray
  91865. */
  91866. static Zero(): Ray;
  91867. /**
  91868. * Creates a new ray from screen space and viewport
  91869. * @param x position
  91870. * @param y y position
  91871. * @param viewportWidth viewport width
  91872. * @param viewportHeight viewport height
  91873. * @param world world matrix
  91874. * @param view view matrix
  91875. * @param projection projection matrix
  91876. * @returns new ray
  91877. */
  91878. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91879. /**
  91880. * 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
  91881. * transformed to the given world matrix.
  91882. * @param origin The origin point
  91883. * @param end The end point
  91884. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91885. * @returns the new ray
  91886. */
  91887. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91888. /**
  91889. * Transforms a ray by a matrix
  91890. * @param ray ray to transform
  91891. * @param matrix matrix to apply
  91892. * @returns the resulting new ray
  91893. */
  91894. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91895. /**
  91896. * Transforms a ray by a matrix
  91897. * @param ray ray to transform
  91898. * @param matrix matrix to apply
  91899. * @param result ray to store result in
  91900. */
  91901. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91902. /**
  91903. * Unproject a ray from screen space to object space
  91904. * @param sourceX defines the screen space x coordinate to use
  91905. * @param sourceY defines the screen space y coordinate to use
  91906. * @param viewportWidth defines the current width of the viewport
  91907. * @param viewportHeight defines the current height of the viewport
  91908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91909. * @param view defines the view matrix to use
  91910. * @param projection defines the projection matrix to use
  91911. */
  91912. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91913. }
  91914. /**
  91915. * Type used to define predicate used to select faces when a mesh intersection is detected
  91916. */
  91917. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91918. interface Scene {
  91919. /** @hidden */
  91920. _tempPickingRay: Nullable<Ray>;
  91921. /** @hidden */
  91922. _cachedRayForTransform: Ray;
  91923. /** @hidden */
  91924. _pickWithRayInverseMatrix: Matrix;
  91925. /** @hidden */
  91926. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91927. /** @hidden */
  91928. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91929. /** @hidden */
  91930. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  91931. }
  91932. }
  91933. declare module BABYLON {
  91934. /**
  91935. * Groups all the scene component constants in one place to ease maintenance.
  91936. * @hidden
  91937. */
  91938. export class SceneComponentConstants {
  91939. static readonly NAME_EFFECTLAYER: string;
  91940. static readonly NAME_LAYER: string;
  91941. static readonly NAME_LENSFLARESYSTEM: string;
  91942. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91943. static readonly NAME_PARTICLESYSTEM: string;
  91944. static readonly NAME_GAMEPAD: string;
  91945. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91946. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91947. static readonly NAME_PREPASSRENDERER: string;
  91948. static readonly NAME_DEPTHRENDERER: string;
  91949. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91950. static readonly NAME_SPRITE: string;
  91951. static readonly NAME_SUBSURFACE: string;
  91952. static readonly NAME_OUTLINERENDERER: string;
  91953. static readonly NAME_PROCEDURALTEXTURE: string;
  91954. static readonly NAME_SHADOWGENERATOR: string;
  91955. static readonly NAME_OCTREE: string;
  91956. static readonly NAME_PHYSICSENGINE: string;
  91957. static readonly NAME_AUDIO: string;
  91958. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91959. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91960. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91961. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91962. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91963. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91964. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91965. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91966. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91967. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91968. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91969. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91970. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91971. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91972. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91973. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91974. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91975. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91976. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91977. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91978. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91979. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91980. static readonly STEP_AFTERRENDER_AUDIO: number;
  91981. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91982. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91983. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91984. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91985. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91986. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91987. static readonly STEP_POINTERMOVE_SPRITE: number;
  91988. static readonly STEP_POINTERDOWN_SPRITE: number;
  91989. static readonly STEP_POINTERUP_SPRITE: number;
  91990. }
  91991. /**
  91992. * This represents a scene component.
  91993. *
  91994. * This is used to decouple the dependency the scene is having on the different workloads like
  91995. * layers, post processes...
  91996. */
  91997. export interface ISceneComponent {
  91998. /**
  91999. * The name of the component. Each component must have a unique name.
  92000. */
  92001. name: string;
  92002. /**
  92003. * The scene the component belongs to.
  92004. */
  92005. scene: Scene;
  92006. /**
  92007. * Register the component to one instance of a scene.
  92008. */
  92009. register(): void;
  92010. /**
  92011. * Rebuilds the elements related to this component in case of
  92012. * context lost for instance.
  92013. */
  92014. rebuild(): void;
  92015. /**
  92016. * Disposes the component and the associated ressources.
  92017. */
  92018. dispose(): void;
  92019. }
  92020. /**
  92021. * This represents a SERIALIZABLE scene component.
  92022. *
  92023. * This extends Scene Component to add Serialization methods on top.
  92024. */
  92025. export interface ISceneSerializableComponent extends ISceneComponent {
  92026. /**
  92027. * Adds all the elements from the container to the scene
  92028. * @param container the container holding the elements
  92029. */
  92030. addFromContainer(container: AbstractScene): void;
  92031. /**
  92032. * Removes all the elements in the container from the scene
  92033. * @param container contains the elements to remove
  92034. * @param dispose if the removed element should be disposed (default: false)
  92035. */
  92036. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92037. /**
  92038. * Serializes the component data to the specified json object
  92039. * @param serializationObject The object to serialize to
  92040. */
  92041. serialize(serializationObject: any): void;
  92042. }
  92043. /**
  92044. * Strong typing of a Mesh related stage step action
  92045. */
  92046. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  92047. /**
  92048. * Strong typing of a Evaluate Sub Mesh related stage step action
  92049. */
  92050. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  92051. /**
  92052. * Strong typing of a pre active Mesh related stage step action
  92053. */
  92054. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  92055. /**
  92056. * Strong typing of a Camera related stage step action
  92057. */
  92058. export type CameraStageAction = (camera: Camera) => void;
  92059. /**
  92060. * Strong typing of a Camera Frame buffer related stage step action
  92061. */
  92062. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  92063. /**
  92064. * Strong typing of a Render Target related stage step action
  92065. */
  92066. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  92067. /**
  92068. * Strong typing of a RenderingGroup related stage step action
  92069. */
  92070. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  92071. /**
  92072. * Strong typing of a Mesh Render related stage step action
  92073. */
  92074. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  92075. /**
  92076. * Strong typing of a simple stage step action
  92077. */
  92078. export type SimpleStageAction = () => void;
  92079. /**
  92080. * Strong typing of a render target action.
  92081. */
  92082. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92083. /**
  92084. * Strong typing of a pointer move action.
  92085. */
  92086. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92087. /**
  92088. * Strong typing of a pointer up/down action.
  92089. */
  92090. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92091. /**
  92092. * Representation of a stage in the scene (Basically a list of ordered steps)
  92093. * @hidden
  92094. */
  92095. export class Stage<T extends Function> extends Array<{
  92096. index: number;
  92097. component: ISceneComponent;
  92098. action: T;
  92099. }> {
  92100. /**
  92101. * Hide ctor from the rest of the world.
  92102. * @param items The items to add.
  92103. */
  92104. private constructor();
  92105. /**
  92106. * Creates a new Stage.
  92107. * @returns A new instance of a Stage
  92108. */
  92109. static Create<T extends Function>(): Stage<T>;
  92110. /**
  92111. * Registers a step in an ordered way in the targeted stage.
  92112. * @param index Defines the position to register the step in
  92113. * @param component Defines the component attached to the step
  92114. * @param action Defines the action to launch during the step
  92115. */
  92116. registerStep(index: number, component: ISceneComponent, action: T): void;
  92117. /**
  92118. * Clears all the steps from the stage.
  92119. */
  92120. clear(): void;
  92121. }
  92122. }
  92123. declare module BABYLON {
  92124. interface Scene {
  92125. /** @hidden */
  92126. _pointerOverSprite: Nullable<Sprite>;
  92127. /** @hidden */
  92128. _pickedDownSprite: Nullable<Sprite>;
  92129. /** @hidden */
  92130. _tempSpritePickingRay: Nullable<Ray>;
  92131. /**
  92132. * All of the sprite managers added to this scene
  92133. * @see https://doc.babylonjs.com/babylon101/sprites
  92134. */
  92135. spriteManagers: Array<ISpriteManager>;
  92136. /**
  92137. * An event triggered when sprites rendering is about to start
  92138. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92139. */
  92140. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92141. /**
  92142. * An event triggered when sprites rendering is done
  92143. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92144. */
  92145. onAfterSpritesRenderingObservable: Observable<Scene>;
  92146. /** @hidden */
  92147. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92148. /** Launch a ray to try to pick a sprite in the scene
  92149. * @param x position on screen
  92150. * @param y position on screen
  92151. * @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
  92152. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92153. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92154. * @returns a PickingInfo
  92155. */
  92156. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92157. /** Use the given ray to pick a sprite in the scene
  92158. * @param ray The ray (in world space) to use to pick meshes
  92159. * @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
  92160. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92161. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92162. * @returns a PickingInfo
  92163. */
  92164. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92165. /** @hidden */
  92166. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92167. /** Launch a ray to try to pick sprites in the scene
  92168. * @param x position on screen
  92169. * @param y position on screen
  92170. * @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
  92171. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92172. * @returns a PickingInfo array
  92173. */
  92174. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92175. /** Use the given ray to pick sprites in the scene
  92176. * @param ray The ray (in world space) to use to pick meshes
  92177. * @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
  92178. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92179. * @returns a PickingInfo array
  92180. */
  92181. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92182. /**
  92183. * Force the sprite under the pointer
  92184. * @param sprite defines the sprite to use
  92185. */
  92186. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92187. /**
  92188. * Gets the sprite under the pointer
  92189. * @returns a Sprite or null if no sprite is under the pointer
  92190. */
  92191. getPointerOverSprite(): Nullable<Sprite>;
  92192. }
  92193. /**
  92194. * Defines the sprite scene component responsible to manage sprites
  92195. * in a given scene.
  92196. */
  92197. export class SpriteSceneComponent implements ISceneComponent {
  92198. /**
  92199. * The component name helpfull to identify the component in the list of scene components.
  92200. */
  92201. readonly name: string;
  92202. /**
  92203. * The scene the component belongs to.
  92204. */
  92205. scene: Scene;
  92206. /** @hidden */
  92207. private _spritePredicate;
  92208. /**
  92209. * Creates a new instance of the component for the given scene
  92210. * @param scene Defines the scene to register the component in
  92211. */
  92212. constructor(scene: Scene);
  92213. /**
  92214. * Registers the component in a given scene
  92215. */
  92216. register(): void;
  92217. /**
  92218. * Rebuilds the elements related to this component in case of
  92219. * context lost for instance.
  92220. */
  92221. rebuild(): void;
  92222. /**
  92223. * Disposes the component and the associated ressources.
  92224. */
  92225. dispose(): void;
  92226. private _pickSpriteButKeepRay;
  92227. private _pointerMove;
  92228. private _pointerDown;
  92229. private _pointerUp;
  92230. }
  92231. }
  92232. declare module BABYLON {
  92233. /** @hidden */
  92234. export var fogFragmentDeclaration: {
  92235. name: string;
  92236. shader: string;
  92237. };
  92238. }
  92239. declare module BABYLON {
  92240. /** @hidden */
  92241. export var fogFragment: {
  92242. name: string;
  92243. shader: string;
  92244. };
  92245. }
  92246. declare module BABYLON {
  92247. /** @hidden */
  92248. export var imageProcessingCompatibility: {
  92249. name: string;
  92250. shader: string;
  92251. };
  92252. }
  92253. declare module BABYLON {
  92254. /** @hidden */
  92255. export var spritesPixelShader: {
  92256. name: string;
  92257. shader: string;
  92258. };
  92259. }
  92260. declare module BABYLON {
  92261. /** @hidden */
  92262. export var fogVertexDeclaration: {
  92263. name: string;
  92264. shader: string;
  92265. };
  92266. }
  92267. declare module BABYLON {
  92268. /** @hidden */
  92269. export var spritesVertexShader: {
  92270. name: string;
  92271. shader: string;
  92272. };
  92273. }
  92274. declare module BABYLON {
  92275. /**
  92276. * Defines the minimum interface to fullfil in order to be a sprite manager.
  92277. */
  92278. export interface ISpriteManager extends IDisposable {
  92279. /**
  92280. * Gets manager's name
  92281. */
  92282. name: string;
  92283. /**
  92284. * Restricts the camera to viewing objects with the same layerMask.
  92285. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  92286. */
  92287. layerMask: number;
  92288. /**
  92289. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92290. */
  92291. isPickable: boolean;
  92292. /**
  92293. * Gets the hosting scene
  92294. */
  92295. scene: Scene;
  92296. /**
  92297. * Specifies the rendering group id for this mesh (0 by default)
  92298. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92299. */
  92300. renderingGroupId: number;
  92301. /**
  92302. * Defines the list of sprites managed by the manager.
  92303. */
  92304. sprites: Array<Sprite>;
  92305. /**
  92306. * Gets or sets the spritesheet texture
  92307. */
  92308. texture: Texture;
  92309. /** Defines the default width of a cell in the spritesheet */
  92310. cellWidth: number;
  92311. /** Defines the default height of a cell in the spritesheet */
  92312. cellHeight: number;
  92313. /**
  92314. * Tests the intersection of a sprite with a specific ray.
  92315. * @param ray The ray we are sending to test the collision
  92316. * @param camera The camera space we are sending rays in
  92317. * @param predicate A predicate allowing excluding sprites from the list of object to test
  92318. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92319. * @returns picking info or null.
  92320. */
  92321. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92322. /**
  92323. * Intersects the sprites with a ray
  92324. * @param ray defines the ray to intersect with
  92325. * @param camera defines the current active camera
  92326. * @param predicate defines a predicate used to select candidate sprites
  92327. * @returns null if no hit or a PickingInfo array
  92328. */
  92329. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92330. /**
  92331. * Renders the list of sprites on screen.
  92332. */
  92333. render(): void;
  92334. }
  92335. /**
  92336. * Class used to manage multiple sprites on the same spritesheet
  92337. * @see https://doc.babylonjs.com/babylon101/sprites
  92338. */
  92339. export class SpriteManager implements ISpriteManager {
  92340. /** defines the manager's name */
  92341. name: string;
  92342. /** Define the Url to load snippets */
  92343. static SnippetUrl: string;
  92344. /** Snippet ID if the manager was created from the snippet server */
  92345. snippetId: string;
  92346. /** Gets the list of sprites */
  92347. sprites: Sprite[];
  92348. /** Gets or sets the rendering group id (0 by default) */
  92349. renderingGroupId: number;
  92350. /** Gets or sets camera layer mask */
  92351. layerMask: number;
  92352. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  92353. fogEnabled: boolean;
  92354. /** Gets or sets a boolean indicating if the sprites are pickable */
  92355. isPickable: boolean;
  92356. /** Defines the default width of a cell in the spritesheet */
  92357. cellWidth: number;
  92358. /** Defines the default height of a cell in the spritesheet */
  92359. cellHeight: number;
  92360. /** Associative array from JSON sprite data file */
  92361. private _cellData;
  92362. /** Array of sprite names from JSON sprite data file */
  92363. private _spriteMap;
  92364. /** True when packed cell data from JSON file is ready*/
  92365. private _packedAndReady;
  92366. private _textureContent;
  92367. private _useInstancing;
  92368. /**
  92369. * An event triggered when the manager is disposed.
  92370. */
  92371. onDisposeObservable: Observable<SpriteManager>;
  92372. private _onDisposeObserver;
  92373. /**
  92374. * Callback called when the manager is disposed
  92375. */
  92376. set onDispose(callback: () => void);
  92377. private _capacity;
  92378. private _fromPacked;
  92379. private _spriteTexture;
  92380. private _epsilon;
  92381. private _scene;
  92382. private _vertexData;
  92383. private _buffer;
  92384. private _vertexBuffers;
  92385. private _spriteBuffer;
  92386. private _indexBuffer;
  92387. private _effectBase;
  92388. private _effectFog;
  92389. private _vertexBufferSize;
  92390. /**
  92391. * Gets or sets the unique id of the sprite
  92392. */
  92393. uniqueId: number;
  92394. /**
  92395. * Gets the array of sprites
  92396. */
  92397. get children(): Sprite[];
  92398. /**
  92399. * Gets the hosting scene
  92400. */
  92401. get scene(): Scene;
  92402. /**
  92403. * Gets the capacity of the manager
  92404. */
  92405. get capacity(): number;
  92406. /**
  92407. * Gets or sets the spritesheet texture
  92408. */
  92409. get texture(): Texture;
  92410. set texture(value: Texture);
  92411. private _blendMode;
  92412. /**
  92413. * Blend mode use to render the particle, it can be any of
  92414. * the static Constants.ALPHA_x properties provided in this class.
  92415. * Default value is Constants.ALPHA_COMBINE
  92416. */
  92417. get blendMode(): number;
  92418. set blendMode(blendMode: number);
  92419. /** Disables writing to the depth buffer when rendering the sprites.
  92420. * It can be handy to disable depth writing when using textures without alpha channel
  92421. * and setting some specific blend modes.
  92422. */
  92423. disableDepthWrite: boolean;
  92424. /**
  92425. * Creates a new sprite manager
  92426. * @param name defines the manager's name
  92427. * @param imgUrl defines the sprite sheet url
  92428. * @param capacity defines the maximum allowed number of sprites
  92429. * @param cellSize defines the size of a sprite cell
  92430. * @param scene defines the hosting scene
  92431. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  92432. * @param samplingMode defines the smapling mode to use with spritesheet
  92433. * @param fromPacked set to false; do not alter
  92434. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  92435. */
  92436. constructor(
  92437. /** defines the manager's name */
  92438. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  92439. /**
  92440. * Returns the string "SpriteManager"
  92441. * @returns "SpriteManager"
  92442. */
  92443. getClassName(): string;
  92444. private _makePacked;
  92445. private _appendSpriteVertex;
  92446. private _checkTextureAlpha;
  92447. /**
  92448. * Intersects the sprites with a ray
  92449. * @param ray defines the ray to intersect with
  92450. * @param camera defines the current active camera
  92451. * @param predicate defines a predicate used to select candidate sprites
  92452. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  92453. * @returns null if no hit or a PickingInfo
  92454. */
  92455. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92456. /**
  92457. * Intersects the sprites with a ray
  92458. * @param ray defines the ray to intersect with
  92459. * @param camera defines the current active camera
  92460. * @param predicate defines a predicate used to select candidate sprites
  92461. * @returns null if no hit or a PickingInfo array
  92462. */
  92463. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92464. /**
  92465. * Render all child sprites
  92466. */
  92467. render(): void;
  92468. /**
  92469. * Release associated resources
  92470. */
  92471. dispose(): void;
  92472. /**
  92473. * Serializes the sprite manager to a JSON object
  92474. * @param serializeTexture defines if the texture must be serialized as well
  92475. * @returns the JSON object
  92476. */
  92477. serialize(serializeTexture?: boolean): any;
  92478. /**
  92479. * Parses a JSON object to create a new sprite manager.
  92480. * @param parsedManager The JSON object to parse
  92481. * @param scene The scene to create the sprite managerin
  92482. * @param rootUrl The root url to use to load external dependencies like texture
  92483. * @returns the new sprite manager
  92484. */
  92485. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92486. /**
  92487. * Creates a sprite manager from a snippet saved in a remote file
  92488. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92489. * @param url defines the url to load from
  92490. * @param scene defines the hosting scene
  92491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92492. * @returns a promise that will resolve to the new sprite manager
  92493. */
  92494. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92495. /**
  92496. * Creates a sprite manager from a snippet saved by the sprite editor
  92497. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92498. * @param scene defines the hosting scene
  92499. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92500. * @returns a promise that will resolve to the new sprite manager
  92501. */
  92502. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92503. }
  92504. }
  92505. declare module BABYLON {
  92506. /** Interface used by value gradients (color, factor, ...) */
  92507. export interface IValueGradient {
  92508. /**
  92509. * Gets or sets the gradient value (between 0 and 1)
  92510. */
  92511. gradient: number;
  92512. }
  92513. /** Class used to store color4 gradient */
  92514. export class ColorGradient implements IValueGradient {
  92515. /**
  92516. * Gets or sets the gradient value (between 0 and 1)
  92517. */
  92518. gradient: number;
  92519. /**
  92520. * Gets or sets first associated color
  92521. */
  92522. color1: Color4;
  92523. /**
  92524. * Gets or sets second associated color
  92525. */
  92526. color2?: Color4 | undefined;
  92527. /**
  92528. * Creates a new color4 gradient
  92529. * @param gradient gets or sets the gradient value (between 0 and 1)
  92530. * @param color1 gets or sets first associated color
  92531. * @param color2 gets or sets first second color
  92532. */
  92533. constructor(
  92534. /**
  92535. * Gets or sets the gradient value (between 0 and 1)
  92536. */
  92537. gradient: number,
  92538. /**
  92539. * Gets or sets first associated color
  92540. */
  92541. color1: Color4,
  92542. /**
  92543. * Gets or sets second associated color
  92544. */
  92545. color2?: Color4 | undefined);
  92546. /**
  92547. * Will get a color picked randomly between color1 and color2.
  92548. * If color2 is undefined then color1 will be used
  92549. * @param result defines the target Color4 to store the result in
  92550. */
  92551. getColorToRef(result: Color4): void;
  92552. }
  92553. /** Class used to store color 3 gradient */
  92554. export class Color3Gradient implements IValueGradient {
  92555. /**
  92556. * Gets or sets the gradient value (between 0 and 1)
  92557. */
  92558. gradient: number;
  92559. /**
  92560. * Gets or sets the associated color
  92561. */
  92562. color: Color3;
  92563. /**
  92564. * Creates a new color3 gradient
  92565. * @param gradient gets or sets the gradient value (between 0 and 1)
  92566. * @param color gets or sets associated color
  92567. */
  92568. constructor(
  92569. /**
  92570. * Gets or sets the gradient value (between 0 and 1)
  92571. */
  92572. gradient: number,
  92573. /**
  92574. * Gets or sets the associated color
  92575. */
  92576. color: Color3);
  92577. }
  92578. /** Class used to store factor gradient */
  92579. export class FactorGradient implements IValueGradient {
  92580. /**
  92581. * Gets or sets the gradient value (between 0 and 1)
  92582. */
  92583. gradient: number;
  92584. /**
  92585. * Gets or sets first associated factor
  92586. */
  92587. factor1: number;
  92588. /**
  92589. * Gets or sets second associated factor
  92590. */
  92591. factor2?: number | undefined;
  92592. /**
  92593. * Creates a new factor gradient
  92594. * @param gradient gets or sets the gradient value (between 0 and 1)
  92595. * @param factor1 gets or sets first associated factor
  92596. * @param factor2 gets or sets second associated factor
  92597. */
  92598. constructor(
  92599. /**
  92600. * Gets or sets the gradient value (between 0 and 1)
  92601. */
  92602. gradient: number,
  92603. /**
  92604. * Gets or sets first associated factor
  92605. */
  92606. factor1: number,
  92607. /**
  92608. * Gets or sets second associated factor
  92609. */
  92610. factor2?: number | undefined);
  92611. /**
  92612. * Will get a number picked randomly between factor1 and factor2.
  92613. * If factor2 is undefined then factor1 will be used
  92614. * @returns the picked number
  92615. */
  92616. getFactor(): number;
  92617. }
  92618. /**
  92619. * Helper used to simplify some generic gradient tasks
  92620. */
  92621. export class GradientHelper {
  92622. /**
  92623. * Gets the current gradient from an array of IValueGradient
  92624. * @param ratio defines the current ratio to get
  92625. * @param gradients defines the array of IValueGradient
  92626. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92627. */
  92628. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92629. }
  92630. }
  92631. declare module BABYLON {
  92632. interface ThinEngine {
  92633. /**
  92634. * Creates a raw texture
  92635. * @param data defines the data to store in the texture
  92636. * @param width defines the width of the texture
  92637. * @param height defines the height of the texture
  92638. * @param format defines the format of the data
  92639. * @param generateMipMaps defines if the engine should generate the mip levels
  92640. * @param invertY defines if data must be stored with Y axis inverted
  92641. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92642. * @param compression defines the compression used (null by default)
  92643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92644. * @returns the raw texture inside an InternalTexture
  92645. */
  92646. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92647. /**
  92648. * Update a raw texture
  92649. * @param texture defines the texture to update
  92650. * @param data defines the data to store in the texture
  92651. * @param format defines the format of the data
  92652. * @param invertY defines if data must be stored with Y axis inverted
  92653. */
  92654. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92655. /**
  92656. * Update a raw texture
  92657. * @param texture defines the texture to update
  92658. * @param data defines the data to store in the texture
  92659. * @param format defines the format of the data
  92660. * @param invertY defines if data must be stored with Y axis inverted
  92661. * @param compression defines the compression used (null by default)
  92662. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92663. */
  92664. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92665. /**
  92666. * Creates a new raw cube texture
  92667. * @param data defines the array of data to use to create each face
  92668. * @param size defines the size of the textures
  92669. * @param format defines the format of the data
  92670. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92671. * @param generateMipMaps defines if the engine should generate the mip levels
  92672. * @param invertY defines if data must be stored with Y axis inverted
  92673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92674. * @param compression defines the compression used (null by default)
  92675. * @returns the cube texture as an InternalTexture
  92676. */
  92677. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92678. /**
  92679. * Update a raw cube texture
  92680. * @param texture defines the texture to udpdate
  92681. * @param data defines the data to store
  92682. * @param format defines the data format
  92683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92684. * @param invertY defines if data must be stored with Y axis inverted
  92685. */
  92686. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92687. /**
  92688. * Update a raw cube texture
  92689. * @param texture defines the texture to udpdate
  92690. * @param data defines the data to store
  92691. * @param format defines the data format
  92692. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92693. * @param invertY defines if data must be stored with Y axis inverted
  92694. * @param compression defines the compression used (null by default)
  92695. */
  92696. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92697. /**
  92698. * Update a raw cube texture
  92699. * @param texture defines the texture to udpdate
  92700. * @param data defines the data to store
  92701. * @param format defines the data format
  92702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92703. * @param invertY defines if data must be stored with Y axis inverted
  92704. * @param compression defines the compression used (null by default)
  92705. * @param level defines which level of the texture to update
  92706. */
  92707. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92708. /**
  92709. * Creates a new raw cube texture from a specified url
  92710. * @param url defines the url where the data is located
  92711. * @param scene defines the current scene
  92712. * @param size defines the size of the textures
  92713. * @param format defines the format of the data
  92714. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92715. * @param noMipmap defines if the engine should avoid generating the mip levels
  92716. * @param callback defines a callback used to extract texture data from loaded data
  92717. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92718. * @param onLoad defines a callback called when texture is loaded
  92719. * @param onError defines a callback called if there is an error
  92720. * @returns the cube texture as an InternalTexture
  92721. */
  92722. 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;
  92723. /**
  92724. * Creates a new raw cube texture from a specified url
  92725. * @param url defines the url where the data is located
  92726. * @param scene defines the current scene
  92727. * @param size defines the size of the textures
  92728. * @param format defines the format of the data
  92729. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92730. * @param noMipmap defines if the engine should avoid generating the mip levels
  92731. * @param callback defines a callback used to extract texture data from loaded data
  92732. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92733. * @param onLoad defines a callback called when texture is loaded
  92734. * @param onError defines a callback called if there is an error
  92735. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92736. * @param invertY defines if data must be stored with Y axis inverted
  92737. * @returns the cube texture as an InternalTexture
  92738. */
  92739. 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;
  92740. /**
  92741. * Creates a new raw 3D texture
  92742. * @param data defines the data used to create the texture
  92743. * @param width defines the width of the texture
  92744. * @param height defines the height of the texture
  92745. * @param depth defines the depth of the texture
  92746. * @param format defines the format of the texture
  92747. * @param generateMipMaps defines if the engine must generate mip levels
  92748. * @param invertY defines if data must be stored with Y axis inverted
  92749. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92750. * @param compression defines the compressed used (can be null)
  92751. * @param textureType defines the compressed used (can be null)
  92752. * @returns a new raw 3D texture (stored in an InternalTexture)
  92753. */
  92754. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92755. /**
  92756. * Update a raw 3D texture
  92757. * @param texture defines the texture to update
  92758. * @param data defines the data to store
  92759. * @param format defines the data format
  92760. * @param invertY defines if data must be stored with Y axis inverted
  92761. */
  92762. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92763. /**
  92764. * Update a raw 3D texture
  92765. * @param texture defines the texture to update
  92766. * @param data defines the data to store
  92767. * @param format defines the data format
  92768. * @param invertY defines if data must be stored with Y axis inverted
  92769. * @param compression defines the used compression (can be null)
  92770. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92771. */
  92772. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92773. /**
  92774. * Creates a new raw 2D array texture
  92775. * @param data defines the data used to create the texture
  92776. * @param width defines the width of the texture
  92777. * @param height defines the height of the texture
  92778. * @param depth defines the number of layers of the texture
  92779. * @param format defines the format of the texture
  92780. * @param generateMipMaps defines if the engine must generate mip levels
  92781. * @param invertY defines if data must be stored with Y axis inverted
  92782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92783. * @param compression defines the compressed used (can be null)
  92784. * @param textureType defines the compressed used (can be null)
  92785. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92786. */
  92787. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92788. /**
  92789. * Update a raw 2D array texture
  92790. * @param texture defines the texture to update
  92791. * @param data defines the data to store
  92792. * @param format defines the data format
  92793. * @param invertY defines if data must be stored with Y axis inverted
  92794. */
  92795. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92796. /**
  92797. * Update a raw 2D array texture
  92798. * @param texture defines the texture to update
  92799. * @param data defines the data to store
  92800. * @param format defines the data format
  92801. * @param invertY defines if data must be stored with Y axis inverted
  92802. * @param compression defines the used compression (can be null)
  92803. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92804. */
  92805. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92806. }
  92807. }
  92808. declare module BABYLON {
  92809. /**
  92810. * Raw texture can help creating a texture directly from an array of data.
  92811. * This can be super useful if you either get the data from an uncompressed source or
  92812. * if you wish to create your texture pixel by pixel.
  92813. */
  92814. export class RawTexture extends Texture {
  92815. /**
  92816. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92817. */
  92818. format: number;
  92819. /**
  92820. * Instantiates a new RawTexture.
  92821. * Raw texture can help creating a texture directly from an array of data.
  92822. * This can be super useful if you either get the data from an uncompressed source or
  92823. * if you wish to create your texture pixel by pixel.
  92824. * @param data define the array of data to use to create the texture
  92825. * @param width define the width of the texture
  92826. * @param height define the height of the texture
  92827. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92829. * @param generateMipMaps define whether mip maps should be generated or not
  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. */
  92834. constructor(data: ArrayBufferView, width: number, height: number,
  92835. /**
  92836. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92837. */
  92838. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92839. /**
  92840. * Updates the texture underlying data.
  92841. * @param data Define the new data of the texture
  92842. */
  92843. update(data: ArrayBufferView): void;
  92844. /**
  92845. * Creates a luminance texture from some data.
  92846. * @param data Define the texture data
  92847. * @param width Define the width of the texture
  92848. * @param height Define the height of the texture
  92849. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92850. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92851. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92852. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92853. * @returns the luminance texture
  92854. */
  92855. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92856. /**
  92857. * Creates a luminance alpha texture from some data.
  92858. * @param data Define the texture data
  92859. * @param width Define the width of the texture
  92860. * @param height Define the height of the texture
  92861. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92865. * @returns the luminance alpha texture
  92866. */
  92867. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92868. /**
  92869. * Creates an alpha texture from some data.
  92870. * @param data Define the texture data
  92871. * @param width Define the width of the texture
  92872. * @param height Define the height of the texture
  92873. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92874. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92877. * @returns the alpha texture
  92878. */
  92879. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92880. /**
  92881. * Creates a RGB texture from some data.
  92882. * @param data Define the texture data
  92883. * @param width Define the width of the texture
  92884. * @param height Define the height of the texture
  92885. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92889. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92890. * @returns the RGB alpha texture
  92891. */
  92892. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92893. /**
  92894. * Creates a RGBA texture from some data.
  92895. * @param data Define the texture data
  92896. * @param width Define the width of the texture
  92897. * @param height Define the height of the texture
  92898. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92899. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92900. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92901. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92902. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92903. * @returns the RGBA texture
  92904. */
  92905. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92906. /**
  92907. * Creates a R texture from some data.
  92908. * @param data Define the texture data
  92909. * @param width Define the width of the texture
  92910. * @param height Define the height of the texture
  92911. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92912. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92913. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92914. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92915. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92916. * @returns the R texture
  92917. */
  92918. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92919. }
  92920. }
  92921. declare module BABYLON {
  92922. interface ThinEngine {
  92923. /**
  92924. * Update a dynamic index buffer
  92925. * @param indexBuffer defines the target index buffer
  92926. * @param indices defines the data to update
  92927. * @param offset defines the offset in the target index buffer where update should start
  92928. */
  92929. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92930. /**
  92931. * Updates a dynamic vertex buffer.
  92932. * @param vertexBuffer the vertex buffer to update
  92933. * @param data the data used to update the vertex buffer
  92934. * @param byteOffset the byte offset of the data
  92935. * @param byteLength the byte length of the data
  92936. */
  92937. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92938. }
  92939. }
  92940. declare module BABYLON {
  92941. interface AbstractScene {
  92942. /**
  92943. * The list of procedural textures added to the scene
  92944. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92945. */
  92946. proceduralTextures: Array<ProceduralTexture>;
  92947. }
  92948. /**
  92949. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92950. * in a given scene.
  92951. */
  92952. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92953. /**
  92954. * The component name helpfull to identify the component in the list of scene components.
  92955. */
  92956. readonly name: string;
  92957. /**
  92958. * The scene the component belongs to.
  92959. */
  92960. scene: Scene;
  92961. /**
  92962. * Creates a new instance of the component for the given scene
  92963. * @param scene Defines the scene to register the component in
  92964. */
  92965. constructor(scene: Scene);
  92966. /**
  92967. * Registers the component in a given scene
  92968. */
  92969. register(): void;
  92970. /**
  92971. * Rebuilds the elements related to this component in case of
  92972. * context lost for instance.
  92973. */
  92974. rebuild(): void;
  92975. /**
  92976. * Disposes the component and the associated ressources.
  92977. */
  92978. dispose(): void;
  92979. private _beforeClear;
  92980. }
  92981. }
  92982. declare module BABYLON {
  92983. interface ThinEngine {
  92984. /**
  92985. * Creates a new render target cube texture
  92986. * @param size defines the size of the texture
  92987. * @param options defines the options used to create the texture
  92988. * @returns a new render target cube texture stored in an InternalTexture
  92989. */
  92990. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92991. }
  92992. }
  92993. declare module BABYLON {
  92994. /** @hidden */
  92995. export var proceduralVertexShader: {
  92996. name: string;
  92997. shader: string;
  92998. };
  92999. }
  93000. declare module BABYLON {
  93001. /**
  93002. * 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.
  93003. * This is the base class of any Procedural texture and contains most of the shareable code.
  93004. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  93005. */
  93006. export class ProceduralTexture extends Texture {
  93007. /**
  93008. * Define if the texture is enabled or not (disabled texture will not render)
  93009. */
  93010. isEnabled: boolean;
  93011. /**
  93012. * Define if the texture must be cleared before rendering (default is true)
  93013. */
  93014. autoClear: boolean;
  93015. /**
  93016. * Callback called when the texture is generated
  93017. */
  93018. onGenerated: () => void;
  93019. /**
  93020. * Event raised when the texture is generated
  93021. */
  93022. onGeneratedObservable: Observable<ProceduralTexture>;
  93023. /**
  93024. * Event raised before the texture is generated
  93025. */
  93026. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  93027. /**
  93028. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  93029. */
  93030. nodeMaterialSource: Nullable<NodeMaterial>;
  93031. /** @hidden */
  93032. _generateMipMaps: boolean;
  93033. /** @hidden **/
  93034. _effect: Effect;
  93035. /** @hidden */
  93036. _textures: {
  93037. [key: string]: Texture;
  93038. };
  93039. /** @hidden */
  93040. protected _fallbackTexture: Nullable<Texture>;
  93041. private _size;
  93042. private _currentRefreshId;
  93043. private _frameId;
  93044. private _refreshRate;
  93045. private _vertexBuffers;
  93046. private _indexBuffer;
  93047. private _uniforms;
  93048. private _samplers;
  93049. private _fragment;
  93050. private _floats;
  93051. private _ints;
  93052. private _floatsArrays;
  93053. private _colors3;
  93054. private _colors4;
  93055. private _vectors2;
  93056. private _vectors3;
  93057. private _matrices;
  93058. private _fallbackTextureUsed;
  93059. private _fullEngine;
  93060. private _cachedDefines;
  93061. private _contentUpdateId;
  93062. private _contentData;
  93063. /**
  93064. * Instantiates a new procedural texture.
  93065. * 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.
  93066. * This is the base class of any Procedural texture and contains most of the shareable code.
  93067. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  93068. * @param name Define the name of the texture
  93069. * @param size Define the size of the texture to create
  93070. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  93071. * @param scene Define the scene the texture belongs to
  93072. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  93073. * @param generateMipMaps Define if the texture should creates mip maps or not
  93074. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  93075. * @param textureType The FBO internal texture type
  93076. */
  93077. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  93078. /**
  93079. * The effect that is created when initializing the post process.
  93080. * @returns The created effect corresponding the the postprocess.
  93081. */
  93082. getEffect(): Effect;
  93083. /**
  93084. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  93085. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  93086. */
  93087. getContent(): Nullable<ArrayBufferView>;
  93088. private _createIndexBuffer;
  93089. /** @hidden */
  93090. _rebuild(): void;
  93091. /**
  93092. * Resets the texture in order to recreate its associated resources.
  93093. * This can be called in case of context loss
  93094. */
  93095. reset(): void;
  93096. protected _getDefines(): string;
  93097. /**
  93098. * Is the texture ready to be used ? (rendered at least once)
  93099. * @returns true if ready, otherwise, false.
  93100. */
  93101. isReady(): boolean;
  93102. /**
  93103. * Resets the refresh counter of the texture and start bak from scratch.
  93104. * Could be useful to regenerate the texture if it is setup to render only once.
  93105. */
  93106. resetRefreshCounter(): void;
  93107. /**
  93108. * Set the fragment shader to use in order to render the texture.
  93109. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  93110. */
  93111. setFragment(fragment: any): void;
  93112. /**
  93113. * Define the refresh rate of the texture or the rendering frequency.
  93114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93115. */
  93116. get refreshRate(): number;
  93117. set refreshRate(value: number);
  93118. /** @hidden */
  93119. _shouldRender(): boolean;
  93120. /**
  93121. * Get the size the texture is rendering at.
  93122. * @returns the size (on cube texture it is always squared)
  93123. */
  93124. getRenderSize(): RenderTargetTextureSize;
  93125. /**
  93126. * Resize the texture to new value.
  93127. * @param size Define the new size the texture should have
  93128. * @param generateMipMaps Define whether the new texture should create mip maps
  93129. */
  93130. resize(size: number, generateMipMaps: boolean): void;
  93131. private _checkUniform;
  93132. /**
  93133. * Set a texture in the shader program used to render.
  93134. * @param name Define the name of the uniform samplers as defined in the shader
  93135. * @param texture Define the texture to bind to this sampler
  93136. * @return the texture itself allowing "fluent" like uniform updates
  93137. */
  93138. setTexture(name: string, texture: Texture): ProceduralTexture;
  93139. /**
  93140. * Set a float in the shader.
  93141. * @param name Define the name of the uniform as defined in the shader
  93142. * @param value Define the value to give to the uniform
  93143. * @return the texture itself allowing "fluent" like uniform updates
  93144. */
  93145. setFloat(name: string, value: number): ProceduralTexture;
  93146. /**
  93147. * Set a int in the shader.
  93148. * @param name Define the name of the uniform as defined in the shader
  93149. * @param value Define the value to give to the uniform
  93150. * @return the texture itself allowing "fluent" like uniform updates
  93151. */
  93152. setInt(name: string, value: number): ProceduralTexture;
  93153. /**
  93154. * Set an array of floats in the shader.
  93155. * @param name Define the name of the uniform as defined in the shader
  93156. * @param value Define the value to give to the uniform
  93157. * @return the texture itself allowing "fluent" like uniform updates
  93158. */
  93159. setFloats(name: string, value: number[]): ProceduralTexture;
  93160. /**
  93161. * Set a vec3 in the shader from a Color3.
  93162. * @param name Define the name of the uniform as defined in the shader
  93163. * @param value Define the value to give to the uniform
  93164. * @return the texture itself allowing "fluent" like uniform updates
  93165. */
  93166. setColor3(name: string, value: Color3): ProceduralTexture;
  93167. /**
  93168. * Set a vec4 in the shader from a Color4.
  93169. * @param name Define the name of the uniform as defined in the shader
  93170. * @param value Define the value to give to the uniform
  93171. * @return the texture itself allowing "fluent" like uniform updates
  93172. */
  93173. setColor4(name: string, value: Color4): ProceduralTexture;
  93174. /**
  93175. * Set a vec2 in the shader from a Vector2.
  93176. * @param name Define the name of the uniform as defined in the shader
  93177. * @param value Define the value to give to the uniform
  93178. * @return the texture itself allowing "fluent" like uniform updates
  93179. */
  93180. setVector2(name: string, value: Vector2): ProceduralTexture;
  93181. /**
  93182. * Set a vec3 in the shader from a Vector3.
  93183. * @param name Define the name of the uniform as defined in the shader
  93184. * @param value Define the value to give to the uniform
  93185. * @return the texture itself allowing "fluent" like uniform updates
  93186. */
  93187. setVector3(name: string, value: Vector3): ProceduralTexture;
  93188. /**
  93189. * Set a mat4 in the shader from a MAtrix.
  93190. * @param name Define the name of the uniform as defined in the shader
  93191. * @param value Define the value to give to the uniform
  93192. * @return the texture itself allowing "fluent" like uniform updates
  93193. */
  93194. setMatrix(name: string, value: Matrix): ProceduralTexture;
  93195. /**
  93196. * Render the texture to its associated render target.
  93197. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  93198. */
  93199. render(useCameraPostProcess?: boolean): void;
  93200. /**
  93201. * Clone the texture.
  93202. * @returns the cloned texture
  93203. */
  93204. clone(): ProceduralTexture;
  93205. /**
  93206. * Dispose the texture and release its asoociated resources.
  93207. */
  93208. dispose(): void;
  93209. }
  93210. }
  93211. declare module BABYLON {
  93212. /**
  93213. * This represents the base class for particle system in Babylon.
  93214. * 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.
  93215. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93216. * @example https://doc.babylonjs.com/babylon101/particles
  93217. */
  93218. export class BaseParticleSystem {
  93219. /**
  93220. * Source color is added to the destination color without alpha affecting the result
  93221. */
  93222. static BLENDMODE_ONEONE: number;
  93223. /**
  93224. * Blend current color and particle color using particle’s alpha
  93225. */
  93226. static BLENDMODE_STANDARD: number;
  93227. /**
  93228. * Add current color and particle color multiplied by particle’s alpha
  93229. */
  93230. static BLENDMODE_ADD: number;
  93231. /**
  93232. * Multiply current color with particle color
  93233. */
  93234. static BLENDMODE_MULTIPLY: number;
  93235. /**
  93236. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  93237. */
  93238. static BLENDMODE_MULTIPLYADD: number;
  93239. /**
  93240. * List of animations used by the particle system.
  93241. */
  93242. animations: Animation[];
  93243. /**
  93244. * Gets or sets the unique id of the particle system
  93245. */
  93246. uniqueId: number;
  93247. /**
  93248. * The id of the Particle system.
  93249. */
  93250. id: string;
  93251. /**
  93252. * The friendly name of the Particle system.
  93253. */
  93254. name: string;
  93255. /**
  93256. * Snippet ID if the particle system was created from the snippet server
  93257. */
  93258. snippetId: string;
  93259. /**
  93260. * The rendering group used by the Particle system to chose when to render.
  93261. */
  93262. renderingGroupId: number;
  93263. /**
  93264. * The emitter represents the Mesh or position we are attaching the particle system to.
  93265. */
  93266. emitter: Nullable<AbstractMesh | Vector3>;
  93267. /**
  93268. * The maximum number of particles to emit per frame
  93269. */
  93270. emitRate: number;
  93271. /**
  93272. * If you want to launch only a few particles at once, that can be done, as well.
  93273. */
  93274. manualEmitCount: number;
  93275. /**
  93276. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93277. */
  93278. updateSpeed: number;
  93279. /**
  93280. * The amount of time the particle system is running (depends of the overall update speed).
  93281. */
  93282. targetStopDuration: number;
  93283. /**
  93284. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93285. */
  93286. disposeOnStop: boolean;
  93287. /**
  93288. * Minimum power of emitting particles.
  93289. */
  93290. minEmitPower: number;
  93291. /**
  93292. * Maximum power of emitting particles.
  93293. */
  93294. maxEmitPower: number;
  93295. /**
  93296. * Minimum life time of emitting particles.
  93297. */
  93298. minLifeTime: number;
  93299. /**
  93300. * Maximum life time of emitting particles.
  93301. */
  93302. maxLifeTime: number;
  93303. /**
  93304. * Minimum Size of emitting particles.
  93305. */
  93306. minSize: number;
  93307. /**
  93308. * Maximum Size of emitting particles.
  93309. */
  93310. maxSize: number;
  93311. /**
  93312. * Minimum scale of emitting particles on X axis.
  93313. */
  93314. minScaleX: number;
  93315. /**
  93316. * Maximum scale of emitting particles on X axis.
  93317. */
  93318. maxScaleX: number;
  93319. /**
  93320. * Minimum scale of emitting particles on Y axis.
  93321. */
  93322. minScaleY: number;
  93323. /**
  93324. * Maximum scale of emitting particles on Y axis.
  93325. */
  93326. maxScaleY: number;
  93327. /**
  93328. * Gets or sets the minimal initial rotation in radians.
  93329. */
  93330. minInitialRotation: number;
  93331. /**
  93332. * Gets or sets the maximal initial rotation in radians.
  93333. */
  93334. maxInitialRotation: number;
  93335. /**
  93336. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93337. */
  93338. minAngularSpeed: number;
  93339. /**
  93340. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93341. */
  93342. maxAngularSpeed: number;
  93343. /**
  93344. * The texture used to render each particle. (this can be a spritesheet)
  93345. */
  93346. particleTexture: Nullable<BaseTexture>;
  93347. /**
  93348. * The layer mask we are rendering the particles through.
  93349. */
  93350. layerMask: number;
  93351. /**
  93352. * This can help using your own shader to render the particle system.
  93353. * The according effect will be created
  93354. */
  93355. customShader: any;
  93356. /**
  93357. * By default particle system starts as soon as they are created. This prevents the
  93358. * automatic start to happen and let you decide when to start emitting particles.
  93359. */
  93360. preventAutoStart: boolean;
  93361. private _noiseTexture;
  93362. /**
  93363. * Gets or sets a texture used to add random noise to particle positions
  93364. */
  93365. get noiseTexture(): Nullable<ProceduralTexture>;
  93366. set noiseTexture(value: Nullable<ProceduralTexture>);
  93367. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93368. noiseStrength: Vector3;
  93369. /**
  93370. * Callback triggered when the particle animation is ending.
  93371. */
  93372. onAnimationEnd: Nullable<() => void>;
  93373. /**
  93374. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  93375. */
  93376. blendMode: number;
  93377. /**
  93378. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  93379. * to override the particles.
  93380. */
  93381. forceDepthWrite: boolean;
  93382. /** 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 */
  93383. preWarmCycles: number;
  93384. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  93385. preWarmStepOffset: number;
  93386. /**
  93387. * 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)
  93388. */
  93389. spriteCellChangeSpeed: number;
  93390. /**
  93391. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93392. */
  93393. startSpriteCellID: number;
  93394. /**
  93395. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93396. */
  93397. endSpriteCellID: number;
  93398. /**
  93399. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93400. */
  93401. spriteCellWidth: number;
  93402. /**
  93403. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93404. */
  93405. spriteCellHeight: number;
  93406. /**
  93407. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93408. */
  93409. spriteRandomStartCell: boolean;
  93410. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93411. translationPivot: Vector2;
  93412. /** @hidden */
  93413. protected _isAnimationSheetEnabled: boolean;
  93414. /**
  93415. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93416. */
  93417. beginAnimationOnStart: boolean;
  93418. /**
  93419. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93420. */
  93421. beginAnimationFrom: number;
  93422. /**
  93423. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93424. */
  93425. beginAnimationTo: number;
  93426. /**
  93427. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93428. */
  93429. beginAnimationLoop: boolean;
  93430. /**
  93431. * Gets or sets a world offset applied to all particles
  93432. */
  93433. worldOffset: Vector3;
  93434. /**
  93435. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  93436. */
  93437. get isAnimationSheetEnabled(): boolean;
  93438. set isAnimationSheetEnabled(value: boolean);
  93439. /**
  93440. * Get hosting scene
  93441. * @returns the scene
  93442. */
  93443. getScene(): Nullable<Scene>;
  93444. /**
  93445. * You can use gravity if you want to give an orientation to your particles.
  93446. */
  93447. gravity: Vector3;
  93448. protected _colorGradients: Nullable<Array<ColorGradient>>;
  93449. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  93450. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  93451. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  93452. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  93453. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  93454. protected _dragGradients: Nullable<Array<FactorGradient>>;
  93455. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  93456. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  93457. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  93458. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  93459. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  93460. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  93461. /**
  93462. * Defines the delay in milliseconds before starting the system (0 by default)
  93463. */
  93464. startDelay: number;
  93465. /**
  93466. * Gets the current list of drag gradients.
  93467. * You must use addDragGradient and removeDragGradient to udpate this list
  93468. * @returns the list of drag gradients
  93469. */
  93470. getDragGradients(): Nullable<Array<FactorGradient>>;
  93471. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93472. limitVelocityDamping: number;
  93473. /**
  93474. * Gets the current list of limit velocity gradients.
  93475. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93476. * @returns the list of limit velocity gradients
  93477. */
  93478. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93479. /**
  93480. * Gets the current list of color gradients.
  93481. * You must use addColorGradient and removeColorGradient to udpate this list
  93482. * @returns the list of color gradients
  93483. */
  93484. getColorGradients(): Nullable<Array<ColorGradient>>;
  93485. /**
  93486. * Gets the current list of size gradients.
  93487. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93488. * @returns the list of size gradients
  93489. */
  93490. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93491. /**
  93492. * Gets the current list of color remap gradients.
  93493. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93494. * @returns the list of color remap gradients
  93495. */
  93496. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93497. /**
  93498. * Gets the current list of alpha remap gradients.
  93499. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93500. * @returns the list of alpha remap gradients
  93501. */
  93502. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93503. /**
  93504. * Gets the current list of life time gradients.
  93505. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93506. * @returns the list of life time gradients
  93507. */
  93508. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93509. /**
  93510. * Gets the current list of angular speed gradients.
  93511. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93512. * @returns the list of angular speed gradients
  93513. */
  93514. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93515. /**
  93516. * Gets the current list of velocity gradients.
  93517. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93518. * @returns the list of velocity gradients
  93519. */
  93520. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93521. /**
  93522. * Gets the current list of start size gradients.
  93523. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93524. * @returns the list of start size gradients
  93525. */
  93526. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93527. /**
  93528. * Gets the current list of emit rate gradients.
  93529. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93530. * @returns the list of emit rate gradients
  93531. */
  93532. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93533. /**
  93534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93535. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93536. */
  93537. get direction1(): Vector3;
  93538. set direction1(value: Vector3);
  93539. /**
  93540. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93541. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93542. */
  93543. get direction2(): Vector3;
  93544. set direction2(value: Vector3);
  93545. /**
  93546. * 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.
  93547. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93548. */
  93549. get minEmitBox(): Vector3;
  93550. set minEmitBox(value: Vector3);
  93551. /**
  93552. * 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.
  93553. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93554. */
  93555. get maxEmitBox(): Vector3;
  93556. set maxEmitBox(value: Vector3);
  93557. /**
  93558. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93559. */
  93560. color1: Color4;
  93561. /**
  93562. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93563. */
  93564. color2: Color4;
  93565. /**
  93566. * Color the particle will have at the end of its lifetime
  93567. */
  93568. colorDead: Color4;
  93569. /**
  93570. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93571. */
  93572. textureMask: Color4;
  93573. /**
  93574. * The particle emitter type defines the emitter used by the particle system.
  93575. * It can be for example box, sphere, or cone...
  93576. */
  93577. particleEmitterType: IParticleEmitterType;
  93578. /** @hidden */
  93579. _isSubEmitter: boolean;
  93580. /**
  93581. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93582. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93583. */
  93584. billboardMode: number;
  93585. protected _isBillboardBased: boolean;
  93586. /**
  93587. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93588. */
  93589. get isBillboardBased(): boolean;
  93590. set isBillboardBased(value: boolean);
  93591. /**
  93592. * The scene the particle system belongs to.
  93593. */
  93594. protected _scene: Nullable<Scene>;
  93595. /**
  93596. * The engine the particle system belongs to.
  93597. */
  93598. protected _engine: ThinEngine;
  93599. /**
  93600. * Local cache of defines for image processing.
  93601. */
  93602. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93603. /**
  93604. * Default configuration related to image processing available in the standard Material.
  93605. */
  93606. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93607. /**
  93608. * Gets the image processing configuration used either in this material.
  93609. */
  93610. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93611. /**
  93612. * Sets the Default image processing configuration used either in the this material.
  93613. *
  93614. * If sets to null, the scene one is in use.
  93615. */
  93616. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93617. /**
  93618. * Attaches a new image processing configuration to the Standard Material.
  93619. * @param configuration
  93620. */
  93621. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93622. /** @hidden */
  93623. protected _reset(): void;
  93624. /** @hidden */
  93625. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93626. /**
  93627. * Instantiates a particle system.
  93628. * 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.
  93629. * @param name The name of the particle system
  93630. */
  93631. constructor(name: string);
  93632. /**
  93633. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93634. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93635. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93636. * @returns the emitter
  93637. */
  93638. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93639. /**
  93640. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93641. * @param radius The radius of the hemisphere to emit from
  93642. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93643. * @returns the emitter
  93644. */
  93645. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93646. /**
  93647. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93648. * @param radius The radius of the sphere to emit from
  93649. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93650. * @returns the emitter
  93651. */
  93652. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93653. /**
  93654. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93655. * @param radius The radius of the sphere to emit from
  93656. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93657. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93658. * @returns the emitter
  93659. */
  93660. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93661. /**
  93662. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93663. * @param radius The radius of the emission cylinder
  93664. * @param height The height of the emission cylinder
  93665. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93666. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93667. * @returns the emitter
  93668. */
  93669. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93670. /**
  93671. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93672. * @param radius The radius of the cylinder to emit from
  93673. * @param height The height of the emission cylinder
  93674. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93677. * @returns the emitter
  93678. */
  93679. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93680. /**
  93681. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93682. * @param radius The radius of the cone to emit from
  93683. * @param angle The base angle of the cone
  93684. * @returns the emitter
  93685. */
  93686. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93687. /**
  93688. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93689. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93690. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93691. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93692. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93693. * @returns the emitter
  93694. */
  93695. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93696. }
  93697. }
  93698. declare module BABYLON {
  93699. /**
  93700. * Type of sub emitter
  93701. */
  93702. export enum SubEmitterType {
  93703. /**
  93704. * Attached to the particle over it's lifetime
  93705. */
  93706. ATTACHED = 0,
  93707. /**
  93708. * Created when the particle dies
  93709. */
  93710. END = 1
  93711. }
  93712. /**
  93713. * Sub emitter class used to emit particles from an existing particle
  93714. */
  93715. export class SubEmitter {
  93716. /**
  93717. * the particle system to be used by the sub emitter
  93718. */
  93719. particleSystem: ParticleSystem;
  93720. /**
  93721. * Type of the submitter (Default: END)
  93722. */
  93723. type: SubEmitterType;
  93724. /**
  93725. * 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)
  93726. * Note: This only is supported when using an emitter of type Mesh
  93727. */
  93728. inheritDirection: boolean;
  93729. /**
  93730. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93731. */
  93732. inheritedVelocityAmount: number;
  93733. /**
  93734. * Creates a sub emitter
  93735. * @param particleSystem the particle system to be used by the sub emitter
  93736. */
  93737. constructor(
  93738. /**
  93739. * the particle system to be used by the sub emitter
  93740. */
  93741. particleSystem: ParticleSystem);
  93742. /**
  93743. * Clones the sub emitter
  93744. * @returns the cloned sub emitter
  93745. */
  93746. clone(): SubEmitter;
  93747. /**
  93748. * Serialize current object to a JSON object
  93749. * @returns the serialized object
  93750. */
  93751. serialize(): any;
  93752. /** @hidden */
  93753. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93754. /**
  93755. * Creates a new SubEmitter from a serialized JSON version
  93756. * @param serializationObject defines the JSON object to read from
  93757. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93758. * @param rootUrl defines the rootUrl for data loading
  93759. * @returns a new SubEmitter
  93760. */
  93761. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93762. /** Release associated resources */
  93763. dispose(): void;
  93764. }
  93765. }
  93766. declare module BABYLON {
  93767. /** @hidden */
  93768. export var imageProcessingDeclaration: {
  93769. name: string;
  93770. shader: string;
  93771. };
  93772. }
  93773. declare module BABYLON {
  93774. /** @hidden */
  93775. export var imageProcessingFunctions: {
  93776. name: string;
  93777. shader: string;
  93778. };
  93779. }
  93780. declare module BABYLON {
  93781. /** @hidden */
  93782. export var particlesPixelShader: {
  93783. name: string;
  93784. shader: string;
  93785. };
  93786. }
  93787. declare module BABYLON {
  93788. /** @hidden */
  93789. export var particlesVertexShader: {
  93790. name: string;
  93791. shader: string;
  93792. };
  93793. }
  93794. declare module BABYLON {
  93795. /**
  93796. * Interface used to define entities containing multiple clip planes
  93797. */
  93798. export interface IClipPlanesHolder {
  93799. /**
  93800. * Gets or sets the active clipplane 1
  93801. */
  93802. clipPlane: Nullable<Plane>;
  93803. /**
  93804. * Gets or sets the active clipplane 2
  93805. */
  93806. clipPlane2: Nullable<Plane>;
  93807. /**
  93808. * Gets or sets the active clipplane 3
  93809. */
  93810. clipPlane3: Nullable<Plane>;
  93811. /**
  93812. * Gets or sets the active clipplane 4
  93813. */
  93814. clipPlane4: Nullable<Plane>;
  93815. /**
  93816. * Gets or sets the active clipplane 5
  93817. */
  93818. clipPlane5: Nullable<Plane>;
  93819. /**
  93820. * Gets or sets the active clipplane 6
  93821. */
  93822. clipPlane6: Nullable<Plane>;
  93823. }
  93824. }
  93825. declare module BABYLON {
  93826. /**
  93827. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93828. *
  93829. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93830. *
  93831. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93832. */
  93833. export class ThinMaterialHelper {
  93834. /**
  93835. * Binds the clip plane information from the holder to the effect.
  93836. * @param effect The effect we are binding the data to
  93837. * @param holder The entity containing the clip plane information
  93838. */
  93839. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93840. }
  93841. }
  93842. declare module BABYLON {
  93843. interface ThinEngine {
  93844. /**
  93845. * Sets alpha constants used by some alpha blending modes
  93846. * @param r defines the red component
  93847. * @param g defines the green component
  93848. * @param b defines the blue component
  93849. * @param a defines the alpha component
  93850. */
  93851. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93852. /**
  93853. * Sets the current alpha mode
  93854. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93855. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93856. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93857. */
  93858. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93859. /**
  93860. * Gets the current alpha mode
  93861. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93862. * @returns the current alpha mode
  93863. */
  93864. getAlphaMode(): number;
  93865. /**
  93866. * Sets the current alpha equation
  93867. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93868. */
  93869. setAlphaEquation(equation: number): void;
  93870. /**
  93871. * Gets the current alpha equation.
  93872. * @returns the current alpha equation
  93873. */
  93874. getAlphaEquation(): number;
  93875. }
  93876. }
  93877. declare module BABYLON {
  93878. /**
  93879. * This represents a particle system in Babylon.
  93880. * 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.
  93881. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93882. * @example https://doc.babylonjs.com/babylon101/particles
  93883. */
  93884. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93885. /**
  93886. * Billboard mode will only apply to Y axis
  93887. */
  93888. static readonly BILLBOARDMODE_Y: number;
  93889. /**
  93890. * Billboard mode will apply to all axes
  93891. */
  93892. static readonly BILLBOARDMODE_ALL: number;
  93893. /**
  93894. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93895. */
  93896. static readonly BILLBOARDMODE_STRETCHED: number;
  93897. /**
  93898. * This function can be defined to provide custom update for active particles.
  93899. * This function will be called instead of regular update (age, position, color, etc.).
  93900. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93901. */
  93902. updateFunction: (particles: Particle[]) => void;
  93903. private _emitterWorldMatrix;
  93904. /**
  93905. * This function can be defined to specify initial direction for every new particle.
  93906. * It by default use the emitterType defined function
  93907. */
  93908. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93909. /**
  93910. * This function can be defined to specify initial position for every new particle.
  93911. * It by default use the emitterType defined function
  93912. */
  93913. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93914. /**
  93915. * @hidden
  93916. */
  93917. _inheritedVelocityOffset: Vector3;
  93918. /**
  93919. * An event triggered when the system is disposed
  93920. */
  93921. onDisposeObservable: Observable<IParticleSystem>;
  93922. /**
  93923. * An event triggered when the system is stopped
  93924. */
  93925. onStoppedObservable: Observable<IParticleSystem>;
  93926. private _onDisposeObserver;
  93927. /**
  93928. * Sets a callback that will be triggered when the system is disposed
  93929. */
  93930. set onDispose(callback: () => void);
  93931. private _particles;
  93932. private _epsilon;
  93933. private _capacity;
  93934. private _stockParticles;
  93935. private _newPartsExcess;
  93936. private _vertexData;
  93937. private _vertexBuffer;
  93938. private _vertexBuffers;
  93939. private _spriteBuffer;
  93940. private _indexBuffer;
  93941. private _effect;
  93942. private _customEffect;
  93943. private _cachedDefines;
  93944. private _scaledColorStep;
  93945. private _colorDiff;
  93946. private _scaledDirection;
  93947. private _scaledGravity;
  93948. private _currentRenderId;
  93949. private _alive;
  93950. private _useInstancing;
  93951. private _vertexArrayObject;
  93952. private _started;
  93953. private _stopped;
  93954. private _actualFrame;
  93955. private _scaledUpdateSpeed;
  93956. private _vertexBufferSize;
  93957. /** @hidden */
  93958. _currentEmitRateGradient: Nullable<FactorGradient>;
  93959. /** @hidden */
  93960. _currentEmitRate1: number;
  93961. /** @hidden */
  93962. _currentEmitRate2: number;
  93963. /** @hidden */
  93964. _currentStartSizeGradient: Nullable<FactorGradient>;
  93965. /** @hidden */
  93966. _currentStartSize1: number;
  93967. /** @hidden */
  93968. _currentStartSize2: number;
  93969. private readonly _rawTextureWidth;
  93970. private _rampGradientsTexture;
  93971. private _useRampGradients;
  93972. /** Gets or sets a matrix to use to compute projection */
  93973. defaultProjectionMatrix: Matrix;
  93974. /** Gets or sets a matrix to use to compute view */
  93975. defaultViewMatrix: Matrix;
  93976. /** Gets or sets a boolean indicating that ramp gradients must be used
  93977. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93978. */
  93979. get useRampGradients(): boolean;
  93980. set useRampGradients(value: boolean);
  93981. /**
  93982. * 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.
  93983. * 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: [])
  93984. */
  93985. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93986. private _subEmitters;
  93987. /**
  93988. * @hidden
  93989. * If the particle systems emitter should be disposed when the particle system is disposed
  93990. */
  93991. _disposeEmitterOnDispose: boolean;
  93992. /**
  93993. * The current active Sub-systems, this property is used by the root particle system only.
  93994. */
  93995. activeSubSystems: Array<ParticleSystem>;
  93996. /**
  93997. * Specifies if the particles are updated in emitter local space or world space
  93998. */
  93999. isLocal: boolean;
  94000. private _rootParticleSystem;
  94001. /**
  94002. * Gets the current list of active particles
  94003. */
  94004. get particles(): Particle[];
  94005. /**
  94006. * Gets the number of particles active at the same time.
  94007. * @returns The number of active particles.
  94008. */
  94009. getActiveCount(): number;
  94010. /**
  94011. * Returns the string "ParticleSystem"
  94012. * @returns a string containing the class name
  94013. */
  94014. getClassName(): string;
  94015. /**
  94016. * Gets a boolean indicating that the system is stopping
  94017. * @returns true if the system is currently stopping
  94018. */
  94019. isStopping(): boolean;
  94020. /**
  94021. * Gets the custom effect used to render the particles
  94022. * @param blendMode Blend mode for which the effect should be retrieved
  94023. * @returns The effect
  94024. */
  94025. getCustomEffect(blendMode?: number): Nullable<Effect>;
  94026. /**
  94027. * Sets the custom effect used to render the particles
  94028. * @param effect The effect to set
  94029. * @param blendMode Blend mode for which the effect should be set
  94030. */
  94031. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  94032. /** @hidden */
  94033. private _onBeforeDrawParticlesObservable;
  94034. /**
  94035. * Observable that will be called just before the particles are drawn
  94036. */
  94037. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  94038. /**
  94039. * Gets the name of the particle vertex shader
  94040. */
  94041. get vertexShaderName(): string;
  94042. /**
  94043. * Instantiates a particle system.
  94044. * 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.
  94045. * @param name The name of the particle system
  94046. * @param capacity The max number of particles alive at the same time
  94047. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  94048. * @param customEffect a custom effect used to change the way particles are rendered by default
  94049. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  94050. * @param epsilon Offset used to render the particles
  94051. */
  94052. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  94053. private _addFactorGradient;
  94054. private _removeFactorGradient;
  94055. /**
  94056. * Adds a new life time gradient
  94057. * @param gradient defines the gradient to use (between 0 and 1)
  94058. * @param factor defines the life time factor to affect to the specified gradient
  94059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94060. * @returns the current particle system
  94061. */
  94062. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94063. /**
  94064. * Remove a specific life time gradient
  94065. * @param gradient defines the gradient to remove
  94066. * @returns the current particle system
  94067. */
  94068. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94069. /**
  94070. * Adds a new size gradient
  94071. * @param gradient defines the gradient to use (between 0 and 1)
  94072. * @param factor defines the size factor to affect to the specified gradient
  94073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94074. * @returns the current particle system
  94075. */
  94076. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94077. /**
  94078. * Remove a specific size gradient
  94079. * @param gradient defines the gradient to remove
  94080. * @returns the current particle system
  94081. */
  94082. removeSizeGradient(gradient: number): IParticleSystem;
  94083. /**
  94084. * Adds a new color remap gradient
  94085. * @param gradient defines the gradient to use (between 0 and 1)
  94086. * @param min defines the color remap minimal range
  94087. * @param max defines the color remap maximal range
  94088. * @returns the current particle system
  94089. */
  94090. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94091. /**
  94092. * Remove a specific color remap gradient
  94093. * @param gradient defines the gradient to remove
  94094. * @returns the current particle system
  94095. */
  94096. removeColorRemapGradient(gradient: number): IParticleSystem;
  94097. /**
  94098. * Adds a new alpha remap gradient
  94099. * @param gradient defines the gradient to use (between 0 and 1)
  94100. * @param min defines the alpha remap minimal range
  94101. * @param max defines the alpha remap maximal range
  94102. * @returns the current particle system
  94103. */
  94104. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94105. /**
  94106. * Remove a specific alpha remap gradient
  94107. * @param gradient defines the gradient to remove
  94108. * @returns the current particle system
  94109. */
  94110. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  94111. /**
  94112. * Adds a new angular speed gradient
  94113. * @param gradient defines the gradient to use (between 0 and 1)
  94114. * @param factor defines the angular speed to affect to the specified gradient
  94115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94116. * @returns the current particle system
  94117. */
  94118. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94119. /**
  94120. * Remove a specific angular speed gradient
  94121. * @param gradient defines the gradient to remove
  94122. * @returns the current particle system
  94123. */
  94124. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94125. /**
  94126. * Adds a new velocity gradient
  94127. * @param gradient defines the gradient to use (between 0 and 1)
  94128. * @param factor defines the velocity to affect to the specified gradient
  94129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94130. * @returns the current particle system
  94131. */
  94132. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94133. /**
  94134. * Remove a specific velocity gradient
  94135. * @param gradient defines the gradient to remove
  94136. * @returns the current particle system
  94137. */
  94138. removeVelocityGradient(gradient: number): IParticleSystem;
  94139. /**
  94140. * Adds a new limit velocity gradient
  94141. * @param gradient defines the gradient to use (between 0 and 1)
  94142. * @param factor defines the limit velocity value to affect to the specified gradient
  94143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94144. * @returns the current particle system
  94145. */
  94146. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94147. /**
  94148. * Remove a specific limit velocity gradient
  94149. * @param gradient defines the gradient to remove
  94150. * @returns the current particle system
  94151. */
  94152. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94153. /**
  94154. * Adds a new drag gradient
  94155. * @param gradient defines the gradient to use (between 0 and 1)
  94156. * @param factor defines the drag value to affect to the specified gradient
  94157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94158. * @returns the current particle system
  94159. */
  94160. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94161. /**
  94162. * Remove a specific drag gradient
  94163. * @param gradient defines the gradient to remove
  94164. * @returns the current particle system
  94165. */
  94166. removeDragGradient(gradient: number): IParticleSystem;
  94167. /**
  94168. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94169. * @param gradient defines the gradient to use (between 0 and 1)
  94170. * @param factor defines the emit rate value to affect to the specified gradient
  94171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94172. * @returns the current particle system
  94173. */
  94174. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94175. /**
  94176. * Remove a specific emit rate gradient
  94177. * @param gradient defines the gradient to remove
  94178. * @returns the current particle system
  94179. */
  94180. removeEmitRateGradient(gradient: number): IParticleSystem;
  94181. /**
  94182. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94183. * @param gradient defines the gradient to use (between 0 and 1)
  94184. * @param factor defines the start size value to affect to the specified gradient
  94185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94186. * @returns the current particle system
  94187. */
  94188. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94189. /**
  94190. * Remove a specific start size gradient
  94191. * @param gradient defines the gradient to remove
  94192. * @returns the current particle system
  94193. */
  94194. removeStartSizeGradient(gradient: number): IParticleSystem;
  94195. private _createRampGradientTexture;
  94196. /**
  94197. * Gets the current list of ramp gradients.
  94198. * You must use addRampGradient and removeRampGradient to udpate this list
  94199. * @returns the list of ramp gradients
  94200. */
  94201. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94202. /** Force the system to rebuild all gradients that need to be resync */
  94203. forceRefreshGradients(): void;
  94204. private _syncRampGradientTexture;
  94205. /**
  94206. * Adds a new ramp gradient used to remap particle colors
  94207. * @param gradient defines the gradient to use (between 0 and 1)
  94208. * @param color defines the color to affect to the specified gradient
  94209. * @returns the current particle system
  94210. */
  94211. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  94212. /**
  94213. * Remove a specific ramp gradient
  94214. * @param gradient defines the gradient to remove
  94215. * @returns the current particle system
  94216. */
  94217. removeRampGradient(gradient: number): ParticleSystem;
  94218. /**
  94219. * Adds a new color gradient
  94220. * @param gradient defines the gradient to use (between 0 and 1)
  94221. * @param color1 defines the color to affect to the specified gradient
  94222. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94223. * @returns this particle system
  94224. */
  94225. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94226. /**
  94227. * Remove a specific color gradient
  94228. * @param gradient defines the gradient to remove
  94229. * @returns this particle system
  94230. */
  94231. removeColorGradient(gradient: number): IParticleSystem;
  94232. private _fetchR;
  94233. protected _reset(): void;
  94234. private _resetEffect;
  94235. private _createVertexBuffers;
  94236. private _createIndexBuffer;
  94237. /**
  94238. * Gets the maximum number of particles active at the same time.
  94239. * @returns The max number of active particles.
  94240. */
  94241. getCapacity(): number;
  94242. /**
  94243. * Gets whether there are still active particles in the system.
  94244. * @returns True if it is alive, otherwise false.
  94245. */
  94246. isAlive(): boolean;
  94247. /**
  94248. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94249. * @returns True if it has been started, otherwise false.
  94250. */
  94251. isStarted(): boolean;
  94252. private _prepareSubEmitterInternalArray;
  94253. /**
  94254. * Starts the particle system and begins to emit
  94255. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  94256. */
  94257. start(delay?: number): void;
  94258. /**
  94259. * Stops the particle system.
  94260. * @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.
  94261. */
  94262. stop(stopSubEmitters?: boolean): void;
  94263. /**
  94264. * Remove all active particles
  94265. */
  94266. reset(): void;
  94267. /**
  94268. * @hidden (for internal use only)
  94269. */
  94270. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  94271. /**
  94272. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  94273. * Its lifetime will start back at 0.
  94274. */
  94275. recycleParticle: (particle: Particle) => void;
  94276. private _stopSubEmitters;
  94277. private _createParticle;
  94278. private _removeFromRoot;
  94279. private _emitFromParticle;
  94280. private _update;
  94281. /** @hidden */
  94282. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  94283. /** @hidden */
  94284. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  94285. /**
  94286. * Fill the defines array according to the current settings of the particle system
  94287. * @param defines Array to be updated
  94288. * @param blendMode blend mode to take into account when updating the array
  94289. */
  94290. fillDefines(defines: Array<string>, blendMode: number): void;
  94291. /**
  94292. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94293. * @param uniforms Uniforms array to fill
  94294. * @param attributes Attributes array to fill
  94295. * @param samplers Samplers array to fill
  94296. */
  94297. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94298. /** @hidden */
  94299. private _getEffect;
  94300. /**
  94301. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  94302. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  94303. */
  94304. animate(preWarmOnly?: boolean): void;
  94305. private _appendParticleVertices;
  94306. /**
  94307. * Rebuilds the particle system.
  94308. */
  94309. rebuild(): void;
  94310. /**
  94311. * Is this system ready to be used/rendered
  94312. * @return true if the system is ready
  94313. */
  94314. isReady(): boolean;
  94315. private _render;
  94316. /**
  94317. * Renders the particle system in its current state.
  94318. * @returns the current number of particles
  94319. */
  94320. render(): number;
  94321. /**
  94322. * Disposes the particle system and free the associated resources
  94323. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94324. */
  94325. dispose(disposeTexture?: boolean): void;
  94326. /**
  94327. * Clones the particle system.
  94328. * @param name The name of the cloned object
  94329. * @param newEmitter The new emitter to use
  94330. * @returns the cloned particle system
  94331. */
  94332. clone(name: string, newEmitter: any): ParticleSystem;
  94333. /**
  94334. * Serializes the particle system to a JSON object
  94335. * @param serializeTexture defines if the texture must be serialized as well
  94336. * @returns the JSON object
  94337. */
  94338. serialize(serializeTexture?: boolean): any;
  94339. /** @hidden */
  94340. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  94341. /** @hidden */
  94342. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  94343. /**
  94344. * Parses a JSON object to create a particle system.
  94345. * @param parsedParticleSystem The JSON object to parse
  94346. * @param sceneOrEngine The scene or the engine to create the particle system in
  94347. * @param rootUrl The root url to use to load external dependencies like texture
  94348. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  94349. * @returns the Parsed particle system
  94350. */
  94351. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  94352. }
  94353. }
  94354. declare module BABYLON {
  94355. /**
  94356. * A particle represents one of the element emitted by a particle system.
  94357. * This is mainly define by its coordinates, direction, velocity and age.
  94358. */
  94359. export class Particle {
  94360. /**
  94361. * The particle system the particle belongs to.
  94362. */
  94363. particleSystem: ParticleSystem;
  94364. private static _Count;
  94365. /**
  94366. * Unique ID of the particle
  94367. */
  94368. id: number;
  94369. /**
  94370. * The world position of the particle in the scene.
  94371. */
  94372. position: Vector3;
  94373. /**
  94374. * The world direction of the particle in the scene.
  94375. */
  94376. direction: Vector3;
  94377. /**
  94378. * The color of the particle.
  94379. */
  94380. color: Color4;
  94381. /**
  94382. * The color change of the particle per step.
  94383. */
  94384. colorStep: Color4;
  94385. /**
  94386. * Defines how long will the life of the particle be.
  94387. */
  94388. lifeTime: number;
  94389. /**
  94390. * The current age of the particle.
  94391. */
  94392. age: number;
  94393. /**
  94394. * The current size of the particle.
  94395. */
  94396. size: number;
  94397. /**
  94398. * The current scale of the particle.
  94399. */
  94400. scale: Vector2;
  94401. /**
  94402. * The current angle of the particle.
  94403. */
  94404. angle: number;
  94405. /**
  94406. * Defines how fast is the angle changing.
  94407. */
  94408. angularSpeed: number;
  94409. /**
  94410. * Defines the cell index used by the particle to be rendered from a sprite.
  94411. */
  94412. cellIndex: number;
  94413. /**
  94414. * The information required to support color remapping
  94415. */
  94416. remapData: Vector4;
  94417. /** @hidden */
  94418. _randomCellOffset?: number;
  94419. /** @hidden */
  94420. _initialDirection: Nullable<Vector3>;
  94421. /** @hidden */
  94422. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  94423. /** @hidden */
  94424. _initialStartSpriteCellID: number;
  94425. /** @hidden */
  94426. _initialEndSpriteCellID: number;
  94427. /** @hidden */
  94428. _currentColorGradient: Nullable<ColorGradient>;
  94429. /** @hidden */
  94430. _currentColor1: Color4;
  94431. /** @hidden */
  94432. _currentColor2: Color4;
  94433. /** @hidden */
  94434. _currentSizeGradient: Nullable<FactorGradient>;
  94435. /** @hidden */
  94436. _currentSize1: number;
  94437. /** @hidden */
  94438. _currentSize2: number;
  94439. /** @hidden */
  94440. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  94441. /** @hidden */
  94442. _currentAngularSpeed1: number;
  94443. /** @hidden */
  94444. _currentAngularSpeed2: number;
  94445. /** @hidden */
  94446. _currentVelocityGradient: Nullable<FactorGradient>;
  94447. /** @hidden */
  94448. _currentVelocity1: number;
  94449. /** @hidden */
  94450. _currentVelocity2: number;
  94451. /** @hidden */
  94452. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  94453. /** @hidden */
  94454. _currentLimitVelocity1: number;
  94455. /** @hidden */
  94456. _currentLimitVelocity2: number;
  94457. /** @hidden */
  94458. _currentDragGradient: Nullable<FactorGradient>;
  94459. /** @hidden */
  94460. _currentDrag1: number;
  94461. /** @hidden */
  94462. _currentDrag2: number;
  94463. /** @hidden */
  94464. _randomNoiseCoordinates1: Vector3;
  94465. /** @hidden */
  94466. _randomNoiseCoordinates2: Vector3;
  94467. /** @hidden */
  94468. _localPosition?: Vector3;
  94469. /**
  94470. * Creates a new instance Particle
  94471. * @param particleSystem the particle system the particle belongs to
  94472. */
  94473. constructor(
  94474. /**
  94475. * The particle system the particle belongs to.
  94476. */
  94477. particleSystem: ParticleSystem);
  94478. private updateCellInfoFromSystem;
  94479. /**
  94480. * Defines how the sprite cell index is updated for the particle
  94481. */
  94482. updateCellIndex(): void;
  94483. /** @hidden */
  94484. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94485. /** @hidden */
  94486. _inheritParticleInfoToSubEmitters(): void;
  94487. /** @hidden */
  94488. _reset(): void;
  94489. /**
  94490. * Copy the properties of particle to another one.
  94491. * @param other the particle to copy the information to.
  94492. */
  94493. copyTo(other: Particle): void;
  94494. }
  94495. }
  94496. declare module BABYLON {
  94497. /**
  94498. * Particle emitter represents a volume emitting particles.
  94499. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94500. */
  94501. export interface IParticleEmitterType {
  94502. /**
  94503. * Called by the particle System when the direction is computed for the created particle.
  94504. * @param worldMatrix is the world matrix of the particle system
  94505. * @param directionToUpdate is the direction vector to update with the result
  94506. * @param particle is the particle we are computed the direction for
  94507. * @param isLocal defines if the direction should be set in local space
  94508. */
  94509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94510. /**
  94511. * Called by the particle System when the position is computed for the created particle.
  94512. * @param worldMatrix is the world matrix of the particle system
  94513. * @param positionToUpdate is the position vector to update with the result
  94514. * @param particle is the particle we are computed the position for
  94515. * @param isLocal defines if the position should be set in local space
  94516. */
  94517. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94518. /**
  94519. * Clones the current emitter and returns a copy of it
  94520. * @returns the new emitter
  94521. */
  94522. clone(): IParticleEmitterType;
  94523. /**
  94524. * Called by the GPUParticleSystem to setup the update shader
  94525. * @param effect defines the update shader
  94526. */
  94527. applyToShader(effect: Effect): void;
  94528. /**
  94529. * Returns a string to use to update the GPU particles update shader
  94530. * @returns the effect defines string
  94531. */
  94532. getEffectDefines(): string;
  94533. /**
  94534. * Returns a string representing the class name
  94535. * @returns a string containing the class name
  94536. */
  94537. getClassName(): string;
  94538. /**
  94539. * Serializes the particle system to a JSON object.
  94540. * @returns the JSON object
  94541. */
  94542. serialize(): any;
  94543. /**
  94544. * Parse properties from a JSON object
  94545. * @param serializationObject defines the JSON object
  94546. * @param scene defines the hosting scene
  94547. */
  94548. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94549. }
  94550. }
  94551. declare module BABYLON {
  94552. /**
  94553. * Particle emitter emitting particles from the inside of a box.
  94554. * It emits the particles randomly between 2 given directions.
  94555. */
  94556. export class BoxParticleEmitter implements IParticleEmitterType {
  94557. /**
  94558. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94559. */
  94560. direction1: Vector3;
  94561. /**
  94562. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94563. */
  94564. direction2: Vector3;
  94565. /**
  94566. * 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.
  94567. */
  94568. minEmitBox: Vector3;
  94569. /**
  94570. * 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.
  94571. */
  94572. maxEmitBox: Vector3;
  94573. /**
  94574. * Creates a new instance BoxParticleEmitter
  94575. */
  94576. constructor();
  94577. /**
  94578. * Called by the particle System when the direction is computed for the created particle.
  94579. * @param worldMatrix is the world matrix of the particle system
  94580. * @param directionToUpdate is the direction vector to update with the result
  94581. * @param particle is the particle we are computed the direction for
  94582. * @param isLocal defines if the direction should be set in local space
  94583. */
  94584. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94585. /**
  94586. * Called by the particle System when the position is computed for the created particle.
  94587. * @param worldMatrix is the world matrix of the particle system
  94588. * @param positionToUpdate is the position vector to update with the result
  94589. * @param particle is the particle we are computed the position for
  94590. * @param isLocal defines if the position should be set in local space
  94591. */
  94592. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94593. /**
  94594. * Clones the current emitter and returns a copy of it
  94595. * @returns the new emitter
  94596. */
  94597. clone(): BoxParticleEmitter;
  94598. /**
  94599. * Called by the GPUParticleSystem to setup the update shader
  94600. * @param effect defines the update shader
  94601. */
  94602. applyToShader(effect: Effect): void;
  94603. /**
  94604. * Returns a string to use to update the GPU particles update shader
  94605. * @returns a string containng the defines string
  94606. */
  94607. getEffectDefines(): string;
  94608. /**
  94609. * Returns the string "BoxParticleEmitter"
  94610. * @returns a string containing the class name
  94611. */
  94612. getClassName(): string;
  94613. /**
  94614. * Serializes the particle system to a JSON object.
  94615. * @returns the JSON object
  94616. */
  94617. serialize(): any;
  94618. /**
  94619. * Parse properties from a JSON object
  94620. * @param serializationObject defines the JSON object
  94621. */
  94622. parse(serializationObject: any): void;
  94623. }
  94624. }
  94625. declare module BABYLON {
  94626. /**
  94627. * Particle emitter emitting particles from the inside of a cone.
  94628. * It emits the particles alongside the cone volume from the base to the particle.
  94629. * The emission direction might be randomized.
  94630. */
  94631. export class ConeParticleEmitter implements IParticleEmitterType {
  94632. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94633. directionRandomizer: number;
  94634. private _radius;
  94635. private _angle;
  94636. private _height;
  94637. /**
  94638. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94639. */
  94640. radiusRange: number;
  94641. /**
  94642. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94643. */
  94644. heightRange: number;
  94645. /**
  94646. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94647. */
  94648. emitFromSpawnPointOnly: boolean;
  94649. /**
  94650. * Gets or sets the radius of the emission cone
  94651. */
  94652. get radius(): number;
  94653. set radius(value: number);
  94654. /**
  94655. * Gets or sets the angle of the emission cone
  94656. */
  94657. get angle(): number;
  94658. set angle(value: number);
  94659. private _buildHeight;
  94660. /**
  94661. * Creates a new instance ConeParticleEmitter
  94662. * @param radius the radius of the emission cone (1 by default)
  94663. * @param angle the cone base angle (PI by default)
  94664. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94665. */
  94666. constructor(radius?: number, angle?: number,
  94667. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94668. directionRandomizer?: number);
  94669. /**
  94670. * Called by the particle System when the direction is computed for the created particle.
  94671. * @param worldMatrix is the world matrix of the particle system
  94672. * @param directionToUpdate is the direction vector to update with the result
  94673. * @param particle is the particle we are computed the direction for
  94674. * @param isLocal defines if the direction should be set in local space
  94675. */
  94676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94677. /**
  94678. * Called by the particle System when the position is computed for the created particle.
  94679. * @param worldMatrix is the world matrix of the particle system
  94680. * @param positionToUpdate is the position vector to update with the result
  94681. * @param particle is the particle we are computed the position for
  94682. * @param isLocal defines if the position should be set in local space
  94683. */
  94684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94685. /**
  94686. * Clones the current emitter and returns a copy of it
  94687. * @returns the new emitter
  94688. */
  94689. clone(): ConeParticleEmitter;
  94690. /**
  94691. * Called by the GPUParticleSystem to setup the update shader
  94692. * @param effect defines the update shader
  94693. */
  94694. applyToShader(effect: Effect): void;
  94695. /**
  94696. * Returns a string to use to update the GPU particles update shader
  94697. * @returns a string containng the defines string
  94698. */
  94699. getEffectDefines(): string;
  94700. /**
  94701. * Returns the string "ConeParticleEmitter"
  94702. * @returns a string containing the class name
  94703. */
  94704. getClassName(): string;
  94705. /**
  94706. * Serializes the particle system to a JSON object.
  94707. * @returns the JSON object
  94708. */
  94709. serialize(): any;
  94710. /**
  94711. * Parse properties from a JSON object
  94712. * @param serializationObject defines the JSON object
  94713. */
  94714. parse(serializationObject: any): void;
  94715. }
  94716. }
  94717. declare module BABYLON {
  94718. /**
  94719. * Particle emitter emitting particles from the inside of a cylinder.
  94720. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94721. */
  94722. export class CylinderParticleEmitter implements IParticleEmitterType {
  94723. /**
  94724. * The radius of the emission cylinder.
  94725. */
  94726. radius: number;
  94727. /**
  94728. * The height of the emission cylinder.
  94729. */
  94730. height: number;
  94731. /**
  94732. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94733. */
  94734. radiusRange: number;
  94735. /**
  94736. * How much to randomize the particle direction [0-1].
  94737. */
  94738. directionRandomizer: number;
  94739. /**
  94740. * Creates a new instance CylinderParticleEmitter
  94741. * @param radius the radius of the emission cylinder (1 by default)
  94742. * @param height the height of the emission cylinder (1 by default)
  94743. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94744. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94745. */
  94746. constructor(
  94747. /**
  94748. * The radius of the emission cylinder.
  94749. */
  94750. radius?: number,
  94751. /**
  94752. * The height of the emission cylinder.
  94753. */
  94754. height?: number,
  94755. /**
  94756. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94757. */
  94758. radiusRange?: number,
  94759. /**
  94760. * How much to randomize the particle direction [0-1].
  94761. */
  94762. directionRandomizer?: number);
  94763. /**
  94764. * Called by the particle System when the direction is computed for the created particle.
  94765. * @param worldMatrix is the world matrix of the particle system
  94766. * @param directionToUpdate is the direction vector to update with the result
  94767. * @param particle is the particle we are computed the direction for
  94768. * @param isLocal defines if the direction should be set in local space
  94769. */
  94770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94771. /**
  94772. * Called by the particle System when the position is computed for the created particle.
  94773. * @param worldMatrix is the world matrix of the particle system
  94774. * @param positionToUpdate is the position vector to update with the result
  94775. * @param particle is the particle we are computed the position for
  94776. * @param isLocal defines if the position should be set in local space
  94777. */
  94778. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94779. /**
  94780. * Clones the current emitter and returns a copy of it
  94781. * @returns the new emitter
  94782. */
  94783. clone(): CylinderParticleEmitter;
  94784. /**
  94785. * Called by the GPUParticleSystem to setup the update shader
  94786. * @param effect defines the update shader
  94787. */
  94788. applyToShader(effect: Effect): void;
  94789. /**
  94790. * Returns a string to use to update the GPU particles update shader
  94791. * @returns a string containng the defines string
  94792. */
  94793. getEffectDefines(): string;
  94794. /**
  94795. * Returns the string "CylinderParticleEmitter"
  94796. * @returns a string containing the class name
  94797. */
  94798. getClassName(): string;
  94799. /**
  94800. * Serializes the particle system to a JSON object.
  94801. * @returns the JSON object
  94802. */
  94803. serialize(): any;
  94804. /**
  94805. * Parse properties from a JSON object
  94806. * @param serializationObject defines the JSON object
  94807. */
  94808. parse(serializationObject: any): void;
  94809. }
  94810. /**
  94811. * Particle emitter emitting particles from the inside of a cylinder.
  94812. * It emits the particles randomly between two vectors.
  94813. */
  94814. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94815. /**
  94816. * The min limit of the emission direction.
  94817. */
  94818. direction1: Vector3;
  94819. /**
  94820. * The max limit of the emission direction.
  94821. */
  94822. direction2: Vector3;
  94823. /**
  94824. * Creates a new instance CylinderDirectedParticleEmitter
  94825. * @param radius the radius of the emission cylinder (1 by default)
  94826. * @param height the height of the emission cylinder (1 by default)
  94827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94828. * @param direction1 the min limit of the emission direction (up vector by default)
  94829. * @param direction2 the max limit of the emission direction (up vector by default)
  94830. */
  94831. constructor(radius?: number, height?: number, radiusRange?: number,
  94832. /**
  94833. * The min limit of the emission direction.
  94834. */
  94835. direction1?: Vector3,
  94836. /**
  94837. * The max limit of the emission direction.
  94838. */
  94839. direction2?: Vector3);
  94840. /**
  94841. * Called by the particle System when the direction is computed for the created particle.
  94842. * @param worldMatrix is the world matrix of the particle system
  94843. * @param directionToUpdate is the direction vector to update with the result
  94844. * @param particle is the particle we are computed the direction for
  94845. */
  94846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94847. /**
  94848. * Clones the current emitter and returns a copy of it
  94849. * @returns the new emitter
  94850. */
  94851. clone(): CylinderDirectedParticleEmitter;
  94852. /**
  94853. * Called by the GPUParticleSystem to setup the update shader
  94854. * @param effect defines the update shader
  94855. */
  94856. applyToShader(effect: Effect): void;
  94857. /**
  94858. * Returns a string to use to update the GPU particles update shader
  94859. * @returns a string containng the defines string
  94860. */
  94861. getEffectDefines(): string;
  94862. /**
  94863. * Returns the string "CylinderDirectedParticleEmitter"
  94864. * @returns a string containing the class name
  94865. */
  94866. getClassName(): string;
  94867. /**
  94868. * Serializes the particle system to a JSON object.
  94869. * @returns the JSON object
  94870. */
  94871. serialize(): any;
  94872. /**
  94873. * Parse properties from a JSON object
  94874. * @param serializationObject defines the JSON object
  94875. */
  94876. parse(serializationObject: any): void;
  94877. }
  94878. }
  94879. declare module BABYLON {
  94880. /**
  94881. * Particle emitter emitting particles from the inside of a hemisphere.
  94882. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94883. */
  94884. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94885. /**
  94886. * The radius of the emission hemisphere.
  94887. */
  94888. radius: number;
  94889. /**
  94890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94891. */
  94892. radiusRange: number;
  94893. /**
  94894. * How much to randomize the particle direction [0-1].
  94895. */
  94896. directionRandomizer: number;
  94897. /**
  94898. * Creates a new instance HemisphericParticleEmitter
  94899. * @param radius the radius of the emission hemisphere (1 by default)
  94900. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94901. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94902. */
  94903. constructor(
  94904. /**
  94905. * The radius of the emission hemisphere.
  94906. */
  94907. radius?: number,
  94908. /**
  94909. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94910. */
  94911. radiusRange?: number,
  94912. /**
  94913. * How much to randomize the particle direction [0-1].
  94914. */
  94915. directionRandomizer?: number);
  94916. /**
  94917. * Called by the particle System when the direction is computed for the created particle.
  94918. * @param worldMatrix is the world matrix of the particle system
  94919. * @param directionToUpdate is the direction vector to update with the result
  94920. * @param particle is the particle we are computed the direction for
  94921. * @param isLocal defines if the direction should be set in local space
  94922. */
  94923. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94924. /**
  94925. * Called by the particle System when the position is computed for the created particle.
  94926. * @param worldMatrix is the world matrix of the particle system
  94927. * @param positionToUpdate is the position vector to update with the result
  94928. * @param particle is the particle we are computed the position for
  94929. * @param isLocal defines if the position should be set in local space
  94930. */
  94931. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94932. /**
  94933. * Clones the current emitter and returns a copy of it
  94934. * @returns the new emitter
  94935. */
  94936. clone(): HemisphericParticleEmitter;
  94937. /**
  94938. * Called by the GPUParticleSystem to setup the update shader
  94939. * @param effect defines the update shader
  94940. */
  94941. applyToShader(effect: Effect): void;
  94942. /**
  94943. * Returns a string to use to update the GPU particles update shader
  94944. * @returns a string containng the defines string
  94945. */
  94946. getEffectDefines(): string;
  94947. /**
  94948. * Returns the string "HemisphericParticleEmitter"
  94949. * @returns a string containing the class name
  94950. */
  94951. getClassName(): string;
  94952. /**
  94953. * Serializes the particle system to a JSON object.
  94954. * @returns the JSON object
  94955. */
  94956. serialize(): any;
  94957. /**
  94958. * Parse properties from a JSON object
  94959. * @param serializationObject defines the JSON object
  94960. */
  94961. parse(serializationObject: any): void;
  94962. }
  94963. }
  94964. declare module BABYLON {
  94965. /**
  94966. * Particle emitter emitting particles from a point.
  94967. * It emits the particles randomly between 2 given directions.
  94968. */
  94969. export class PointParticleEmitter implements IParticleEmitterType {
  94970. /**
  94971. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94972. */
  94973. direction1: Vector3;
  94974. /**
  94975. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94976. */
  94977. direction2: Vector3;
  94978. /**
  94979. * Creates a new instance PointParticleEmitter
  94980. */
  94981. constructor();
  94982. /**
  94983. * Called by the particle System when the direction is computed for the created particle.
  94984. * @param worldMatrix is the world matrix of the particle system
  94985. * @param directionToUpdate is the direction vector to update with the result
  94986. * @param particle is the particle we are computed the direction for
  94987. * @param isLocal defines if the direction should be set in local space
  94988. */
  94989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94990. /**
  94991. * Called by the particle System when the position is computed for the created particle.
  94992. * @param worldMatrix is the world matrix of the particle system
  94993. * @param positionToUpdate is the position vector to update with the result
  94994. * @param particle is the particle we are computed the position for
  94995. * @param isLocal defines if the position should be set in local space
  94996. */
  94997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94998. /**
  94999. * Clones the current emitter and returns a copy of it
  95000. * @returns the new emitter
  95001. */
  95002. clone(): PointParticleEmitter;
  95003. /**
  95004. * Called by the GPUParticleSystem to setup the update shader
  95005. * @param effect defines the update shader
  95006. */
  95007. applyToShader(effect: Effect): void;
  95008. /**
  95009. * Returns a string to use to update the GPU particles update shader
  95010. * @returns a string containng the defines string
  95011. */
  95012. getEffectDefines(): string;
  95013. /**
  95014. * Returns the string "PointParticleEmitter"
  95015. * @returns a string containing the class name
  95016. */
  95017. getClassName(): string;
  95018. /**
  95019. * Serializes the particle system to a JSON object.
  95020. * @returns the JSON object
  95021. */
  95022. serialize(): any;
  95023. /**
  95024. * Parse properties from a JSON object
  95025. * @param serializationObject defines the JSON object
  95026. */
  95027. parse(serializationObject: any): void;
  95028. }
  95029. }
  95030. declare module BABYLON {
  95031. /**
  95032. * Particle emitter emitting particles from the inside of a sphere.
  95033. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  95034. */
  95035. export class SphereParticleEmitter implements IParticleEmitterType {
  95036. /**
  95037. * The radius of the emission sphere.
  95038. */
  95039. radius: number;
  95040. /**
  95041. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  95042. */
  95043. radiusRange: number;
  95044. /**
  95045. * How much to randomize the particle direction [0-1].
  95046. */
  95047. directionRandomizer: number;
  95048. /**
  95049. * Creates a new instance SphereParticleEmitter
  95050. * @param radius the radius of the emission sphere (1 by default)
  95051. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95052. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  95053. */
  95054. constructor(
  95055. /**
  95056. * The radius of the emission sphere.
  95057. */
  95058. radius?: number,
  95059. /**
  95060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  95061. */
  95062. radiusRange?: number,
  95063. /**
  95064. * How much to randomize the particle direction [0-1].
  95065. */
  95066. directionRandomizer?: number);
  95067. /**
  95068. * Called by the particle System when the direction is computed for the created particle.
  95069. * @param worldMatrix is the world matrix of the particle system
  95070. * @param directionToUpdate is the direction vector to update with the result
  95071. * @param particle is the particle we are computed the direction for
  95072. * @param isLocal defines if the direction should be set in local space
  95073. */
  95074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95075. /**
  95076. * Called by the particle System when the position is computed for the created particle.
  95077. * @param worldMatrix is the world matrix of the particle system
  95078. * @param positionToUpdate is the position vector to update with the result
  95079. * @param particle is the particle we are computed the position for
  95080. * @param isLocal defines if the position should be set in local space
  95081. */
  95082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95083. /**
  95084. * Clones the current emitter and returns a copy of it
  95085. * @returns the new emitter
  95086. */
  95087. clone(): SphereParticleEmitter;
  95088. /**
  95089. * Called by the GPUParticleSystem to setup the update shader
  95090. * @param effect defines the update shader
  95091. */
  95092. applyToShader(effect: Effect): void;
  95093. /**
  95094. * Returns a string to use to update the GPU particles update shader
  95095. * @returns a string containng the defines string
  95096. */
  95097. getEffectDefines(): string;
  95098. /**
  95099. * Returns the string "SphereParticleEmitter"
  95100. * @returns a string containing the class name
  95101. */
  95102. getClassName(): string;
  95103. /**
  95104. * Serializes the particle system to a JSON object.
  95105. * @returns the JSON object
  95106. */
  95107. serialize(): any;
  95108. /**
  95109. * Parse properties from a JSON object
  95110. * @param serializationObject defines the JSON object
  95111. */
  95112. parse(serializationObject: any): void;
  95113. }
  95114. /**
  95115. * Particle emitter emitting particles from the inside of a sphere.
  95116. * It emits the particles randomly between two vectors.
  95117. */
  95118. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  95119. /**
  95120. * The min limit of the emission direction.
  95121. */
  95122. direction1: Vector3;
  95123. /**
  95124. * The max limit of the emission direction.
  95125. */
  95126. direction2: Vector3;
  95127. /**
  95128. * Creates a new instance SphereDirectedParticleEmitter
  95129. * @param radius the radius of the emission sphere (1 by default)
  95130. * @param direction1 the min limit of the emission direction (up vector by default)
  95131. * @param direction2 the max limit of the emission direction (up vector by default)
  95132. */
  95133. constructor(radius?: number,
  95134. /**
  95135. * The min limit of the emission direction.
  95136. */
  95137. direction1?: Vector3,
  95138. /**
  95139. * The max limit of the emission direction.
  95140. */
  95141. direction2?: Vector3);
  95142. /**
  95143. * Called by the particle System when the direction is computed for the created particle.
  95144. * @param worldMatrix is the world matrix of the particle system
  95145. * @param directionToUpdate is the direction vector to update with the result
  95146. * @param particle is the particle we are computed the direction for
  95147. */
  95148. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  95149. /**
  95150. * Clones the current emitter and returns a copy of it
  95151. * @returns the new emitter
  95152. */
  95153. clone(): SphereDirectedParticleEmitter;
  95154. /**
  95155. * Called by the GPUParticleSystem to setup the update shader
  95156. * @param effect defines the update shader
  95157. */
  95158. applyToShader(effect: Effect): void;
  95159. /**
  95160. * Returns a string to use to update the GPU particles update shader
  95161. * @returns a string containng the defines string
  95162. */
  95163. getEffectDefines(): string;
  95164. /**
  95165. * Returns the string "SphereDirectedParticleEmitter"
  95166. * @returns a string containing the class name
  95167. */
  95168. getClassName(): string;
  95169. /**
  95170. * Serializes the particle system to a JSON object.
  95171. * @returns the JSON object
  95172. */
  95173. serialize(): any;
  95174. /**
  95175. * Parse properties from a JSON object
  95176. * @param serializationObject defines the JSON object
  95177. */
  95178. parse(serializationObject: any): void;
  95179. }
  95180. }
  95181. declare module BABYLON {
  95182. /**
  95183. * Particle emitter emitting particles from a custom list of positions.
  95184. */
  95185. export class CustomParticleEmitter implements IParticleEmitterType {
  95186. /**
  95187. * Gets or sets the position generator that will create the inital position of each particle.
  95188. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95189. */
  95190. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  95191. /**
  95192. * Gets or sets the destination generator that will create the final destination of each particle.
  95193. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95194. */
  95195. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  95196. /**
  95197. * Creates a new instance CustomParticleEmitter
  95198. */
  95199. constructor();
  95200. /**
  95201. * Called by the particle System when the direction is computed for the created particle.
  95202. * @param worldMatrix is the world matrix of the particle system
  95203. * @param directionToUpdate is the direction vector to update with the result
  95204. * @param particle is the particle we are computed the direction for
  95205. * @param isLocal defines if the direction should be set in local space
  95206. */
  95207. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95208. /**
  95209. * Called by the particle System when the position is computed for the created particle.
  95210. * @param worldMatrix is the world matrix of the particle system
  95211. * @param positionToUpdate is the position vector to update with the result
  95212. * @param particle is the particle we are computed the position for
  95213. * @param isLocal defines if the position should be set in local space
  95214. */
  95215. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95216. /**
  95217. * Clones the current emitter and returns a copy of it
  95218. * @returns the new emitter
  95219. */
  95220. clone(): CustomParticleEmitter;
  95221. /**
  95222. * Called by the GPUParticleSystem to setup the update shader
  95223. * @param effect defines the update shader
  95224. */
  95225. applyToShader(effect: Effect): void;
  95226. /**
  95227. * Returns a string to use to update the GPU particles update shader
  95228. * @returns a string containng the defines string
  95229. */
  95230. getEffectDefines(): string;
  95231. /**
  95232. * Returns the string "PointParticleEmitter"
  95233. * @returns a string containing the class name
  95234. */
  95235. getClassName(): string;
  95236. /**
  95237. * Serializes the particle system to a JSON object.
  95238. * @returns the JSON object
  95239. */
  95240. serialize(): any;
  95241. /**
  95242. * Parse properties from a JSON object
  95243. * @param serializationObject defines the JSON object
  95244. */
  95245. parse(serializationObject: any): void;
  95246. }
  95247. }
  95248. declare module BABYLON {
  95249. /**
  95250. * Particle emitter emitting particles from the inside of a box.
  95251. * It emits the particles randomly between 2 given directions.
  95252. */
  95253. export class MeshParticleEmitter implements IParticleEmitterType {
  95254. private _indices;
  95255. private _positions;
  95256. private _normals;
  95257. private _storedNormal;
  95258. private _mesh;
  95259. /**
  95260. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95261. */
  95262. direction1: Vector3;
  95263. /**
  95264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95265. */
  95266. direction2: Vector3;
  95267. /**
  95268. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  95269. */
  95270. useMeshNormalsForDirection: boolean;
  95271. /** Defines the mesh to use as source */
  95272. get mesh(): Nullable<AbstractMesh>;
  95273. set mesh(value: Nullable<AbstractMesh>);
  95274. /**
  95275. * Creates a new instance MeshParticleEmitter
  95276. * @param mesh defines the mesh to use as source
  95277. */
  95278. constructor(mesh?: Nullable<AbstractMesh>);
  95279. /**
  95280. * Called by the particle System when the direction is computed for the created particle.
  95281. * @param worldMatrix is the world matrix of the particle system
  95282. * @param directionToUpdate is the direction vector to update with the result
  95283. * @param particle is the particle we are computed the direction for
  95284. * @param isLocal defines if the direction should be set in local space
  95285. */
  95286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95287. /**
  95288. * Called by the particle System when the position is computed for the created particle.
  95289. * @param worldMatrix is the world matrix of the particle system
  95290. * @param positionToUpdate is the position vector to update with the result
  95291. * @param particle is the particle we are computed the position for
  95292. * @param isLocal defines if the position should be set in local space
  95293. */
  95294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95295. /**
  95296. * Clones the current emitter and returns a copy of it
  95297. * @returns the new emitter
  95298. */
  95299. clone(): MeshParticleEmitter;
  95300. /**
  95301. * Called by the GPUParticleSystem to setup the update shader
  95302. * @param effect defines the update shader
  95303. */
  95304. applyToShader(effect: Effect): void;
  95305. /**
  95306. * Returns a string to use to update the GPU particles update shader
  95307. * @returns a string containng the defines string
  95308. */
  95309. getEffectDefines(): string;
  95310. /**
  95311. * Returns the string "BoxParticleEmitter"
  95312. * @returns a string containing the class name
  95313. */
  95314. getClassName(): string;
  95315. /**
  95316. * Serializes the particle system to a JSON object.
  95317. * @returns the JSON object
  95318. */
  95319. serialize(): any;
  95320. /**
  95321. * Parse properties from a JSON object
  95322. * @param serializationObject defines the JSON object
  95323. * @param scene defines the hosting scene
  95324. */
  95325. parse(serializationObject: any, scene: Nullable<Scene>): void;
  95326. }
  95327. }
  95328. declare module BABYLON {
  95329. /**
  95330. * Interface representing a particle system in Babylon.js.
  95331. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  95332. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  95333. */
  95334. export interface IParticleSystem {
  95335. /**
  95336. * List of animations used by the particle system.
  95337. */
  95338. animations: Animation[];
  95339. /**
  95340. * The id of the Particle system.
  95341. */
  95342. id: string;
  95343. /**
  95344. * The name of the Particle system.
  95345. */
  95346. name: string;
  95347. /**
  95348. * The emitter represents the Mesh or position we are attaching the particle system to.
  95349. */
  95350. emitter: Nullable<AbstractMesh | Vector3>;
  95351. /**
  95352. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  95353. */
  95354. isBillboardBased: boolean;
  95355. /**
  95356. * The rendering group used by the Particle system to chose when to render.
  95357. */
  95358. renderingGroupId: number;
  95359. /**
  95360. * The layer mask we are rendering the particles through.
  95361. */
  95362. layerMask: number;
  95363. /**
  95364. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95365. */
  95366. updateSpeed: number;
  95367. /**
  95368. * The amount of time the particle system is running (depends of the overall update speed).
  95369. */
  95370. targetStopDuration: number;
  95371. /**
  95372. * The texture used to render each particle. (this can be a spritesheet)
  95373. */
  95374. particleTexture: Nullable<BaseTexture>;
  95375. /**
  95376. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  95377. */
  95378. blendMode: number;
  95379. /**
  95380. * Minimum life time of emitting particles.
  95381. */
  95382. minLifeTime: number;
  95383. /**
  95384. * Maximum life time of emitting particles.
  95385. */
  95386. maxLifeTime: number;
  95387. /**
  95388. * Minimum Size of emitting particles.
  95389. */
  95390. minSize: number;
  95391. /**
  95392. * Maximum Size of emitting particles.
  95393. */
  95394. maxSize: number;
  95395. /**
  95396. * Minimum scale of emitting particles on X axis.
  95397. */
  95398. minScaleX: number;
  95399. /**
  95400. * Maximum scale of emitting particles on X axis.
  95401. */
  95402. maxScaleX: number;
  95403. /**
  95404. * Minimum scale of emitting particles on Y axis.
  95405. */
  95406. minScaleY: number;
  95407. /**
  95408. * Maximum scale of emitting particles on Y axis.
  95409. */
  95410. maxScaleY: number;
  95411. /**
  95412. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95413. */
  95414. color1: Color4;
  95415. /**
  95416. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95417. */
  95418. color2: Color4;
  95419. /**
  95420. * Color the particle will have at the end of its lifetime.
  95421. */
  95422. colorDead: Color4;
  95423. /**
  95424. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  95425. */
  95426. emitRate: number;
  95427. /**
  95428. * You can use gravity if you want to give an orientation to your particles.
  95429. */
  95430. gravity: Vector3;
  95431. /**
  95432. * Minimum power of emitting particles.
  95433. */
  95434. minEmitPower: number;
  95435. /**
  95436. * Maximum power of emitting particles.
  95437. */
  95438. maxEmitPower: number;
  95439. /**
  95440. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95441. */
  95442. minAngularSpeed: number;
  95443. /**
  95444. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95445. */
  95446. maxAngularSpeed: number;
  95447. /**
  95448. * Gets or sets the minimal initial rotation in radians.
  95449. */
  95450. minInitialRotation: number;
  95451. /**
  95452. * Gets or sets the maximal initial rotation in radians.
  95453. */
  95454. maxInitialRotation: number;
  95455. /**
  95456. * The particle emitter type defines the emitter used by the particle system.
  95457. * It can be for example box, sphere, or cone...
  95458. */
  95459. particleEmitterType: Nullable<IParticleEmitterType>;
  95460. /**
  95461. * Defines the delay in milliseconds before starting the system (0 by default)
  95462. */
  95463. startDelay: number;
  95464. /**
  95465. * 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
  95466. */
  95467. preWarmCycles: number;
  95468. /**
  95469. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  95470. */
  95471. preWarmStepOffset: number;
  95472. /**
  95473. * 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)
  95474. */
  95475. spriteCellChangeSpeed: number;
  95476. /**
  95477. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95478. */
  95479. startSpriteCellID: number;
  95480. /**
  95481. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95482. */
  95483. endSpriteCellID: number;
  95484. /**
  95485. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95486. */
  95487. spriteCellWidth: number;
  95488. /**
  95489. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95490. */
  95491. spriteCellHeight: number;
  95492. /**
  95493. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95494. */
  95495. spriteRandomStartCell: boolean;
  95496. /**
  95497. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95498. */
  95499. isAnimationSheetEnabled: boolean;
  95500. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95501. translationPivot: Vector2;
  95502. /**
  95503. * Gets or sets a texture used to add random noise to particle positions
  95504. */
  95505. noiseTexture: Nullable<BaseTexture>;
  95506. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95507. noiseStrength: Vector3;
  95508. /**
  95509. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95510. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95511. */
  95512. billboardMode: number;
  95513. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95514. limitVelocityDamping: number;
  95515. /**
  95516. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95517. */
  95518. beginAnimationOnStart: boolean;
  95519. /**
  95520. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95521. */
  95522. beginAnimationFrom: number;
  95523. /**
  95524. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95525. */
  95526. beginAnimationTo: number;
  95527. /**
  95528. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95529. */
  95530. beginAnimationLoop: boolean;
  95531. /**
  95532. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95533. */
  95534. disposeOnStop: boolean;
  95535. /**
  95536. * Specifies if the particles are updated in emitter local space or world space
  95537. */
  95538. isLocal: boolean;
  95539. /** Snippet ID if the particle system was created from the snippet server */
  95540. snippetId: string;
  95541. /** Gets or sets a matrix to use to compute projection */
  95542. defaultProjectionMatrix: Matrix;
  95543. /**
  95544. * Gets the maximum number of particles active at the same time.
  95545. * @returns The max number of active particles.
  95546. */
  95547. getCapacity(): number;
  95548. /**
  95549. * Gets the number of particles active at the same time.
  95550. * @returns The number of active particles.
  95551. */
  95552. getActiveCount(): number;
  95553. /**
  95554. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95555. * @returns True if it has been started, otherwise false.
  95556. */
  95557. isStarted(): boolean;
  95558. /**
  95559. * Animates the particle system for this frame.
  95560. */
  95561. animate(): void;
  95562. /**
  95563. * Renders the particle system in its current state.
  95564. * @returns the current number of particles
  95565. */
  95566. render(): number;
  95567. /**
  95568. * Dispose the particle system and frees its associated resources.
  95569. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95570. */
  95571. dispose(disposeTexture?: boolean): void;
  95572. /**
  95573. * An event triggered when the system is disposed
  95574. */
  95575. onDisposeObservable: Observable<IParticleSystem>;
  95576. /**
  95577. * An event triggered when the system is stopped
  95578. */
  95579. onStoppedObservable: Observable<IParticleSystem>;
  95580. /**
  95581. * Clones the particle system.
  95582. * @param name The name of the cloned object
  95583. * @param newEmitter The new emitter to use
  95584. * @returns the cloned particle system
  95585. */
  95586. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95587. /**
  95588. * Serializes the particle system to a JSON object
  95589. * @param serializeTexture defines if the texture must be serialized as well
  95590. * @returns the JSON object
  95591. */
  95592. serialize(serializeTexture: boolean): any;
  95593. /**
  95594. * Rebuild the particle system
  95595. */
  95596. rebuild(): void;
  95597. /** Force the system to rebuild all gradients that need to be resync */
  95598. forceRefreshGradients(): void;
  95599. /**
  95600. * Starts the particle system and begins to emit
  95601. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95602. */
  95603. start(delay?: number): void;
  95604. /**
  95605. * Stops the particle system.
  95606. */
  95607. stop(): void;
  95608. /**
  95609. * Remove all active particles
  95610. */
  95611. reset(): void;
  95612. /**
  95613. * Gets a boolean indicating that the system is stopping
  95614. * @returns true if the system is currently stopping
  95615. */
  95616. isStopping(): boolean;
  95617. /**
  95618. * Is this system ready to be used/rendered
  95619. * @return true if the system is ready
  95620. */
  95621. isReady(): boolean;
  95622. /**
  95623. * Returns the string "ParticleSystem"
  95624. * @returns a string containing the class name
  95625. */
  95626. getClassName(): string;
  95627. /**
  95628. * Gets the custom effect used to render the particles
  95629. * @param blendMode Blend mode for which the effect should be retrieved
  95630. * @returns The effect
  95631. */
  95632. getCustomEffect(blendMode: number): Nullable<Effect>;
  95633. /**
  95634. * Sets the custom effect used to render the particles
  95635. * @param effect The effect to set
  95636. * @param blendMode Blend mode for which the effect should be set
  95637. */
  95638. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95639. /**
  95640. * Fill the defines array according to the current settings of the particle system
  95641. * @param defines Array to be updated
  95642. * @param blendMode blend mode to take into account when updating the array
  95643. */
  95644. fillDefines(defines: Array<string>, blendMode: number): void;
  95645. /**
  95646. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95647. * @param uniforms Uniforms array to fill
  95648. * @param attributes Attributes array to fill
  95649. * @param samplers Samplers array to fill
  95650. */
  95651. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95652. /**
  95653. * Observable that will be called just before the particles are drawn
  95654. */
  95655. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95656. /**
  95657. * Gets the name of the particle vertex shader
  95658. */
  95659. vertexShaderName: string;
  95660. /**
  95661. * Adds a new color gradient
  95662. * @param gradient defines the gradient to use (between 0 and 1)
  95663. * @param color1 defines the color to affect to the specified gradient
  95664. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95665. * @returns the current particle system
  95666. */
  95667. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95668. /**
  95669. * Remove a specific color gradient
  95670. * @param gradient defines the gradient to remove
  95671. * @returns the current particle system
  95672. */
  95673. removeColorGradient(gradient: number): IParticleSystem;
  95674. /**
  95675. * Adds a new size gradient
  95676. * @param gradient defines the gradient to use (between 0 and 1)
  95677. * @param factor defines the size factor to affect to the specified gradient
  95678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95679. * @returns the current particle system
  95680. */
  95681. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95682. /**
  95683. * Remove a specific size gradient
  95684. * @param gradient defines the gradient to remove
  95685. * @returns the current particle system
  95686. */
  95687. removeSizeGradient(gradient: number): IParticleSystem;
  95688. /**
  95689. * Gets the current list of color gradients.
  95690. * You must use addColorGradient and removeColorGradient to udpate this list
  95691. * @returns the list of color gradients
  95692. */
  95693. getColorGradients(): Nullable<Array<ColorGradient>>;
  95694. /**
  95695. * Gets the current list of size gradients.
  95696. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95697. * @returns the list of size gradients
  95698. */
  95699. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95700. /**
  95701. * Gets the current list of angular speed gradients.
  95702. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95703. * @returns the list of angular speed gradients
  95704. */
  95705. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95706. /**
  95707. * Adds a new angular speed gradient
  95708. * @param gradient defines the gradient to use (between 0 and 1)
  95709. * @param factor defines the angular speed to affect to the specified gradient
  95710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95711. * @returns the current particle system
  95712. */
  95713. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95714. /**
  95715. * Remove a specific angular speed gradient
  95716. * @param gradient defines the gradient to remove
  95717. * @returns the current particle system
  95718. */
  95719. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95720. /**
  95721. * Gets the current list of velocity gradients.
  95722. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95723. * @returns the list of velocity gradients
  95724. */
  95725. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95726. /**
  95727. * Adds a new velocity gradient
  95728. * @param gradient defines the gradient to use (between 0 and 1)
  95729. * @param factor defines the velocity to affect to the specified gradient
  95730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95731. * @returns the current particle system
  95732. */
  95733. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95734. /**
  95735. * Remove a specific velocity gradient
  95736. * @param gradient defines the gradient to remove
  95737. * @returns the current particle system
  95738. */
  95739. removeVelocityGradient(gradient: number): IParticleSystem;
  95740. /**
  95741. * Gets the current list of limit velocity gradients.
  95742. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95743. * @returns the list of limit velocity gradients
  95744. */
  95745. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95746. /**
  95747. * Adds a new limit velocity gradient
  95748. * @param gradient defines the gradient to use (between 0 and 1)
  95749. * @param factor defines the limit velocity to affect to the specified gradient
  95750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95751. * @returns the current particle system
  95752. */
  95753. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95754. /**
  95755. * Remove a specific limit velocity gradient
  95756. * @param gradient defines the gradient to remove
  95757. * @returns the current particle system
  95758. */
  95759. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95760. /**
  95761. * Adds a new drag gradient
  95762. * @param gradient defines the gradient to use (between 0 and 1)
  95763. * @param factor defines the drag to affect to the specified gradient
  95764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95765. * @returns the current particle system
  95766. */
  95767. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95768. /**
  95769. * Remove a specific drag gradient
  95770. * @param gradient defines the gradient to remove
  95771. * @returns the current particle system
  95772. */
  95773. removeDragGradient(gradient: number): IParticleSystem;
  95774. /**
  95775. * Gets the current list of drag gradients.
  95776. * You must use addDragGradient and removeDragGradient to udpate this list
  95777. * @returns the list of drag gradients
  95778. */
  95779. getDragGradients(): Nullable<Array<FactorGradient>>;
  95780. /**
  95781. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95782. * @param gradient defines the gradient to use (between 0 and 1)
  95783. * @param factor defines the emit rate to affect to the specified gradient
  95784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95785. * @returns the current particle system
  95786. */
  95787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95788. /**
  95789. * Remove a specific emit rate gradient
  95790. * @param gradient defines the gradient to remove
  95791. * @returns the current particle system
  95792. */
  95793. removeEmitRateGradient(gradient: number): IParticleSystem;
  95794. /**
  95795. * Gets the current list of emit rate gradients.
  95796. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95797. * @returns the list of emit rate gradients
  95798. */
  95799. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95800. /**
  95801. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95802. * @param gradient defines the gradient to use (between 0 and 1)
  95803. * @param factor defines the start size to affect to the specified gradient
  95804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95805. * @returns the current particle system
  95806. */
  95807. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95808. /**
  95809. * Remove a specific start size gradient
  95810. * @param gradient defines the gradient to remove
  95811. * @returns the current particle system
  95812. */
  95813. removeStartSizeGradient(gradient: number): IParticleSystem;
  95814. /**
  95815. * Gets the current list of start size gradients.
  95816. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95817. * @returns the list of start size gradients
  95818. */
  95819. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95820. /**
  95821. * Adds a new life time gradient
  95822. * @param gradient defines the gradient to use (between 0 and 1)
  95823. * @param factor defines the life time factor to affect to the specified gradient
  95824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95825. * @returns the current particle system
  95826. */
  95827. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95828. /**
  95829. * Remove a specific life time gradient
  95830. * @param gradient defines the gradient to remove
  95831. * @returns the current particle system
  95832. */
  95833. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95834. /**
  95835. * Gets the current list of life time gradients.
  95836. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95837. * @returns the list of life time gradients
  95838. */
  95839. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95840. /**
  95841. * Gets the current list of color gradients.
  95842. * You must use addColorGradient and removeColorGradient to udpate this list
  95843. * @returns the list of color gradients
  95844. */
  95845. getColorGradients(): Nullable<Array<ColorGradient>>;
  95846. /**
  95847. * Adds a new ramp gradient used to remap particle colors
  95848. * @param gradient defines the gradient to use (between 0 and 1)
  95849. * @param color defines the color to affect to the specified gradient
  95850. * @returns the current particle system
  95851. */
  95852. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95853. /**
  95854. * Gets the current list of ramp gradients.
  95855. * You must use addRampGradient and removeRampGradient to udpate this list
  95856. * @returns the list of ramp gradients
  95857. */
  95858. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95859. /** Gets or sets a boolean indicating that ramp gradients must be used
  95860. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95861. */
  95862. useRampGradients: boolean;
  95863. /**
  95864. * Adds a new color remap gradient
  95865. * @param gradient defines the gradient to use (between 0 and 1)
  95866. * @param min defines the color remap minimal range
  95867. * @param max defines the color remap maximal range
  95868. * @returns the current particle system
  95869. */
  95870. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95871. /**
  95872. * Gets the current list of color remap gradients.
  95873. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95874. * @returns the list of color remap gradients
  95875. */
  95876. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95877. /**
  95878. * Adds a new alpha remap gradient
  95879. * @param gradient defines the gradient to use (between 0 and 1)
  95880. * @param min defines the alpha remap minimal range
  95881. * @param max defines the alpha remap maximal range
  95882. * @returns the current particle system
  95883. */
  95884. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95885. /**
  95886. * Gets the current list of alpha remap gradients.
  95887. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95888. * @returns the list of alpha remap gradients
  95889. */
  95890. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95891. /**
  95892. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95893. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95894. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95895. * @returns the emitter
  95896. */
  95897. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95898. /**
  95899. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95900. * @param radius The radius of the hemisphere to emit from
  95901. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95902. * @returns the emitter
  95903. */
  95904. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95905. /**
  95906. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95907. * @param radius The radius of the sphere to emit from
  95908. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95909. * @returns the emitter
  95910. */
  95911. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95912. /**
  95913. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95914. * @param radius The radius of the sphere to emit from
  95915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95917. * @returns the emitter
  95918. */
  95919. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95920. /**
  95921. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95922. * @param radius The radius of the emission cylinder
  95923. * @param height The height of the emission cylinder
  95924. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95925. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95926. * @returns the emitter
  95927. */
  95928. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95929. /**
  95930. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95931. * @param radius The radius of the cylinder to emit from
  95932. * @param height The height of the emission cylinder
  95933. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95936. * @returns the emitter
  95937. */
  95938. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95939. /**
  95940. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95941. * @param radius The radius of the cone to emit from
  95942. * @param angle The base angle of the cone
  95943. * @returns the emitter
  95944. */
  95945. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95946. /**
  95947. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95948. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95949. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95950. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95951. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95952. * @returns the emitter
  95953. */
  95954. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95955. /**
  95956. * Get hosting scene
  95957. * @returns the scene
  95958. */
  95959. getScene(): Nullable<Scene>;
  95960. }
  95961. }
  95962. declare module BABYLON {
  95963. /**
  95964. * 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.
  95965. * @see https://doc.babylonjs.com/how_to/transformnode
  95966. */
  95967. export class TransformNode extends Node {
  95968. /**
  95969. * Object will not rotate to face the camera
  95970. */
  95971. static BILLBOARDMODE_NONE: number;
  95972. /**
  95973. * Object will rotate to face the camera but only on the x axis
  95974. */
  95975. static BILLBOARDMODE_X: number;
  95976. /**
  95977. * Object will rotate to face the camera but only on the y axis
  95978. */
  95979. static BILLBOARDMODE_Y: number;
  95980. /**
  95981. * Object will rotate to face the camera but only on the z axis
  95982. */
  95983. static BILLBOARDMODE_Z: number;
  95984. /**
  95985. * Object will rotate to face the camera
  95986. */
  95987. static BILLBOARDMODE_ALL: number;
  95988. /**
  95989. * Object will rotate to face the camera's position instead of orientation
  95990. */
  95991. static BILLBOARDMODE_USE_POSITION: number;
  95992. private static _TmpRotation;
  95993. private static _TmpScaling;
  95994. private static _TmpTranslation;
  95995. private _forward;
  95996. private _forwardInverted;
  95997. private _up;
  95998. private _right;
  95999. private _rightInverted;
  96000. private _position;
  96001. private _rotation;
  96002. private _rotationQuaternion;
  96003. protected _scaling: Vector3;
  96004. protected _isDirty: boolean;
  96005. private _transformToBoneReferal;
  96006. private _isAbsoluteSynced;
  96007. private _billboardMode;
  96008. /**
  96009. * Gets or sets the billboard mode. Default is 0.
  96010. *
  96011. * | Value | Type | Description |
  96012. * | --- | --- | --- |
  96013. * | 0 | BILLBOARDMODE_NONE | |
  96014. * | 1 | BILLBOARDMODE_X | |
  96015. * | 2 | BILLBOARDMODE_Y | |
  96016. * | 4 | BILLBOARDMODE_Z | |
  96017. * | 7 | BILLBOARDMODE_ALL | |
  96018. *
  96019. */
  96020. get billboardMode(): number;
  96021. set billboardMode(value: number);
  96022. private _preserveParentRotationForBillboard;
  96023. /**
  96024. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  96025. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  96026. */
  96027. get preserveParentRotationForBillboard(): boolean;
  96028. set preserveParentRotationForBillboard(value: boolean);
  96029. /**
  96030. * 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
  96031. */
  96032. scalingDeterminant: number;
  96033. private _infiniteDistance;
  96034. /**
  96035. * Gets or sets the distance of the object to max, often used by skybox
  96036. */
  96037. get infiniteDistance(): boolean;
  96038. set infiniteDistance(value: boolean);
  96039. /**
  96040. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  96041. * By default the system will update normals to compensate
  96042. */
  96043. ignoreNonUniformScaling: boolean;
  96044. /**
  96045. * 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
  96046. */
  96047. reIntegrateRotationIntoRotationQuaternion: boolean;
  96048. /** @hidden */
  96049. _poseMatrix: Nullable<Matrix>;
  96050. /** @hidden */
  96051. _localMatrix: Matrix;
  96052. private _usePivotMatrix;
  96053. private _absolutePosition;
  96054. private _absoluteScaling;
  96055. private _absoluteRotationQuaternion;
  96056. private _pivotMatrix;
  96057. private _pivotMatrixInverse;
  96058. /** @hidden */
  96059. _postMultiplyPivotMatrix: boolean;
  96060. protected _isWorldMatrixFrozen: boolean;
  96061. /** @hidden */
  96062. _indexInSceneTransformNodesArray: number;
  96063. /**
  96064. * An event triggered after the world matrix is updated
  96065. */
  96066. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  96067. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  96068. /**
  96069. * Gets a string identifying the name of the class
  96070. * @returns "TransformNode" string
  96071. */
  96072. getClassName(): string;
  96073. /**
  96074. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  96075. */
  96076. get position(): Vector3;
  96077. set position(newPosition: Vector3);
  96078. /**
  96079. * 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)).
  96080. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  96081. */
  96082. get rotation(): Vector3;
  96083. set rotation(newRotation: Vector3);
  96084. /**
  96085. * 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)).
  96086. */
  96087. get scaling(): Vector3;
  96088. set scaling(newScaling: Vector3);
  96089. /**
  96090. * 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).
  96091. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  96092. */
  96093. get rotationQuaternion(): Nullable<Quaternion>;
  96094. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  96095. /**
  96096. * The forward direction of that transform in world space.
  96097. */
  96098. get forward(): Vector3;
  96099. /**
  96100. * The up direction of that transform in world space.
  96101. */
  96102. get up(): Vector3;
  96103. /**
  96104. * The right direction of that transform in world space.
  96105. */
  96106. get right(): Vector3;
  96107. /**
  96108. * Copies the parameter passed Matrix into the mesh Pose matrix.
  96109. * @param matrix the matrix to copy the pose from
  96110. * @returns this TransformNode.
  96111. */
  96112. updatePoseMatrix(matrix: Matrix): TransformNode;
  96113. /**
  96114. * Returns the mesh Pose matrix.
  96115. * @returns the pose matrix
  96116. */
  96117. getPoseMatrix(): Matrix;
  96118. /** @hidden */
  96119. _isSynchronized(): boolean;
  96120. /** @hidden */
  96121. _initCache(): void;
  96122. /**
  96123. * Flag the transform node as dirty (Forcing it to update everything)
  96124. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  96125. * @returns this transform node
  96126. */
  96127. markAsDirty(property: string): TransformNode;
  96128. /**
  96129. * Returns the current mesh absolute position.
  96130. * Returns a Vector3.
  96131. */
  96132. get absolutePosition(): Vector3;
  96133. /**
  96134. * Returns the current mesh absolute scaling.
  96135. * Returns a Vector3.
  96136. */
  96137. get absoluteScaling(): Vector3;
  96138. /**
  96139. * Returns the current mesh absolute rotation.
  96140. * Returns a Quaternion.
  96141. */
  96142. get absoluteRotationQuaternion(): Quaternion;
  96143. /**
  96144. * Sets a new matrix to apply before all other transformation
  96145. * @param matrix defines the transform matrix
  96146. * @returns the current TransformNode
  96147. */
  96148. setPreTransformMatrix(matrix: Matrix): TransformNode;
  96149. /**
  96150. * Sets a new pivot matrix to the current node
  96151. * @param matrix defines the new pivot matrix to use
  96152. * @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
  96153. * @returns the current TransformNode
  96154. */
  96155. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  96156. /**
  96157. * Returns the mesh pivot matrix.
  96158. * Default : Identity.
  96159. * @returns the matrix
  96160. */
  96161. getPivotMatrix(): Matrix;
  96162. /**
  96163. * Instantiate (when possible) or clone that node with its hierarchy
  96164. * @param newParent defines the new parent to use for the instance (or clone)
  96165. * @param options defines options to configure how copy is done
  96166. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  96167. * @returns an instance (or a clone) of the current node with its hiearchy
  96168. */
  96169. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96170. doNotInstantiate: boolean;
  96171. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96172. /**
  96173. * Prevents the World matrix to be computed any longer
  96174. * @param newWorldMatrix defines an optional matrix to use as world matrix
  96175. * @returns the TransformNode.
  96176. */
  96177. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  96178. /**
  96179. * Allows back the World matrix computation.
  96180. * @returns the TransformNode.
  96181. */
  96182. unfreezeWorldMatrix(): this;
  96183. /**
  96184. * True if the World matrix has been frozen.
  96185. */
  96186. get isWorldMatrixFrozen(): boolean;
  96187. /**
  96188. * Retuns the mesh absolute position in the World.
  96189. * @returns a Vector3.
  96190. */
  96191. getAbsolutePosition(): Vector3;
  96192. /**
  96193. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  96194. * @param absolutePosition the absolute position to set
  96195. * @returns the TransformNode.
  96196. */
  96197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96198. /**
  96199. * Sets the mesh position in its local space.
  96200. * @param vector3 the position to set in localspace
  96201. * @returns the TransformNode.
  96202. */
  96203. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  96204. /**
  96205. * Returns the mesh position in the local space from the current World matrix values.
  96206. * @returns a new Vector3.
  96207. */
  96208. getPositionExpressedInLocalSpace(): Vector3;
  96209. /**
  96210. * Translates the mesh along the passed Vector3 in its local space.
  96211. * @param vector3 the distance to translate in localspace
  96212. * @returns the TransformNode.
  96213. */
  96214. locallyTranslate(vector3: Vector3): TransformNode;
  96215. private static _lookAtVectorCache;
  96216. /**
  96217. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  96218. * @param targetPoint the position (must be in same space as current mesh) to look at
  96219. * @param yawCor optional yaw (y-axis) correction in radians
  96220. * @param pitchCor optional pitch (x-axis) correction in radians
  96221. * @param rollCor optional roll (z-axis) correction in radians
  96222. * @param space the choosen space of the target
  96223. * @returns the TransformNode.
  96224. */
  96225. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  96226. /**
  96227. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96228. * This Vector3 is expressed in the World space.
  96229. * @param localAxis axis to rotate
  96230. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96231. */
  96232. getDirection(localAxis: Vector3): Vector3;
  96233. /**
  96234. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  96235. * localAxis is expressed in the mesh local space.
  96236. * result is computed in the Wordl space from the mesh World matrix.
  96237. * @param localAxis axis to rotate
  96238. * @param result the resulting transformnode
  96239. * @returns this TransformNode.
  96240. */
  96241. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  96242. /**
  96243. * Sets this transform node rotation to the given local axis.
  96244. * @param localAxis the axis in local space
  96245. * @param yawCor optional yaw (y-axis) correction in radians
  96246. * @param pitchCor optional pitch (x-axis) correction in radians
  96247. * @param rollCor optional roll (z-axis) correction in radians
  96248. * @returns this TransformNode
  96249. */
  96250. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  96251. /**
  96252. * Sets a new pivot point to the current node
  96253. * @param point defines the new pivot point to use
  96254. * @param space defines if the point is in world or local space (local by default)
  96255. * @returns the current TransformNode
  96256. */
  96257. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  96258. /**
  96259. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  96260. * @returns the pivot point
  96261. */
  96262. getPivotPoint(): Vector3;
  96263. /**
  96264. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  96265. * @param result the vector3 to store the result
  96266. * @returns this TransformNode.
  96267. */
  96268. getPivotPointToRef(result: Vector3): TransformNode;
  96269. /**
  96270. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  96271. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  96272. */
  96273. getAbsolutePivotPoint(): Vector3;
  96274. /**
  96275. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  96276. * @param result vector3 to store the result
  96277. * @returns this TransformNode.
  96278. */
  96279. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  96280. /**
  96281. * Defines the passed node as the parent of the current node.
  96282. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  96283. * @see https://doc.babylonjs.com/how_to/parenting
  96284. * @param node the node ot set as the parent
  96285. * @returns this TransformNode.
  96286. */
  96287. setParent(node: Nullable<Node>): TransformNode;
  96288. private _nonUniformScaling;
  96289. /**
  96290. * True if the scaling property of this object is non uniform eg. (1,2,1)
  96291. */
  96292. get nonUniformScaling(): boolean;
  96293. /** @hidden */
  96294. _updateNonUniformScalingState(value: boolean): boolean;
  96295. /**
  96296. * Attach the current TransformNode to another TransformNode associated with a bone
  96297. * @param bone Bone affecting the TransformNode
  96298. * @param affectedTransformNode TransformNode associated with the bone
  96299. * @returns this object
  96300. */
  96301. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  96302. /**
  96303. * Detach the transform node if its associated with a bone
  96304. * @returns this object
  96305. */
  96306. detachFromBone(): TransformNode;
  96307. private static _rotationAxisCache;
  96308. /**
  96309. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  96310. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96311. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96312. * The passed axis is also normalized.
  96313. * @param axis the axis to rotate around
  96314. * @param amount the amount to rotate in radians
  96315. * @param space Space to rotate in (Default: local)
  96316. * @returns the TransformNode.
  96317. */
  96318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96319. /**
  96320. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  96321. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96322. * The passed axis is also normalized. .
  96323. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  96324. * @param point the point to rotate around
  96325. * @param axis the axis to rotate around
  96326. * @param amount the amount to rotate in radians
  96327. * @returns the TransformNode
  96328. */
  96329. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  96330. /**
  96331. * Translates the mesh along the axis vector for the passed distance in the given space.
  96332. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96333. * @param axis the axis to translate in
  96334. * @param distance the distance to translate
  96335. * @param space Space to rotate in (Default: local)
  96336. * @returns the TransformNode.
  96337. */
  96338. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96339. /**
  96340. * Adds a rotation step to the mesh current rotation.
  96341. * x, y, z are Euler angles expressed in radians.
  96342. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  96343. * This means this rotation is made in the mesh local space only.
  96344. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  96345. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  96346. * ```javascript
  96347. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  96348. * ```
  96349. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  96350. * 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.
  96351. * @param x Rotation to add
  96352. * @param y Rotation to add
  96353. * @param z Rotation to add
  96354. * @returns the TransformNode.
  96355. */
  96356. addRotation(x: number, y: number, z: number): TransformNode;
  96357. /**
  96358. * @hidden
  96359. */
  96360. protected _getEffectiveParent(): Nullable<Node>;
  96361. /**
  96362. * Computes the world matrix of the node
  96363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96364. * @returns the world matrix
  96365. */
  96366. computeWorldMatrix(force?: boolean): Matrix;
  96367. /**
  96368. * Resets this nodeTransform's local matrix to Matrix.Identity().
  96369. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  96370. */
  96371. resetLocalMatrix(independentOfChildren?: boolean): void;
  96372. protected _afterComputeWorldMatrix(): void;
  96373. /**
  96374. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  96375. * @param func callback function to add
  96376. *
  96377. * @returns the TransformNode.
  96378. */
  96379. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96380. /**
  96381. * Removes a registered callback function.
  96382. * @param func callback function to remove
  96383. * @returns the TransformNode.
  96384. */
  96385. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96386. /**
  96387. * Gets the position of the current mesh in camera space
  96388. * @param camera defines the camera to use
  96389. * @returns a position
  96390. */
  96391. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  96392. /**
  96393. * Returns the distance from the mesh to the active camera
  96394. * @param camera defines the camera to use
  96395. * @returns the distance
  96396. */
  96397. getDistanceToCamera(camera?: Nullable<Camera>): number;
  96398. /**
  96399. * Clone the current transform node
  96400. * @param name Name of the new clone
  96401. * @param newParent New parent for the clone
  96402. * @param doNotCloneChildren Do not clone children hierarchy
  96403. * @returns the new transform node
  96404. */
  96405. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  96406. /**
  96407. * Serializes the objects information.
  96408. * @param currentSerializationObject defines the object to serialize in
  96409. * @returns the serialized object
  96410. */
  96411. serialize(currentSerializationObject?: any): any;
  96412. /**
  96413. * Returns a new TransformNode object parsed from the source provided.
  96414. * @param parsedTransformNode is the source.
  96415. * @param scene the scne the object belongs to
  96416. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  96417. * @returns a new TransformNode object parsed from the source provided.
  96418. */
  96419. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  96420. /**
  96421. * Get all child-transformNodes of this node
  96422. * @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
  96423. * @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
  96424. * @returns an array of TransformNode
  96425. */
  96426. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  96427. /**
  96428. * Releases resources associated with this transform node.
  96429. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96430. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96431. */
  96432. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96433. /**
  96434. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96435. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96436. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96437. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96438. * @returns the current mesh
  96439. */
  96440. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  96441. private _syncAbsoluteScalingAndRotation;
  96442. }
  96443. }
  96444. declare module BABYLON {
  96445. /**
  96446. * Class used to override all child animations of a given target
  96447. */
  96448. export class AnimationPropertiesOverride {
  96449. /**
  96450. * Gets or sets a value indicating if animation blending must be used
  96451. */
  96452. enableBlending: boolean;
  96453. /**
  96454. * Gets or sets the blending speed to use when enableBlending is true
  96455. */
  96456. blendingSpeed: number;
  96457. /**
  96458. * Gets or sets the default loop mode to use
  96459. */
  96460. loopMode: number;
  96461. }
  96462. }
  96463. declare module BABYLON {
  96464. /**
  96465. * Class used to store bone information
  96466. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96467. */
  96468. export class Bone extends Node {
  96469. /**
  96470. * defines the bone name
  96471. */
  96472. name: string;
  96473. private static _tmpVecs;
  96474. private static _tmpQuat;
  96475. private static _tmpMats;
  96476. /**
  96477. * Gets the list of child bones
  96478. */
  96479. children: Bone[];
  96480. /** Gets the animations associated with this bone */
  96481. animations: Animation[];
  96482. /**
  96483. * Gets or sets bone length
  96484. */
  96485. length: number;
  96486. /**
  96487. * @hidden Internal only
  96488. * Set this value to map this bone to a different index in the transform matrices
  96489. * Set this value to -1 to exclude the bone from the transform matrices
  96490. */
  96491. _index: Nullable<number>;
  96492. private _skeleton;
  96493. private _localMatrix;
  96494. private _restPose;
  96495. private _bindPose;
  96496. private _baseMatrix;
  96497. private _absoluteTransform;
  96498. private _invertedAbsoluteTransform;
  96499. private _parent;
  96500. private _scalingDeterminant;
  96501. private _worldTransform;
  96502. private _localScaling;
  96503. private _localRotation;
  96504. private _localPosition;
  96505. private _needToDecompose;
  96506. private _needToCompose;
  96507. /** @hidden */
  96508. _linkedTransformNode: Nullable<TransformNode>;
  96509. /** @hidden */
  96510. _waitingTransformNodeId: Nullable<string>;
  96511. /** @hidden */
  96512. get _matrix(): Matrix;
  96513. /** @hidden */
  96514. set _matrix(value: Matrix);
  96515. /**
  96516. * Create a new bone
  96517. * @param name defines the bone name
  96518. * @param skeleton defines the parent skeleton
  96519. * @param parentBone defines the parent (can be null if the bone is the root)
  96520. * @param localMatrix defines the local matrix
  96521. * @param restPose defines the rest pose matrix
  96522. * @param baseMatrix defines the base matrix
  96523. * @param index defines index of the bone in the hiearchy
  96524. */
  96525. constructor(
  96526. /**
  96527. * defines the bone name
  96528. */
  96529. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96530. /**
  96531. * Gets the current object class name.
  96532. * @return the class name
  96533. */
  96534. getClassName(): string;
  96535. /**
  96536. * Gets the parent skeleton
  96537. * @returns a skeleton
  96538. */
  96539. getSkeleton(): Skeleton;
  96540. /**
  96541. * Gets parent bone
  96542. * @returns a bone or null if the bone is the root of the bone hierarchy
  96543. */
  96544. getParent(): Nullable<Bone>;
  96545. /**
  96546. * Returns an array containing the root bones
  96547. * @returns an array containing the root bones
  96548. */
  96549. getChildren(): Array<Bone>;
  96550. /**
  96551. * Gets the node index in matrix array generated for rendering
  96552. * @returns the node index
  96553. */
  96554. getIndex(): number;
  96555. /**
  96556. * Sets the parent bone
  96557. * @param parent defines the parent (can be null if the bone is the root)
  96558. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96559. */
  96560. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96561. /**
  96562. * Gets the local matrix
  96563. * @returns a matrix
  96564. */
  96565. getLocalMatrix(): Matrix;
  96566. /**
  96567. * Gets the base matrix (initial matrix which remains unchanged)
  96568. * @returns a matrix
  96569. */
  96570. getBaseMatrix(): Matrix;
  96571. /**
  96572. * Gets the rest pose matrix
  96573. * @returns a matrix
  96574. */
  96575. getRestPose(): Matrix;
  96576. /**
  96577. * Sets the rest pose matrix
  96578. * @param matrix the local-space rest pose to set for this bone
  96579. */
  96580. setRestPose(matrix: Matrix): void;
  96581. /**
  96582. * Gets the bind pose matrix
  96583. * @returns the bind pose matrix
  96584. */
  96585. getBindPose(): Matrix;
  96586. /**
  96587. * Sets the bind pose matrix
  96588. * @param matrix the local-space bind pose to set for this bone
  96589. */
  96590. setBindPose(matrix: Matrix): void;
  96591. /**
  96592. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96593. */
  96594. getWorldMatrix(): Matrix;
  96595. /**
  96596. * Sets the local matrix to rest pose matrix
  96597. */
  96598. returnToRest(): void;
  96599. /**
  96600. * Gets the inverse of the absolute transform matrix.
  96601. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96602. * @returns a matrix
  96603. */
  96604. getInvertedAbsoluteTransform(): Matrix;
  96605. /**
  96606. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96607. * @returns a matrix
  96608. */
  96609. getAbsoluteTransform(): Matrix;
  96610. /**
  96611. * Links with the given transform node.
  96612. * The local matrix of this bone is copied from the transform node every frame.
  96613. * @param transformNode defines the transform node to link to
  96614. */
  96615. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96616. /**
  96617. * Gets the node used to drive the bone's transformation
  96618. * @returns a transform node or null
  96619. */
  96620. getTransformNode(): Nullable<TransformNode>;
  96621. /** Gets or sets current position (in local space) */
  96622. get position(): Vector3;
  96623. set position(newPosition: Vector3);
  96624. /** Gets or sets current rotation (in local space) */
  96625. get rotation(): Vector3;
  96626. set rotation(newRotation: Vector3);
  96627. /** Gets or sets current rotation quaternion (in local space) */
  96628. get rotationQuaternion(): Quaternion;
  96629. set rotationQuaternion(newRotation: Quaternion);
  96630. /** Gets or sets current scaling (in local space) */
  96631. get scaling(): Vector3;
  96632. set scaling(newScaling: Vector3);
  96633. /**
  96634. * Gets the animation properties override
  96635. */
  96636. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96637. private _decompose;
  96638. private _compose;
  96639. /**
  96640. * Update the base and local matrices
  96641. * @param matrix defines the new base or local matrix
  96642. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96643. * @param updateLocalMatrix defines if the local matrix should be updated
  96644. */
  96645. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96646. /** @hidden */
  96647. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96648. /**
  96649. * Flag the bone as dirty (Forcing it to update everything)
  96650. */
  96651. markAsDirty(): void;
  96652. /** @hidden */
  96653. _markAsDirtyAndCompose(): void;
  96654. private _markAsDirtyAndDecompose;
  96655. /**
  96656. * Translate the bone in local or world space
  96657. * @param vec The amount to translate the bone
  96658. * @param space The space that the translation is in
  96659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96660. */
  96661. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96662. /**
  96663. * Set the postion of the bone in local or world space
  96664. * @param position The position to set the bone
  96665. * @param space The space that the position is in
  96666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96667. */
  96668. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96669. /**
  96670. * Set the absolute position of the bone (world space)
  96671. * @param position The position to set the bone
  96672. * @param mesh The mesh that this bone is attached to
  96673. */
  96674. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96675. /**
  96676. * Scale the bone on the x, y and z axes (in local space)
  96677. * @param x The amount to scale the bone on the x axis
  96678. * @param y The amount to scale the bone on the y axis
  96679. * @param z The amount to scale the bone on the z axis
  96680. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96681. */
  96682. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96683. /**
  96684. * Set the bone scaling in local space
  96685. * @param scale defines the scaling vector
  96686. */
  96687. setScale(scale: Vector3): void;
  96688. /**
  96689. * Gets the current scaling in local space
  96690. * @returns the current scaling vector
  96691. */
  96692. getScale(): Vector3;
  96693. /**
  96694. * Gets the current scaling in local space and stores it in a target vector
  96695. * @param result defines the target vector
  96696. */
  96697. getScaleToRef(result: Vector3): void;
  96698. /**
  96699. * Set the yaw, pitch, and roll of the bone in local or world space
  96700. * @param yaw The rotation of the bone on the y axis
  96701. * @param pitch The rotation of the bone on the x axis
  96702. * @param roll The rotation of the bone on the z axis
  96703. * @param space The space that the axes of rotation are in
  96704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96705. */
  96706. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96707. /**
  96708. * Add a rotation to the bone on an axis in local or world space
  96709. * @param axis The axis to rotate the bone on
  96710. * @param amount The amount to rotate the bone
  96711. * @param space The space that the axis is in
  96712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96713. */
  96714. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96715. /**
  96716. * Set the rotation of the bone to a particular axis angle in local or world space
  96717. * @param axis The axis to rotate the bone on
  96718. * @param angle The angle that the bone should be rotated to
  96719. * @param space The space that the axis is in
  96720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96721. */
  96722. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96723. /**
  96724. * Set the euler rotation of the bone in local or world space
  96725. * @param rotation The euler rotation that the bone should be set to
  96726. * @param space The space that the rotation is in
  96727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96728. */
  96729. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96730. /**
  96731. * Set the quaternion rotation of the bone in local or world space
  96732. * @param quat The quaternion rotation that the bone should be set to
  96733. * @param space The space that the rotation is in
  96734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96735. */
  96736. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96737. /**
  96738. * Set the rotation matrix of the bone in local or world space
  96739. * @param rotMat The rotation matrix that the bone should be set to
  96740. * @param space The space that the rotation is in
  96741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96742. */
  96743. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96744. private _rotateWithMatrix;
  96745. private _getNegativeRotationToRef;
  96746. /**
  96747. * Get the position of the bone in local or world space
  96748. * @param space The space that the returned position is in
  96749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96750. * @returns The position of the bone
  96751. */
  96752. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96753. /**
  96754. * Copy the position of the bone to a vector3 in local or world space
  96755. * @param space The space that the returned position is in
  96756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96757. * @param result The vector3 to copy the position to
  96758. */
  96759. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96760. /**
  96761. * Get the absolute position of the bone (world space)
  96762. * @param mesh The mesh that this bone is attached to
  96763. * @returns The absolute position of the bone
  96764. */
  96765. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96766. /**
  96767. * Copy the absolute position of the bone (world space) to the result param
  96768. * @param mesh The mesh that this bone is attached to
  96769. * @param result The vector3 to copy the absolute position to
  96770. */
  96771. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96772. /**
  96773. * Compute the absolute transforms of this bone and its children
  96774. */
  96775. computeAbsoluteTransforms(): void;
  96776. /**
  96777. * Get the world direction from an axis that is in the local space of the bone
  96778. * @param localAxis The local direction that is used to compute the world direction
  96779. * @param mesh The mesh that this bone is attached to
  96780. * @returns The world direction
  96781. */
  96782. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96783. /**
  96784. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96785. * @param localAxis The local direction that is used to compute the world direction
  96786. * @param mesh The mesh that this bone is attached to
  96787. * @param result The vector3 that the world direction will be copied to
  96788. */
  96789. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96790. /**
  96791. * Get the euler rotation of the bone in local or world space
  96792. * @param space The space that the rotation should be in
  96793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96794. * @returns The euler rotation
  96795. */
  96796. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96797. /**
  96798. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96799. * @param space The space that the rotation should be in
  96800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96801. * @param result The vector3 that the rotation should be copied to
  96802. */
  96803. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96804. /**
  96805. * Get the quaternion rotation of the bone in either local or world space
  96806. * @param space The space that the rotation should be in
  96807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96808. * @returns The quaternion rotation
  96809. */
  96810. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96811. /**
  96812. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96813. * @param space The space that the rotation should be in
  96814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96815. * @param result The quaternion that the rotation should be copied to
  96816. */
  96817. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96818. /**
  96819. * Get the rotation matrix of the bone in local or world space
  96820. * @param space The space that the rotation should be in
  96821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96822. * @returns The rotation matrix
  96823. */
  96824. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96825. /**
  96826. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96827. * @param space The space that the rotation should be in
  96828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96829. * @param result The quaternion that the rotation should be copied to
  96830. */
  96831. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96832. /**
  96833. * Get the world position of a point that is in the local space of the bone
  96834. * @param position The local position
  96835. * @param mesh The mesh that this bone is attached to
  96836. * @returns The world position
  96837. */
  96838. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96839. /**
  96840. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96841. * @param position The local position
  96842. * @param mesh The mesh that this bone is attached to
  96843. * @param result The vector3 that the world position should be copied to
  96844. */
  96845. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96846. /**
  96847. * Get the local position of a point that is in world space
  96848. * @param position The world position
  96849. * @param mesh The mesh that this bone is attached to
  96850. * @returns The local position
  96851. */
  96852. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96853. /**
  96854. * Get the local position of a point that is in world space and copy it to the result param
  96855. * @param position The world position
  96856. * @param mesh The mesh that this bone is attached to
  96857. * @param result The vector3 that the local position should be copied to
  96858. */
  96859. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96860. /**
  96861. * Set the current local matrix as the restPose for this bone.
  96862. */
  96863. setCurrentPoseAsRest(): void;
  96864. }
  96865. }
  96866. declare module BABYLON {
  96867. /**
  96868. * Defines a runtime animation
  96869. */
  96870. export class RuntimeAnimation {
  96871. private _events;
  96872. /**
  96873. * The current frame of the runtime animation
  96874. */
  96875. private _currentFrame;
  96876. /**
  96877. * The animation used by the runtime animation
  96878. */
  96879. private _animation;
  96880. /**
  96881. * The target of the runtime animation
  96882. */
  96883. private _target;
  96884. /**
  96885. * The initiating animatable
  96886. */
  96887. private _host;
  96888. /**
  96889. * The original value of the runtime animation
  96890. */
  96891. private _originalValue;
  96892. /**
  96893. * The original blend value of the runtime animation
  96894. */
  96895. private _originalBlendValue;
  96896. /**
  96897. * The offsets cache of the runtime animation
  96898. */
  96899. private _offsetsCache;
  96900. /**
  96901. * The high limits cache of the runtime animation
  96902. */
  96903. private _highLimitsCache;
  96904. /**
  96905. * Specifies if the runtime animation has been stopped
  96906. */
  96907. private _stopped;
  96908. /**
  96909. * The blending factor of the runtime animation
  96910. */
  96911. private _blendingFactor;
  96912. /**
  96913. * The BabylonJS scene
  96914. */
  96915. private _scene;
  96916. /**
  96917. * The current value of the runtime animation
  96918. */
  96919. private _currentValue;
  96920. /** @hidden */
  96921. _animationState: _IAnimationState;
  96922. /**
  96923. * The active target of the runtime animation
  96924. */
  96925. private _activeTargets;
  96926. private _currentActiveTarget;
  96927. private _directTarget;
  96928. /**
  96929. * The target path of the runtime animation
  96930. */
  96931. private _targetPath;
  96932. /**
  96933. * The weight of the runtime animation
  96934. */
  96935. private _weight;
  96936. /**
  96937. * The ratio offset of the runtime animation
  96938. */
  96939. private _ratioOffset;
  96940. /**
  96941. * The previous delay of the runtime animation
  96942. */
  96943. private _previousDelay;
  96944. /**
  96945. * The previous ratio of the runtime animation
  96946. */
  96947. private _previousRatio;
  96948. private _enableBlending;
  96949. private _keys;
  96950. private _minFrame;
  96951. private _maxFrame;
  96952. private _minValue;
  96953. private _maxValue;
  96954. private _targetIsArray;
  96955. /**
  96956. * Gets the current frame of the runtime animation
  96957. */
  96958. get currentFrame(): number;
  96959. /**
  96960. * Gets the weight of the runtime animation
  96961. */
  96962. get weight(): number;
  96963. /**
  96964. * Gets the current value of the runtime animation
  96965. */
  96966. get currentValue(): any;
  96967. /**
  96968. * Gets the target path of the runtime animation
  96969. */
  96970. get targetPath(): string;
  96971. /**
  96972. * Gets the actual target of the runtime animation
  96973. */
  96974. get target(): any;
  96975. /**
  96976. * Gets the additive state of the runtime animation
  96977. */
  96978. get isAdditive(): boolean;
  96979. /** @hidden */
  96980. _onLoop: () => void;
  96981. /**
  96982. * Create a new RuntimeAnimation object
  96983. * @param target defines the target of the animation
  96984. * @param animation defines the source animation object
  96985. * @param scene defines the hosting scene
  96986. * @param host defines the initiating Animatable
  96987. */
  96988. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96989. private _preparePath;
  96990. /**
  96991. * Gets the animation from the runtime animation
  96992. */
  96993. get animation(): Animation;
  96994. /**
  96995. * Resets the runtime animation to the beginning
  96996. * @param restoreOriginal defines whether to restore the target property to the original value
  96997. */
  96998. reset(restoreOriginal?: boolean): void;
  96999. /**
  97000. * Specifies if the runtime animation is stopped
  97001. * @returns Boolean specifying if the runtime animation is stopped
  97002. */
  97003. isStopped(): boolean;
  97004. /**
  97005. * Disposes of the runtime animation
  97006. */
  97007. dispose(): void;
  97008. /**
  97009. * Apply the interpolated value to the target
  97010. * @param currentValue defines the value computed by the animation
  97011. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  97012. */
  97013. setValue(currentValue: any, weight: number): void;
  97014. private _getOriginalValues;
  97015. private _setValue;
  97016. /**
  97017. * Gets the loop pmode of the runtime animation
  97018. * @returns Loop Mode
  97019. */
  97020. private _getCorrectLoopMode;
  97021. /**
  97022. * Move the current animation to a given frame
  97023. * @param frame defines the frame to move to
  97024. */
  97025. goToFrame(frame: number): void;
  97026. /**
  97027. * @hidden Internal use only
  97028. */
  97029. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  97030. /**
  97031. * Execute the current animation
  97032. * @param delay defines the delay to add to the current frame
  97033. * @param from defines the lower bound of the animation range
  97034. * @param to defines the upper bound of the animation range
  97035. * @param loop defines if the current animation must loop
  97036. * @param speedRatio defines the current speed ratio
  97037. * @param weight defines the weight of the animation (default is -1 so no weight)
  97038. * @param onLoop optional callback called when animation loops
  97039. * @returns a boolean indicating if the animation is running
  97040. */
  97041. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  97042. }
  97043. }
  97044. declare module BABYLON {
  97045. /**
  97046. * Class used to store an actual running animation
  97047. */
  97048. export class Animatable {
  97049. /** defines the target object */
  97050. target: any;
  97051. /** defines the starting frame number (default is 0) */
  97052. fromFrame: number;
  97053. /** defines the ending frame number (default is 100) */
  97054. toFrame: number;
  97055. /** defines if the animation must loop (default is false) */
  97056. loopAnimation: boolean;
  97057. /** defines a callback to call when animation ends if it is not looping */
  97058. onAnimationEnd?: (() => void) | null | undefined;
  97059. /** defines a callback to call when animation loops */
  97060. onAnimationLoop?: (() => void) | null | undefined;
  97061. /** defines whether the animation should be evaluated additively */
  97062. isAdditive: boolean;
  97063. private _localDelayOffset;
  97064. private _pausedDelay;
  97065. private _runtimeAnimations;
  97066. private _paused;
  97067. private _scene;
  97068. private _speedRatio;
  97069. private _weight;
  97070. private _syncRoot;
  97071. /**
  97072. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  97073. * This will only apply for non looping animation (default is true)
  97074. */
  97075. disposeOnEnd: boolean;
  97076. /**
  97077. * Gets a boolean indicating if the animation has started
  97078. */
  97079. animationStarted: boolean;
  97080. /**
  97081. * Observer raised when the animation ends
  97082. */
  97083. onAnimationEndObservable: Observable<Animatable>;
  97084. /**
  97085. * Observer raised when the animation loops
  97086. */
  97087. onAnimationLoopObservable: Observable<Animatable>;
  97088. /**
  97089. * Gets the root Animatable used to synchronize and normalize animations
  97090. */
  97091. get syncRoot(): Nullable<Animatable>;
  97092. /**
  97093. * Gets the current frame of the first RuntimeAnimation
  97094. * Used to synchronize Animatables
  97095. */
  97096. get masterFrame(): number;
  97097. /**
  97098. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  97099. */
  97100. get weight(): number;
  97101. set weight(value: number);
  97102. /**
  97103. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  97104. */
  97105. get speedRatio(): number;
  97106. set speedRatio(value: number);
  97107. /**
  97108. * Creates a new Animatable
  97109. * @param scene defines the hosting scene
  97110. * @param target defines the target object
  97111. * @param fromFrame defines the starting frame number (default is 0)
  97112. * @param toFrame defines the ending frame number (default is 100)
  97113. * @param loopAnimation defines if the animation must loop (default is false)
  97114. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  97115. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  97116. * @param animations defines a group of animation to add to the new Animatable
  97117. * @param onAnimationLoop defines a callback to call when animation loops
  97118. * @param isAdditive defines whether the animation should be evaluated additively
  97119. */
  97120. constructor(scene: Scene,
  97121. /** defines the target object */
  97122. target: any,
  97123. /** defines the starting frame number (default is 0) */
  97124. fromFrame?: number,
  97125. /** defines the ending frame number (default is 100) */
  97126. toFrame?: number,
  97127. /** defines if the animation must loop (default is false) */
  97128. loopAnimation?: boolean, speedRatio?: number,
  97129. /** defines a callback to call when animation ends if it is not looping */
  97130. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  97131. /** defines a callback to call when animation loops */
  97132. onAnimationLoop?: (() => void) | null | undefined,
  97133. /** defines whether the animation should be evaluated additively */
  97134. isAdditive?: boolean);
  97135. /**
  97136. * Synchronize and normalize current Animatable with a source Animatable
  97137. * This is useful when using animation weights and when animations are not of the same length
  97138. * @param root defines the root Animatable to synchronize with
  97139. * @returns the current Animatable
  97140. */
  97141. syncWith(root: Animatable): Animatable;
  97142. /**
  97143. * Gets the list of runtime animations
  97144. * @returns an array of RuntimeAnimation
  97145. */
  97146. getAnimations(): RuntimeAnimation[];
  97147. /**
  97148. * Adds more animations to the current animatable
  97149. * @param target defines the target of the animations
  97150. * @param animations defines the new animations to add
  97151. */
  97152. appendAnimations(target: any, animations: Animation[]): void;
  97153. /**
  97154. * Gets the source animation for a specific property
  97155. * @param property defines the propertyu to look for
  97156. * @returns null or the source animation for the given property
  97157. */
  97158. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  97159. /**
  97160. * Gets the runtime animation for a specific property
  97161. * @param property defines the propertyu to look for
  97162. * @returns null or the runtime animation for the given property
  97163. */
  97164. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  97165. /**
  97166. * Resets the animatable to its original state
  97167. */
  97168. reset(): void;
  97169. /**
  97170. * Allows the animatable to blend with current running animations
  97171. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97172. * @param blendingSpeed defines the blending speed to use
  97173. */
  97174. enableBlending(blendingSpeed: number): void;
  97175. /**
  97176. * Disable animation blending
  97177. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97178. */
  97179. disableBlending(): void;
  97180. /**
  97181. * Jump directly to a given frame
  97182. * @param frame defines the frame to jump to
  97183. */
  97184. goToFrame(frame: number): void;
  97185. /**
  97186. * Pause the animation
  97187. */
  97188. pause(): void;
  97189. /**
  97190. * Restart the animation
  97191. */
  97192. restart(): void;
  97193. private _raiseOnAnimationEnd;
  97194. /**
  97195. * Stop and delete the current animation
  97196. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  97197. * @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)
  97198. */
  97199. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  97200. /**
  97201. * Wait asynchronously for the animation to end
  97202. * @returns a promise which will be fullfilled when the animation ends
  97203. */
  97204. waitAsync(): Promise<Animatable>;
  97205. /** @hidden */
  97206. _animate(delay: number): boolean;
  97207. }
  97208. interface Scene {
  97209. /** @hidden */
  97210. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  97211. /** @hidden */
  97212. _processLateAnimationBindingsForMatrices(holder: {
  97213. totalWeight: number;
  97214. totalAdditiveWeight: number;
  97215. animations: RuntimeAnimation[];
  97216. additiveAnimations: RuntimeAnimation[];
  97217. originalValue: Matrix;
  97218. }): any;
  97219. /** @hidden */
  97220. _processLateAnimationBindingsForQuaternions(holder: {
  97221. totalWeight: number;
  97222. totalAdditiveWeight: number;
  97223. animations: RuntimeAnimation[];
  97224. additiveAnimations: RuntimeAnimation[];
  97225. originalValue: Quaternion;
  97226. }, refQuaternion: Quaternion): Quaternion;
  97227. /** @hidden */
  97228. _processLateAnimationBindings(): void;
  97229. /**
  97230. * Will start the animation sequence of a given target
  97231. * @param target defines the target
  97232. * @param from defines from which frame should animation start
  97233. * @param to defines until which frame should animation run.
  97234. * @param weight defines the weight to apply to the animation (1.0 by default)
  97235. * @param loop defines if the animation loops
  97236. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97237. * @param onAnimationEnd defines the function to be executed when the animation ends
  97238. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97239. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97240. * @param onAnimationLoop defines the callback to call when an animation loops
  97241. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97242. * @returns the animatable object created for this animation
  97243. */
  97244. 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;
  97245. /**
  97246. * Will start the animation sequence of a given target
  97247. * @param target defines the target
  97248. * @param from defines from which frame should animation start
  97249. * @param to defines until which frame should animation run.
  97250. * @param loop defines if the animation loops
  97251. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97252. * @param onAnimationEnd defines the function to be executed when the animation ends
  97253. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97254. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97255. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  97256. * @param onAnimationLoop defines the callback to call when an animation loops
  97257. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97258. * @returns the animatable object created for this animation
  97259. */
  97260. 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;
  97261. /**
  97262. * Will start the animation sequence of a given target and its hierarchy
  97263. * @param target defines the target
  97264. * @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.
  97265. * @param from defines from which frame should animation start
  97266. * @param to defines until which frame should animation run.
  97267. * @param loop defines if the animation loops
  97268. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97269. * @param onAnimationEnd defines the function to be executed when the animation ends
  97270. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97271. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97272. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97273. * @param onAnimationLoop defines the callback to call when an animation loops
  97274. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97275. * @returns the list of created animatables
  97276. */
  97277. 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[];
  97278. /**
  97279. * Begin a new animation on a given node
  97280. * @param target defines the target where the animation will take place
  97281. * @param animations defines the list of animations to start
  97282. * @param from defines the initial value
  97283. * @param to defines the final value
  97284. * @param loop defines if you want animation to loop (off by default)
  97285. * @param speedRatio defines the speed ratio to apply to all animations
  97286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97287. * @param onAnimationLoop defines the callback to call when an animation loops
  97288. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97289. * @returns the list of created animatables
  97290. */
  97291. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  97292. /**
  97293. * Begin a new animation on a given node and its hierarchy
  97294. * @param target defines the root node where the animation will take place
  97295. * @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.
  97296. * @param animations defines the list of animations to start
  97297. * @param from defines the initial value
  97298. * @param to defines the final value
  97299. * @param loop defines if you want animation to loop (off by default)
  97300. * @param speedRatio defines the speed ratio to apply to all animations
  97301. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97302. * @param onAnimationLoop defines the callback to call when an animation loops
  97303. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97304. * @returns the list of animatables created for all nodes
  97305. */
  97306. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  97307. /**
  97308. * Gets the animatable associated with a specific target
  97309. * @param target defines the target of the animatable
  97310. * @returns the required animatable if found
  97311. */
  97312. getAnimatableByTarget(target: any): Nullable<Animatable>;
  97313. /**
  97314. * Gets all animatables associated with a given target
  97315. * @param target defines the target to look animatables for
  97316. * @returns an array of Animatables
  97317. */
  97318. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  97319. /**
  97320. * Stops and removes all animations that have been applied to the scene
  97321. */
  97322. stopAllAnimations(): void;
  97323. /**
  97324. * Gets the current delta time used by animation engine
  97325. */
  97326. deltaTime: number;
  97327. }
  97328. interface Bone {
  97329. /**
  97330. * Copy an animation range from another bone
  97331. * @param source defines the source bone
  97332. * @param rangeName defines the range name to copy
  97333. * @param frameOffset defines the frame offset
  97334. * @param rescaleAsRequired defines if rescaling must be applied if required
  97335. * @param skelDimensionsRatio defines the scaling ratio
  97336. * @returns true if operation was successful
  97337. */
  97338. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  97339. }
  97340. }
  97341. declare module BABYLON {
  97342. /**
  97343. * Class used to handle skinning animations
  97344. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97345. */
  97346. export class Skeleton implements IAnimatable {
  97347. /** defines the skeleton name */
  97348. name: string;
  97349. /** defines the skeleton Id */
  97350. id: string;
  97351. /**
  97352. * Defines the list of child bones
  97353. */
  97354. bones: Bone[];
  97355. /**
  97356. * Defines an estimate of the dimension of the skeleton at rest
  97357. */
  97358. dimensionsAtRest: Vector3;
  97359. /**
  97360. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  97361. */
  97362. needInitialSkinMatrix: boolean;
  97363. /**
  97364. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  97365. */
  97366. overrideMesh: Nullable<AbstractMesh>;
  97367. /**
  97368. * Gets the list of animations attached to this skeleton
  97369. */
  97370. animations: Array<Animation>;
  97371. private _scene;
  97372. private _isDirty;
  97373. private _transformMatrices;
  97374. private _transformMatrixTexture;
  97375. private _meshesWithPoseMatrix;
  97376. private _animatables;
  97377. private _identity;
  97378. private _synchronizedWithMesh;
  97379. private _ranges;
  97380. private _lastAbsoluteTransformsUpdateId;
  97381. private _canUseTextureForBones;
  97382. private _uniqueId;
  97383. /** @hidden */
  97384. _numBonesWithLinkedTransformNode: number;
  97385. /** @hidden */
  97386. _hasWaitingData: Nullable<boolean>;
  97387. /** @hidden */
  97388. _waitingOverrideMeshId: Nullable<string>;
  97389. /**
  97390. * Specifies if the skeleton should be serialized
  97391. */
  97392. doNotSerialize: boolean;
  97393. private _useTextureToStoreBoneMatrices;
  97394. /**
  97395. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  97396. * Please note that this option is not available if the hardware does not support it
  97397. */
  97398. get useTextureToStoreBoneMatrices(): boolean;
  97399. set useTextureToStoreBoneMatrices(value: boolean);
  97400. private _animationPropertiesOverride;
  97401. /**
  97402. * Gets or sets the animation properties override
  97403. */
  97404. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97405. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97406. /**
  97407. * List of inspectable custom properties (used by the Inspector)
  97408. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97409. */
  97410. inspectableCustomProperties: IInspectable[];
  97411. /**
  97412. * An observable triggered before computing the skeleton's matrices
  97413. */
  97414. onBeforeComputeObservable: Observable<Skeleton>;
  97415. /**
  97416. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  97417. */
  97418. get isUsingTextureForMatrices(): boolean;
  97419. /**
  97420. * Gets the unique ID of this skeleton
  97421. */
  97422. get uniqueId(): number;
  97423. /**
  97424. * Creates a new skeleton
  97425. * @param name defines the skeleton name
  97426. * @param id defines the skeleton Id
  97427. * @param scene defines the hosting scene
  97428. */
  97429. constructor(
  97430. /** defines the skeleton name */
  97431. name: string,
  97432. /** defines the skeleton Id */
  97433. id: string, scene: Scene);
  97434. /**
  97435. * Gets the current object class name.
  97436. * @return the class name
  97437. */
  97438. getClassName(): string;
  97439. /**
  97440. * Returns an array containing the root bones
  97441. * @returns an array containing the root bones
  97442. */
  97443. getChildren(): Array<Bone>;
  97444. /**
  97445. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  97446. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97447. * @returns a Float32Array containing matrices data
  97448. */
  97449. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  97450. /**
  97451. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  97452. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97453. * @returns a raw texture containing the data
  97454. */
  97455. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  97456. /**
  97457. * Gets the current hosting scene
  97458. * @returns a scene object
  97459. */
  97460. getScene(): Scene;
  97461. /**
  97462. * Gets a string representing the current skeleton data
  97463. * @param fullDetails defines a boolean indicating if we want a verbose version
  97464. * @returns a string representing the current skeleton data
  97465. */
  97466. toString(fullDetails?: boolean): string;
  97467. /**
  97468. * Get bone's index searching by name
  97469. * @param name defines bone's name to search for
  97470. * @return the indice of the bone. Returns -1 if not found
  97471. */
  97472. getBoneIndexByName(name: string): number;
  97473. /**
  97474. * Creater a new animation range
  97475. * @param name defines the name of the range
  97476. * @param from defines the start key
  97477. * @param to defines the end key
  97478. */
  97479. createAnimationRange(name: string, from: number, to: number): void;
  97480. /**
  97481. * Delete a specific animation range
  97482. * @param name defines the name of the range
  97483. * @param deleteFrames defines if frames must be removed as well
  97484. */
  97485. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97486. /**
  97487. * Gets a specific animation range
  97488. * @param name defines the name of the range to look for
  97489. * @returns the requested animation range or null if not found
  97490. */
  97491. getAnimationRange(name: string): Nullable<AnimationRange>;
  97492. /**
  97493. * Gets the list of all animation ranges defined on this skeleton
  97494. * @returns an array
  97495. */
  97496. getAnimationRanges(): Nullable<AnimationRange>[];
  97497. /**
  97498. * Copy animation range from a source skeleton.
  97499. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97500. * @param source defines the source skeleton
  97501. * @param name defines the name of the range to copy
  97502. * @param rescaleAsRequired defines if rescaling must be applied if required
  97503. * @returns true if operation was successful
  97504. */
  97505. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97506. /**
  97507. * Forces the skeleton to go to rest pose
  97508. */
  97509. returnToRest(): void;
  97510. private _getHighestAnimationFrame;
  97511. /**
  97512. * Begin a specific animation range
  97513. * @param name defines the name of the range to start
  97514. * @param loop defines if looping must be turned on (false by default)
  97515. * @param speedRatio defines the speed ratio to apply (1 by default)
  97516. * @param onAnimationEnd defines a callback which will be called when animation will end
  97517. * @returns a new animatable
  97518. */
  97519. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97520. /**
  97521. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97522. * @param skeleton defines the Skeleton containing the animation range to convert
  97523. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97524. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97525. * @returns the original skeleton
  97526. */
  97527. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97528. /** @hidden */
  97529. _markAsDirty(): void;
  97530. /** @hidden */
  97531. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97532. /** @hidden */
  97533. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97534. private _computeTransformMatrices;
  97535. /**
  97536. * Build all resources required to render a skeleton
  97537. */
  97538. prepare(): void;
  97539. /**
  97540. * Gets the list of animatables currently running for this skeleton
  97541. * @returns an array of animatables
  97542. */
  97543. getAnimatables(): IAnimatable[];
  97544. /**
  97545. * Clone the current skeleton
  97546. * @param name defines the name of the new skeleton
  97547. * @param id defines the id of the new skeleton
  97548. * @returns the new skeleton
  97549. */
  97550. clone(name: string, id?: string): Skeleton;
  97551. /**
  97552. * Enable animation blending for this skeleton
  97553. * @param blendingSpeed defines the blending speed to apply
  97554. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97555. */
  97556. enableBlending(blendingSpeed?: number): void;
  97557. /**
  97558. * Releases all resources associated with the current skeleton
  97559. */
  97560. dispose(): void;
  97561. /**
  97562. * Serialize the skeleton in a JSON object
  97563. * @returns a JSON object
  97564. */
  97565. serialize(): any;
  97566. /**
  97567. * Creates a new skeleton from serialized data
  97568. * @param parsedSkeleton defines the serialized data
  97569. * @param scene defines the hosting scene
  97570. * @returns a new skeleton
  97571. */
  97572. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97573. /**
  97574. * Compute all node absolute transforms
  97575. * @param forceUpdate defines if computation must be done even if cache is up to date
  97576. */
  97577. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97578. /**
  97579. * Gets the root pose matrix
  97580. * @returns a matrix
  97581. */
  97582. getPoseMatrix(): Nullable<Matrix>;
  97583. /**
  97584. * Sorts bones per internal index
  97585. */
  97586. sortBones(): void;
  97587. private _sortBones;
  97588. /**
  97589. * Set the current local matrix as the restPose for all bones in the skeleton.
  97590. */
  97591. setCurrentPoseAsRest(): void;
  97592. }
  97593. }
  97594. declare module BABYLON {
  97595. /**
  97596. * Creates an instance based on a source mesh.
  97597. */
  97598. export class InstancedMesh extends AbstractMesh {
  97599. private _sourceMesh;
  97600. private _currentLOD;
  97601. /** @hidden */
  97602. _indexInSourceMeshInstanceArray: number;
  97603. constructor(name: string, source: Mesh);
  97604. /**
  97605. * Returns the string "InstancedMesh".
  97606. */
  97607. getClassName(): string;
  97608. /** Gets the list of lights affecting that mesh */
  97609. get lightSources(): Light[];
  97610. _resyncLightSources(): void;
  97611. _resyncLightSource(light: Light): void;
  97612. _removeLightSource(light: Light, dispose: boolean): void;
  97613. /**
  97614. * If the source mesh receives shadows
  97615. */
  97616. get receiveShadows(): boolean;
  97617. /**
  97618. * The material of the source mesh
  97619. */
  97620. get material(): Nullable<Material>;
  97621. /**
  97622. * Visibility of the source mesh
  97623. */
  97624. get visibility(): number;
  97625. /**
  97626. * Skeleton of the source mesh
  97627. */
  97628. get skeleton(): Nullable<Skeleton>;
  97629. /**
  97630. * Rendering ground id of the source mesh
  97631. */
  97632. get renderingGroupId(): number;
  97633. set renderingGroupId(value: number);
  97634. /**
  97635. * Returns the total number of vertices (integer).
  97636. */
  97637. getTotalVertices(): number;
  97638. /**
  97639. * Returns a positive integer : the total number of indices in this mesh geometry.
  97640. * @returns the numner of indices or zero if the mesh has no geometry.
  97641. */
  97642. getTotalIndices(): number;
  97643. /**
  97644. * The source mesh of the instance
  97645. */
  97646. get sourceMesh(): Mesh;
  97647. /**
  97648. * Creates a new InstancedMesh object from the mesh model.
  97649. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97650. * @param name defines the name of the new instance
  97651. * @returns a new InstancedMesh
  97652. */
  97653. createInstance(name: string): InstancedMesh;
  97654. /**
  97655. * Is this node ready to be used/rendered
  97656. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97657. * @return {boolean} is it ready
  97658. */
  97659. isReady(completeCheck?: boolean): boolean;
  97660. /**
  97661. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97662. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97663. * @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.
  97664. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97665. */
  97666. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97667. /**
  97668. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97669. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97670. * The `data` are either a numeric array either a Float32Array.
  97671. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97672. * 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).
  97673. * Note that a new underlying VertexBuffer object is created each call.
  97674. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97675. *
  97676. * Possible `kind` values :
  97677. * - VertexBuffer.PositionKind
  97678. * - VertexBuffer.UVKind
  97679. * - VertexBuffer.UV2Kind
  97680. * - VertexBuffer.UV3Kind
  97681. * - VertexBuffer.UV4Kind
  97682. * - VertexBuffer.UV5Kind
  97683. * - VertexBuffer.UV6Kind
  97684. * - VertexBuffer.ColorKind
  97685. * - VertexBuffer.MatricesIndicesKind
  97686. * - VertexBuffer.MatricesIndicesExtraKind
  97687. * - VertexBuffer.MatricesWeightsKind
  97688. * - VertexBuffer.MatricesWeightsExtraKind
  97689. *
  97690. * Returns the Mesh.
  97691. */
  97692. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97693. /**
  97694. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97695. * If the mesh has no geometry, it is simply returned as it is.
  97696. * The `data` are either a numeric array either a Float32Array.
  97697. * No new underlying VertexBuffer object is created.
  97698. * 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.
  97699. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97700. *
  97701. * Possible `kind` values :
  97702. * - VertexBuffer.PositionKind
  97703. * - VertexBuffer.UVKind
  97704. * - VertexBuffer.UV2Kind
  97705. * - VertexBuffer.UV3Kind
  97706. * - VertexBuffer.UV4Kind
  97707. * - VertexBuffer.UV5Kind
  97708. * - VertexBuffer.UV6Kind
  97709. * - VertexBuffer.ColorKind
  97710. * - VertexBuffer.MatricesIndicesKind
  97711. * - VertexBuffer.MatricesIndicesExtraKind
  97712. * - VertexBuffer.MatricesWeightsKind
  97713. * - VertexBuffer.MatricesWeightsExtraKind
  97714. *
  97715. * Returns the Mesh.
  97716. */
  97717. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97718. /**
  97719. * Sets the mesh indices.
  97720. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97721. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97722. * This method creates a new index buffer each call.
  97723. * Returns the Mesh.
  97724. */
  97725. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97726. /**
  97727. * Boolean : True if the mesh owns the requested kind of data.
  97728. */
  97729. isVerticesDataPresent(kind: string): boolean;
  97730. /**
  97731. * Returns an array of indices (IndicesArray).
  97732. */
  97733. getIndices(): Nullable<IndicesArray>;
  97734. get _positions(): Nullable<Vector3[]>;
  97735. /**
  97736. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97737. * This means the mesh underlying bounding box and sphere are recomputed.
  97738. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97739. * @returns the current mesh
  97740. */
  97741. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97742. /** @hidden */
  97743. _preActivate(): InstancedMesh;
  97744. /** @hidden */
  97745. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97746. /** @hidden */
  97747. _postActivate(): void;
  97748. getWorldMatrix(): Matrix;
  97749. get isAnInstance(): boolean;
  97750. /**
  97751. * Returns the current associated LOD AbstractMesh.
  97752. */
  97753. getLOD(camera: Camera): AbstractMesh;
  97754. /** @hidden */
  97755. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97756. /** @hidden */
  97757. _syncSubMeshes(): InstancedMesh;
  97758. /** @hidden */
  97759. _generatePointsArray(): boolean;
  97760. /** @hidden */
  97761. _updateBoundingInfo(): AbstractMesh;
  97762. /**
  97763. * Creates a new InstancedMesh from the current mesh.
  97764. * - name (string) : the cloned mesh name
  97765. * - newParent (optional Node) : the optional Node to parent the clone to.
  97766. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97767. *
  97768. * Returns the clone.
  97769. */
  97770. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97771. /**
  97772. * Disposes the InstancedMesh.
  97773. * Returns nothing.
  97774. */
  97775. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97776. }
  97777. interface Mesh {
  97778. /**
  97779. * Register a custom buffer that will be instanced
  97780. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97781. * @param kind defines the buffer kind
  97782. * @param stride defines the stride in floats
  97783. */
  97784. registerInstancedBuffer(kind: string, stride: number): void;
  97785. /**
  97786. * true to use the edge renderer for all instances of this mesh
  97787. */
  97788. edgesShareWithInstances: boolean;
  97789. /** @hidden */
  97790. _userInstancedBuffersStorage: {
  97791. data: {
  97792. [key: string]: Float32Array;
  97793. };
  97794. sizes: {
  97795. [key: string]: number;
  97796. };
  97797. vertexBuffers: {
  97798. [key: string]: Nullable<VertexBuffer>;
  97799. };
  97800. strides: {
  97801. [key: string]: number;
  97802. };
  97803. };
  97804. }
  97805. interface AbstractMesh {
  97806. /**
  97807. * Object used to store instanced buffers defined by user
  97808. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97809. */
  97810. instancedBuffers: {
  97811. [key: string]: any;
  97812. };
  97813. }
  97814. }
  97815. declare module BABYLON {
  97816. /**
  97817. * Defines the options associated with the creation of a shader material.
  97818. */
  97819. export interface IShaderMaterialOptions {
  97820. /**
  97821. * Does the material work in alpha blend mode
  97822. */
  97823. needAlphaBlending: boolean;
  97824. /**
  97825. * Does the material work in alpha test mode
  97826. */
  97827. needAlphaTesting: boolean;
  97828. /**
  97829. * The list of attribute names used in the shader
  97830. */
  97831. attributes: string[];
  97832. /**
  97833. * The list of unifrom names used in the shader
  97834. */
  97835. uniforms: string[];
  97836. /**
  97837. * The list of UBO names used in the shader
  97838. */
  97839. uniformBuffers: string[];
  97840. /**
  97841. * The list of sampler names used in the shader
  97842. */
  97843. samplers: string[];
  97844. /**
  97845. * The list of defines used in the shader
  97846. */
  97847. defines: string[];
  97848. }
  97849. /**
  97850. * 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.
  97851. *
  97852. * This returned material effects how the mesh will look based on the code in the shaders.
  97853. *
  97854. * @see https://doc.babylonjs.com/how_to/shader_material
  97855. */
  97856. export class ShaderMaterial extends Material {
  97857. private _shaderPath;
  97858. private _options;
  97859. private _textures;
  97860. private _textureArrays;
  97861. private _floats;
  97862. private _ints;
  97863. private _floatsArrays;
  97864. private _colors3;
  97865. private _colors3Arrays;
  97866. private _colors4;
  97867. private _colors4Arrays;
  97868. private _vectors2;
  97869. private _vectors3;
  97870. private _vectors4;
  97871. private _matrices;
  97872. private _matrixArrays;
  97873. private _matrices3x3;
  97874. private _matrices2x2;
  97875. private _vectors2Arrays;
  97876. private _vectors3Arrays;
  97877. private _vectors4Arrays;
  97878. private _cachedWorldViewMatrix;
  97879. private _cachedWorldViewProjectionMatrix;
  97880. private _renderId;
  97881. private _multiview;
  97882. private _cachedDefines;
  97883. /** Define the Url to load snippets */
  97884. static SnippetUrl: string;
  97885. /** Snippet ID if the material was created from the snippet server */
  97886. snippetId: string;
  97887. /**
  97888. * Instantiate a new shader material.
  97889. * 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.
  97890. * This returned material effects how the mesh will look based on the code in the shaders.
  97891. * @see https://doc.babylonjs.com/how_to/shader_material
  97892. * @param name Define the name of the material in the scene
  97893. * @param scene Define the scene the material belongs to
  97894. * @param shaderPath Defines the route to the shader code in one of three ways:
  97895. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97896. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97897. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97898. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97899. * @param options Define the options used to create the shader
  97900. */
  97901. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97902. /**
  97903. * Gets the shader path used to define the shader code
  97904. * It can be modified to trigger a new compilation
  97905. */
  97906. get shaderPath(): any;
  97907. /**
  97908. * Sets the shader path used to define the shader code
  97909. * It can be modified to trigger a new compilation
  97910. */
  97911. set shaderPath(shaderPath: any);
  97912. /**
  97913. * Gets the options used to compile the shader.
  97914. * They can be modified to trigger a new compilation
  97915. */
  97916. get options(): IShaderMaterialOptions;
  97917. /**
  97918. * Gets the current class name of the material e.g. "ShaderMaterial"
  97919. * Mainly use in serialization.
  97920. * @returns the class name
  97921. */
  97922. getClassName(): string;
  97923. /**
  97924. * Specifies if the material will require alpha blending
  97925. * @returns a boolean specifying if alpha blending is needed
  97926. */
  97927. needAlphaBlending(): boolean;
  97928. /**
  97929. * Specifies if this material should be rendered in alpha test mode
  97930. * @returns a boolean specifying if an alpha test is needed.
  97931. */
  97932. needAlphaTesting(): boolean;
  97933. private _checkUniform;
  97934. /**
  97935. * Set a texture in the shader.
  97936. * @param name Define the name of the uniform samplers as defined in the shader
  97937. * @param texture Define the texture to bind to this sampler
  97938. * @return the material itself allowing "fluent" like uniform updates
  97939. */
  97940. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97941. /**
  97942. * Set a texture array in the shader.
  97943. * @param name Define the name of the uniform sampler array as defined in the shader
  97944. * @param textures Define the list of textures to bind to this sampler
  97945. * @return the material itself allowing "fluent" like uniform updates
  97946. */
  97947. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97948. /**
  97949. * Set a float in the shader.
  97950. * @param name Define the name of the uniform as defined in the shader
  97951. * @param value Define the value to give to the uniform
  97952. * @return the material itself allowing "fluent" like uniform updates
  97953. */
  97954. setFloat(name: string, value: number): ShaderMaterial;
  97955. /**
  97956. * Set a int in the shader.
  97957. * @param name Define the name of the uniform as defined in the shader
  97958. * @param value Define the value to give to the uniform
  97959. * @return the material itself allowing "fluent" like uniform updates
  97960. */
  97961. setInt(name: string, value: number): ShaderMaterial;
  97962. /**
  97963. * Set an array of floats in the shader.
  97964. * @param name Define the name of the uniform as defined in the shader
  97965. * @param value Define the value to give to the uniform
  97966. * @return the material itself allowing "fluent" like uniform updates
  97967. */
  97968. setFloats(name: string, value: number[]): ShaderMaterial;
  97969. /**
  97970. * Set a vec3 in the shader from a Color3.
  97971. * @param name Define the name of the uniform as defined in the shader
  97972. * @param value Define the value to give to the uniform
  97973. * @return the material itself allowing "fluent" like uniform updates
  97974. */
  97975. setColor3(name: string, value: Color3): ShaderMaterial;
  97976. /**
  97977. * Set a vec3 array in the shader from a Color3 array.
  97978. * @param name Define the name of the uniform as defined in the shader
  97979. * @param value Define the value to give to the uniform
  97980. * @return the material itself allowing "fluent" like uniform updates
  97981. */
  97982. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97983. /**
  97984. * Set a vec4 in the shader from a Color4.
  97985. * @param name Define the name of the uniform as defined in the shader
  97986. * @param value Define the value to give to the uniform
  97987. * @return the material itself allowing "fluent" like uniform updates
  97988. */
  97989. setColor4(name: string, value: Color4): ShaderMaterial;
  97990. /**
  97991. * Set a vec4 array in the shader from a Color4 array.
  97992. * @param name Define the name of the uniform as defined in the shader
  97993. * @param value Define the value to give to the uniform
  97994. * @return the material itself allowing "fluent" like uniform updates
  97995. */
  97996. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97997. /**
  97998. * Set a vec2 in the shader from a Vector2.
  97999. * @param name Define the name of the uniform as defined in the shader
  98000. * @param value Define the value to give to the uniform
  98001. * @return the material itself allowing "fluent" like uniform updates
  98002. */
  98003. setVector2(name: string, value: Vector2): ShaderMaterial;
  98004. /**
  98005. * Set a vec3 in the shader from a Vector3.
  98006. * @param name Define the name of the uniform as defined in the shader
  98007. * @param value Define the value to give to the uniform
  98008. * @return the material itself allowing "fluent" like uniform updates
  98009. */
  98010. setVector3(name: string, value: Vector3): ShaderMaterial;
  98011. /**
  98012. * Set a vec4 in the shader from a Vector4.
  98013. * @param name Define the name of the uniform as defined in the shader
  98014. * @param value Define the value to give to the uniform
  98015. * @return the material itself allowing "fluent" like uniform updates
  98016. */
  98017. setVector4(name: string, value: Vector4): ShaderMaterial;
  98018. /**
  98019. * Set a mat4 in the shader from a Matrix.
  98020. * @param name Define the name of the uniform as defined in the shader
  98021. * @param value Define the value to give to the uniform
  98022. * @return the material itself allowing "fluent" like uniform updates
  98023. */
  98024. setMatrix(name: string, value: Matrix): ShaderMaterial;
  98025. /**
  98026. * Set a float32Array in the shader from a matrix array.
  98027. * @param name Define the name of the uniform as defined in the shader
  98028. * @param value Define the value to give to the uniform
  98029. * @return the material itself allowing "fluent" like uniform updates
  98030. */
  98031. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  98032. /**
  98033. * Set a mat3 in the shader from a Float32Array.
  98034. * @param name Define the name of the uniform as defined in the shader
  98035. * @param value Define the value to give to the uniform
  98036. * @return the material itself allowing "fluent" like uniform updates
  98037. */
  98038. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  98039. /**
  98040. * Set a mat2 in the shader from a Float32Array.
  98041. * @param name Define the name of the uniform as defined in the shader
  98042. * @param value Define the value to give to the uniform
  98043. * @return the material itself allowing "fluent" like uniform updates
  98044. */
  98045. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  98046. /**
  98047. * Set a vec2 array in the shader from a number array.
  98048. * @param name Define the name of the uniform as defined in the shader
  98049. * @param value Define the value to give to the uniform
  98050. * @return the material itself allowing "fluent" like uniform updates
  98051. */
  98052. setArray2(name: string, value: number[]): ShaderMaterial;
  98053. /**
  98054. * Set a vec3 array in the shader from a number array.
  98055. * @param name Define the name of the uniform as defined in the shader
  98056. * @param value Define the value to give to the uniform
  98057. * @return the material itself allowing "fluent" like uniform updates
  98058. */
  98059. setArray3(name: string, value: number[]): ShaderMaterial;
  98060. /**
  98061. * Set a vec4 array in the shader from a number array.
  98062. * @param name Define the name of the uniform as defined in the shader
  98063. * @param value Define the value to give to the uniform
  98064. * @return the material itself allowing "fluent" like uniform updates
  98065. */
  98066. setArray4(name: string, value: number[]): ShaderMaterial;
  98067. private _checkCache;
  98068. /**
  98069. * Specifies that the submesh is ready to be used
  98070. * @param mesh defines the mesh to check
  98071. * @param subMesh defines which submesh to check
  98072. * @param useInstances specifies that instances should be used
  98073. * @returns a boolean indicating that the submesh is ready or not
  98074. */
  98075. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98076. /**
  98077. * Checks if the material is ready to render the requested mesh
  98078. * @param mesh Define the mesh to render
  98079. * @param useInstances Define whether or not the material is used with instances
  98080. * @returns true if ready, otherwise false
  98081. */
  98082. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98083. /**
  98084. * Binds the world matrix to the material
  98085. * @param world defines the world transformation matrix
  98086. * @param effectOverride - If provided, use this effect instead of internal effect
  98087. */
  98088. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  98089. /**
  98090. * Binds the submesh to this material by preparing the effect and shader to draw
  98091. * @param world defines the world transformation matrix
  98092. * @param mesh defines the mesh containing the submesh
  98093. * @param subMesh defines the submesh to bind the material to
  98094. */
  98095. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98096. /**
  98097. * Binds the material to the mesh
  98098. * @param world defines the world transformation matrix
  98099. * @param mesh defines the mesh to bind the material to
  98100. * @param effectOverride - If provided, use this effect instead of internal effect
  98101. */
  98102. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  98103. protected _afterBind(mesh?: Mesh): void;
  98104. /**
  98105. * Gets the active textures from the material
  98106. * @returns an array of textures
  98107. */
  98108. getActiveTextures(): BaseTexture[];
  98109. /**
  98110. * Specifies if the material uses a texture
  98111. * @param texture defines the texture to check against the material
  98112. * @returns a boolean specifying if the material uses the texture
  98113. */
  98114. hasTexture(texture: BaseTexture): boolean;
  98115. /**
  98116. * Makes a duplicate of the material, and gives it a new name
  98117. * @param name defines the new name for the duplicated material
  98118. * @returns the cloned material
  98119. */
  98120. clone(name: string): ShaderMaterial;
  98121. /**
  98122. * Disposes the material
  98123. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98124. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98125. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  98126. */
  98127. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  98128. /**
  98129. * Serializes this material in a JSON representation
  98130. * @returns the serialized material object
  98131. */
  98132. serialize(): any;
  98133. /**
  98134. * Creates a shader material from parsed shader material data
  98135. * @param source defines the JSON represnetation of the material
  98136. * @param scene defines the hosting scene
  98137. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98138. * @returns a new material
  98139. */
  98140. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  98141. /**
  98142. * Creates a new ShaderMaterial from a snippet saved in a remote file
  98143. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  98144. * @param url defines the url to load from
  98145. * @param scene defines the hosting scene
  98146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98147. * @returns a promise that will resolve to the new ShaderMaterial
  98148. */
  98149. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98150. /**
  98151. * Creates a ShaderMaterial from a snippet saved by the Inspector
  98152. * @param snippetId defines the snippet to load
  98153. * @param scene defines the hosting scene
  98154. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98155. * @returns a promise that will resolve to the new ShaderMaterial
  98156. */
  98157. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98158. }
  98159. }
  98160. declare module BABYLON {
  98161. /** @hidden */
  98162. export var colorPixelShader: {
  98163. name: string;
  98164. shader: string;
  98165. };
  98166. }
  98167. declare module BABYLON {
  98168. /** @hidden */
  98169. export var colorVertexShader: {
  98170. name: string;
  98171. shader: string;
  98172. };
  98173. }
  98174. declare module BABYLON {
  98175. /**
  98176. * Line mesh
  98177. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  98178. */
  98179. export class LinesMesh extends Mesh {
  98180. /**
  98181. * If vertex color should be applied to the mesh
  98182. */
  98183. readonly useVertexColor?: boolean | undefined;
  98184. /**
  98185. * If vertex alpha should be applied to the mesh
  98186. */
  98187. readonly useVertexAlpha?: boolean | undefined;
  98188. /**
  98189. * Color of the line (Default: White)
  98190. */
  98191. color: Color3;
  98192. /**
  98193. * Alpha of the line (Default: 1)
  98194. */
  98195. alpha: number;
  98196. /**
  98197. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98198. * This margin is expressed in world space coordinates, so its value may vary.
  98199. * Default value is 0.1
  98200. */
  98201. intersectionThreshold: number;
  98202. private _colorShader;
  98203. private color4;
  98204. /**
  98205. * Creates a new LinesMesh
  98206. * @param name defines the name
  98207. * @param scene defines the hosting scene
  98208. * @param parent defines the parent mesh if any
  98209. * @param source defines the optional source LinesMesh used to clone data from
  98210. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98211. * When false, achieved by calling a clone(), also passing False.
  98212. * This will make creation of children, recursive.
  98213. * @param useVertexColor defines if this LinesMesh supports vertex color
  98214. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  98215. */
  98216. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  98217. /**
  98218. * If vertex color should be applied to the mesh
  98219. */
  98220. useVertexColor?: boolean | undefined,
  98221. /**
  98222. * If vertex alpha should be applied to the mesh
  98223. */
  98224. useVertexAlpha?: boolean | undefined);
  98225. private _addClipPlaneDefine;
  98226. private _removeClipPlaneDefine;
  98227. isReady(): boolean;
  98228. /**
  98229. * Returns the string "LineMesh"
  98230. */
  98231. getClassName(): string;
  98232. /**
  98233. * @hidden
  98234. */
  98235. get material(): Material;
  98236. /**
  98237. * @hidden
  98238. */
  98239. set material(value: Material);
  98240. /**
  98241. * @hidden
  98242. */
  98243. get checkCollisions(): boolean;
  98244. /** @hidden */
  98245. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98246. /** @hidden */
  98247. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98248. /**
  98249. * Disposes of the line mesh
  98250. * @param doNotRecurse If children should be disposed
  98251. */
  98252. dispose(doNotRecurse?: boolean): void;
  98253. /**
  98254. * Returns a new LineMesh object cloned from the current one.
  98255. */
  98256. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  98257. /**
  98258. * Creates a new InstancedLinesMesh object from the mesh model.
  98259. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  98260. * @param name defines the name of the new instance
  98261. * @returns a new InstancedLinesMesh
  98262. */
  98263. createInstance(name: string): InstancedLinesMesh;
  98264. }
  98265. /**
  98266. * Creates an instance based on a source LinesMesh
  98267. */
  98268. export class InstancedLinesMesh extends InstancedMesh {
  98269. /**
  98270. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98271. * This margin is expressed in world space coordinates, so its value may vary.
  98272. * Initilized with the intersectionThreshold value of the source LinesMesh
  98273. */
  98274. intersectionThreshold: number;
  98275. constructor(name: string, source: LinesMesh);
  98276. /**
  98277. * Returns the string "InstancedLinesMesh".
  98278. */
  98279. getClassName(): string;
  98280. }
  98281. }
  98282. declare module BABYLON {
  98283. /** @hidden */
  98284. export var linePixelShader: {
  98285. name: string;
  98286. shader: string;
  98287. };
  98288. }
  98289. declare module BABYLON {
  98290. /** @hidden */
  98291. export var lineVertexShader: {
  98292. name: string;
  98293. shader: string;
  98294. };
  98295. }
  98296. declare module BABYLON {
  98297. interface Scene {
  98298. /** @hidden */
  98299. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  98300. }
  98301. interface AbstractMesh {
  98302. /**
  98303. * Gets the edgesRenderer associated with the mesh
  98304. */
  98305. edgesRenderer: Nullable<EdgesRenderer>;
  98306. }
  98307. interface LinesMesh {
  98308. /**
  98309. * Enables the edge rendering mode on the mesh.
  98310. * This mode makes the mesh edges visible
  98311. * @param epsilon defines the maximal distance between two angles to detect a face
  98312. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98313. * @returns the currentAbstractMesh
  98314. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98315. */
  98316. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98317. }
  98318. interface InstancedLinesMesh {
  98319. /**
  98320. * Enables the edge rendering mode on the mesh.
  98321. * This mode makes the mesh edges visible
  98322. * @param epsilon defines the maximal distance between two angles to detect a face
  98323. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98324. * @returns the current InstancedLinesMesh
  98325. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98326. */
  98327. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  98328. }
  98329. /**
  98330. * Defines the minimum contract an Edges renderer should follow.
  98331. */
  98332. export interface IEdgesRenderer extends IDisposable {
  98333. /**
  98334. * Gets or sets a boolean indicating if the edgesRenderer is active
  98335. */
  98336. isEnabled: boolean;
  98337. /**
  98338. * Renders the edges of the attached mesh,
  98339. */
  98340. render(): void;
  98341. /**
  98342. * Checks wether or not the edges renderer is ready to render.
  98343. * @return true if ready, otherwise false.
  98344. */
  98345. isReady(): boolean;
  98346. /**
  98347. * List of instances to render in case the source mesh has instances
  98348. */
  98349. customInstances: SmartArray<Matrix>;
  98350. }
  98351. /**
  98352. * Defines the additional options of the edges renderer
  98353. */
  98354. export interface IEdgesRendererOptions {
  98355. /**
  98356. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  98357. * If not defined, the default value is true
  98358. */
  98359. useAlternateEdgeFinder?: boolean;
  98360. /**
  98361. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  98362. * If not defined, the default value is true.
  98363. * 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)
  98364. * This option is used only if useAlternateEdgeFinder = true
  98365. */
  98366. useFastVertexMerger?: boolean;
  98367. /**
  98368. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  98369. * The default value is 1e-6
  98370. * This option is used only if useAlternateEdgeFinder = true
  98371. */
  98372. epsilonVertexMerge?: number;
  98373. /**
  98374. * 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
  98375. * 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.
  98376. * This option is used only if useAlternateEdgeFinder = true
  98377. */
  98378. applyTessellation?: boolean;
  98379. /**
  98380. * 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
  98381. * The default value is 1e-6
  98382. * This option is used only if useAlternateEdgeFinder = true
  98383. */
  98384. epsilonVertexAligned?: number;
  98385. }
  98386. /**
  98387. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  98388. */
  98389. export class EdgesRenderer implements IEdgesRenderer {
  98390. /**
  98391. * Define the size of the edges with an orthographic camera
  98392. */
  98393. edgesWidthScalerForOrthographic: number;
  98394. /**
  98395. * Define the size of the edges with a perspective camera
  98396. */
  98397. edgesWidthScalerForPerspective: number;
  98398. protected _source: AbstractMesh;
  98399. protected _linesPositions: number[];
  98400. protected _linesNormals: number[];
  98401. protected _linesIndices: number[];
  98402. protected _epsilon: number;
  98403. protected _indicesCount: number;
  98404. protected _lineShader: ShaderMaterial;
  98405. protected _ib: DataBuffer;
  98406. protected _buffers: {
  98407. [key: string]: Nullable<VertexBuffer>;
  98408. };
  98409. protected _buffersForInstances: {
  98410. [key: string]: Nullable<VertexBuffer>;
  98411. };
  98412. protected _checkVerticesInsteadOfIndices: boolean;
  98413. protected _options: Nullable<IEdgesRendererOptions>;
  98414. private _meshRebuildObserver;
  98415. private _meshDisposeObserver;
  98416. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  98417. isEnabled: boolean;
  98418. /**
  98419. * List of instances to render in case the source mesh has instances
  98420. */
  98421. customInstances: SmartArray<Matrix>;
  98422. private static GetShader;
  98423. /**
  98424. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  98425. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  98426. * @param source Mesh used to create edges
  98427. * @param epsilon sum of angles in adjacency to check for edge
  98428. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  98429. * @param generateEdgesLines - should generate Lines or only prepare resources.
  98430. * @param options The options to apply when generating the edges
  98431. */
  98432. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  98433. protected _prepareRessources(): void;
  98434. /** @hidden */
  98435. _rebuild(): void;
  98436. /**
  98437. * Releases the required resources for the edges renderer
  98438. */
  98439. dispose(): void;
  98440. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  98441. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  98442. /**
  98443. * Checks if the pair of p0 and p1 is en edge
  98444. * @param faceIndex
  98445. * @param edge
  98446. * @param faceNormals
  98447. * @param p0
  98448. * @param p1
  98449. * @private
  98450. */
  98451. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  98452. /**
  98453. * push line into the position, normal and index buffer
  98454. * @protected
  98455. */
  98456. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  98457. /**
  98458. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  98459. */
  98460. private _tessellateTriangle;
  98461. private _generateEdgesLinesAlternate;
  98462. /**
  98463. * Generates lines edges from adjacencjes
  98464. * @private
  98465. */
  98466. _generateEdgesLines(): void;
  98467. /**
  98468. * Checks wether or not the edges renderer is ready to render.
  98469. * @return true if ready, otherwise false.
  98470. */
  98471. isReady(): boolean;
  98472. /**
  98473. * Renders the edges of the attached mesh,
  98474. */
  98475. render(): void;
  98476. }
  98477. /**
  98478. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  98479. */
  98480. export class LineEdgesRenderer extends EdgesRenderer {
  98481. /**
  98482. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98483. * @param source LineMesh used to generate edges
  98484. * @param epsilon not important (specified angle for edge detection)
  98485. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98486. */
  98487. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98488. /**
  98489. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98490. */
  98491. _generateEdgesLines(): void;
  98492. }
  98493. }
  98494. declare module BABYLON {
  98495. /**
  98496. * This represents the object necessary to create a rendering group.
  98497. * This is exclusively used and created by the rendering manager.
  98498. * To modify the behavior, you use the available helpers in your scene or meshes.
  98499. * @hidden
  98500. */
  98501. export class RenderingGroup {
  98502. index: number;
  98503. private static _zeroVector;
  98504. private _scene;
  98505. private _opaqueSubMeshes;
  98506. private _transparentSubMeshes;
  98507. private _alphaTestSubMeshes;
  98508. private _depthOnlySubMeshes;
  98509. private _particleSystems;
  98510. private _spriteManagers;
  98511. private _opaqueSortCompareFn;
  98512. private _alphaTestSortCompareFn;
  98513. private _transparentSortCompareFn;
  98514. private _renderOpaque;
  98515. private _renderAlphaTest;
  98516. private _renderTransparent;
  98517. /** @hidden */
  98518. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98519. onBeforeTransparentRendering: () => void;
  98520. /**
  98521. * Set the opaque sort comparison function.
  98522. * If null the sub meshes will be render in the order they were created
  98523. */
  98524. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98525. /**
  98526. * Set the alpha test sort comparison function.
  98527. * If null the sub meshes will be render in the order they were created
  98528. */
  98529. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98530. /**
  98531. * Set the transparent sort comparison function.
  98532. * If null the sub meshes will be render in the order they were created
  98533. */
  98534. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98535. /**
  98536. * Creates a new rendering group.
  98537. * @param index The rendering group index
  98538. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98539. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98540. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98541. */
  98542. 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>);
  98543. /**
  98544. * Render all the sub meshes contained in the group.
  98545. * @param customRenderFunction Used to override the default render behaviour of the group.
  98546. * @returns true if rendered some submeshes.
  98547. */
  98548. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98549. /**
  98550. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98551. * @param subMeshes The submeshes to render
  98552. */
  98553. private renderOpaqueSorted;
  98554. /**
  98555. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98556. * @param subMeshes The submeshes to render
  98557. */
  98558. private renderAlphaTestSorted;
  98559. /**
  98560. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98561. * @param subMeshes The submeshes to render
  98562. */
  98563. private renderTransparentSorted;
  98564. /**
  98565. * Renders the submeshes in a specified order.
  98566. * @param subMeshes The submeshes to sort before render
  98567. * @param sortCompareFn The comparison function use to sort
  98568. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98569. * @param transparent Specifies to activate blending if true
  98570. */
  98571. private static renderSorted;
  98572. /**
  98573. * Renders the submeshes in the order they were dispatched (no sort applied).
  98574. * @param subMeshes The submeshes to render
  98575. */
  98576. private static renderUnsorted;
  98577. /**
  98578. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98579. * are rendered back to front if in the same alpha index.
  98580. *
  98581. * @param a The first submesh
  98582. * @param b The second submesh
  98583. * @returns The result of the comparison
  98584. */
  98585. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98586. /**
  98587. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98588. * are rendered back to front.
  98589. *
  98590. * @param a The first submesh
  98591. * @param b The second submesh
  98592. * @returns The result of the comparison
  98593. */
  98594. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98595. /**
  98596. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98597. * are rendered front to back (prevent overdraw).
  98598. *
  98599. * @param a The first submesh
  98600. * @param b The second submesh
  98601. * @returns The result of the comparison
  98602. */
  98603. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98604. /**
  98605. * Resets the different lists of submeshes to prepare a new frame.
  98606. */
  98607. prepare(): void;
  98608. dispose(): void;
  98609. /**
  98610. * Inserts the submesh in its correct queue depending on its material.
  98611. * @param subMesh The submesh to dispatch
  98612. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98613. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98614. */
  98615. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98616. dispatchSprites(spriteManager: ISpriteManager): void;
  98617. dispatchParticles(particleSystem: IParticleSystem): void;
  98618. private _renderParticles;
  98619. private _renderSprites;
  98620. }
  98621. }
  98622. declare module BABYLON {
  98623. /**
  98624. * Interface describing the different options available in the rendering manager
  98625. * regarding Auto Clear between groups.
  98626. */
  98627. export interface IRenderingManagerAutoClearSetup {
  98628. /**
  98629. * Defines whether or not autoclear is enable.
  98630. */
  98631. autoClear: boolean;
  98632. /**
  98633. * Defines whether or not to autoclear the depth buffer.
  98634. */
  98635. depth: boolean;
  98636. /**
  98637. * Defines whether or not to autoclear the stencil buffer.
  98638. */
  98639. stencil: boolean;
  98640. }
  98641. /**
  98642. * This class is used by the onRenderingGroupObservable
  98643. */
  98644. export class RenderingGroupInfo {
  98645. /**
  98646. * The Scene that being rendered
  98647. */
  98648. scene: Scene;
  98649. /**
  98650. * The camera currently used for the rendering pass
  98651. */
  98652. camera: Nullable<Camera>;
  98653. /**
  98654. * The ID of the renderingGroup being processed
  98655. */
  98656. renderingGroupId: number;
  98657. }
  98658. /**
  98659. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98660. * It is enable to manage the different groups as well as the different necessary sort functions.
  98661. * This should not be used directly aside of the few static configurations
  98662. */
  98663. export class RenderingManager {
  98664. /**
  98665. * The max id used for rendering groups (not included)
  98666. */
  98667. static MAX_RENDERINGGROUPS: number;
  98668. /**
  98669. * The min id used for rendering groups (included)
  98670. */
  98671. static MIN_RENDERINGGROUPS: number;
  98672. /**
  98673. * Used to globally prevent autoclearing scenes.
  98674. */
  98675. static AUTOCLEAR: boolean;
  98676. /**
  98677. * @hidden
  98678. */
  98679. _useSceneAutoClearSetup: boolean;
  98680. private _scene;
  98681. private _renderingGroups;
  98682. private _depthStencilBufferAlreadyCleaned;
  98683. private _autoClearDepthStencil;
  98684. private _customOpaqueSortCompareFn;
  98685. private _customAlphaTestSortCompareFn;
  98686. private _customTransparentSortCompareFn;
  98687. private _renderingGroupInfo;
  98688. /**
  98689. * Instantiates a new rendering group for a particular scene
  98690. * @param scene Defines the scene the groups belongs to
  98691. */
  98692. constructor(scene: Scene);
  98693. private _clearDepthStencilBuffer;
  98694. /**
  98695. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98696. * @hidden
  98697. */
  98698. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98699. /**
  98700. * Resets the different information of the group to prepare a new frame
  98701. * @hidden
  98702. */
  98703. reset(): void;
  98704. /**
  98705. * Dispose and release the group and its associated resources.
  98706. * @hidden
  98707. */
  98708. dispose(): void;
  98709. /**
  98710. * Clear the info related to rendering groups preventing retention points during dispose.
  98711. */
  98712. freeRenderingGroups(): void;
  98713. private _prepareRenderingGroup;
  98714. /**
  98715. * Add a sprite manager to the rendering manager in order to render it this frame.
  98716. * @param spriteManager Define the sprite manager to render
  98717. */
  98718. dispatchSprites(spriteManager: ISpriteManager): void;
  98719. /**
  98720. * Add a particle system to the rendering manager in order to render it this frame.
  98721. * @param particleSystem Define the particle system to render
  98722. */
  98723. dispatchParticles(particleSystem: IParticleSystem): void;
  98724. /**
  98725. * Add a submesh to the manager in order to render it this frame
  98726. * @param subMesh The submesh to dispatch
  98727. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98728. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98729. */
  98730. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98731. /**
  98732. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98733. * This allowed control for front to back rendering or reversly depending of the special needs.
  98734. *
  98735. * @param renderingGroupId The rendering group id corresponding to its index
  98736. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98737. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98738. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98739. */
  98740. 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;
  98741. /**
  98742. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98743. *
  98744. * @param renderingGroupId The rendering group id corresponding to its index
  98745. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98746. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98747. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98748. */
  98749. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98750. /**
  98751. * Gets the current auto clear configuration for one rendering group of the rendering
  98752. * manager.
  98753. * @param index the rendering group index to get the information for
  98754. * @returns The auto clear setup for the requested rendering group
  98755. */
  98756. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98757. }
  98758. }
  98759. declare module BABYLON {
  98760. /**
  98761. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98762. */
  98763. export interface ICustomShaderOptions {
  98764. /**
  98765. * Gets or sets the custom shader name to use
  98766. */
  98767. shaderName: string;
  98768. /**
  98769. * The list of attribute names used in the shader
  98770. */
  98771. attributes?: string[];
  98772. /**
  98773. * The list of unifrom names used in the shader
  98774. */
  98775. uniforms?: string[];
  98776. /**
  98777. * The list of sampler names used in the shader
  98778. */
  98779. samplers?: string[];
  98780. /**
  98781. * The list of defines used in the shader
  98782. */
  98783. defines?: string[];
  98784. }
  98785. /**
  98786. * Interface to implement to create a shadow generator compatible with BJS.
  98787. */
  98788. export interface IShadowGenerator {
  98789. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98790. id: string;
  98791. /**
  98792. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98793. * @returns The render target texture if present otherwise, null
  98794. */
  98795. getShadowMap(): Nullable<RenderTargetTexture>;
  98796. /**
  98797. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98798. * @param subMesh The submesh we want to render in the shadow map
  98799. * @param useInstances Defines wether will draw in the map using instances
  98800. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98801. * @returns true if ready otherwise, false
  98802. */
  98803. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98804. /**
  98805. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98806. * @param defines Defines of the material we want to update
  98807. * @param lightIndex Index of the light in the enabled light list of the material
  98808. */
  98809. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98810. /**
  98811. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98812. * defined in the generator but impacting the effect).
  98813. * It implies the unifroms available on the materials are the standard BJS ones.
  98814. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98815. * @param effect The effect we are binfing the information for
  98816. */
  98817. bindShadowLight(lightIndex: string, effect: Effect): void;
  98818. /**
  98819. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98820. * (eq to shadow prjection matrix * light transform matrix)
  98821. * @returns The transform matrix used to create the shadow map
  98822. */
  98823. getTransformMatrix(): Matrix;
  98824. /**
  98825. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98826. * Cube and 2D textures for instance.
  98827. */
  98828. recreateShadowMap(): void;
  98829. /**
  98830. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98831. * @param onCompiled Callback triggered at the and of the effects compilation
  98832. * @param options Sets of optional options forcing the compilation with different modes
  98833. */
  98834. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98835. useInstances: boolean;
  98836. }>): void;
  98837. /**
  98838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98839. * @param options Sets of optional options forcing the compilation with different modes
  98840. * @returns A promise that resolves when the compilation completes
  98841. */
  98842. forceCompilationAsync(options?: Partial<{
  98843. useInstances: boolean;
  98844. }>): Promise<void>;
  98845. /**
  98846. * Serializes the shadow generator setup to a json object.
  98847. * @returns The serialized JSON object
  98848. */
  98849. serialize(): any;
  98850. /**
  98851. * Disposes the Shadow map and related Textures and effects.
  98852. */
  98853. dispose(): void;
  98854. }
  98855. /**
  98856. * Default implementation IShadowGenerator.
  98857. * This is the main object responsible of generating shadows in the framework.
  98858. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98859. */
  98860. export class ShadowGenerator implements IShadowGenerator {
  98861. /**
  98862. * Name of the shadow generator class
  98863. */
  98864. static CLASSNAME: string;
  98865. /**
  98866. * Shadow generator mode None: no filtering applied.
  98867. */
  98868. static readonly FILTER_NONE: number;
  98869. /**
  98870. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98871. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98872. */
  98873. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98874. /**
  98875. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98876. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98877. */
  98878. static readonly FILTER_POISSONSAMPLING: number;
  98879. /**
  98880. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98881. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98882. */
  98883. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98884. /**
  98885. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98886. * edge artifacts on steep falloff.
  98887. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98888. */
  98889. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98890. /**
  98891. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98892. * edge artifacts on steep falloff.
  98893. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98894. */
  98895. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98896. /**
  98897. * Shadow generator mode PCF: Percentage Closer Filtering
  98898. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98899. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98900. */
  98901. static readonly FILTER_PCF: number;
  98902. /**
  98903. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98904. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98905. * Contact Hardening
  98906. */
  98907. static readonly FILTER_PCSS: number;
  98908. /**
  98909. * Reserved for PCF and PCSS
  98910. * Highest Quality.
  98911. *
  98912. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98913. *
  98914. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98915. */
  98916. static readonly QUALITY_HIGH: number;
  98917. /**
  98918. * Reserved for PCF and PCSS
  98919. * Good tradeoff for quality/perf cross devices
  98920. *
  98921. * Execute PCF on a 3*3 kernel.
  98922. *
  98923. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98924. */
  98925. static readonly QUALITY_MEDIUM: number;
  98926. /**
  98927. * Reserved for PCF and PCSS
  98928. * The lowest quality but the fastest.
  98929. *
  98930. * Execute PCF on a 1*1 kernel.
  98931. *
  98932. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98933. */
  98934. static readonly QUALITY_LOW: number;
  98935. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98936. id: string;
  98937. /** Gets or sets the custom shader name to use */
  98938. customShaderOptions: ICustomShaderOptions;
  98939. /**
  98940. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98941. */
  98942. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98943. /**
  98944. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98945. */
  98946. onAfterShadowMapRenderObservable: Observable<Effect>;
  98947. /**
  98948. * Observable triggered before a mesh is rendered in the shadow map.
  98949. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98950. */
  98951. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98952. /**
  98953. * Observable triggered after a mesh is rendered in the shadow map.
  98954. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98955. */
  98956. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98957. protected _bias: number;
  98958. /**
  98959. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98960. */
  98961. get bias(): number;
  98962. /**
  98963. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98964. */
  98965. set bias(bias: number);
  98966. protected _normalBias: number;
  98967. /**
  98968. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98969. */
  98970. get normalBias(): number;
  98971. /**
  98972. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98973. */
  98974. set normalBias(normalBias: number);
  98975. protected _blurBoxOffset: number;
  98976. /**
  98977. * Gets the blur box offset: offset applied during the blur pass.
  98978. * Only useful if useKernelBlur = false
  98979. */
  98980. get blurBoxOffset(): number;
  98981. /**
  98982. * Sets the blur box offset: offset applied during the blur pass.
  98983. * Only useful if useKernelBlur = false
  98984. */
  98985. set blurBoxOffset(value: number);
  98986. protected _blurScale: number;
  98987. /**
  98988. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98989. * 2 means half of the size.
  98990. */
  98991. get blurScale(): number;
  98992. /**
  98993. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98994. * 2 means half of the size.
  98995. */
  98996. set blurScale(value: number);
  98997. protected _blurKernel: number;
  98998. /**
  98999. * Gets the blur kernel: kernel size of the blur pass.
  99000. * Only useful if useKernelBlur = true
  99001. */
  99002. get blurKernel(): number;
  99003. /**
  99004. * Sets the blur kernel: kernel size of the blur pass.
  99005. * Only useful if useKernelBlur = true
  99006. */
  99007. set blurKernel(value: number);
  99008. protected _useKernelBlur: boolean;
  99009. /**
  99010. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  99011. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  99012. */
  99013. get useKernelBlur(): boolean;
  99014. /**
  99015. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  99016. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  99017. */
  99018. set useKernelBlur(value: boolean);
  99019. protected _depthScale: number;
  99020. /**
  99021. * Gets the depth scale used in ESM mode.
  99022. */
  99023. get depthScale(): number;
  99024. /**
  99025. * Sets the depth scale used in ESM mode.
  99026. * This can override the scale stored on the light.
  99027. */
  99028. set depthScale(value: number);
  99029. protected _validateFilter(filter: number): number;
  99030. protected _filter: number;
  99031. /**
  99032. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  99033. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  99034. */
  99035. get filter(): number;
  99036. /**
  99037. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  99038. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  99039. */
  99040. set filter(value: number);
  99041. /**
  99042. * Gets if the current filter is set to Poisson Sampling.
  99043. */
  99044. get usePoissonSampling(): boolean;
  99045. /**
  99046. * Sets the current filter to Poisson Sampling.
  99047. */
  99048. set usePoissonSampling(value: boolean);
  99049. /**
  99050. * Gets if the current filter is set to ESM.
  99051. */
  99052. get useExponentialShadowMap(): boolean;
  99053. /**
  99054. * Sets the current filter is to ESM.
  99055. */
  99056. set useExponentialShadowMap(value: boolean);
  99057. /**
  99058. * Gets if the current filter is set to filtered ESM.
  99059. */
  99060. get useBlurExponentialShadowMap(): boolean;
  99061. /**
  99062. * Gets if the current filter is set to filtered ESM.
  99063. */
  99064. set useBlurExponentialShadowMap(value: boolean);
  99065. /**
  99066. * Gets if the current filter is set to "close ESM" (using the inverse of the
  99067. * exponential to prevent steep falloff artifacts).
  99068. */
  99069. get useCloseExponentialShadowMap(): boolean;
  99070. /**
  99071. * Sets the current filter to "close ESM" (using the inverse of the
  99072. * exponential to prevent steep falloff artifacts).
  99073. */
  99074. set useCloseExponentialShadowMap(value: boolean);
  99075. /**
  99076. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  99077. * exponential to prevent steep falloff artifacts).
  99078. */
  99079. get useBlurCloseExponentialShadowMap(): boolean;
  99080. /**
  99081. * Sets the current filter to filtered "close ESM" (using the inverse of the
  99082. * exponential to prevent steep falloff artifacts).
  99083. */
  99084. set useBlurCloseExponentialShadowMap(value: boolean);
  99085. /**
  99086. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  99087. */
  99088. get usePercentageCloserFiltering(): boolean;
  99089. /**
  99090. * Sets the current filter to "PCF" (percentage closer filtering).
  99091. */
  99092. set usePercentageCloserFiltering(value: boolean);
  99093. protected _filteringQuality: number;
  99094. /**
  99095. * Gets the PCF or PCSS Quality.
  99096. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99097. */
  99098. get filteringQuality(): number;
  99099. /**
  99100. * Sets the PCF or PCSS Quality.
  99101. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99102. */
  99103. set filteringQuality(filteringQuality: number);
  99104. /**
  99105. * Gets if the current filter is set to "PCSS" (contact hardening).
  99106. */
  99107. get useContactHardeningShadow(): boolean;
  99108. /**
  99109. * Sets the current filter to "PCSS" (contact hardening).
  99110. */
  99111. set useContactHardeningShadow(value: boolean);
  99112. protected _contactHardeningLightSizeUVRatio: number;
  99113. /**
  99114. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99115. * Using a ratio helps keeping shape stability independently of the map size.
  99116. *
  99117. * It does not account for the light projection as it was having too much
  99118. * instability during the light setup or during light position changes.
  99119. *
  99120. * Only valid if useContactHardeningShadow is true.
  99121. */
  99122. get contactHardeningLightSizeUVRatio(): number;
  99123. /**
  99124. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99125. * Using a ratio helps keeping shape stability independently of the map size.
  99126. *
  99127. * It does not account for the light projection as it was having too much
  99128. * instability during the light setup or during light position changes.
  99129. *
  99130. * Only valid if useContactHardeningShadow is true.
  99131. */
  99132. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  99133. protected _darkness: number;
  99134. /** Gets or sets the actual darkness of a shadow */
  99135. get darkness(): number;
  99136. set darkness(value: number);
  99137. /**
  99138. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  99139. * 0 means strongest and 1 would means no shadow.
  99140. * @returns the darkness.
  99141. */
  99142. getDarkness(): number;
  99143. /**
  99144. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  99145. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  99146. * @returns the shadow generator allowing fluent coding.
  99147. */
  99148. setDarkness(darkness: number): ShadowGenerator;
  99149. protected _transparencyShadow: boolean;
  99150. /** Gets or sets the ability to have transparent shadow */
  99151. get transparencyShadow(): boolean;
  99152. set transparencyShadow(value: boolean);
  99153. /**
  99154. * Sets the ability to have transparent shadow (boolean).
  99155. * @param transparent True if transparent else False
  99156. * @returns the shadow generator allowing fluent coding
  99157. */
  99158. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  99159. /**
  99160. * Enables or disables shadows with varying strength based on the transparency
  99161. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  99162. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  99163. * mesh.visibility * alphaTexture.a
  99164. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  99165. */
  99166. enableSoftTransparentShadow: boolean;
  99167. protected _shadowMap: Nullable<RenderTargetTexture>;
  99168. protected _shadowMap2: Nullable<RenderTargetTexture>;
  99169. /**
  99170. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  99171. * @returns The render target texture if present otherwise, null
  99172. */
  99173. getShadowMap(): Nullable<RenderTargetTexture>;
  99174. /**
  99175. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  99176. * @returns The render target texture if the shadow map is present otherwise, null
  99177. */
  99178. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  99179. /**
  99180. * Gets the class name of that object
  99181. * @returns "ShadowGenerator"
  99182. */
  99183. getClassName(): string;
  99184. /**
  99185. * Helper function to add a mesh and its descendants to the list of shadow casters.
  99186. * @param mesh Mesh to add
  99187. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  99188. * @returns the Shadow Generator itself
  99189. */
  99190. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99191. /**
  99192. * Helper function to remove a mesh and its descendants from the list of shadow casters
  99193. * @param mesh Mesh to remove
  99194. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  99195. * @returns the Shadow Generator itself
  99196. */
  99197. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99198. /**
  99199. * Controls the extent to which the shadows fade out at the edge of the frustum
  99200. */
  99201. frustumEdgeFalloff: number;
  99202. protected _light: IShadowLight;
  99203. /**
  99204. * Returns the associated light object.
  99205. * @returns the light generating the shadow
  99206. */
  99207. getLight(): IShadowLight;
  99208. /**
  99209. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  99210. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  99211. * It might on the other hand introduce peter panning.
  99212. */
  99213. forceBackFacesOnly: boolean;
  99214. protected _scene: Scene;
  99215. protected _lightDirection: Vector3;
  99216. protected _effect: Effect;
  99217. protected _viewMatrix: Matrix;
  99218. protected _projectionMatrix: Matrix;
  99219. protected _transformMatrix: Matrix;
  99220. protected _cachedPosition: Vector3;
  99221. protected _cachedDirection: Vector3;
  99222. protected _cachedDefines: string;
  99223. protected _currentRenderID: number;
  99224. protected _boxBlurPostprocess: Nullable<PostProcess>;
  99225. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  99226. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  99227. protected _blurPostProcesses: PostProcess[];
  99228. protected _mapSize: number;
  99229. protected _currentFaceIndex: number;
  99230. protected _currentFaceIndexCache: number;
  99231. protected _textureType: number;
  99232. protected _defaultTextureMatrix: Matrix;
  99233. protected _storedUniqueId: Nullable<number>;
  99234. /** @hidden */
  99235. static _SceneComponentInitialization: (scene: Scene) => void;
  99236. /**
  99237. * Gets or sets the size of the texture what stores the shadows
  99238. */
  99239. get mapSize(): number;
  99240. set mapSize(size: number);
  99241. /**
  99242. * Creates a ShadowGenerator object.
  99243. * A ShadowGenerator is the required tool to use the shadows.
  99244. * Each light casting shadows needs to use its own ShadowGenerator.
  99245. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  99246. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  99247. * @param light The light object generating the shadows.
  99248. * @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.
  99249. */
  99250. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  99251. protected _initializeGenerator(): void;
  99252. protected _createTargetRenderTexture(): void;
  99253. protected _initializeShadowMap(): void;
  99254. protected _initializeBlurRTTAndPostProcesses(): void;
  99255. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  99256. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  99257. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  99258. protected _applyFilterValues(): void;
  99259. /**
  99260. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99261. * @param onCompiled Callback triggered at the and of the effects compilation
  99262. * @param options Sets of optional options forcing the compilation with different modes
  99263. */
  99264. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  99265. useInstances: boolean;
  99266. }>): void;
  99267. /**
  99268. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99269. * @param options Sets of optional options forcing the compilation with different modes
  99270. * @returns A promise that resolves when the compilation completes
  99271. */
  99272. forceCompilationAsync(options?: Partial<{
  99273. useInstances: boolean;
  99274. }>): Promise<void>;
  99275. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  99276. private _prepareShadowDefines;
  99277. /**
  99278. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  99279. * @param subMesh The submesh we want to render in the shadow map
  99280. * @param useInstances Defines wether will draw in the map using instances
  99281. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  99282. * @returns true if ready otherwise, false
  99283. */
  99284. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  99285. /**
  99286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  99287. * @param defines Defines of the material we want to update
  99288. * @param lightIndex Index of the light in the enabled light list of the material
  99289. */
  99290. prepareDefines(defines: any, lightIndex: number): void;
  99291. /**
  99292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  99293. * defined in the generator but impacting the effect).
  99294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  99295. * @param effect The effect we are binfing the information for
  99296. */
  99297. bindShadowLight(lightIndex: string, effect: Effect): void;
  99298. /**
  99299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  99300. * (eq to shadow prjection matrix * light transform matrix)
  99301. * @returns The transform matrix used to create the shadow map
  99302. */
  99303. getTransformMatrix(): Matrix;
  99304. /**
  99305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  99306. * Cube and 2D textures for instance.
  99307. */
  99308. recreateShadowMap(): void;
  99309. protected _disposeBlurPostProcesses(): void;
  99310. protected _disposeRTTandPostProcesses(): void;
  99311. /**
  99312. * Disposes the ShadowGenerator.
  99313. * Returns nothing.
  99314. */
  99315. dispose(): void;
  99316. /**
  99317. * Serializes the shadow generator setup to a json object.
  99318. * @returns The serialized JSON object
  99319. */
  99320. serialize(): any;
  99321. /**
  99322. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  99323. * @param parsedShadowGenerator The JSON object to parse
  99324. * @param scene The scene to create the shadow map for
  99325. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  99326. * @returns The parsed shadow generator
  99327. */
  99328. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  99329. }
  99330. }
  99331. declare module BABYLON {
  99332. /**
  99333. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  99334. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  99335. * 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.
  99336. */
  99337. export abstract class Light extends Node {
  99338. /**
  99339. * Falloff Default: light is falling off following the material specification:
  99340. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  99341. */
  99342. static readonly FALLOFF_DEFAULT: number;
  99343. /**
  99344. * Falloff Physical: light is falling off following the inverse squared distance law.
  99345. */
  99346. static readonly FALLOFF_PHYSICAL: number;
  99347. /**
  99348. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  99349. * to enhance interoperability with other engines.
  99350. */
  99351. static readonly FALLOFF_GLTF: number;
  99352. /**
  99353. * Falloff Standard: light is falling off like in the standard material
  99354. * to enhance interoperability with other materials.
  99355. */
  99356. static readonly FALLOFF_STANDARD: number;
  99357. /**
  99358. * If every light affecting the material is in this lightmapMode,
  99359. * material.lightmapTexture adds or multiplies
  99360. * (depends on material.useLightmapAsShadowmap)
  99361. * after every other light calculations.
  99362. */
  99363. static readonly LIGHTMAP_DEFAULT: number;
  99364. /**
  99365. * material.lightmapTexture as only diffuse lighting from this light
  99366. * adds only specular lighting from this light
  99367. * adds dynamic shadows
  99368. */
  99369. static readonly LIGHTMAP_SPECULAR: number;
  99370. /**
  99371. * material.lightmapTexture as only lighting
  99372. * no light calculation from this light
  99373. * only adds dynamic shadows from this light
  99374. */
  99375. static readonly LIGHTMAP_SHADOWSONLY: number;
  99376. /**
  99377. * Each light type uses the default quantity according to its type:
  99378. * point/spot lights use luminous intensity
  99379. * directional lights use illuminance
  99380. */
  99381. static readonly INTENSITYMODE_AUTOMATIC: number;
  99382. /**
  99383. * lumen (lm)
  99384. */
  99385. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  99386. /**
  99387. * candela (lm/sr)
  99388. */
  99389. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  99390. /**
  99391. * lux (lm/m^2)
  99392. */
  99393. static readonly INTENSITYMODE_ILLUMINANCE: number;
  99394. /**
  99395. * nit (cd/m^2)
  99396. */
  99397. static readonly INTENSITYMODE_LUMINANCE: number;
  99398. /**
  99399. * Light type const id of the point light.
  99400. */
  99401. static readonly LIGHTTYPEID_POINTLIGHT: number;
  99402. /**
  99403. * Light type const id of the directional light.
  99404. */
  99405. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  99406. /**
  99407. * Light type const id of the spot light.
  99408. */
  99409. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  99410. /**
  99411. * Light type const id of the hemispheric light.
  99412. */
  99413. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  99414. /**
  99415. * Diffuse gives the basic color to an object.
  99416. */
  99417. diffuse: Color3;
  99418. /**
  99419. * Specular produces a highlight color on an object.
  99420. * Note: This is note affecting PBR materials.
  99421. */
  99422. specular: Color3;
  99423. /**
  99424. * Defines the falloff type for this light. This lets overrriding how punctual light are
  99425. * falling off base on range or angle.
  99426. * This can be set to any values in Light.FALLOFF_x.
  99427. *
  99428. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  99429. * other types of materials.
  99430. */
  99431. falloffType: number;
  99432. /**
  99433. * Strength of the light.
  99434. * Note: By default it is define in the framework own unit.
  99435. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  99436. */
  99437. intensity: number;
  99438. private _range;
  99439. protected _inverseSquaredRange: number;
  99440. /**
  99441. * Defines how far from the source the light is impacting in scene units.
  99442. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99443. */
  99444. get range(): number;
  99445. /**
  99446. * Defines how far from the source the light is impacting in scene units.
  99447. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99448. */
  99449. set range(value: number);
  99450. /**
  99451. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  99452. * of light.
  99453. */
  99454. private _photometricScale;
  99455. private _intensityMode;
  99456. /**
  99457. * Gets the photometric scale used to interpret the intensity.
  99458. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99459. */
  99460. get intensityMode(): number;
  99461. /**
  99462. * Sets the photometric scale used to interpret the intensity.
  99463. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99464. */
  99465. set intensityMode(value: number);
  99466. private _radius;
  99467. /**
  99468. * Gets the light radius used by PBR Materials to simulate soft area lights.
  99469. */
  99470. get radius(): number;
  99471. /**
  99472. * sets the light radius used by PBR Materials to simulate soft area lights.
  99473. */
  99474. set radius(value: number);
  99475. private _renderPriority;
  99476. /**
  99477. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  99478. * exceeding the number allowed of the materials.
  99479. */
  99480. renderPriority: number;
  99481. private _shadowEnabled;
  99482. /**
  99483. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99484. * the current shadow generator.
  99485. */
  99486. get shadowEnabled(): boolean;
  99487. /**
  99488. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99489. * the current shadow generator.
  99490. */
  99491. set shadowEnabled(value: boolean);
  99492. private _includedOnlyMeshes;
  99493. /**
  99494. * Gets the only meshes impacted by this light.
  99495. */
  99496. get includedOnlyMeshes(): AbstractMesh[];
  99497. /**
  99498. * Sets the only meshes impacted by this light.
  99499. */
  99500. set includedOnlyMeshes(value: AbstractMesh[]);
  99501. private _excludedMeshes;
  99502. /**
  99503. * Gets the meshes not impacted by this light.
  99504. */
  99505. get excludedMeshes(): AbstractMesh[];
  99506. /**
  99507. * Sets the meshes not impacted by this light.
  99508. */
  99509. set excludedMeshes(value: AbstractMesh[]);
  99510. private _excludeWithLayerMask;
  99511. /**
  99512. * Gets the layer id use to find what meshes are not impacted by the light.
  99513. * Inactive if 0
  99514. */
  99515. get excludeWithLayerMask(): number;
  99516. /**
  99517. * Sets the layer id use to find what meshes are not impacted by the light.
  99518. * Inactive if 0
  99519. */
  99520. set excludeWithLayerMask(value: number);
  99521. private _includeOnlyWithLayerMask;
  99522. /**
  99523. * Gets the layer id use to find what meshes are impacted by the light.
  99524. * Inactive if 0
  99525. */
  99526. get includeOnlyWithLayerMask(): number;
  99527. /**
  99528. * Sets the layer id use to find what meshes are impacted by the light.
  99529. * Inactive if 0
  99530. */
  99531. set includeOnlyWithLayerMask(value: number);
  99532. private _lightmapMode;
  99533. /**
  99534. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99535. */
  99536. get lightmapMode(): number;
  99537. /**
  99538. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99539. */
  99540. set lightmapMode(value: number);
  99541. /**
  99542. * Shadow generator associted to the light.
  99543. * @hidden Internal use only.
  99544. */
  99545. _shadowGenerator: Nullable<IShadowGenerator>;
  99546. /**
  99547. * @hidden Internal use only.
  99548. */
  99549. _excludedMeshesIds: string[];
  99550. /**
  99551. * @hidden Internal use only.
  99552. */
  99553. _includedOnlyMeshesIds: string[];
  99554. /**
  99555. * The current light unifom buffer.
  99556. * @hidden Internal use only.
  99557. */
  99558. _uniformBuffer: UniformBuffer;
  99559. /** @hidden */
  99560. _renderId: number;
  99561. /**
  99562. * Creates a Light object in the scene.
  99563. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99564. * @param name The firendly name of the light
  99565. * @param scene The scene the light belongs too
  99566. */
  99567. constructor(name: string, scene: Scene);
  99568. protected abstract _buildUniformLayout(): void;
  99569. /**
  99570. * Sets the passed Effect "effect" with the Light information.
  99571. * @param effect The effect to update
  99572. * @param lightIndex The index of the light in the effect to update
  99573. * @returns The light
  99574. */
  99575. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99576. /**
  99577. * Sets the passed Effect "effect" with the Light textures.
  99578. * @param effect The effect to update
  99579. * @param lightIndex The index of the light in the effect to update
  99580. * @returns The light
  99581. */
  99582. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99583. /**
  99584. * Binds the lights information from the scene to the effect for the given mesh.
  99585. * @param lightIndex Light index
  99586. * @param scene The scene where the light belongs to
  99587. * @param effect The effect we are binding the data to
  99588. * @param useSpecular Defines if specular is supported
  99589. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99590. */
  99591. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99592. /**
  99593. * Sets the passed Effect "effect" with the Light information.
  99594. * @param effect The effect to update
  99595. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99596. * @returns The light
  99597. */
  99598. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99599. /**
  99600. * Returns the string "Light".
  99601. * @returns the class name
  99602. */
  99603. getClassName(): string;
  99604. /** @hidden */
  99605. readonly _isLight: boolean;
  99606. /**
  99607. * Converts the light information to a readable string for debug purpose.
  99608. * @param fullDetails Supports for multiple levels of logging within scene loading
  99609. * @returns the human readable light info
  99610. */
  99611. toString(fullDetails?: boolean): string;
  99612. /** @hidden */
  99613. protected _syncParentEnabledState(): void;
  99614. /**
  99615. * Set the enabled state of this node.
  99616. * @param value - the new enabled state
  99617. */
  99618. setEnabled(value: boolean): void;
  99619. /**
  99620. * Returns the Light associated shadow generator if any.
  99621. * @return the associated shadow generator.
  99622. */
  99623. getShadowGenerator(): Nullable<IShadowGenerator>;
  99624. /**
  99625. * Returns a Vector3, the absolute light position in the World.
  99626. * @returns the world space position of the light
  99627. */
  99628. getAbsolutePosition(): Vector3;
  99629. /**
  99630. * Specifies if the light will affect the passed mesh.
  99631. * @param mesh The mesh to test against the light
  99632. * @return true the mesh is affected otherwise, false.
  99633. */
  99634. canAffectMesh(mesh: AbstractMesh): boolean;
  99635. /**
  99636. * Sort function to order lights for rendering.
  99637. * @param a First Light object to compare to second.
  99638. * @param b Second Light object to compare first.
  99639. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99640. */
  99641. static CompareLightsPriority(a: Light, b: Light): number;
  99642. /**
  99643. * Releases resources associated with this node.
  99644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99646. */
  99647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99648. /**
  99649. * Returns the light type ID (integer).
  99650. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99651. */
  99652. getTypeID(): number;
  99653. /**
  99654. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99655. * @returns the scaled intensity in intensity mode unit
  99656. */
  99657. getScaledIntensity(): number;
  99658. /**
  99659. * Returns a new Light object, named "name", from the current one.
  99660. * @param name The name of the cloned light
  99661. * @param newParent The parent of this light, if it has one
  99662. * @returns the new created light
  99663. */
  99664. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99665. /**
  99666. * Serializes the current light into a Serialization object.
  99667. * @returns the serialized object.
  99668. */
  99669. serialize(): any;
  99670. /**
  99671. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99672. * This new light is named "name" and added to the passed scene.
  99673. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99674. * @param name The friendly name of the light
  99675. * @param scene The scene the new light will belong to
  99676. * @returns the constructor function
  99677. */
  99678. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99679. /**
  99680. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99681. * @param parsedLight The JSON representation of the light
  99682. * @param scene The scene to create the parsed light in
  99683. * @returns the created light after parsing
  99684. */
  99685. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99686. private _hookArrayForExcluded;
  99687. private _hookArrayForIncludedOnly;
  99688. private _resyncMeshes;
  99689. /**
  99690. * Forces the meshes to update their light related information in their rendering used effects
  99691. * @hidden Internal Use Only
  99692. */
  99693. _markMeshesAsLightDirty(): void;
  99694. /**
  99695. * Recomputes the cached photometric scale if needed.
  99696. */
  99697. private _computePhotometricScale;
  99698. /**
  99699. * Returns the Photometric Scale according to the light type and intensity mode.
  99700. */
  99701. private _getPhotometricScale;
  99702. /**
  99703. * Reorder the light in the scene according to their defined priority.
  99704. * @hidden Internal Use Only
  99705. */
  99706. _reorderLightsInScene(): void;
  99707. /**
  99708. * Prepares the list of defines specific to the light type.
  99709. * @param defines the list of defines
  99710. * @param lightIndex defines the index of the light for the effect
  99711. */
  99712. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99713. }
  99714. }
  99715. declare module BABYLON {
  99716. /**
  99717. * Configuration needed for prepass-capable materials
  99718. */
  99719. export class PrePassConfiguration {
  99720. /**
  99721. * Previous world matrices of meshes carrying this material
  99722. * Used for computing velocity
  99723. */
  99724. previousWorldMatrices: {
  99725. [index: number]: Matrix;
  99726. };
  99727. /**
  99728. * Previous view project matrix
  99729. * Used for computing velocity
  99730. */
  99731. previousViewProjection: Matrix;
  99732. /**
  99733. * Previous bones of meshes carrying this material
  99734. * Used for computing velocity
  99735. */
  99736. previousBones: {
  99737. [index: number]: Float32Array;
  99738. };
  99739. /**
  99740. * Add the required uniforms to the current list.
  99741. * @param uniforms defines the current uniform list.
  99742. */
  99743. static AddUniforms(uniforms: string[]): void;
  99744. /**
  99745. * Add the required samplers to the current list.
  99746. * @param samplers defines the current sampler list.
  99747. */
  99748. static AddSamplers(samplers: string[]): void;
  99749. /**
  99750. * Binds the material data.
  99751. * @param effect defines the effect to update
  99752. * @param scene defines the scene the material belongs to.
  99753. * @param mesh The mesh
  99754. * @param world World matrix of this mesh
  99755. * @param isFrozen Is the material frozen
  99756. */
  99757. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99758. }
  99759. }
  99760. declare module BABYLON {
  99761. /**
  99762. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99763. * This is the base of the follow, arc rotate cameras and Free camera
  99764. * @see https://doc.babylonjs.com/features/cameras
  99765. */
  99766. export class TargetCamera extends Camera {
  99767. private static _RigCamTransformMatrix;
  99768. private static _TargetTransformMatrix;
  99769. private static _TargetFocalPoint;
  99770. private _tmpUpVector;
  99771. private _tmpTargetVector;
  99772. /**
  99773. * Define the current direction the camera is moving to
  99774. */
  99775. cameraDirection: Vector3;
  99776. /**
  99777. * Define the current rotation the camera is rotating to
  99778. */
  99779. cameraRotation: Vector2;
  99780. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99781. ignoreParentScaling: boolean;
  99782. /**
  99783. * When set, the up vector of the camera will be updated by the rotation of the camera
  99784. */
  99785. updateUpVectorFromRotation: boolean;
  99786. private _tmpQuaternion;
  99787. /**
  99788. * Define the current rotation of the camera
  99789. */
  99790. rotation: Vector3;
  99791. /**
  99792. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99793. */
  99794. rotationQuaternion: Quaternion;
  99795. /**
  99796. * Define the current speed of the camera
  99797. */
  99798. speed: number;
  99799. /**
  99800. * Add constraint to the camera to prevent it to move freely in all directions and
  99801. * around all axis.
  99802. */
  99803. noRotationConstraint: boolean;
  99804. /**
  99805. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99806. * panning
  99807. */
  99808. invertRotation: boolean;
  99809. /**
  99810. * Speed multiplier for inverse camera panning
  99811. */
  99812. inverseRotationSpeed: number;
  99813. /**
  99814. * Define the current target of the camera as an object or a position.
  99815. */
  99816. lockedTarget: any;
  99817. /** @hidden */
  99818. _currentTarget: Vector3;
  99819. /** @hidden */
  99820. _initialFocalDistance: number;
  99821. /** @hidden */
  99822. _viewMatrix: Matrix;
  99823. /** @hidden */
  99824. _camMatrix: Matrix;
  99825. /** @hidden */
  99826. _cameraTransformMatrix: Matrix;
  99827. /** @hidden */
  99828. _cameraRotationMatrix: Matrix;
  99829. /** @hidden */
  99830. _referencePoint: Vector3;
  99831. /** @hidden */
  99832. _transformedReferencePoint: Vector3;
  99833. /** @hidden */
  99834. _reset: () => void;
  99835. private _defaultUp;
  99836. /**
  99837. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99838. * This is the base of the follow, arc rotate cameras and Free camera
  99839. * @see https://doc.babylonjs.com/features/cameras
  99840. * @param name Defines the name of the camera in the scene
  99841. * @param position Defines the start position of the camera in the scene
  99842. * @param scene Defines the scene the camera belongs to
  99843. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99844. */
  99845. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99846. /**
  99847. * Gets the position in front of the camera at a given distance.
  99848. * @param distance The distance from the camera we want the position to be
  99849. * @returns the position
  99850. */
  99851. getFrontPosition(distance: number): Vector3;
  99852. /** @hidden */
  99853. _getLockedTargetPosition(): Nullable<Vector3>;
  99854. private _storedPosition;
  99855. private _storedRotation;
  99856. private _storedRotationQuaternion;
  99857. /**
  99858. * Store current camera state of the camera (fov, position, rotation, etc..)
  99859. * @returns the camera
  99860. */
  99861. storeState(): Camera;
  99862. /**
  99863. * Restored camera state. You must call storeState() first
  99864. * @returns whether it was successful or not
  99865. * @hidden
  99866. */
  99867. _restoreStateValues(): boolean;
  99868. /** @hidden */
  99869. _initCache(): void;
  99870. /** @hidden */
  99871. _updateCache(ignoreParentClass?: boolean): void;
  99872. /** @hidden */
  99873. _isSynchronizedViewMatrix(): boolean;
  99874. /** @hidden */
  99875. _computeLocalCameraSpeed(): number;
  99876. /**
  99877. * Defines the target the camera should look at.
  99878. * @param target Defines the new target as a Vector or a mesh
  99879. */
  99880. setTarget(target: Vector3): void;
  99881. /**
  99882. * Defines the target point of the camera.
  99883. * The camera looks towards it form the radius distance.
  99884. */
  99885. get target(): Vector3;
  99886. set target(value: Vector3);
  99887. /**
  99888. * Return the current target position of the camera. This value is expressed in local space.
  99889. * @returns the target position
  99890. */
  99891. getTarget(): Vector3;
  99892. /** @hidden */
  99893. _decideIfNeedsToMove(): boolean;
  99894. /** @hidden */
  99895. _updatePosition(): void;
  99896. /** @hidden */
  99897. _checkInputs(): void;
  99898. protected _updateCameraRotationMatrix(): void;
  99899. /**
  99900. * 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)
  99901. * @returns the current camera
  99902. */
  99903. private _rotateUpVectorWithCameraRotationMatrix;
  99904. private _cachedRotationZ;
  99905. private _cachedQuaternionRotationZ;
  99906. /** @hidden */
  99907. _getViewMatrix(): Matrix;
  99908. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99909. /**
  99910. * @hidden
  99911. */
  99912. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99913. /**
  99914. * @hidden
  99915. */
  99916. _updateRigCameras(): void;
  99917. private _getRigCamPositionAndTarget;
  99918. /**
  99919. * Gets the current object class name.
  99920. * @return the class name
  99921. */
  99922. getClassName(): string;
  99923. }
  99924. }
  99925. declare module BABYLON {
  99926. /**
  99927. * Gather the list of keyboard event types as constants.
  99928. */
  99929. export class KeyboardEventTypes {
  99930. /**
  99931. * The keydown event is fired when a key becomes active (pressed).
  99932. */
  99933. static readonly KEYDOWN: number;
  99934. /**
  99935. * The keyup event is fired when a key has been released.
  99936. */
  99937. static readonly KEYUP: number;
  99938. }
  99939. /**
  99940. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99941. */
  99942. export class KeyboardInfo {
  99943. /**
  99944. * Defines the type of event (KeyboardEventTypes)
  99945. */
  99946. type: number;
  99947. /**
  99948. * Defines the related dom event
  99949. */
  99950. event: KeyboardEvent;
  99951. /**
  99952. * Instantiates a new keyboard info.
  99953. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99954. * @param type Defines the type of event (KeyboardEventTypes)
  99955. * @param event Defines the related dom event
  99956. */
  99957. constructor(
  99958. /**
  99959. * Defines the type of event (KeyboardEventTypes)
  99960. */
  99961. type: number,
  99962. /**
  99963. * Defines the related dom event
  99964. */
  99965. event: KeyboardEvent);
  99966. }
  99967. /**
  99968. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99969. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99970. */
  99971. export class KeyboardInfoPre extends KeyboardInfo {
  99972. /**
  99973. * Defines the type of event (KeyboardEventTypes)
  99974. */
  99975. type: number;
  99976. /**
  99977. * Defines the related dom event
  99978. */
  99979. event: KeyboardEvent;
  99980. /**
  99981. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99982. */
  99983. skipOnPointerObservable: boolean;
  99984. /**
  99985. * Instantiates a new keyboard pre info.
  99986. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99987. * @param type Defines the type of event (KeyboardEventTypes)
  99988. * @param event Defines the related dom event
  99989. */
  99990. constructor(
  99991. /**
  99992. * Defines the type of event (KeyboardEventTypes)
  99993. */
  99994. type: number,
  99995. /**
  99996. * Defines the related dom event
  99997. */
  99998. event: KeyboardEvent);
  99999. }
  100000. }
  100001. declare module BABYLON {
  100002. /**
  100003. * Manage the keyboard inputs to control the movement of a free camera.
  100004. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100005. */
  100006. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  100007. /**
  100008. * Defines the camera the input is attached to.
  100009. */
  100010. camera: FreeCamera;
  100011. /**
  100012. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  100013. */
  100014. keysUp: number[];
  100015. /**
  100016. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  100017. */
  100018. keysUpward: number[];
  100019. /**
  100020. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100021. */
  100022. keysDown: number[];
  100023. /**
  100024. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100025. */
  100026. keysDownward: number[];
  100027. /**
  100028. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100029. */
  100030. keysLeft: number[];
  100031. /**
  100032. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100033. */
  100034. keysRight: number[];
  100035. private _keys;
  100036. private _onCanvasBlurObserver;
  100037. private _onKeyboardObserver;
  100038. private _engine;
  100039. private _scene;
  100040. /**
  100041. * Attach the input controls to a specific dom element to get the input from.
  100042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100043. */
  100044. attachControl(noPreventDefault?: boolean): void;
  100045. /**
  100046. * Detach the current controls from the specified dom element.
  100047. */
  100048. detachControl(): void;
  100049. /**
  100050. * Update the current camera state depending on the inputs that have been used this frame.
  100051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100052. */
  100053. checkInputs(): void;
  100054. /**
  100055. * Gets the class name of the current intput.
  100056. * @returns the class name
  100057. */
  100058. getClassName(): string;
  100059. /** @hidden */
  100060. _onLostFocus(): void;
  100061. /**
  100062. * Get the friendly name associated with the input class.
  100063. * @returns the input friendly name
  100064. */
  100065. getSimpleName(): string;
  100066. }
  100067. }
  100068. declare module BABYLON {
  100069. /**
  100070. * Gather the list of pointer event types as constants.
  100071. */
  100072. export class PointerEventTypes {
  100073. /**
  100074. * 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.
  100075. */
  100076. static readonly POINTERDOWN: number;
  100077. /**
  100078. * The pointerup event is fired when a pointer is no longer active.
  100079. */
  100080. static readonly POINTERUP: number;
  100081. /**
  100082. * The pointermove event is fired when a pointer changes coordinates.
  100083. */
  100084. static readonly POINTERMOVE: number;
  100085. /**
  100086. * The pointerwheel event is fired when a mouse wheel has been rotated.
  100087. */
  100088. static readonly POINTERWHEEL: number;
  100089. /**
  100090. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  100091. */
  100092. static readonly POINTERPICK: number;
  100093. /**
  100094. * The pointertap event is fired when a the object has been touched and released without drag.
  100095. */
  100096. static readonly POINTERTAP: number;
  100097. /**
  100098. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  100099. */
  100100. static readonly POINTERDOUBLETAP: number;
  100101. }
  100102. /**
  100103. * Base class of pointer info types.
  100104. */
  100105. export class PointerInfoBase {
  100106. /**
  100107. * Defines the type of event (PointerEventTypes)
  100108. */
  100109. type: number;
  100110. /**
  100111. * Defines the related dom event
  100112. */
  100113. event: PointerEvent | MouseWheelEvent;
  100114. /**
  100115. * Instantiates the base class of pointers info.
  100116. * @param type Defines the type of event (PointerEventTypes)
  100117. * @param event Defines the related dom event
  100118. */
  100119. constructor(
  100120. /**
  100121. * Defines the type of event (PointerEventTypes)
  100122. */
  100123. type: number,
  100124. /**
  100125. * Defines the related dom event
  100126. */
  100127. event: PointerEvent | MouseWheelEvent);
  100128. }
  100129. /**
  100130. * This class is used to store pointer related info for the onPrePointerObservable event.
  100131. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  100132. */
  100133. export class PointerInfoPre extends PointerInfoBase {
  100134. /**
  100135. * Ray from a pointer if availible (eg. 6dof controller)
  100136. */
  100137. ray: Nullable<Ray>;
  100138. /**
  100139. * Defines the local position of the pointer on the canvas.
  100140. */
  100141. localPosition: Vector2;
  100142. /**
  100143. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  100144. */
  100145. skipOnPointerObservable: boolean;
  100146. /**
  100147. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  100148. * @param type Defines the type of event (PointerEventTypes)
  100149. * @param event Defines the related dom event
  100150. * @param localX Defines the local x coordinates of the pointer when the event occured
  100151. * @param localY Defines the local y coordinates of the pointer when the event occured
  100152. */
  100153. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  100154. }
  100155. /**
  100156. * This type contains all the data related to a pointer event in Babylon.js.
  100157. * 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.
  100158. */
  100159. export class PointerInfo extends PointerInfoBase {
  100160. /**
  100161. * Defines the picking info associated to the info (if any)\
  100162. */
  100163. pickInfo: Nullable<PickingInfo>;
  100164. /**
  100165. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  100166. * @param type Defines the type of event (PointerEventTypes)
  100167. * @param event Defines the related dom event
  100168. * @param pickInfo Defines the picking info associated to the info (if any)\
  100169. */
  100170. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  100171. /**
  100172. * Defines the picking info associated to the info (if any)\
  100173. */
  100174. pickInfo: Nullable<PickingInfo>);
  100175. }
  100176. /**
  100177. * Data relating to a touch event on the screen.
  100178. */
  100179. export interface PointerTouch {
  100180. /**
  100181. * X coordinate of touch.
  100182. */
  100183. x: number;
  100184. /**
  100185. * Y coordinate of touch.
  100186. */
  100187. y: number;
  100188. /**
  100189. * Id of touch. Unique for each finger.
  100190. */
  100191. pointerId: number;
  100192. /**
  100193. * Event type passed from DOM.
  100194. */
  100195. type: any;
  100196. }
  100197. }
  100198. declare module BABYLON {
  100199. /**
  100200. * Manage the mouse inputs to control the movement of a free camera.
  100201. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100202. */
  100203. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  100204. /**
  100205. * Define if touch is enabled in the mouse input
  100206. */
  100207. touchEnabled: boolean;
  100208. /**
  100209. * Defines the camera the input is attached to.
  100210. */
  100211. camera: FreeCamera;
  100212. /**
  100213. * Defines the buttons associated with the input to handle camera move.
  100214. */
  100215. buttons: number[];
  100216. /**
  100217. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  100218. */
  100219. angularSensibility: number;
  100220. private _pointerInput;
  100221. private _onMouseMove;
  100222. private _observer;
  100223. private previousPosition;
  100224. /**
  100225. * Observable for when a pointer move event occurs containing the move offset
  100226. */
  100227. onPointerMovedObservable: Observable<{
  100228. offsetX: number;
  100229. offsetY: number;
  100230. }>;
  100231. /**
  100232. * @hidden
  100233. * If the camera should be rotated automatically based on pointer movement
  100234. */
  100235. _allowCameraRotation: boolean;
  100236. /**
  100237. * Manage the mouse inputs to control the movement of a free camera.
  100238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100239. * @param touchEnabled Defines if touch is enabled or not
  100240. */
  100241. constructor(
  100242. /**
  100243. * Define if touch is enabled in the mouse input
  100244. */
  100245. touchEnabled?: boolean);
  100246. /**
  100247. * Attach the input controls to a specific dom element to get the input from.
  100248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100249. */
  100250. attachControl(noPreventDefault?: boolean): void;
  100251. /**
  100252. * Called on JS contextmenu event.
  100253. * Override this method to provide functionality.
  100254. */
  100255. protected onContextMenu(evt: PointerEvent): void;
  100256. /**
  100257. * Detach the current controls from the specified dom element.
  100258. */
  100259. detachControl(): void;
  100260. /**
  100261. * Gets the class name of the current intput.
  100262. * @returns the class name
  100263. */
  100264. getClassName(): string;
  100265. /**
  100266. * Get the friendly name associated with the input class.
  100267. * @returns the input friendly name
  100268. */
  100269. getSimpleName(): string;
  100270. }
  100271. }
  100272. declare module BABYLON {
  100273. /**
  100274. * Base class for mouse wheel input..
  100275. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  100276. * for example usage.
  100277. */
  100278. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  100279. /**
  100280. * Defines the camera the input is attached to.
  100281. */
  100282. abstract camera: Camera;
  100283. /**
  100284. * How fast is the camera moves in relation to X axis mouseWheel events.
  100285. * Use negative value to reverse direction.
  100286. */
  100287. wheelPrecisionX: number;
  100288. /**
  100289. * How fast is the camera moves in relation to Y axis mouseWheel events.
  100290. * Use negative value to reverse direction.
  100291. */
  100292. wheelPrecisionY: number;
  100293. /**
  100294. * How fast is the camera moves in relation to Z axis mouseWheel events.
  100295. * Use negative value to reverse direction.
  100296. */
  100297. wheelPrecisionZ: number;
  100298. /**
  100299. * Observable for when a mouse wheel move event occurs.
  100300. */
  100301. onChangedObservable: Observable<{
  100302. wheelDeltaX: number;
  100303. wheelDeltaY: number;
  100304. wheelDeltaZ: number;
  100305. }>;
  100306. private _wheel;
  100307. private _observer;
  100308. /**
  100309. * Attach the input controls to a specific dom element to get the input from.
  100310. * @param noPreventDefault Defines whether event caught by the controls
  100311. * should call preventdefault().
  100312. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100313. */
  100314. attachControl(noPreventDefault?: boolean): void;
  100315. /**
  100316. * Detach the current controls from the specified dom element.
  100317. */
  100318. detachControl(): void;
  100319. /**
  100320. * Called for each rendered frame.
  100321. */
  100322. checkInputs(): void;
  100323. /**
  100324. * Gets the class name of the current intput.
  100325. * @returns the class name
  100326. */
  100327. getClassName(): string;
  100328. /**
  100329. * Get the friendly name associated with the input class.
  100330. * @returns the input friendly name
  100331. */
  100332. getSimpleName(): string;
  100333. /**
  100334. * Incremental value of multiple mouse wheel movements of the X axis.
  100335. * Should be zero-ed when read.
  100336. */
  100337. protected _wheelDeltaX: number;
  100338. /**
  100339. * Incremental value of multiple mouse wheel movements of the Y axis.
  100340. * Should be zero-ed when read.
  100341. */
  100342. protected _wheelDeltaY: number;
  100343. /**
  100344. * Incremental value of multiple mouse wheel movements of the Z axis.
  100345. * Should be zero-ed when read.
  100346. */
  100347. protected _wheelDeltaZ: number;
  100348. /**
  100349. * Firefox uses a different scheme to report scroll distances to other
  100350. * browsers. Rather than use complicated methods to calculate the exact
  100351. * multiple we need to apply, let's just cheat and use a constant.
  100352. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  100353. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  100354. */
  100355. private readonly _ffMultiplier;
  100356. /**
  100357. * Different event attributes for wheel data fall into a few set ranges.
  100358. * Some relevant but dated date here:
  100359. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  100360. */
  100361. private readonly _normalize;
  100362. }
  100363. }
  100364. declare module BABYLON {
  100365. /**
  100366. * Manage the mouse wheel inputs to control a free camera.
  100367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100368. */
  100369. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  100370. /**
  100371. * Defines the camera the input is attached to.
  100372. */
  100373. camera: FreeCamera;
  100374. /**
  100375. * Gets the class name of the current input.
  100376. * @returns the class name
  100377. */
  100378. getClassName(): string;
  100379. /**
  100380. * Set which movement axis (relative to camera's orientation) the mouse
  100381. * wheel's X axis controls.
  100382. * @param axis The axis to be moved. Set null to clear.
  100383. */
  100384. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  100385. /**
  100386. * Get the configured movement axis (relative to camera's orientation) the
  100387. * mouse wheel's X axis controls.
  100388. * @returns The configured axis or null if none.
  100389. */
  100390. get wheelXMoveRelative(): Nullable<Coordinate>;
  100391. /**
  100392. * Set which movement axis (relative to camera's orientation) the mouse
  100393. * wheel's Y axis controls.
  100394. * @param axis The axis to be moved. Set null to clear.
  100395. */
  100396. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  100397. /**
  100398. * Get the configured movement axis (relative to camera's orientation) the
  100399. * mouse wheel's Y axis controls.
  100400. * @returns The configured axis or null if none.
  100401. */
  100402. get wheelYMoveRelative(): Nullable<Coordinate>;
  100403. /**
  100404. * Set which movement axis (relative to camera's orientation) the mouse
  100405. * wheel's Z axis controls.
  100406. * @param axis The axis to be moved. Set null to clear.
  100407. */
  100408. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  100409. /**
  100410. * Get the configured movement axis (relative to camera's orientation) the
  100411. * mouse wheel's Z axis controls.
  100412. * @returns The configured axis or null if none.
  100413. */
  100414. get wheelZMoveRelative(): Nullable<Coordinate>;
  100415. /**
  100416. * Set which rotation axis (relative to camera's orientation) the mouse
  100417. * wheel's X axis controls.
  100418. * @param axis The axis to be moved. Set null to clear.
  100419. */
  100420. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  100421. /**
  100422. * Get the configured rotation axis (relative to camera's orientation) the
  100423. * mouse wheel's X axis controls.
  100424. * @returns The configured axis or null if none.
  100425. */
  100426. get wheelXRotateRelative(): Nullable<Coordinate>;
  100427. /**
  100428. * Set which rotation axis (relative to camera's orientation) the mouse
  100429. * wheel's Y axis controls.
  100430. * @param axis The axis to be moved. Set null to clear.
  100431. */
  100432. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  100433. /**
  100434. * Get the configured rotation axis (relative to camera's orientation) the
  100435. * mouse wheel's Y axis controls.
  100436. * @returns The configured axis or null if none.
  100437. */
  100438. get wheelYRotateRelative(): Nullable<Coordinate>;
  100439. /**
  100440. * Set which rotation axis (relative to camera's orientation) the mouse
  100441. * wheel's Z axis controls.
  100442. * @param axis The axis to be moved. Set null to clear.
  100443. */
  100444. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  100445. /**
  100446. * Get the configured rotation axis (relative to camera's orientation) the
  100447. * mouse wheel's Z axis controls.
  100448. * @returns The configured axis or null if none.
  100449. */
  100450. get wheelZRotateRelative(): Nullable<Coordinate>;
  100451. /**
  100452. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  100453. * controls.
  100454. * @param axis The axis to be moved. Set null to clear.
  100455. */
  100456. set wheelXMoveScene(axis: Nullable<Coordinate>);
  100457. /**
  100458. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100459. * X axis controls.
  100460. * @returns The configured axis or null if none.
  100461. */
  100462. get wheelXMoveScene(): Nullable<Coordinate>;
  100463. /**
  100464. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  100465. * controls.
  100466. * @param axis The axis to be moved. Set null to clear.
  100467. */
  100468. set wheelYMoveScene(axis: Nullable<Coordinate>);
  100469. /**
  100470. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100471. * Y axis controls.
  100472. * @returns The configured axis or null if none.
  100473. */
  100474. get wheelYMoveScene(): Nullable<Coordinate>;
  100475. /**
  100476. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  100477. * controls.
  100478. * @param axis The axis to be moved. Set null to clear.
  100479. */
  100480. set wheelZMoveScene(axis: Nullable<Coordinate>);
  100481. /**
  100482. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100483. * Z axis controls.
  100484. * @returns The configured axis or null if none.
  100485. */
  100486. get wheelZMoveScene(): Nullable<Coordinate>;
  100487. /**
  100488. * Called for each rendered frame.
  100489. */
  100490. checkInputs(): void;
  100491. private _moveRelative;
  100492. private _rotateRelative;
  100493. private _moveScene;
  100494. /**
  100495. * These are set to the desired default behaviour.
  100496. */
  100497. private _wheelXAction;
  100498. private _wheelXActionCoordinate;
  100499. private _wheelYAction;
  100500. private _wheelYActionCoordinate;
  100501. private _wheelZAction;
  100502. private _wheelZActionCoordinate;
  100503. /**
  100504. * Update the camera according to any configured properties for the 3
  100505. * mouse-wheel axis.
  100506. */
  100507. private _updateCamera;
  100508. }
  100509. }
  100510. declare module BABYLON {
  100511. /**
  100512. * Manage the touch inputs to control the movement of a free camera.
  100513. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100514. */
  100515. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  100516. /**
  100517. * Define if mouse events can be treated as touch events
  100518. */
  100519. allowMouse: boolean;
  100520. /**
  100521. * Defines the camera the input is attached to.
  100522. */
  100523. camera: FreeCamera;
  100524. /**
  100525. * Defines the touch sensibility for rotation.
  100526. * The higher the faster.
  100527. */
  100528. touchAngularSensibility: number;
  100529. /**
  100530. * Defines the touch sensibility for move.
  100531. * The higher the faster.
  100532. */
  100533. touchMoveSensibility: number;
  100534. private _offsetX;
  100535. private _offsetY;
  100536. private _pointerPressed;
  100537. private _pointerInput?;
  100538. private _observer;
  100539. private _onLostFocus;
  100540. /**
  100541. * Manage the touch inputs to control the movement of a free camera.
  100542. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100543. * @param allowMouse Defines if mouse events can be treated as touch events
  100544. */
  100545. constructor(
  100546. /**
  100547. * Define if mouse events can be treated as touch events
  100548. */
  100549. allowMouse?: boolean);
  100550. /**
  100551. * Attach the input controls to a specific dom element to get the input from.
  100552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100553. */
  100554. attachControl(noPreventDefault?: boolean): void;
  100555. /**
  100556. * Detach the current controls from the specified dom element.
  100557. */
  100558. detachControl(): void;
  100559. /**
  100560. * Update the current camera state depending on the inputs that have been used this frame.
  100561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100562. */
  100563. checkInputs(): void;
  100564. /**
  100565. * Gets the class name of the current intput.
  100566. * @returns the class name
  100567. */
  100568. getClassName(): string;
  100569. /**
  100570. * Get the friendly name associated with the input class.
  100571. * @returns the input friendly name
  100572. */
  100573. getSimpleName(): string;
  100574. }
  100575. }
  100576. declare module BABYLON {
  100577. /**
  100578. * Default Inputs manager for the FreeCamera.
  100579. * It groups all the default supported inputs for ease of use.
  100580. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100581. */
  100582. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  100583. /**
  100584. * @hidden
  100585. */
  100586. _mouseInput: Nullable<FreeCameraMouseInput>;
  100587. /**
  100588. * @hidden
  100589. */
  100590. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  100591. /**
  100592. * Instantiates a new FreeCameraInputsManager.
  100593. * @param camera Defines the camera the inputs belong to
  100594. */
  100595. constructor(camera: FreeCamera);
  100596. /**
  100597. * Add keyboard input support to the input manager.
  100598. * @returns the current input manager
  100599. */
  100600. addKeyboard(): FreeCameraInputsManager;
  100601. /**
  100602. * Add mouse input support to the input manager.
  100603. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  100604. * @returns the current input manager
  100605. */
  100606. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  100607. /**
  100608. * Removes the mouse input support from the manager
  100609. * @returns the current input manager
  100610. */
  100611. removeMouse(): FreeCameraInputsManager;
  100612. /**
  100613. * Add mouse wheel input support to the input manager.
  100614. * @returns the current input manager
  100615. */
  100616. addMouseWheel(): FreeCameraInputsManager;
  100617. /**
  100618. * Removes the mouse wheel input support from the manager
  100619. * @returns the current input manager
  100620. */
  100621. removeMouseWheel(): FreeCameraInputsManager;
  100622. /**
  100623. * Add touch input support to the input manager.
  100624. * @returns the current input manager
  100625. */
  100626. addTouch(): FreeCameraInputsManager;
  100627. /**
  100628. * Remove all attached input methods from a camera
  100629. */
  100630. clear(): void;
  100631. }
  100632. }
  100633. declare module BABYLON {
  100634. /**
  100635. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100636. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  100637. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100638. */
  100639. export class FreeCamera extends TargetCamera {
  100640. /**
  100641. * Define the collision ellipsoid of the camera.
  100642. * This is helpful to simulate a camera body like the player body around the camera
  100643. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100644. */
  100645. ellipsoid: Vector3;
  100646. /**
  100647. * Define an offset for the position of the ellipsoid around the camera.
  100648. * This can be helpful to determine the center of the body near the gravity center of the body
  100649. * instead of its head.
  100650. */
  100651. ellipsoidOffset: Vector3;
  100652. /**
  100653. * Enable or disable collisions of the camera with the rest of the scene objects.
  100654. */
  100655. checkCollisions: boolean;
  100656. /**
  100657. * Enable or disable gravity on the camera.
  100658. */
  100659. applyGravity: boolean;
  100660. /**
  100661. * Define the input manager associated to the camera.
  100662. */
  100663. inputs: FreeCameraInputsManager;
  100664. /**
  100665. * Gets the input sensibility for a mouse input. (default is 2000.0)
  100666. * Higher values reduce sensitivity.
  100667. */
  100668. get angularSensibility(): number;
  100669. /**
  100670. * Sets the input sensibility for a mouse input. (default is 2000.0)
  100671. * Higher values reduce sensitivity.
  100672. */
  100673. set angularSensibility(value: number);
  100674. /**
  100675. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  100676. */
  100677. get keysUp(): number[];
  100678. set keysUp(value: number[]);
  100679. /**
  100680. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  100681. */
  100682. get keysUpward(): number[];
  100683. set keysUpward(value: number[]);
  100684. /**
  100685. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100686. */
  100687. get keysDown(): number[];
  100688. set keysDown(value: number[]);
  100689. /**
  100690. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100691. */
  100692. get keysDownward(): number[];
  100693. set keysDownward(value: number[]);
  100694. /**
  100695. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100696. */
  100697. get keysLeft(): number[];
  100698. set keysLeft(value: number[]);
  100699. /**
  100700. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100701. */
  100702. get keysRight(): number[];
  100703. set keysRight(value: number[]);
  100704. /**
  100705. * Event raised when the camera collide with a mesh in the scene.
  100706. */
  100707. onCollide: (collidedMesh: AbstractMesh) => void;
  100708. private _collider;
  100709. private _needMoveForGravity;
  100710. private _oldPosition;
  100711. private _diffPosition;
  100712. private _newPosition;
  100713. /** @hidden */
  100714. _localDirection: Vector3;
  100715. /** @hidden */
  100716. _transformedDirection: Vector3;
  100717. /**
  100718. * Instantiates a Free Camera.
  100719. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100720. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  100721. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100722. * @param name Define the name of the camera in the scene
  100723. * @param position Define the start position of the camera in the scene
  100724. * @param scene Define the scene the camera belongs to
  100725. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100726. */
  100727. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100728. /**
  100729. * Attach the input controls to a specific dom element to get the input from.
  100730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100731. */
  100732. attachControl(noPreventDefault?: boolean): void;
  100733. /**
  100734. * Detach the current controls from the specified dom element.
  100735. */
  100736. detachControl(): void;
  100737. private _collisionMask;
  100738. /**
  100739. * Define a collision mask to limit the list of object the camera can collide with
  100740. */
  100741. get collisionMask(): number;
  100742. set collisionMask(mask: number);
  100743. /** @hidden */
  100744. _collideWithWorld(displacement: Vector3): void;
  100745. private _onCollisionPositionChange;
  100746. /** @hidden */
  100747. _checkInputs(): void;
  100748. /** @hidden */
  100749. _decideIfNeedsToMove(): boolean;
  100750. /** @hidden */
  100751. _updatePosition(): void;
  100752. /**
  100753. * Destroy the camera and release the current resources hold by it.
  100754. */
  100755. dispose(): void;
  100756. /**
  100757. * Gets the current object class name.
  100758. * @return the class name
  100759. */
  100760. getClassName(): string;
  100761. }
  100762. }
  100763. declare module BABYLON {
  100764. /**
  100765. * Represents a gamepad control stick position
  100766. */
  100767. export class StickValues {
  100768. /**
  100769. * The x component of the control stick
  100770. */
  100771. x: number;
  100772. /**
  100773. * The y component of the control stick
  100774. */
  100775. y: number;
  100776. /**
  100777. * Initializes the gamepad x and y control stick values
  100778. * @param x The x component of the gamepad control stick value
  100779. * @param y The y component of the gamepad control stick value
  100780. */
  100781. constructor(
  100782. /**
  100783. * The x component of the control stick
  100784. */
  100785. x: number,
  100786. /**
  100787. * The y component of the control stick
  100788. */
  100789. y: number);
  100790. }
  100791. /**
  100792. * An interface which manages callbacks for gamepad button changes
  100793. */
  100794. export interface GamepadButtonChanges {
  100795. /**
  100796. * Called when a gamepad has been changed
  100797. */
  100798. changed: boolean;
  100799. /**
  100800. * Called when a gamepad press event has been triggered
  100801. */
  100802. pressChanged: boolean;
  100803. /**
  100804. * Called when a touch event has been triggered
  100805. */
  100806. touchChanged: boolean;
  100807. /**
  100808. * Called when a value has changed
  100809. */
  100810. valueChanged: boolean;
  100811. }
  100812. /**
  100813. * Represents a gamepad
  100814. */
  100815. export class Gamepad {
  100816. /**
  100817. * The id of the gamepad
  100818. */
  100819. id: string;
  100820. /**
  100821. * The index of the gamepad
  100822. */
  100823. index: number;
  100824. /**
  100825. * The browser gamepad
  100826. */
  100827. browserGamepad: any;
  100828. /**
  100829. * Specifies what type of gamepad this represents
  100830. */
  100831. type: number;
  100832. private _leftStick;
  100833. private _rightStick;
  100834. /** @hidden */
  100835. _isConnected: boolean;
  100836. private _leftStickAxisX;
  100837. private _leftStickAxisY;
  100838. private _rightStickAxisX;
  100839. private _rightStickAxisY;
  100840. /**
  100841. * Triggered when the left control stick has been changed
  100842. */
  100843. private _onleftstickchanged;
  100844. /**
  100845. * Triggered when the right control stick has been changed
  100846. */
  100847. private _onrightstickchanged;
  100848. /**
  100849. * Represents a gamepad controller
  100850. */
  100851. static GAMEPAD: number;
  100852. /**
  100853. * Represents a generic controller
  100854. */
  100855. static GENERIC: number;
  100856. /**
  100857. * Represents an XBox controller
  100858. */
  100859. static XBOX: number;
  100860. /**
  100861. * Represents a pose-enabled controller
  100862. */
  100863. static POSE_ENABLED: number;
  100864. /**
  100865. * Represents an Dual Shock controller
  100866. */
  100867. static DUALSHOCK: number;
  100868. /**
  100869. * Specifies whether the left control stick should be Y-inverted
  100870. */
  100871. protected _invertLeftStickY: boolean;
  100872. /**
  100873. * Specifies if the gamepad has been connected
  100874. */
  100875. get isConnected(): boolean;
  100876. /**
  100877. * Initializes the gamepad
  100878. * @param id The id of the gamepad
  100879. * @param index The index of the gamepad
  100880. * @param browserGamepad The browser gamepad
  100881. * @param leftStickX The x component of the left joystick
  100882. * @param leftStickY The y component of the left joystick
  100883. * @param rightStickX The x component of the right joystick
  100884. * @param rightStickY The y component of the right joystick
  100885. */
  100886. constructor(
  100887. /**
  100888. * The id of the gamepad
  100889. */
  100890. id: string,
  100891. /**
  100892. * The index of the gamepad
  100893. */
  100894. index: number,
  100895. /**
  100896. * The browser gamepad
  100897. */
  100898. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100899. /**
  100900. * Callback triggered when the left joystick has changed
  100901. * @param callback
  100902. */
  100903. onleftstickchanged(callback: (values: StickValues) => void): void;
  100904. /**
  100905. * Callback triggered when the right joystick has changed
  100906. * @param callback
  100907. */
  100908. onrightstickchanged(callback: (values: StickValues) => void): void;
  100909. /**
  100910. * Gets the left joystick
  100911. */
  100912. get leftStick(): StickValues;
  100913. /**
  100914. * Sets the left joystick values
  100915. */
  100916. set leftStick(newValues: StickValues);
  100917. /**
  100918. * Gets the right joystick
  100919. */
  100920. get rightStick(): StickValues;
  100921. /**
  100922. * Sets the right joystick value
  100923. */
  100924. set rightStick(newValues: StickValues);
  100925. /**
  100926. * Updates the gamepad joystick positions
  100927. */
  100928. update(): void;
  100929. /**
  100930. * Disposes the gamepad
  100931. */
  100932. dispose(): void;
  100933. }
  100934. /**
  100935. * Represents a generic gamepad
  100936. */
  100937. export class GenericPad extends Gamepad {
  100938. private _buttons;
  100939. private _onbuttondown;
  100940. private _onbuttonup;
  100941. /**
  100942. * Observable triggered when a button has been pressed
  100943. */
  100944. onButtonDownObservable: Observable<number>;
  100945. /**
  100946. * Observable triggered when a button has been released
  100947. */
  100948. onButtonUpObservable: Observable<number>;
  100949. /**
  100950. * Callback triggered when a button has been pressed
  100951. * @param callback Called when a button has been pressed
  100952. */
  100953. onbuttondown(callback: (buttonPressed: number) => void): void;
  100954. /**
  100955. * Callback triggered when a button has been released
  100956. * @param callback Called when a button has been released
  100957. */
  100958. onbuttonup(callback: (buttonReleased: number) => void): void;
  100959. /**
  100960. * Initializes the generic gamepad
  100961. * @param id The id of the generic gamepad
  100962. * @param index The index of the generic gamepad
  100963. * @param browserGamepad The browser gamepad
  100964. */
  100965. constructor(id: string, index: number, browserGamepad: any);
  100966. private _setButtonValue;
  100967. /**
  100968. * Updates the generic gamepad
  100969. */
  100970. update(): void;
  100971. /**
  100972. * Disposes the generic gamepad
  100973. */
  100974. dispose(): void;
  100975. }
  100976. }
  100977. declare module BABYLON {
  100978. /**
  100979. * Defines the types of pose enabled controllers that are supported
  100980. */
  100981. export enum PoseEnabledControllerType {
  100982. /**
  100983. * HTC Vive
  100984. */
  100985. VIVE = 0,
  100986. /**
  100987. * Oculus Rift
  100988. */
  100989. OCULUS = 1,
  100990. /**
  100991. * Windows mixed reality
  100992. */
  100993. WINDOWS = 2,
  100994. /**
  100995. * Samsung gear VR
  100996. */
  100997. GEAR_VR = 3,
  100998. /**
  100999. * Google Daydream
  101000. */
  101001. DAYDREAM = 4,
  101002. /**
  101003. * Generic
  101004. */
  101005. GENERIC = 5
  101006. }
  101007. /**
  101008. * Defines the MutableGamepadButton interface for the state of a gamepad button
  101009. */
  101010. export interface MutableGamepadButton {
  101011. /**
  101012. * Value of the button/trigger
  101013. */
  101014. value: number;
  101015. /**
  101016. * If the button/trigger is currently touched
  101017. */
  101018. touched: boolean;
  101019. /**
  101020. * If the button/trigger is currently pressed
  101021. */
  101022. pressed: boolean;
  101023. }
  101024. /**
  101025. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  101026. * @hidden
  101027. */
  101028. export interface ExtendedGamepadButton extends GamepadButton {
  101029. /**
  101030. * If the button/trigger is currently pressed
  101031. */
  101032. readonly pressed: boolean;
  101033. /**
  101034. * If the button/trigger is currently touched
  101035. */
  101036. readonly touched: boolean;
  101037. /**
  101038. * Value of the button/trigger
  101039. */
  101040. readonly value: number;
  101041. }
  101042. /** @hidden */
  101043. export interface _GamePadFactory {
  101044. /**
  101045. * Returns whether or not the current gamepad can be created for this type of controller.
  101046. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  101047. * @returns true if it can be created, otherwise false
  101048. */
  101049. canCreate(gamepadInfo: any): boolean;
  101050. /**
  101051. * Creates a new instance of the Gamepad.
  101052. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  101053. * @returns the new gamepad instance
  101054. */
  101055. create(gamepadInfo: any): Gamepad;
  101056. }
  101057. /**
  101058. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  101059. */
  101060. export class PoseEnabledControllerHelper {
  101061. /** @hidden */
  101062. static _ControllerFactories: _GamePadFactory[];
  101063. /** @hidden */
  101064. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  101065. /**
  101066. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  101067. * @param vrGamepad the gamepad to initialized
  101068. * @returns a vr controller of the type the gamepad identified as
  101069. */
  101070. static InitiateController(vrGamepad: any): Gamepad;
  101071. }
  101072. /**
  101073. * Defines the PoseEnabledController object that contains state of a vr capable controller
  101074. */
  101075. export class PoseEnabledController extends Gamepad implements PoseControlled {
  101076. /**
  101077. * If the controller is used in a webXR session
  101078. */
  101079. isXR: boolean;
  101080. private _deviceRoomPosition;
  101081. private _deviceRoomRotationQuaternion;
  101082. /**
  101083. * The device position in babylon space
  101084. */
  101085. devicePosition: Vector3;
  101086. /**
  101087. * The device rotation in babylon space
  101088. */
  101089. deviceRotationQuaternion: Quaternion;
  101090. /**
  101091. * The scale factor of the device in babylon space
  101092. */
  101093. deviceScaleFactor: number;
  101094. /**
  101095. * (Likely devicePosition should be used instead) The device position in its room space
  101096. */
  101097. position: Vector3;
  101098. /**
  101099. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  101100. */
  101101. rotationQuaternion: Quaternion;
  101102. /**
  101103. * The type of controller (Eg. Windows mixed reality)
  101104. */
  101105. controllerType: PoseEnabledControllerType;
  101106. protected _calculatedPosition: Vector3;
  101107. private _calculatedRotation;
  101108. /**
  101109. * The raw pose from the device
  101110. */
  101111. rawPose: DevicePose;
  101112. private _trackPosition;
  101113. private _maxRotationDistFromHeadset;
  101114. private _draggedRoomRotation;
  101115. /**
  101116. * @hidden
  101117. */
  101118. _disableTrackPosition(fixedPosition: Vector3): void;
  101119. /**
  101120. * Internal, the mesh attached to the controller
  101121. * @hidden
  101122. */
  101123. _mesh: Nullable<AbstractMesh>;
  101124. private _poseControlledCamera;
  101125. private _leftHandSystemQuaternion;
  101126. /**
  101127. * Internal, matrix used to convert room space to babylon space
  101128. * @hidden
  101129. */
  101130. _deviceToWorld: Matrix;
  101131. /**
  101132. * Node to be used when casting a ray from the controller
  101133. * @hidden
  101134. */
  101135. _pointingPoseNode: Nullable<TransformNode>;
  101136. /**
  101137. * Name of the child mesh that can be used to cast a ray from the controller
  101138. */
  101139. static readonly POINTING_POSE: string;
  101140. /**
  101141. * Creates a new PoseEnabledController from a gamepad
  101142. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  101143. */
  101144. constructor(browserGamepad: any);
  101145. private _workingMatrix;
  101146. /**
  101147. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  101148. */
  101149. update(): void;
  101150. /**
  101151. * Updates only the pose device and mesh without doing any button event checking
  101152. */
  101153. protected _updatePoseAndMesh(): void;
  101154. /**
  101155. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  101156. * @param poseData raw pose fromthe device
  101157. */
  101158. updateFromDevice(poseData: DevicePose): void;
  101159. /**
  101160. * @hidden
  101161. */
  101162. _meshAttachedObservable: Observable<AbstractMesh>;
  101163. /**
  101164. * Attaches a mesh to the controller
  101165. * @param mesh the mesh to be attached
  101166. */
  101167. attachToMesh(mesh: AbstractMesh): void;
  101168. /**
  101169. * Attaches the controllers mesh to a camera
  101170. * @param camera the camera the mesh should be attached to
  101171. */
  101172. attachToPoseControlledCamera(camera: TargetCamera): void;
  101173. /**
  101174. * Disposes of the controller
  101175. */
  101176. dispose(): void;
  101177. /**
  101178. * The mesh that is attached to the controller
  101179. */
  101180. get mesh(): Nullable<AbstractMesh>;
  101181. /**
  101182. * Gets the ray of the controller in the direction the controller is pointing
  101183. * @param length the length the resulting ray should be
  101184. * @returns a ray in the direction the controller is pointing
  101185. */
  101186. getForwardRay(length?: number): Ray;
  101187. }
  101188. }
  101189. declare module BABYLON {
  101190. /**
  101191. * Defines the WebVRController object that represents controllers tracked in 3D space
  101192. */
  101193. export abstract class WebVRController extends PoseEnabledController {
  101194. /**
  101195. * Internal, the default controller model for the controller
  101196. */
  101197. protected _defaultModel: Nullable<AbstractMesh>;
  101198. /**
  101199. * Fired when the trigger state has changed
  101200. */
  101201. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101202. /**
  101203. * Fired when the main button state has changed
  101204. */
  101205. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101206. /**
  101207. * Fired when the secondary button state has changed
  101208. */
  101209. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101210. /**
  101211. * Fired when the pad state has changed
  101212. */
  101213. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  101214. /**
  101215. * Fired when controllers stick values have changed
  101216. */
  101217. onPadValuesChangedObservable: Observable<StickValues>;
  101218. /**
  101219. * Array of button availible on the controller
  101220. */
  101221. protected _buttons: Array<MutableGamepadButton>;
  101222. private _onButtonStateChange;
  101223. /**
  101224. * Fired when a controller button's state has changed
  101225. * @param callback the callback containing the button that was modified
  101226. */
  101227. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  101228. /**
  101229. * X and Y axis corresponding to the controllers joystick
  101230. */
  101231. pad: StickValues;
  101232. /**
  101233. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  101234. */
  101235. hand: string;
  101236. /**
  101237. * The default controller model for the controller
  101238. */
  101239. get defaultModel(): Nullable<AbstractMesh>;
  101240. /**
  101241. * Creates a new WebVRController from a gamepad
  101242. * @param vrGamepad the gamepad that the WebVRController should be created from
  101243. */
  101244. constructor(vrGamepad: any);
  101245. /**
  101246. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  101247. */
  101248. update(): void;
  101249. /**
  101250. * Function to be called when a button is modified
  101251. */
  101252. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101253. /**
  101254. * Loads a mesh and attaches it to the controller
  101255. * @param scene the scene the mesh should be added to
  101256. * @param meshLoaded callback for when the mesh has been loaded
  101257. */
  101258. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101259. private _setButtonValue;
  101260. private _changes;
  101261. private _checkChanges;
  101262. /**
  101263. * Disposes of th webVRCOntroller
  101264. */
  101265. dispose(): void;
  101266. }
  101267. }
  101268. declare module BABYLON {
  101269. /**
  101270. * The HemisphericLight simulates the ambient environment light,
  101271. * so the passed direction is the light reflection direction, not the incoming direction.
  101272. */
  101273. export class HemisphericLight extends Light {
  101274. /**
  101275. * The groundColor is the light in the opposite direction to the one specified during creation.
  101276. * 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.
  101277. */
  101278. groundColor: Color3;
  101279. /**
  101280. * The light reflection direction, not the incoming direction.
  101281. */
  101282. direction: Vector3;
  101283. /**
  101284. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  101285. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  101286. * The HemisphericLight can't cast shadows.
  101287. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101288. * @param name The friendly name of the light
  101289. * @param direction The direction of the light reflection
  101290. * @param scene The scene the light belongs to
  101291. */
  101292. constructor(name: string, direction: Vector3, scene: Scene);
  101293. protected _buildUniformLayout(): void;
  101294. /**
  101295. * Returns the string "HemisphericLight".
  101296. * @return The class name
  101297. */
  101298. getClassName(): string;
  101299. /**
  101300. * Sets the HemisphericLight direction towards the passed target (Vector3).
  101301. * Returns the updated direction.
  101302. * @param target The target the direction should point to
  101303. * @return The computed direction
  101304. */
  101305. setDirectionToTarget(target: Vector3): Vector3;
  101306. /**
  101307. * Returns the shadow generator associated to the light.
  101308. * @returns Always null for hemispheric lights because it does not support shadows.
  101309. */
  101310. getShadowGenerator(): Nullable<IShadowGenerator>;
  101311. /**
  101312. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  101313. * @param effect The effect to update
  101314. * @param lightIndex The index of the light in the effect to update
  101315. * @returns The hemispheric light
  101316. */
  101317. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  101318. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  101319. /**
  101320. * Computes the world matrix of the node
  101321. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101322. * @param useWasUpdatedFlag defines a reserved property
  101323. * @returns the world matrix
  101324. */
  101325. computeWorldMatrix(): Matrix;
  101326. /**
  101327. * Returns the integer 3.
  101328. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101329. */
  101330. getTypeID(): number;
  101331. /**
  101332. * Prepares the list of defines specific to the light type.
  101333. * @param defines the list of defines
  101334. * @param lightIndex defines the index of the light for the effect
  101335. */
  101336. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101337. }
  101338. }
  101339. declare module BABYLON {
  101340. /** @hidden */
  101341. export var vrMultiviewToSingleviewPixelShader: {
  101342. name: string;
  101343. shader: string;
  101344. };
  101345. }
  101346. declare module BABYLON {
  101347. /**
  101348. * Renders to multiple views with a single draw call
  101349. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  101350. */
  101351. export class MultiviewRenderTarget extends RenderTargetTexture {
  101352. /**
  101353. * Creates a multiview render target
  101354. * @param scene scene used with the render target
  101355. * @param size the size of the render target (used for each view)
  101356. */
  101357. constructor(scene: Scene, size?: number | {
  101358. width: number;
  101359. height: number;
  101360. } | {
  101361. ratio: number;
  101362. });
  101363. /**
  101364. * @hidden
  101365. * @param faceIndex the face index, if its a cube texture
  101366. */
  101367. _bindFrameBuffer(faceIndex?: number): void;
  101368. /**
  101369. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101370. * @returns the view count
  101371. */
  101372. getViewCount(): number;
  101373. }
  101374. }
  101375. declare module BABYLON {
  101376. interface Engine {
  101377. /**
  101378. * Creates a new multiview render target
  101379. * @param width defines the width of the texture
  101380. * @param height defines the height of the texture
  101381. * @returns the created multiview texture
  101382. */
  101383. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  101384. /**
  101385. * Binds a multiview framebuffer to be drawn to
  101386. * @param multiviewTexture texture to bind
  101387. */
  101388. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  101389. }
  101390. interface Camera {
  101391. /**
  101392. * @hidden
  101393. * 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)
  101394. */
  101395. _useMultiviewToSingleView: boolean;
  101396. /**
  101397. * @hidden
  101398. * 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)
  101399. */
  101400. _multiviewTexture: Nullable<RenderTargetTexture>;
  101401. /**
  101402. * @hidden
  101403. * ensures the multiview texture of the camera exists and has the specified width/height
  101404. * @param width height to set on the multiview texture
  101405. * @param height width to set on the multiview texture
  101406. */
  101407. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  101408. }
  101409. interface Scene {
  101410. /** @hidden */
  101411. _transformMatrixR: Matrix;
  101412. /** @hidden */
  101413. _multiviewSceneUbo: Nullable<UniformBuffer>;
  101414. /** @hidden */
  101415. _createMultiviewUbo(): void;
  101416. /** @hidden */
  101417. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  101418. /** @hidden */
  101419. _renderMultiviewToSingleView(camera: Camera): void;
  101420. }
  101421. }
  101422. declare module BABYLON {
  101423. /**
  101424. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  101425. * This will not be used for webXR as it supports displaying texture arrays directly
  101426. */
  101427. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  101428. /**
  101429. * Gets a string identifying the name of the class
  101430. * @returns "VRMultiviewToSingleviewPostProcess" string
  101431. */
  101432. getClassName(): string;
  101433. /**
  101434. * Initializes a VRMultiviewToSingleview
  101435. * @param name name of the post process
  101436. * @param camera camera to be applied to
  101437. * @param scaleFactor scaling factor to the size of the output texture
  101438. */
  101439. constructor(name: string, camera: Camera, scaleFactor: number);
  101440. }
  101441. }
  101442. declare module BABYLON {
  101443. /**
  101444. * Interface used to define additional presentation attributes
  101445. */
  101446. export interface IVRPresentationAttributes {
  101447. /**
  101448. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  101449. */
  101450. highRefreshRate: boolean;
  101451. /**
  101452. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  101453. */
  101454. foveationLevel: number;
  101455. }
  101456. interface Engine {
  101457. /** @hidden */
  101458. _vrDisplay: any;
  101459. /** @hidden */
  101460. _vrSupported: boolean;
  101461. /** @hidden */
  101462. _oldSize: Size;
  101463. /** @hidden */
  101464. _oldHardwareScaleFactor: number;
  101465. /** @hidden */
  101466. _vrExclusivePointerMode: boolean;
  101467. /** @hidden */
  101468. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  101469. /** @hidden */
  101470. _onVRDisplayPointerRestricted: () => void;
  101471. /** @hidden */
  101472. _onVRDisplayPointerUnrestricted: () => void;
  101473. /** @hidden */
  101474. _onVrDisplayConnect: Nullable<(display: any) => void>;
  101475. /** @hidden */
  101476. _onVrDisplayDisconnect: Nullable<() => void>;
  101477. /** @hidden */
  101478. _onVrDisplayPresentChange: Nullable<() => void>;
  101479. /**
  101480. * Observable signaled when VR display mode changes
  101481. */
  101482. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  101483. /**
  101484. * Observable signaled when VR request present is complete
  101485. */
  101486. onVRRequestPresentComplete: Observable<boolean>;
  101487. /**
  101488. * Observable signaled when VR request present starts
  101489. */
  101490. onVRRequestPresentStart: Observable<Engine>;
  101491. /**
  101492. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  101493. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  101494. */
  101495. isInVRExclusivePointerMode: boolean;
  101496. /**
  101497. * Gets a boolean indicating if a webVR device was detected
  101498. * @returns true if a webVR device was detected
  101499. */
  101500. isVRDevicePresent(): boolean;
  101501. /**
  101502. * Gets the current webVR device
  101503. * @returns the current webVR device (or null)
  101504. */
  101505. getVRDevice(): any;
  101506. /**
  101507. * Initializes a webVR display and starts listening to display change events
  101508. * The onVRDisplayChangedObservable will be notified upon these changes
  101509. * @returns A promise containing a VRDisplay and if vr is supported
  101510. */
  101511. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  101512. /** @hidden */
  101513. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  101514. /**
  101515. * Gets or sets the presentation attributes used to configure VR rendering
  101516. */
  101517. vrPresentationAttributes?: IVRPresentationAttributes;
  101518. /**
  101519. * Call this function to switch to webVR mode
  101520. * Will do nothing if webVR is not supported or if there is no webVR device
  101521. * @param options the webvr options provided to the camera. mainly used for multiview
  101522. * @see https://doc.babylonjs.com/how_to/webvr_camera
  101523. */
  101524. enableVR(options: WebVROptions): void;
  101525. /** @hidden */
  101526. _onVRFullScreenTriggered(): void;
  101527. }
  101528. }
  101529. declare module BABYLON {
  101530. /**
  101531. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  101532. * IMPORTANT!! The data is right-hand data.
  101533. * @export
  101534. * @interface DevicePose
  101535. */
  101536. export interface DevicePose {
  101537. /**
  101538. * The position of the device, values in array are [x,y,z].
  101539. */
  101540. readonly position: Nullable<Float32Array>;
  101541. /**
  101542. * The linearVelocity of the device, values in array are [x,y,z].
  101543. */
  101544. readonly linearVelocity: Nullable<Float32Array>;
  101545. /**
  101546. * The linearAcceleration of the device, values in array are [x,y,z].
  101547. */
  101548. readonly linearAcceleration: Nullable<Float32Array>;
  101549. /**
  101550. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  101551. */
  101552. readonly orientation: Nullable<Float32Array>;
  101553. /**
  101554. * The angularVelocity of the device, values in array are [x,y,z].
  101555. */
  101556. readonly angularVelocity: Nullable<Float32Array>;
  101557. /**
  101558. * The angularAcceleration of the device, values in array are [x,y,z].
  101559. */
  101560. readonly angularAcceleration: Nullable<Float32Array>;
  101561. }
  101562. /**
  101563. * Interface representing a pose controlled object in Babylon.
  101564. * A pose controlled object has both regular pose values as well as pose values
  101565. * from an external device such as a VR head mounted display
  101566. */
  101567. export interface PoseControlled {
  101568. /**
  101569. * The position of the object in babylon space.
  101570. */
  101571. position: Vector3;
  101572. /**
  101573. * The rotation quaternion of the object in babylon space.
  101574. */
  101575. rotationQuaternion: Quaternion;
  101576. /**
  101577. * The position of the device in babylon space.
  101578. */
  101579. devicePosition?: Vector3;
  101580. /**
  101581. * The rotation quaternion of the device in babylon space.
  101582. */
  101583. deviceRotationQuaternion: Quaternion;
  101584. /**
  101585. * The raw pose coming from the device.
  101586. */
  101587. rawPose: Nullable<DevicePose>;
  101588. /**
  101589. * The scale of the device to be used when translating from device space to babylon space.
  101590. */
  101591. deviceScaleFactor: number;
  101592. /**
  101593. * Updates the poseControlled values based on the input device pose.
  101594. * @param poseData the pose data to update the object with
  101595. */
  101596. updateFromDevice(poseData: DevicePose): void;
  101597. }
  101598. /**
  101599. * Set of options to customize the webVRCamera
  101600. */
  101601. export interface WebVROptions {
  101602. /**
  101603. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  101604. */
  101605. trackPosition?: boolean;
  101606. /**
  101607. * Sets the scale of the vrDevice in babylon space. (default: 1)
  101608. */
  101609. positionScale?: number;
  101610. /**
  101611. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  101612. */
  101613. displayName?: string;
  101614. /**
  101615. * Should the native controller meshes be initialized. (default: true)
  101616. */
  101617. controllerMeshes?: boolean;
  101618. /**
  101619. * Creating a default HemiLight only on controllers. (default: true)
  101620. */
  101621. defaultLightingOnControllers?: boolean;
  101622. /**
  101623. * If you don't want to use the default VR button of the helper. (default: false)
  101624. */
  101625. useCustomVRButton?: boolean;
  101626. /**
  101627. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  101628. */
  101629. customVRButton?: HTMLButtonElement;
  101630. /**
  101631. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  101632. */
  101633. rayLength?: number;
  101634. /**
  101635. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  101636. */
  101637. defaultHeight?: number;
  101638. /**
  101639. * If multiview should be used if availible (default: false)
  101640. */
  101641. useMultiview?: boolean;
  101642. }
  101643. /**
  101644. * This represents a WebVR camera.
  101645. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  101646. * @example https://doc.babylonjs.com/how_to/webvr_camera
  101647. */
  101648. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  101649. private webVROptions;
  101650. /**
  101651. * @hidden
  101652. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  101653. */
  101654. _vrDevice: any;
  101655. /**
  101656. * The rawPose of the vrDevice.
  101657. */
  101658. rawPose: Nullable<DevicePose>;
  101659. private _onVREnabled;
  101660. private _specsVersion;
  101661. private _attached;
  101662. private _frameData;
  101663. protected _descendants: Array<Node>;
  101664. private _deviceRoomPosition;
  101665. /** @hidden */
  101666. _deviceRoomRotationQuaternion: Quaternion;
  101667. private _standingMatrix;
  101668. /**
  101669. * Represents device position in babylon space.
  101670. */
  101671. devicePosition: Vector3;
  101672. /**
  101673. * Represents device rotation in babylon space.
  101674. */
  101675. deviceRotationQuaternion: Quaternion;
  101676. /**
  101677. * The scale of the device to be used when translating from device space to babylon space.
  101678. */
  101679. deviceScaleFactor: number;
  101680. private _deviceToWorld;
  101681. private _worldToDevice;
  101682. /**
  101683. * References to the webVR controllers for the vrDevice.
  101684. */
  101685. controllers: Array<WebVRController>;
  101686. /**
  101687. * Emits an event when a controller is attached.
  101688. */
  101689. onControllersAttachedObservable: Observable<WebVRController[]>;
  101690. /**
  101691. * Emits an event when a controller's mesh has been loaded;
  101692. */
  101693. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101694. /**
  101695. * Emits an event when the HMD's pose has been updated.
  101696. */
  101697. onPoseUpdatedFromDeviceObservable: Observable<any>;
  101698. private _poseSet;
  101699. /**
  101700. * If the rig cameras be used as parent instead of this camera.
  101701. */
  101702. rigParenting: boolean;
  101703. private _lightOnControllers;
  101704. private _defaultHeight?;
  101705. /**
  101706. * Instantiates a WebVRFreeCamera.
  101707. * @param name The name of the WebVRFreeCamera
  101708. * @param position The starting anchor position for the camera
  101709. * @param scene The scene the camera belongs to
  101710. * @param webVROptions a set of customizable options for the webVRCamera
  101711. */
  101712. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  101713. /**
  101714. * Gets the device distance from the ground in meters.
  101715. * @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.
  101716. */
  101717. deviceDistanceToRoomGround(): number;
  101718. /**
  101719. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101720. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  101721. */
  101722. useStandingMatrix(callback?: (bool: boolean) => void): void;
  101723. /**
  101724. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101725. * @returns A promise with a boolean set to if the standing matrix is supported.
  101726. */
  101727. useStandingMatrixAsync(): Promise<boolean>;
  101728. /**
  101729. * Disposes the camera
  101730. */
  101731. dispose(): void;
  101732. /**
  101733. * Gets a vrController by name.
  101734. * @param name The name of the controller to retreive
  101735. * @returns the controller matching the name specified or null if not found
  101736. */
  101737. getControllerByName(name: string): Nullable<WebVRController>;
  101738. private _leftController;
  101739. /**
  101740. * The controller corresponding to the users left hand.
  101741. */
  101742. get leftController(): Nullable<WebVRController>;
  101743. private _rightController;
  101744. /**
  101745. * The controller corresponding to the users right hand.
  101746. */
  101747. get rightController(): Nullable<WebVRController>;
  101748. /**
  101749. * Casts a ray forward from the vrCamera's gaze.
  101750. * @param length Length of the ray (default: 100)
  101751. * @returns the ray corresponding to the gaze
  101752. */
  101753. getForwardRay(length?: number): Ray;
  101754. /**
  101755. * @hidden
  101756. * Updates the camera based on device's frame data
  101757. */
  101758. _checkInputs(): void;
  101759. /**
  101760. * Updates the poseControlled values based on the input device pose.
  101761. * @param poseData Pose coming from the device
  101762. */
  101763. updateFromDevice(poseData: DevicePose): void;
  101764. private _detachIfAttached;
  101765. /**
  101766. * WebVR's attach control will start broadcasting frames to the device.
  101767. * Note that in certain browsers (chrome for example) this function must be called
  101768. * within a user-interaction callback. Example:
  101769. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101770. *
  101771. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101772. */
  101773. attachControl(noPreventDefault?: boolean): void;
  101774. /**
  101775. * Detach the current controls from the specified dom element.
  101776. */
  101777. detachControl(): void;
  101778. /**
  101779. * @returns the name of this class
  101780. */
  101781. getClassName(): string;
  101782. /**
  101783. * Calls resetPose on the vrDisplay
  101784. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101785. */
  101786. resetToCurrentRotation(): void;
  101787. /**
  101788. * @hidden
  101789. * Updates the rig cameras (left and right eye)
  101790. */
  101791. _updateRigCameras(): void;
  101792. private _workingVector;
  101793. private _oneVector;
  101794. private _workingMatrix;
  101795. private updateCacheCalled;
  101796. private _correctPositionIfNotTrackPosition;
  101797. /**
  101798. * @hidden
  101799. * Updates the cached values of the camera
  101800. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101801. */
  101802. _updateCache(ignoreParentClass?: boolean): void;
  101803. /**
  101804. * @hidden
  101805. * Get current device position in babylon world
  101806. */
  101807. _computeDevicePosition(): void;
  101808. /**
  101809. * Updates the current device position and rotation in the babylon world
  101810. */
  101811. update(): void;
  101812. /**
  101813. * @hidden
  101814. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101815. * @returns an identity matrix
  101816. */
  101817. _getViewMatrix(): Matrix;
  101818. private _tmpMatrix;
  101819. /**
  101820. * This function is called by the two RIG cameras.
  101821. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101822. * @hidden
  101823. */
  101824. _getWebVRViewMatrix(): Matrix;
  101825. /** @hidden */
  101826. _getWebVRProjectionMatrix(): Matrix;
  101827. private _onGamepadConnectedObserver;
  101828. private _onGamepadDisconnectedObserver;
  101829. private _updateCacheWhenTrackingDisabledObserver;
  101830. /**
  101831. * Initializes the controllers and their meshes
  101832. */
  101833. initControllers(): void;
  101834. }
  101835. }
  101836. declare module BABYLON {
  101837. /**
  101838. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101839. *
  101840. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101841. *
  101842. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101843. */
  101844. export class MaterialHelper {
  101845. /**
  101846. * Bind the current view position to an effect.
  101847. * @param effect The effect to be bound
  101848. * @param scene The scene the eyes position is used from
  101849. * @param variableName name of the shader variable that will hold the eye position
  101850. */
  101851. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101852. /**
  101853. * Helps preparing the defines values about the UVs in used in the effect.
  101854. * UVs are shared as much as we can accross channels in the shaders.
  101855. * @param texture The texture we are preparing the UVs for
  101856. * @param defines The defines to update
  101857. * @param key The channel key "diffuse", "specular"... used in the shader
  101858. */
  101859. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101860. /**
  101861. * Binds a texture matrix value to its corrsponding uniform
  101862. * @param texture The texture to bind the matrix for
  101863. * @param uniformBuffer The uniform buffer receivin the data
  101864. * @param key The channel key "diffuse", "specular"... used in the shader
  101865. */
  101866. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101867. /**
  101868. * Gets the current status of the fog (should it be enabled?)
  101869. * @param mesh defines the mesh to evaluate for fog support
  101870. * @param scene defines the hosting scene
  101871. * @returns true if fog must be enabled
  101872. */
  101873. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101874. /**
  101875. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101876. * @param mesh defines the current mesh
  101877. * @param scene defines the current scene
  101878. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101879. * @param pointsCloud defines if point cloud rendering has to be turned on
  101880. * @param fogEnabled defines if fog has to be turned on
  101881. * @param alphaTest defines if alpha testing has to be turned on
  101882. * @param defines defines the current list of defines
  101883. */
  101884. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101885. /**
  101886. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101887. * @param scene defines the current scene
  101888. * @param engine defines the current engine
  101889. * @param defines specifies the list of active defines
  101890. * @param useInstances defines if instances have to be turned on
  101891. * @param useClipPlane defines if clip plane have to be turned on
  101892. * @param useInstances defines if instances have to be turned on
  101893. * @param useThinInstances defines if thin instances have to be turned on
  101894. */
  101895. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101896. /**
  101897. * Prepares the defines for bones
  101898. * @param mesh The mesh containing the geometry data we will draw
  101899. * @param defines The defines to update
  101900. */
  101901. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101902. /**
  101903. * Prepares the defines for morph targets
  101904. * @param mesh The mesh containing the geometry data we will draw
  101905. * @param defines The defines to update
  101906. */
  101907. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101908. /**
  101909. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101910. * @param mesh The mesh containing the geometry data we will draw
  101911. * @param defines The defines to update
  101912. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101913. * @param useBones Precise whether bones should be used or not (override mesh info)
  101914. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101915. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101916. * @returns false if defines are considered not dirty and have not been checked
  101917. */
  101918. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101919. /**
  101920. * Prepares the defines related to multiview
  101921. * @param scene The scene we are intending to draw
  101922. * @param defines The defines to update
  101923. */
  101924. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101925. /**
  101926. * Prepares the defines related to the prepass
  101927. * @param scene The scene we are intending to draw
  101928. * @param defines The defines to update
  101929. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101930. */
  101931. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101932. /**
  101933. * Prepares the defines related to the light information passed in parameter
  101934. * @param scene The scene we are intending to draw
  101935. * @param mesh The mesh the effect is compiling for
  101936. * @param light The light the effect is compiling for
  101937. * @param lightIndex The index of the light
  101938. * @param defines The defines to update
  101939. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101940. * @param state Defines the current state regarding what is needed (normals, etc...)
  101941. */
  101942. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101943. needNormals: boolean;
  101944. needRebuild: boolean;
  101945. shadowEnabled: boolean;
  101946. specularEnabled: boolean;
  101947. lightmapMode: boolean;
  101948. }): void;
  101949. /**
  101950. * Prepares the defines related to the light information passed in parameter
  101951. * @param scene The scene we are intending to draw
  101952. * @param mesh The mesh the effect is compiling for
  101953. * @param defines The defines to update
  101954. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101955. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101956. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101957. * @returns true if normals will be required for the rest of the effect
  101958. */
  101959. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101960. /**
  101961. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101962. * @param lightIndex defines the light index
  101963. * @param uniformsList The uniform list
  101964. * @param samplersList The sampler list
  101965. * @param projectedLightTexture defines if projected texture must be used
  101966. * @param uniformBuffersList defines an optional list of uniform buffers
  101967. */
  101968. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101969. /**
  101970. * Prepares the uniforms and samplers list to be used in the effect
  101971. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101972. * @param samplersList The sampler list
  101973. * @param defines The defines helping in the list generation
  101974. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101975. */
  101976. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101977. /**
  101978. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101979. * @param defines The defines to update while falling back
  101980. * @param fallbacks The authorized effect fallbacks
  101981. * @param maxSimultaneousLights The maximum number of lights allowed
  101982. * @param rank the current rank of the Effect
  101983. * @returns The newly affected rank
  101984. */
  101985. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101986. private static _TmpMorphInfluencers;
  101987. /**
  101988. * Prepares the list of attributes required for morph targets according to the effect defines.
  101989. * @param attribs The current list of supported attribs
  101990. * @param mesh The mesh to prepare the morph targets attributes for
  101991. * @param influencers The number of influencers
  101992. */
  101993. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101994. /**
  101995. * Prepares the list of attributes required for morph targets according to the effect defines.
  101996. * @param attribs The current list of supported attribs
  101997. * @param mesh The mesh to prepare the morph targets attributes for
  101998. * @param defines The current Defines of the effect
  101999. */
  102000. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  102001. /**
  102002. * Prepares the list of attributes required for bones according to the effect defines.
  102003. * @param attribs The current list of supported attribs
  102004. * @param mesh The mesh to prepare the bones attributes for
  102005. * @param defines The current Defines of the effect
  102006. * @param fallbacks The current efffect fallback strategy
  102007. */
  102008. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  102009. /**
  102010. * Check and prepare the list of attributes required for instances according to the effect defines.
  102011. * @param attribs The current list of supported attribs
  102012. * @param defines The current MaterialDefines of the effect
  102013. */
  102014. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  102015. /**
  102016. * Add the list of attributes required for instances to the attribs array.
  102017. * @param attribs The current list of supported attribs
  102018. */
  102019. static PushAttributesForInstances(attribs: string[]): void;
  102020. /**
  102021. * Binds the light information to the effect.
  102022. * @param light The light containing the generator
  102023. * @param effect The effect we are binding the data to
  102024. * @param lightIndex The light index in the effect used to render
  102025. */
  102026. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  102027. /**
  102028. * Binds the lights information from the scene to the effect for the given mesh.
  102029. * @param light Light to bind
  102030. * @param lightIndex Light index
  102031. * @param scene The scene where the light belongs to
  102032. * @param effect The effect we are binding the data to
  102033. * @param useSpecular Defines if specular is supported
  102034. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  102035. */
  102036. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  102037. /**
  102038. * Binds the lights information from the scene to the effect for the given mesh.
  102039. * @param scene The scene the lights belongs to
  102040. * @param mesh The mesh we are binding the information to render
  102041. * @param effect The effect we are binding the data to
  102042. * @param defines The generated defines for the effect
  102043. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  102044. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  102045. */
  102046. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  102047. private static _tempFogColor;
  102048. /**
  102049. * Binds the fog information from the scene to the effect for the given mesh.
  102050. * @param scene The scene the lights belongs to
  102051. * @param mesh The mesh we are binding the information to render
  102052. * @param effect The effect we are binding the data to
  102053. * @param linearSpace Defines if the fog effect is applied in linear space
  102054. */
  102055. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  102056. /**
  102057. * Binds the bones information from the mesh to the effect.
  102058. * @param mesh The mesh we are binding the information to render
  102059. * @param effect The effect we are binding the data to
  102060. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  102061. */
  102062. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  102063. private static _CopyBonesTransformationMatrices;
  102064. /**
  102065. * Binds the morph targets information from the mesh to the effect.
  102066. * @param abstractMesh The mesh we are binding the information to render
  102067. * @param effect The effect we are binding the data to
  102068. */
  102069. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  102070. /**
  102071. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  102072. * @param defines The generated defines used in the effect
  102073. * @param effect The effect we are binding the data to
  102074. * @param scene The scene we are willing to render with logarithmic scale for
  102075. */
  102076. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  102077. /**
  102078. * Binds the clip plane information from the scene to the effect.
  102079. * @param scene The scene the clip plane information are extracted from
  102080. * @param effect The effect we are binding the data to
  102081. */
  102082. static BindClipPlane(effect: Effect, scene: Scene): void;
  102083. }
  102084. }
  102085. declare module BABYLON {
  102086. /**
  102087. * Block used to expose an input value
  102088. */
  102089. export class InputBlock extends NodeMaterialBlock {
  102090. private _mode;
  102091. private _associatedVariableName;
  102092. private _storedValue;
  102093. private _valueCallback;
  102094. private _type;
  102095. private _animationType;
  102096. /** Gets or set a value used to limit the range of float values */
  102097. min: number;
  102098. /** Gets or set a value used to limit the range of float values */
  102099. max: number;
  102100. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  102101. isBoolean: boolean;
  102102. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  102103. matrixMode: number;
  102104. /** @hidden */
  102105. _systemValue: Nullable<NodeMaterialSystemValues>;
  102106. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  102107. isConstant: boolean;
  102108. /** Gets or sets the group to use to display this block in the Inspector */
  102109. groupInInspector: string;
  102110. /** Gets an observable raised when the value is changed */
  102111. onValueChangedObservable: Observable<InputBlock>;
  102112. /**
  102113. * Gets or sets the connection point type (default is float)
  102114. */
  102115. get type(): NodeMaterialBlockConnectionPointTypes;
  102116. /**
  102117. * Creates a new InputBlock
  102118. * @param name defines the block name
  102119. * @param target defines the target of that block (Vertex by default)
  102120. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  102121. */
  102122. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  102123. /**
  102124. * Validates if a name is a reserve word.
  102125. * @param newName the new name to be given to the node.
  102126. * @returns false if the name is a reserve word, else true.
  102127. */
  102128. validateBlockName(newName: string): boolean;
  102129. /**
  102130. * Gets the output component
  102131. */
  102132. get output(): NodeMaterialConnectionPoint;
  102133. /**
  102134. * Set the source of this connection point to a vertex attribute
  102135. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  102136. * @returns the current connection point
  102137. */
  102138. setAsAttribute(attributeName?: string): InputBlock;
  102139. /**
  102140. * Set the source of this connection point to a system value
  102141. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  102142. * @returns the current connection point
  102143. */
  102144. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  102145. /**
  102146. * Gets or sets the value of that point.
  102147. * Please note that this value will be ignored if valueCallback is defined
  102148. */
  102149. get value(): any;
  102150. set value(value: any);
  102151. /**
  102152. * Gets or sets a callback used to get the value of that point.
  102153. * Please note that setting this value will force the connection point to ignore the value property
  102154. */
  102155. get valueCallback(): () => any;
  102156. set valueCallback(value: () => any);
  102157. /**
  102158. * Gets or sets the associated variable name in the shader
  102159. */
  102160. get associatedVariableName(): string;
  102161. set associatedVariableName(value: string);
  102162. /** Gets or sets the type of animation applied to the input */
  102163. get animationType(): AnimatedInputBlockTypes;
  102164. set animationType(value: AnimatedInputBlockTypes);
  102165. /**
  102166. * Gets a boolean indicating that this connection point not defined yet
  102167. */
  102168. get isUndefined(): boolean;
  102169. /**
  102170. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  102171. * In this case the connection point name must be the name of the uniform to use.
  102172. * Can only be set on inputs
  102173. */
  102174. get isUniform(): boolean;
  102175. set isUniform(value: boolean);
  102176. /**
  102177. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  102178. * In this case the connection point name must be the name of the attribute to use
  102179. * Can only be set on inputs
  102180. */
  102181. get isAttribute(): boolean;
  102182. set isAttribute(value: boolean);
  102183. /**
  102184. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  102185. * Can only be set on exit points
  102186. */
  102187. get isVarying(): boolean;
  102188. set isVarying(value: boolean);
  102189. /**
  102190. * Gets a boolean indicating that the current connection point is a system value
  102191. */
  102192. get isSystemValue(): boolean;
  102193. /**
  102194. * Gets or sets the current well known value or null if not defined as a system value
  102195. */
  102196. get systemValue(): Nullable<NodeMaterialSystemValues>;
  102197. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  102198. /**
  102199. * Gets the current class name
  102200. * @returns the class name
  102201. */
  102202. getClassName(): string;
  102203. /**
  102204. * Animate the input if animationType !== None
  102205. * @param scene defines the rendering scene
  102206. */
  102207. animate(scene: Scene): void;
  102208. private _emitDefine;
  102209. initialize(state: NodeMaterialBuildState): void;
  102210. /**
  102211. * Set the input block to its default value (based on its type)
  102212. */
  102213. setDefaultValue(): void;
  102214. private _emitConstant;
  102215. /** @hidden */
  102216. get _noContextSwitch(): boolean;
  102217. private _emit;
  102218. /** @hidden */
  102219. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  102220. /** @hidden */
  102221. _transmit(effect: Effect, scene: Scene): void;
  102222. protected _buildBlock(state: NodeMaterialBuildState): void;
  102223. protected _dumpPropertiesCode(): string;
  102224. dispose(): void;
  102225. serialize(): any;
  102226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102227. }
  102228. }
  102229. declare module BABYLON {
  102230. /**
  102231. * Enum used to define the compatibility state between two connection points
  102232. */
  102233. export enum NodeMaterialConnectionPointCompatibilityStates {
  102234. /** Points are compatibles */
  102235. Compatible = 0,
  102236. /** Points are incompatible because of their types */
  102237. TypeIncompatible = 1,
  102238. /** Points are incompatible because of their targets (vertex vs fragment) */
  102239. TargetIncompatible = 2
  102240. }
  102241. /**
  102242. * Defines the direction of a connection point
  102243. */
  102244. export enum NodeMaterialConnectionPointDirection {
  102245. /** Input */
  102246. Input = 0,
  102247. /** Output */
  102248. Output = 1
  102249. }
  102250. /**
  102251. * Defines a connection point for a block
  102252. */
  102253. export class NodeMaterialConnectionPoint {
  102254. /**
  102255. * Checks if two types are equivalent
  102256. * @param type1 type 1 to check
  102257. * @param type2 type 2 to check
  102258. * @returns true if both types are equivalent, else false
  102259. */
  102260. static AreEquivalentTypes(type1: number, type2: number): boolean;
  102261. /** @hidden */
  102262. _ownerBlock: NodeMaterialBlock;
  102263. /** @hidden */
  102264. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  102265. private _endpoints;
  102266. private _associatedVariableName;
  102267. private _direction;
  102268. /** @hidden */
  102269. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102270. /** @hidden */
  102271. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102272. /** @hidden */
  102273. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  102274. private _type;
  102275. /** @hidden */
  102276. _enforceAssociatedVariableName: boolean;
  102277. /** Gets the direction of the point */
  102278. get direction(): NodeMaterialConnectionPointDirection;
  102279. /** Indicates that this connection point needs dual validation before being connected to another point */
  102280. needDualDirectionValidation: boolean;
  102281. /**
  102282. * Gets or sets the additional types supported by this connection point
  102283. */
  102284. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102285. /**
  102286. * Gets or sets the additional types excluded by this connection point
  102287. */
  102288. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102289. /**
  102290. * Observable triggered when this point is connected
  102291. */
  102292. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  102293. /**
  102294. * Gets or sets the associated variable name in the shader
  102295. */
  102296. get associatedVariableName(): string;
  102297. set associatedVariableName(value: string);
  102298. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  102299. get innerType(): NodeMaterialBlockConnectionPointTypes;
  102300. /**
  102301. * Gets or sets the connection point type (default is float)
  102302. */
  102303. get type(): NodeMaterialBlockConnectionPointTypes;
  102304. set type(value: NodeMaterialBlockConnectionPointTypes);
  102305. /**
  102306. * Gets or sets the connection point name
  102307. */
  102308. name: string;
  102309. /**
  102310. * Gets or sets the connection point name
  102311. */
  102312. displayName: string;
  102313. /**
  102314. * Gets or sets a boolean indicating that this connection point can be omitted
  102315. */
  102316. isOptional: boolean;
  102317. /**
  102318. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  102319. */
  102320. isExposedOnFrame: boolean;
  102321. /**
  102322. * Gets or sets number indicating the position that the port is exposed to on a frame
  102323. */
  102324. exposedPortPosition: number;
  102325. /**
  102326. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  102327. */
  102328. define: string;
  102329. /** @hidden */
  102330. _prioritizeVertex: boolean;
  102331. private _target;
  102332. /** Gets or sets the target of that connection point */
  102333. get target(): NodeMaterialBlockTargets;
  102334. set target(value: NodeMaterialBlockTargets);
  102335. /**
  102336. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  102337. */
  102338. get isConnected(): boolean;
  102339. /**
  102340. * Gets a boolean indicating that the current point is connected to an input block
  102341. */
  102342. get isConnectedToInputBlock(): boolean;
  102343. /**
  102344. * Gets a the connected input block (if any)
  102345. */
  102346. get connectInputBlock(): Nullable<InputBlock>;
  102347. /** Get the other side of the connection (if any) */
  102348. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  102349. /** Get the block that owns this connection point */
  102350. get ownerBlock(): NodeMaterialBlock;
  102351. /** Get the block connected on the other side of this connection (if any) */
  102352. get sourceBlock(): Nullable<NodeMaterialBlock>;
  102353. /** Get the block connected on the endpoints of this connection (if any) */
  102354. get connectedBlocks(): Array<NodeMaterialBlock>;
  102355. /** Gets the list of connected endpoints */
  102356. get endpoints(): NodeMaterialConnectionPoint[];
  102357. /** Gets a boolean indicating if that output point is connected to at least one input */
  102358. get hasEndpoints(): boolean;
  102359. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  102360. get isConnectedInVertexShader(): boolean;
  102361. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  102362. get isConnectedInFragmentShader(): boolean;
  102363. /**
  102364. * Creates a block suitable to be used as an input for this input point.
  102365. * If null is returned, a block based on the point type will be created.
  102366. * @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
  102367. */
  102368. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102369. /**
  102370. * Creates a new connection point
  102371. * @param name defines the connection point name
  102372. * @param ownerBlock defines the block hosting this connection point
  102373. * @param direction defines the direction of the connection point
  102374. */
  102375. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  102376. /**
  102377. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  102378. * @returns the class name
  102379. */
  102380. getClassName(): string;
  102381. /**
  102382. * Gets a boolean indicating if the current point can be connected to another point
  102383. * @param connectionPoint defines the other connection point
  102384. * @returns a boolean
  102385. */
  102386. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  102387. /**
  102388. * Gets a number indicating if the current point can be connected to another point
  102389. * @param connectionPoint defines the other connection point
  102390. * @returns a number defining the compatibility state
  102391. */
  102392. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102393. /**
  102394. * Connect this point to another connection point
  102395. * @param connectionPoint defines the other connection point
  102396. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  102397. * @returns the current connection point
  102398. */
  102399. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  102400. /**
  102401. * Disconnect this point from one of his endpoint
  102402. * @param endpoint defines the other connection point
  102403. * @returns the current connection point
  102404. */
  102405. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  102406. /**
  102407. * Serializes this point in a JSON representation
  102408. * @param isInput defines if the connection point is an input (default is true)
  102409. * @returns the serialized point object
  102410. */
  102411. serialize(isInput?: boolean): any;
  102412. /**
  102413. * Release resources
  102414. */
  102415. dispose(): void;
  102416. }
  102417. }
  102418. declare module BABYLON {
  102419. /**
  102420. * Enum used to define the material modes
  102421. */
  102422. export enum NodeMaterialModes {
  102423. /** Regular material */
  102424. Material = 0,
  102425. /** For post process */
  102426. PostProcess = 1,
  102427. /** For particle system */
  102428. Particle = 2,
  102429. /** For procedural texture */
  102430. ProceduralTexture = 3
  102431. }
  102432. }
  102433. declare module BABYLON {
  102434. /**
  102435. * Block used to read a texture from a sampler
  102436. */
  102437. export class TextureBlock extends NodeMaterialBlock {
  102438. private _defineName;
  102439. private _linearDefineName;
  102440. private _gammaDefineName;
  102441. private _tempTextureRead;
  102442. private _samplerName;
  102443. private _transformedUVName;
  102444. private _textureTransformName;
  102445. private _textureInfoName;
  102446. private _mainUVName;
  102447. private _mainUVDefineName;
  102448. private _fragmentOnly;
  102449. /**
  102450. * Gets or sets the texture associated with the node
  102451. */
  102452. texture: Nullable<Texture>;
  102453. /**
  102454. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102455. */
  102456. convertToGammaSpace: boolean;
  102457. /**
  102458. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102459. */
  102460. convertToLinearSpace: boolean;
  102461. /**
  102462. * Create a new TextureBlock
  102463. * @param name defines the block name
  102464. */
  102465. constructor(name: string, fragmentOnly?: boolean);
  102466. /**
  102467. * Gets the current class name
  102468. * @returns the class name
  102469. */
  102470. getClassName(): string;
  102471. /**
  102472. * Gets the uv input component
  102473. */
  102474. get uv(): NodeMaterialConnectionPoint;
  102475. /**
  102476. * Gets the rgba output component
  102477. */
  102478. get rgba(): NodeMaterialConnectionPoint;
  102479. /**
  102480. * Gets the rgb output component
  102481. */
  102482. get rgb(): NodeMaterialConnectionPoint;
  102483. /**
  102484. * Gets the r output component
  102485. */
  102486. get r(): NodeMaterialConnectionPoint;
  102487. /**
  102488. * Gets the g output component
  102489. */
  102490. get g(): NodeMaterialConnectionPoint;
  102491. /**
  102492. * Gets the b output component
  102493. */
  102494. get b(): NodeMaterialConnectionPoint;
  102495. /**
  102496. * Gets the a output component
  102497. */
  102498. get a(): NodeMaterialConnectionPoint;
  102499. get target(): NodeMaterialBlockTargets;
  102500. autoConfigure(material: NodeMaterial): void;
  102501. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102503. isReady(): boolean;
  102504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102505. private get _isMixed();
  102506. private _injectVertexCode;
  102507. private _writeTextureRead;
  102508. private _writeOutput;
  102509. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102510. protected _dumpPropertiesCode(): string;
  102511. serialize(): any;
  102512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102513. }
  102514. }
  102515. declare module BABYLON {
  102516. /** @hidden */
  102517. export var reflectionFunction: {
  102518. name: string;
  102519. shader: string;
  102520. };
  102521. }
  102522. declare module BABYLON {
  102523. /**
  102524. * Base block used to read a reflection texture from a sampler
  102525. */
  102526. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  102527. /** @hidden */
  102528. _define3DName: string;
  102529. /** @hidden */
  102530. _defineCubicName: string;
  102531. /** @hidden */
  102532. _defineExplicitName: string;
  102533. /** @hidden */
  102534. _defineProjectionName: string;
  102535. /** @hidden */
  102536. _defineLocalCubicName: string;
  102537. /** @hidden */
  102538. _defineSphericalName: string;
  102539. /** @hidden */
  102540. _definePlanarName: string;
  102541. /** @hidden */
  102542. _defineEquirectangularName: string;
  102543. /** @hidden */
  102544. _defineMirroredEquirectangularFixedName: string;
  102545. /** @hidden */
  102546. _defineEquirectangularFixedName: string;
  102547. /** @hidden */
  102548. _defineSkyboxName: string;
  102549. /** @hidden */
  102550. _defineOppositeZ: string;
  102551. /** @hidden */
  102552. _cubeSamplerName: string;
  102553. /** @hidden */
  102554. _2DSamplerName: string;
  102555. protected _positionUVWName: string;
  102556. protected _directionWName: string;
  102557. protected _reflectionVectorName: string;
  102558. /** @hidden */
  102559. _reflectionCoordsName: string;
  102560. /** @hidden */
  102561. _reflectionMatrixName: string;
  102562. protected _reflectionColorName: string;
  102563. /**
  102564. * Gets or sets the texture associated with the node
  102565. */
  102566. texture: Nullable<BaseTexture>;
  102567. /**
  102568. * Create a new ReflectionTextureBaseBlock
  102569. * @param name defines the block name
  102570. */
  102571. constructor(name: string);
  102572. /**
  102573. * Gets the current class name
  102574. * @returns the class name
  102575. */
  102576. getClassName(): string;
  102577. /**
  102578. * Gets the world position input component
  102579. */
  102580. abstract get position(): NodeMaterialConnectionPoint;
  102581. /**
  102582. * Gets the world position input component
  102583. */
  102584. abstract get worldPosition(): NodeMaterialConnectionPoint;
  102585. /**
  102586. * Gets the world normal input component
  102587. */
  102588. abstract get worldNormal(): NodeMaterialConnectionPoint;
  102589. /**
  102590. * Gets the world input component
  102591. */
  102592. abstract get world(): NodeMaterialConnectionPoint;
  102593. /**
  102594. * Gets the camera (or eye) position component
  102595. */
  102596. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  102597. /**
  102598. * Gets the view input component
  102599. */
  102600. abstract get view(): NodeMaterialConnectionPoint;
  102601. protected _getTexture(): Nullable<BaseTexture>;
  102602. autoConfigure(material: NodeMaterial): void;
  102603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102604. isReady(): boolean;
  102605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102606. /**
  102607. * Gets the code to inject in the vertex shader
  102608. * @param state current state of the node material building
  102609. * @returns the shader code
  102610. */
  102611. handleVertexSide(state: NodeMaterialBuildState): string;
  102612. /**
  102613. * Handles the inits for the fragment code path
  102614. * @param state node material build state
  102615. */
  102616. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  102617. /**
  102618. * Generates the reflection coords code for the fragment code path
  102619. * @param worldNormalVarName name of the world normal variable
  102620. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  102621. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  102622. * @returns the shader code
  102623. */
  102624. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  102625. /**
  102626. * Generates the reflection color code for the fragment code path
  102627. * @param lodVarName name of the lod variable
  102628. * @param swizzleLookupTexture swizzle to use for the final color variable
  102629. * @returns the shader code
  102630. */
  102631. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  102632. /**
  102633. * Generates the code corresponding to the connected output points
  102634. * @param state node material build state
  102635. * @param varName name of the variable to output
  102636. * @returns the shader code
  102637. */
  102638. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  102639. protected _buildBlock(state: NodeMaterialBuildState): this;
  102640. protected _dumpPropertiesCode(): string;
  102641. serialize(): any;
  102642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102643. }
  102644. }
  102645. declare module BABYLON {
  102646. /**
  102647. * Defines a connection point to be used for points with a custom object type
  102648. */
  102649. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  102650. private _blockType;
  102651. private _blockName;
  102652. private _nameForCheking?;
  102653. /**
  102654. * Creates a new connection point
  102655. * @param name defines the connection point name
  102656. * @param ownerBlock defines the block hosting this connection point
  102657. * @param direction defines the direction of the connection point
  102658. */
  102659. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  102660. /**
  102661. * Gets a number indicating if the current point can be connected to another point
  102662. * @param connectionPoint defines the other connection point
  102663. * @returns a number defining the compatibility state
  102664. */
  102665. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102666. /**
  102667. * Creates a block suitable to be used as an input for this input point.
  102668. * If null is returned, a block based on the point type will be created.
  102669. * @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
  102670. */
  102671. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102672. }
  102673. }
  102674. declare module BABYLON {
  102675. /**
  102676. * Enum defining the type of properties that can be edited in the property pages in the NME
  102677. */
  102678. export enum PropertyTypeForEdition {
  102679. /** property is a boolean */
  102680. Boolean = 0,
  102681. /** property is a float */
  102682. Float = 1,
  102683. /** property is a Vector2 */
  102684. Vector2 = 2,
  102685. /** property is a list of values */
  102686. List = 3
  102687. }
  102688. /**
  102689. * Interface that defines an option in a variable of type list
  102690. */
  102691. export interface IEditablePropertyListOption {
  102692. /** label of the option */
  102693. "label": string;
  102694. /** value of the option */
  102695. "value": number;
  102696. }
  102697. /**
  102698. * Interface that defines the options available for an editable property
  102699. */
  102700. export interface IEditablePropertyOption {
  102701. /** min value */
  102702. "min"?: number;
  102703. /** max value */
  102704. "max"?: number;
  102705. /** notifiers: indicates which actions to take when the property is changed */
  102706. "notifiers"?: {
  102707. /** the material should be rebuilt */
  102708. "rebuild"?: boolean;
  102709. /** the preview should be updated */
  102710. "update"?: boolean;
  102711. };
  102712. /** list of the options for a variable of type list */
  102713. "options"?: IEditablePropertyListOption[];
  102714. }
  102715. /**
  102716. * Interface that describes an editable property
  102717. */
  102718. export interface IPropertyDescriptionForEdition {
  102719. /** name of the property */
  102720. "propertyName": string;
  102721. /** display name of the property */
  102722. "displayName": string;
  102723. /** type of the property */
  102724. "type": PropertyTypeForEdition;
  102725. /** group of the property - all properties with the same group value will be displayed in a specific section */
  102726. "groupName": string;
  102727. /** options for the property */
  102728. "options": IEditablePropertyOption;
  102729. }
  102730. /**
  102731. * Decorator that flags a property in a node material block as being editable
  102732. */
  102733. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102734. }
  102735. declare module BABYLON {
  102736. /**
  102737. * Block used to implement the refraction part of the sub surface module of the PBR material
  102738. */
  102739. export class RefractionBlock extends NodeMaterialBlock {
  102740. /** @hidden */
  102741. _define3DName: string;
  102742. /** @hidden */
  102743. _refractionMatrixName: string;
  102744. /** @hidden */
  102745. _defineLODRefractionAlpha: string;
  102746. /** @hidden */
  102747. _defineLinearSpecularRefraction: string;
  102748. /** @hidden */
  102749. _defineOppositeZ: string;
  102750. /** @hidden */
  102751. _cubeSamplerName: string;
  102752. /** @hidden */
  102753. _2DSamplerName: string;
  102754. /** @hidden */
  102755. _vRefractionMicrosurfaceInfosName: string;
  102756. /** @hidden */
  102757. _vRefractionInfosName: string;
  102758. private _scene;
  102759. /**
  102760. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102761. * Materials half opaque for instance using refraction could benefit from this control.
  102762. */
  102763. linkRefractionWithTransparency: boolean;
  102764. /**
  102765. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102766. */
  102767. invertRefractionY: boolean;
  102768. /**
  102769. * Gets or sets the texture associated with the node
  102770. */
  102771. texture: Nullable<BaseTexture>;
  102772. /**
  102773. * Create a new RefractionBlock
  102774. * @param name defines the block name
  102775. */
  102776. constructor(name: string);
  102777. /**
  102778. * Gets the current class name
  102779. * @returns the class name
  102780. */
  102781. getClassName(): string;
  102782. /**
  102783. * Gets the intensity input component
  102784. */
  102785. get intensity(): NodeMaterialConnectionPoint;
  102786. /**
  102787. * Gets the index of refraction input component
  102788. */
  102789. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102790. /**
  102791. * Gets the tint at distance input component
  102792. */
  102793. get tintAtDistance(): NodeMaterialConnectionPoint;
  102794. /**
  102795. * Gets the view input component
  102796. */
  102797. get view(): NodeMaterialConnectionPoint;
  102798. /**
  102799. * Gets the refraction object output component
  102800. */
  102801. get refraction(): NodeMaterialConnectionPoint;
  102802. /**
  102803. * Returns true if the block has a texture
  102804. */
  102805. get hasTexture(): boolean;
  102806. protected _getTexture(): Nullable<BaseTexture>;
  102807. autoConfigure(material: NodeMaterial): void;
  102808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102809. isReady(): boolean;
  102810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102811. /**
  102812. * Gets the main code of the block (fragment side)
  102813. * @param state current state of the node material building
  102814. * @returns the shader code
  102815. */
  102816. getCode(state: NodeMaterialBuildState): string;
  102817. protected _buildBlock(state: NodeMaterialBuildState): this;
  102818. protected _dumpPropertiesCode(): string;
  102819. serialize(): any;
  102820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102821. }
  102822. }
  102823. declare module BABYLON {
  102824. /**
  102825. * Base block used as input for post process
  102826. */
  102827. export class CurrentScreenBlock extends NodeMaterialBlock {
  102828. private _samplerName;
  102829. private _linearDefineName;
  102830. private _gammaDefineName;
  102831. private _mainUVName;
  102832. private _tempTextureRead;
  102833. /**
  102834. * Gets or sets the texture associated with the node
  102835. */
  102836. texture: Nullable<BaseTexture>;
  102837. /**
  102838. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102839. */
  102840. convertToGammaSpace: boolean;
  102841. /**
  102842. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102843. */
  102844. convertToLinearSpace: boolean;
  102845. /**
  102846. * Create a new CurrentScreenBlock
  102847. * @param name defines the block name
  102848. */
  102849. constructor(name: string);
  102850. /**
  102851. * Gets the current class name
  102852. * @returns the class name
  102853. */
  102854. getClassName(): string;
  102855. /**
  102856. * Gets the uv input component
  102857. */
  102858. get uv(): NodeMaterialConnectionPoint;
  102859. /**
  102860. * Gets the rgba output component
  102861. */
  102862. get rgba(): NodeMaterialConnectionPoint;
  102863. /**
  102864. * Gets the rgb output component
  102865. */
  102866. get rgb(): NodeMaterialConnectionPoint;
  102867. /**
  102868. * Gets the r output component
  102869. */
  102870. get r(): NodeMaterialConnectionPoint;
  102871. /**
  102872. * Gets the g output component
  102873. */
  102874. get g(): NodeMaterialConnectionPoint;
  102875. /**
  102876. * Gets the b output component
  102877. */
  102878. get b(): NodeMaterialConnectionPoint;
  102879. /**
  102880. * Gets the a output component
  102881. */
  102882. get a(): NodeMaterialConnectionPoint;
  102883. /**
  102884. * Initialize the block and prepare the context for build
  102885. * @param state defines the state that will be used for the build
  102886. */
  102887. initialize(state: NodeMaterialBuildState): void;
  102888. get target(): NodeMaterialBlockTargets;
  102889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102890. isReady(): boolean;
  102891. private _injectVertexCode;
  102892. private _writeTextureRead;
  102893. private _writeOutput;
  102894. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102895. serialize(): any;
  102896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102897. }
  102898. }
  102899. declare module BABYLON {
  102900. /**
  102901. * Base block used for the particle texture
  102902. */
  102903. export class ParticleTextureBlock extends NodeMaterialBlock {
  102904. private _samplerName;
  102905. private _linearDefineName;
  102906. private _gammaDefineName;
  102907. private _tempTextureRead;
  102908. /**
  102909. * Gets or sets the texture associated with the node
  102910. */
  102911. texture: Nullable<BaseTexture>;
  102912. /**
  102913. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102914. */
  102915. convertToGammaSpace: boolean;
  102916. /**
  102917. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102918. */
  102919. convertToLinearSpace: boolean;
  102920. /**
  102921. * Create a new ParticleTextureBlock
  102922. * @param name defines the block name
  102923. */
  102924. constructor(name: string);
  102925. /**
  102926. * Gets the current class name
  102927. * @returns the class name
  102928. */
  102929. getClassName(): string;
  102930. /**
  102931. * Gets the uv input component
  102932. */
  102933. get uv(): NodeMaterialConnectionPoint;
  102934. /**
  102935. * Gets the rgba output component
  102936. */
  102937. get rgba(): NodeMaterialConnectionPoint;
  102938. /**
  102939. * Gets the rgb output component
  102940. */
  102941. get rgb(): NodeMaterialConnectionPoint;
  102942. /**
  102943. * Gets the r output component
  102944. */
  102945. get r(): NodeMaterialConnectionPoint;
  102946. /**
  102947. * Gets the g output component
  102948. */
  102949. get g(): NodeMaterialConnectionPoint;
  102950. /**
  102951. * Gets the b output component
  102952. */
  102953. get b(): NodeMaterialConnectionPoint;
  102954. /**
  102955. * Gets the a output component
  102956. */
  102957. get a(): NodeMaterialConnectionPoint;
  102958. /**
  102959. * Initialize the block and prepare the context for build
  102960. * @param state defines the state that will be used for the build
  102961. */
  102962. initialize(state: NodeMaterialBuildState): void;
  102963. autoConfigure(material: NodeMaterial): void;
  102964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102965. isReady(): boolean;
  102966. private _writeOutput;
  102967. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102968. serialize(): any;
  102969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102970. }
  102971. }
  102972. declare module BABYLON {
  102973. /**
  102974. * Class used to store shared data between 2 NodeMaterialBuildState
  102975. */
  102976. export class NodeMaterialBuildStateSharedData {
  102977. /**
  102978. * Gets the list of emitted varyings
  102979. */
  102980. temps: string[];
  102981. /**
  102982. * Gets the list of emitted varyings
  102983. */
  102984. varyings: string[];
  102985. /**
  102986. * Gets the varying declaration string
  102987. */
  102988. varyingDeclaration: string;
  102989. /**
  102990. * Input blocks
  102991. */
  102992. inputBlocks: InputBlock[];
  102993. /**
  102994. * Input blocks
  102995. */
  102996. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102997. /**
  102998. * Bindable blocks (Blocks that need to set data to the effect)
  102999. */
  103000. bindableBlocks: NodeMaterialBlock[];
  103001. /**
  103002. * List of blocks that can provide a compilation fallback
  103003. */
  103004. blocksWithFallbacks: NodeMaterialBlock[];
  103005. /**
  103006. * List of blocks that can provide a define update
  103007. */
  103008. blocksWithDefines: NodeMaterialBlock[];
  103009. /**
  103010. * List of blocks that can provide a repeatable content
  103011. */
  103012. repeatableContentBlocks: NodeMaterialBlock[];
  103013. /**
  103014. * List of blocks that can provide a dynamic list of uniforms
  103015. */
  103016. dynamicUniformBlocks: NodeMaterialBlock[];
  103017. /**
  103018. * List of blocks that can block the isReady function for the material
  103019. */
  103020. blockingBlocks: NodeMaterialBlock[];
  103021. /**
  103022. * Gets the list of animated inputs
  103023. */
  103024. animatedInputs: InputBlock[];
  103025. /**
  103026. * Build Id used to avoid multiple recompilations
  103027. */
  103028. buildId: number;
  103029. /** List of emitted variables */
  103030. variableNames: {
  103031. [key: string]: number;
  103032. };
  103033. /** List of emitted defines */
  103034. defineNames: {
  103035. [key: string]: number;
  103036. };
  103037. /** Should emit comments? */
  103038. emitComments: boolean;
  103039. /** Emit build activity */
  103040. verbose: boolean;
  103041. /** Gets or sets the hosting scene */
  103042. scene: Scene;
  103043. /**
  103044. * Gets the compilation hints emitted at compilation time
  103045. */
  103046. hints: {
  103047. needWorldViewMatrix: boolean;
  103048. needWorldViewProjectionMatrix: boolean;
  103049. needAlphaBlending: boolean;
  103050. needAlphaTesting: boolean;
  103051. };
  103052. /**
  103053. * List of compilation checks
  103054. */
  103055. checks: {
  103056. emitVertex: boolean;
  103057. emitFragment: boolean;
  103058. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  103059. };
  103060. /**
  103061. * Is vertex program allowed to be empty?
  103062. */
  103063. allowEmptyVertexProgram: boolean;
  103064. /** Creates a new shared data */
  103065. constructor();
  103066. /**
  103067. * Emits console errors and exceptions if there is a failing check
  103068. */
  103069. emitErrors(): void;
  103070. }
  103071. }
  103072. declare module BABYLON {
  103073. /**
  103074. * Class used to store node based material build state
  103075. */
  103076. export class NodeMaterialBuildState {
  103077. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  103078. supportUniformBuffers: boolean;
  103079. /**
  103080. * Gets the list of emitted attributes
  103081. */
  103082. attributes: string[];
  103083. /**
  103084. * Gets the list of emitted uniforms
  103085. */
  103086. uniforms: string[];
  103087. /**
  103088. * Gets the list of emitted constants
  103089. */
  103090. constants: string[];
  103091. /**
  103092. * Gets the list of emitted samplers
  103093. */
  103094. samplers: string[];
  103095. /**
  103096. * Gets the list of emitted functions
  103097. */
  103098. functions: {
  103099. [key: string]: string;
  103100. };
  103101. /**
  103102. * Gets the list of emitted extensions
  103103. */
  103104. extensions: {
  103105. [key: string]: string;
  103106. };
  103107. /**
  103108. * Gets the target of the compilation state
  103109. */
  103110. target: NodeMaterialBlockTargets;
  103111. /**
  103112. * Gets the list of emitted counters
  103113. */
  103114. counters: {
  103115. [key: string]: number;
  103116. };
  103117. /**
  103118. * Shared data between multiple NodeMaterialBuildState instances
  103119. */
  103120. sharedData: NodeMaterialBuildStateSharedData;
  103121. /** @hidden */
  103122. _vertexState: NodeMaterialBuildState;
  103123. /** @hidden */
  103124. _attributeDeclaration: string;
  103125. /** @hidden */
  103126. _uniformDeclaration: string;
  103127. /** @hidden */
  103128. _constantDeclaration: string;
  103129. /** @hidden */
  103130. _samplerDeclaration: string;
  103131. /** @hidden */
  103132. _varyingTransfer: string;
  103133. /** @hidden */
  103134. _injectAtEnd: string;
  103135. private _repeatableContentAnchorIndex;
  103136. /** @hidden */
  103137. _builtCompilationString: string;
  103138. /**
  103139. * Gets the emitted compilation strings
  103140. */
  103141. compilationString: string;
  103142. /**
  103143. * Finalize the compilation strings
  103144. * @param state defines the current compilation state
  103145. */
  103146. finalize(state: NodeMaterialBuildState): void;
  103147. /** @hidden */
  103148. get _repeatableContentAnchor(): string;
  103149. /** @hidden */
  103150. _getFreeVariableName(prefix: string): string;
  103151. /** @hidden */
  103152. _getFreeDefineName(prefix: string): string;
  103153. /** @hidden */
  103154. _excludeVariableName(name: string): void;
  103155. /** @hidden */
  103156. _emit2DSampler(name: string): void;
  103157. /** @hidden */
  103158. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  103159. /** @hidden */
  103160. _emitExtension(name: string, extension: string, define?: string): void;
  103161. /** @hidden */
  103162. _emitFunction(name: string, code: string, comments: string): void;
  103163. /** @hidden */
  103164. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  103165. replaceStrings?: {
  103166. search: RegExp;
  103167. replace: string;
  103168. }[];
  103169. repeatKey?: string;
  103170. }): string;
  103171. /** @hidden */
  103172. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  103173. repeatKey?: string;
  103174. removeAttributes?: boolean;
  103175. removeUniforms?: boolean;
  103176. removeVaryings?: boolean;
  103177. removeIfDef?: boolean;
  103178. replaceStrings?: {
  103179. search: RegExp;
  103180. replace: string;
  103181. }[];
  103182. }, storeKey?: string): void;
  103183. /** @hidden */
  103184. _registerTempVariable(name: string): boolean;
  103185. /** @hidden */
  103186. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  103187. /** @hidden */
  103188. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  103189. /** @hidden */
  103190. _emitFloat(value: number): string;
  103191. }
  103192. }
  103193. declare module BABYLON {
  103194. /**
  103195. * Helper class used to generate session unique ID
  103196. */
  103197. export class UniqueIdGenerator {
  103198. private static _UniqueIdCounter;
  103199. /**
  103200. * Gets an unique (relatively to the current scene) Id
  103201. */
  103202. static get UniqueId(): number;
  103203. }
  103204. }
  103205. declare module BABYLON {
  103206. /**
  103207. * Defines a block that can be used inside a node based material
  103208. */
  103209. export class NodeMaterialBlock {
  103210. private _buildId;
  103211. private _buildTarget;
  103212. private _target;
  103213. private _isFinalMerger;
  103214. private _isInput;
  103215. private _name;
  103216. protected _isUnique: boolean;
  103217. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  103218. inputsAreExclusive: boolean;
  103219. /** @hidden */
  103220. _codeVariableName: string;
  103221. /** @hidden */
  103222. _inputs: NodeMaterialConnectionPoint[];
  103223. /** @hidden */
  103224. _outputs: NodeMaterialConnectionPoint[];
  103225. /** @hidden */
  103226. _preparationId: number;
  103227. /**
  103228. * Gets the name of the block
  103229. */
  103230. get name(): string;
  103231. /**
  103232. * Sets the name of the block. Will check if the name is valid.
  103233. */
  103234. set name(newName: string);
  103235. /**
  103236. * Gets or sets the unique id of the node
  103237. */
  103238. uniqueId: number;
  103239. /**
  103240. * Gets or sets the comments associated with this block
  103241. */
  103242. comments: string;
  103243. /**
  103244. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  103245. */
  103246. get isUnique(): boolean;
  103247. /**
  103248. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  103249. */
  103250. get isFinalMerger(): boolean;
  103251. /**
  103252. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  103253. */
  103254. get isInput(): boolean;
  103255. /**
  103256. * Gets or sets the build Id
  103257. */
  103258. get buildId(): number;
  103259. set buildId(value: number);
  103260. /**
  103261. * Gets or sets the target of the block
  103262. */
  103263. get target(): NodeMaterialBlockTargets;
  103264. set target(value: NodeMaterialBlockTargets);
  103265. /**
  103266. * Gets the list of input points
  103267. */
  103268. get inputs(): NodeMaterialConnectionPoint[];
  103269. /** Gets the list of output points */
  103270. get outputs(): NodeMaterialConnectionPoint[];
  103271. /**
  103272. * Find an input by its name
  103273. * @param name defines the name of the input to look for
  103274. * @returns the input or null if not found
  103275. */
  103276. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103277. /**
  103278. * Find an output by its name
  103279. * @param name defines the name of the outputto look for
  103280. * @returns the output or null if not found
  103281. */
  103282. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103283. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  103284. visibleInInspector: boolean;
  103285. /**
  103286. * Creates a new NodeMaterialBlock
  103287. * @param name defines the block name
  103288. * @param target defines the target of that block (Vertex by default)
  103289. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  103290. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  103291. */
  103292. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  103293. /**
  103294. * Initialize the block and prepare the context for build
  103295. * @param state defines the state that will be used for the build
  103296. */
  103297. initialize(state: NodeMaterialBuildState): void;
  103298. /**
  103299. * Bind data to effect. Will only be called for blocks with isBindable === true
  103300. * @param effect defines the effect to bind data to
  103301. * @param nodeMaterial defines the hosting NodeMaterial
  103302. * @param mesh defines the mesh that will be rendered
  103303. * @param subMesh defines the submesh that will be rendered
  103304. */
  103305. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  103306. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  103307. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  103308. protected _writeFloat(value: number): string;
  103309. /**
  103310. * Gets the current class name e.g. "NodeMaterialBlock"
  103311. * @returns the class name
  103312. */
  103313. getClassName(): string;
  103314. /**
  103315. * Register a new input. Must be called inside a block constructor
  103316. * @param name defines the connection point name
  103317. * @param type defines the connection point type
  103318. * @param isOptional defines a boolean indicating that this input can be omitted
  103319. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103320. * @param point an already created connection point. If not provided, create a new one
  103321. * @returns the current block
  103322. */
  103323. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103324. /**
  103325. * Register a new output. Must be called inside a block constructor
  103326. * @param name defines the connection point name
  103327. * @param type defines the connection point type
  103328. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103329. * @param point an already created connection point. If not provided, create a new one
  103330. * @returns the current block
  103331. */
  103332. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103333. /**
  103334. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  103335. * @param forOutput defines an optional connection point to check compatibility with
  103336. * @returns the first available input or null
  103337. */
  103338. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  103339. /**
  103340. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  103341. * @param forBlock defines an optional block to check compatibility with
  103342. * @returns the first available input or null
  103343. */
  103344. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  103345. /**
  103346. * Gets the sibling of the given output
  103347. * @param current defines the current output
  103348. * @returns the next output in the list or null
  103349. */
  103350. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  103351. /**
  103352. * Connect current block with another block
  103353. * @param other defines the block to connect with
  103354. * @param options define the various options to help pick the right connections
  103355. * @returns the current block
  103356. */
  103357. connectTo(other: NodeMaterialBlock, options?: {
  103358. input?: string;
  103359. output?: string;
  103360. outputSwizzle?: string;
  103361. }): this | undefined;
  103362. protected _buildBlock(state: NodeMaterialBuildState): void;
  103363. /**
  103364. * Add uniforms, samplers and uniform buffers at compilation time
  103365. * @param state defines the state to update
  103366. * @param nodeMaterial defines the node material requesting the update
  103367. * @param defines defines the material defines to update
  103368. * @param uniformBuffers defines the list of uniform buffer names
  103369. */
  103370. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  103371. /**
  103372. * Add potential fallbacks if shader compilation fails
  103373. * @param mesh defines the mesh to be rendered
  103374. * @param fallbacks defines the current prioritized list of fallbacks
  103375. */
  103376. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  103377. /**
  103378. * Initialize defines for shader compilation
  103379. * @param mesh defines the mesh to be rendered
  103380. * @param nodeMaterial defines the node material requesting the update
  103381. * @param defines defines the material defines to update
  103382. * @param useInstances specifies that instances should be used
  103383. */
  103384. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  103385. /**
  103386. * Update defines for shader compilation
  103387. * @param mesh defines the mesh to be rendered
  103388. * @param nodeMaterial defines the node material requesting the update
  103389. * @param defines defines the material defines to update
  103390. * @param useInstances specifies that instances should be used
  103391. * @param subMesh defines which submesh to render
  103392. */
  103393. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103394. /**
  103395. * Lets the block try to connect some inputs automatically
  103396. * @param material defines the hosting NodeMaterial
  103397. */
  103398. autoConfigure(material: NodeMaterial): void;
  103399. /**
  103400. * Function called when a block is declared as repeatable content generator
  103401. * @param vertexShaderState defines the current compilation state for the vertex shader
  103402. * @param fragmentShaderState defines the current compilation state for the fragment shader
  103403. * @param mesh defines the mesh to be rendered
  103404. * @param defines defines the material defines to update
  103405. */
  103406. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  103407. /**
  103408. * Checks if the block is ready
  103409. * @param mesh defines the mesh to be rendered
  103410. * @param nodeMaterial defines the node material requesting the update
  103411. * @param defines defines the material defines to update
  103412. * @param useInstances specifies that instances should be used
  103413. * @returns true if the block is ready
  103414. */
  103415. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  103416. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  103417. private _processBuild;
  103418. /**
  103419. * Validates the new name for the block node.
  103420. * @param newName the new name to be given to the node.
  103421. * @returns false if the name is a reserve word, else true.
  103422. */
  103423. validateBlockName(newName: string): boolean;
  103424. /**
  103425. * Compile the current node and generate the shader code
  103426. * @param state defines the current compilation state (uniforms, samplers, current string)
  103427. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  103428. * @returns true if already built
  103429. */
  103430. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  103431. protected _inputRename(name: string): string;
  103432. protected _outputRename(name: string): string;
  103433. protected _dumpPropertiesCode(): string;
  103434. /** @hidden */
  103435. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  103436. /** @hidden */
  103437. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  103438. /**
  103439. * Clone the current block to a new identical block
  103440. * @param scene defines the hosting scene
  103441. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103442. * @returns a copy of the current block
  103443. */
  103444. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  103445. /**
  103446. * Serializes this block in a JSON representation
  103447. * @returns the serialized block object
  103448. */
  103449. serialize(): any;
  103450. /** @hidden */
  103451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103452. private _deserializePortDisplayNamesAndExposedOnFrame;
  103453. /**
  103454. * Release resources
  103455. */
  103456. dispose(): void;
  103457. }
  103458. }
  103459. declare module BABYLON {
  103460. /**
  103461. * Base class of materials working in push mode in babylon JS
  103462. * @hidden
  103463. */
  103464. export class PushMaterial extends Material {
  103465. protected _activeEffect: Effect;
  103466. protected _normalMatrix: Matrix;
  103467. constructor(name: string, scene: Scene);
  103468. getEffect(): Effect;
  103469. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103470. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  103471. /**
  103472. * Binds the given world matrix to the active effect
  103473. *
  103474. * @param world the matrix to bind
  103475. */
  103476. bindOnlyWorldMatrix(world: Matrix): void;
  103477. /**
  103478. * Binds the given normal matrix to the active effect
  103479. *
  103480. * @param normalMatrix the matrix to bind
  103481. */
  103482. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103483. bind(world: Matrix, mesh?: Mesh): void;
  103484. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103485. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103486. }
  103487. }
  103488. declare module BABYLON {
  103489. /**
  103490. * Root class for all node material optimizers
  103491. */
  103492. export class NodeMaterialOptimizer {
  103493. /**
  103494. * Function used to optimize a NodeMaterial graph
  103495. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  103496. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  103497. */
  103498. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  103499. }
  103500. }
  103501. declare module BABYLON {
  103502. /**
  103503. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  103504. */
  103505. export class TransformBlock extends NodeMaterialBlock {
  103506. /**
  103507. * Defines the value to use to complement W value to transform it to a Vector4
  103508. */
  103509. complementW: number;
  103510. /**
  103511. * Defines the value to use to complement z value to transform it to a Vector4
  103512. */
  103513. complementZ: number;
  103514. /**
  103515. * Creates a new TransformBlock
  103516. * @param name defines the block name
  103517. */
  103518. constructor(name: string);
  103519. /**
  103520. * Gets the current class name
  103521. * @returns the class name
  103522. */
  103523. getClassName(): string;
  103524. /**
  103525. * Gets the vector input
  103526. */
  103527. get vector(): NodeMaterialConnectionPoint;
  103528. /**
  103529. * Gets the output component
  103530. */
  103531. get output(): NodeMaterialConnectionPoint;
  103532. /**
  103533. * Gets the xyz output component
  103534. */
  103535. get xyz(): NodeMaterialConnectionPoint;
  103536. /**
  103537. * Gets the matrix transform input
  103538. */
  103539. get transform(): NodeMaterialConnectionPoint;
  103540. protected _buildBlock(state: NodeMaterialBuildState): this;
  103541. /**
  103542. * Update defines for shader compilation
  103543. * @param mesh defines the mesh to be rendered
  103544. * @param nodeMaterial defines the node material requesting the update
  103545. * @param defines defines the material defines to update
  103546. * @param useInstances specifies that instances should be used
  103547. * @param subMesh defines which submesh to render
  103548. */
  103549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103550. serialize(): any;
  103551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103552. protected _dumpPropertiesCode(): string;
  103553. }
  103554. }
  103555. declare module BABYLON {
  103556. /**
  103557. * Block used to output the vertex position
  103558. */
  103559. export class VertexOutputBlock extends NodeMaterialBlock {
  103560. /**
  103561. * Creates a new VertexOutputBlock
  103562. * @param name defines the block name
  103563. */
  103564. constructor(name: string);
  103565. /**
  103566. * Gets the current class name
  103567. * @returns the class name
  103568. */
  103569. getClassName(): string;
  103570. /**
  103571. * Gets the vector input component
  103572. */
  103573. get vector(): NodeMaterialConnectionPoint;
  103574. protected _buildBlock(state: NodeMaterialBuildState): this;
  103575. }
  103576. }
  103577. declare module BABYLON {
  103578. /**
  103579. * Block used to output the final color
  103580. */
  103581. export class FragmentOutputBlock extends NodeMaterialBlock {
  103582. /**
  103583. * Create a new FragmentOutputBlock
  103584. * @param name defines the block name
  103585. */
  103586. constructor(name: string);
  103587. /**
  103588. * Gets the current class name
  103589. * @returns the class name
  103590. */
  103591. getClassName(): string;
  103592. /**
  103593. * Gets the rgba input component
  103594. */
  103595. get rgba(): NodeMaterialConnectionPoint;
  103596. /**
  103597. * Gets the rgb input component
  103598. */
  103599. get rgb(): NodeMaterialConnectionPoint;
  103600. /**
  103601. * Gets the a input component
  103602. */
  103603. get a(): NodeMaterialConnectionPoint;
  103604. protected _buildBlock(state: NodeMaterialBuildState): this;
  103605. }
  103606. }
  103607. declare module BABYLON {
  103608. /**
  103609. * Block used for the particle ramp gradient section
  103610. */
  103611. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  103612. /**
  103613. * Create a new ParticleRampGradientBlock
  103614. * @param name defines the block name
  103615. */
  103616. constructor(name: string);
  103617. /**
  103618. * Gets the current class name
  103619. * @returns the class name
  103620. */
  103621. getClassName(): string;
  103622. /**
  103623. * Gets the color input component
  103624. */
  103625. get color(): NodeMaterialConnectionPoint;
  103626. /**
  103627. * Gets the rampColor output component
  103628. */
  103629. get rampColor(): NodeMaterialConnectionPoint;
  103630. /**
  103631. * Initialize the block and prepare the context for build
  103632. * @param state defines the state that will be used for the build
  103633. */
  103634. initialize(state: NodeMaterialBuildState): void;
  103635. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103636. }
  103637. }
  103638. declare module BABYLON {
  103639. /**
  103640. * Block used for the particle blend multiply section
  103641. */
  103642. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  103643. /**
  103644. * Create a new ParticleBlendMultiplyBlock
  103645. * @param name defines the block name
  103646. */
  103647. constructor(name: string);
  103648. /**
  103649. * Gets the current class name
  103650. * @returns the class name
  103651. */
  103652. getClassName(): string;
  103653. /**
  103654. * Gets the color input component
  103655. */
  103656. get color(): NodeMaterialConnectionPoint;
  103657. /**
  103658. * Gets the alphaTexture input component
  103659. */
  103660. get alphaTexture(): NodeMaterialConnectionPoint;
  103661. /**
  103662. * Gets the alphaColor input component
  103663. */
  103664. get alphaColor(): NodeMaterialConnectionPoint;
  103665. /**
  103666. * Gets the blendColor output component
  103667. */
  103668. get blendColor(): NodeMaterialConnectionPoint;
  103669. /**
  103670. * Initialize the block and prepare the context for build
  103671. * @param state defines the state that will be used for the build
  103672. */
  103673. initialize(state: NodeMaterialBuildState): void;
  103674. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103675. }
  103676. }
  103677. declare module BABYLON {
  103678. /**
  103679. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  103680. */
  103681. export class VectorMergerBlock extends NodeMaterialBlock {
  103682. /**
  103683. * Create a new VectorMergerBlock
  103684. * @param name defines the block name
  103685. */
  103686. constructor(name: string);
  103687. /**
  103688. * Gets the current class name
  103689. * @returns the class name
  103690. */
  103691. getClassName(): string;
  103692. /**
  103693. * Gets the xyz component (input)
  103694. */
  103695. get xyzIn(): NodeMaterialConnectionPoint;
  103696. /**
  103697. * Gets the xy component (input)
  103698. */
  103699. get xyIn(): NodeMaterialConnectionPoint;
  103700. /**
  103701. * Gets the x component (input)
  103702. */
  103703. get x(): NodeMaterialConnectionPoint;
  103704. /**
  103705. * Gets the y component (input)
  103706. */
  103707. get y(): NodeMaterialConnectionPoint;
  103708. /**
  103709. * Gets the z component (input)
  103710. */
  103711. get z(): NodeMaterialConnectionPoint;
  103712. /**
  103713. * Gets the w component (input)
  103714. */
  103715. get w(): NodeMaterialConnectionPoint;
  103716. /**
  103717. * Gets the xyzw component (output)
  103718. */
  103719. get xyzw(): NodeMaterialConnectionPoint;
  103720. /**
  103721. * Gets the xyz component (output)
  103722. */
  103723. get xyzOut(): NodeMaterialConnectionPoint;
  103724. /**
  103725. * Gets the xy component (output)
  103726. */
  103727. get xyOut(): NodeMaterialConnectionPoint;
  103728. /**
  103729. * Gets the xy component (output)
  103730. * @deprecated Please use xyOut instead.
  103731. */
  103732. get xy(): NodeMaterialConnectionPoint;
  103733. /**
  103734. * Gets the xyz component (output)
  103735. * @deprecated Please use xyzOut instead.
  103736. */
  103737. get xyz(): NodeMaterialConnectionPoint;
  103738. protected _buildBlock(state: NodeMaterialBuildState): this;
  103739. }
  103740. }
  103741. declare module BABYLON {
  103742. /**
  103743. * Block used to remap a float from a range to a new one
  103744. */
  103745. export class RemapBlock extends NodeMaterialBlock {
  103746. /**
  103747. * Gets or sets the source range
  103748. */
  103749. sourceRange: Vector2;
  103750. /**
  103751. * Gets or sets the target range
  103752. */
  103753. targetRange: Vector2;
  103754. /**
  103755. * Creates a new RemapBlock
  103756. * @param name defines the block name
  103757. */
  103758. constructor(name: string);
  103759. /**
  103760. * Gets the current class name
  103761. * @returns the class name
  103762. */
  103763. getClassName(): string;
  103764. /**
  103765. * Gets the input component
  103766. */
  103767. get input(): NodeMaterialConnectionPoint;
  103768. /**
  103769. * Gets the source min input component
  103770. */
  103771. get sourceMin(): NodeMaterialConnectionPoint;
  103772. /**
  103773. * Gets the source max input component
  103774. */
  103775. get sourceMax(): NodeMaterialConnectionPoint;
  103776. /**
  103777. * Gets the target min input component
  103778. */
  103779. get targetMin(): NodeMaterialConnectionPoint;
  103780. /**
  103781. * Gets the target max input component
  103782. */
  103783. get targetMax(): NodeMaterialConnectionPoint;
  103784. /**
  103785. * Gets the output component
  103786. */
  103787. get output(): NodeMaterialConnectionPoint;
  103788. protected _buildBlock(state: NodeMaterialBuildState): this;
  103789. protected _dumpPropertiesCode(): string;
  103790. serialize(): any;
  103791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103792. }
  103793. }
  103794. declare module BABYLON {
  103795. /**
  103796. * Block used to multiply 2 values
  103797. */
  103798. export class MultiplyBlock extends NodeMaterialBlock {
  103799. /**
  103800. * Creates a new MultiplyBlock
  103801. * @param name defines the block name
  103802. */
  103803. constructor(name: string);
  103804. /**
  103805. * Gets the current class name
  103806. * @returns the class name
  103807. */
  103808. getClassName(): string;
  103809. /**
  103810. * Gets the left operand input component
  103811. */
  103812. get left(): NodeMaterialConnectionPoint;
  103813. /**
  103814. * Gets the right operand input component
  103815. */
  103816. get right(): NodeMaterialConnectionPoint;
  103817. /**
  103818. * Gets the output component
  103819. */
  103820. get output(): NodeMaterialConnectionPoint;
  103821. protected _buildBlock(state: NodeMaterialBuildState): this;
  103822. }
  103823. }
  103824. declare module BABYLON {
  103825. /**
  103826. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103827. */
  103828. export class ColorSplitterBlock extends NodeMaterialBlock {
  103829. /**
  103830. * Create a new ColorSplitterBlock
  103831. * @param name defines the block name
  103832. */
  103833. constructor(name: string);
  103834. /**
  103835. * Gets the current class name
  103836. * @returns the class name
  103837. */
  103838. getClassName(): string;
  103839. /**
  103840. * Gets the rgba component (input)
  103841. */
  103842. get rgba(): NodeMaterialConnectionPoint;
  103843. /**
  103844. * Gets the rgb component (input)
  103845. */
  103846. get rgbIn(): NodeMaterialConnectionPoint;
  103847. /**
  103848. * Gets the rgb component (output)
  103849. */
  103850. get rgbOut(): NodeMaterialConnectionPoint;
  103851. /**
  103852. * Gets the r component (output)
  103853. */
  103854. get r(): NodeMaterialConnectionPoint;
  103855. /**
  103856. * Gets the g component (output)
  103857. */
  103858. get g(): NodeMaterialConnectionPoint;
  103859. /**
  103860. * Gets the b component (output)
  103861. */
  103862. get b(): NodeMaterialConnectionPoint;
  103863. /**
  103864. * Gets the a component (output)
  103865. */
  103866. get a(): NodeMaterialConnectionPoint;
  103867. protected _inputRename(name: string): string;
  103868. protected _outputRename(name: string): string;
  103869. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103870. }
  103871. }
  103872. declare module BABYLON {
  103873. /**
  103874. * Operations supported by the Trigonometry block
  103875. */
  103876. export enum TrigonometryBlockOperations {
  103877. /** Cos */
  103878. Cos = 0,
  103879. /** Sin */
  103880. Sin = 1,
  103881. /** Abs */
  103882. Abs = 2,
  103883. /** Exp */
  103884. Exp = 3,
  103885. /** Exp2 */
  103886. Exp2 = 4,
  103887. /** Round */
  103888. Round = 5,
  103889. /** Floor */
  103890. Floor = 6,
  103891. /** Ceiling */
  103892. Ceiling = 7,
  103893. /** Square root */
  103894. Sqrt = 8,
  103895. /** Log */
  103896. Log = 9,
  103897. /** Tangent */
  103898. Tan = 10,
  103899. /** Arc tangent */
  103900. ArcTan = 11,
  103901. /** Arc cosinus */
  103902. ArcCos = 12,
  103903. /** Arc sinus */
  103904. ArcSin = 13,
  103905. /** Fraction */
  103906. Fract = 14,
  103907. /** Sign */
  103908. Sign = 15,
  103909. /** To radians (from degrees) */
  103910. Radians = 16,
  103911. /** To degrees (from radians) */
  103912. Degrees = 17
  103913. }
  103914. /**
  103915. * Block used to apply trigonometry operation to floats
  103916. */
  103917. export class TrigonometryBlock extends NodeMaterialBlock {
  103918. /**
  103919. * Gets or sets the operation applied by the block
  103920. */
  103921. operation: TrigonometryBlockOperations;
  103922. /**
  103923. * Creates a new TrigonometryBlock
  103924. * @param name defines the block name
  103925. */
  103926. constructor(name: string);
  103927. /**
  103928. * Gets the current class name
  103929. * @returns the class name
  103930. */
  103931. getClassName(): string;
  103932. /**
  103933. * Gets the input component
  103934. */
  103935. get input(): NodeMaterialConnectionPoint;
  103936. /**
  103937. * Gets the output component
  103938. */
  103939. get output(): NodeMaterialConnectionPoint;
  103940. protected _buildBlock(state: NodeMaterialBuildState): this;
  103941. serialize(): any;
  103942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103943. protected _dumpPropertiesCode(): string;
  103944. }
  103945. }
  103946. declare module BABYLON {
  103947. /**
  103948. * Interface used to configure the node material editor
  103949. */
  103950. export interface INodeMaterialEditorOptions {
  103951. /** Define the URl to load node editor script */
  103952. editorURL?: string;
  103953. }
  103954. /** @hidden */
  103955. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103956. NORMAL: boolean;
  103957. TANGENT: boolean;
  103958. UV1: boolean;
  103959. /** BONES */
  103960. NUM_BONE_INFLUENCERS: number;
  103961. BonesPerMesh: number;
  103962. BONETEXTURE: boolean;
  103963. /** MORPH TARGETS */
  103964. MORPHTARGETS: boolean;
  103965. MORPHTARGETS_NORMAL: boolean;
  103966. MORPHTARGETS_TANGENT: boolean;
  103967. MORPHTARGETS_UV: boolean;
  103968. NUM_MORPH_INFLUENCERS: number;
  103969. /** IMAGE PROCESSING */
  103970. IMAGEPROCESSING: boolean;
  103971. VIGNETTE: boolean;
  103972. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103973. VIGNETTEBLENDMODEOPAQUE: boolean;
  103974. TONEMAPPING: boolean;
  103975. TONEMAPPING_ACES: boolean;
  103976. CONTRAST: boolean;
  103977. EXPOSURE: boolean;
  103978. COLORCURVES: boolean;
  103979. COLORGRADING: boolean;
  103980. COLORGRADING3D: boolean;
  103981. SAMPLER3DGREENDEPTH: boolean;
  103982. SAMPLER3DBGRMAP: boolean;
  103983. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103984. /** MISC. */
  103985. BUMPDIRECTUV: number;
  103986. constructor();
  103987. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103988. }
  103989. /**
  103990. * Class used to configure NodeMaterial
  103991. */
  103992. export interface INodeMaterialOptions {
  103993. /**
  103994. * Defines if blocks should emit comments
  103995. */
  103996. emitComments: boolean;
  103997. }
  103998. /**
  103999. * Class used to create a node based material built by assembling shader blocks
  104000. */
  104001. export class NodeMaterial extends PushMaterial {
  104002. private static _BuildIdGenerator;
  104003. private _options;
  104004. private _vertexCompilationState;
  104005. private _fragmentCompilationState;
  104006. private _sharedData;
  104007. private _buildId;
  104008. private _buildWasSuccessful;
  104009. private _cachedWorldViewMatrix;
  104010. private _cachedWorldViewProjectionMatrix;
  104011. private _optimizers;
  104012. private _animationFrame;
  104013. /** Define the Url to load node editor script */
  104014. static EditorURL: string;
  104015. /** Define the Url to load snippets */
  104016. static SnippetUrl: string;
  104017. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  104018. static IgnoreTexturesAtLoadTime: boolean;
  104019. private BJSNODEMATERIALEDITOR;
  104020. /** Get the inspector from bundle or global */
  104021. private _getGlobalNodeMaterialEditor;
  104022. /**
  104023. * Snippet ID if the material was created from the snippet server
  104024. */
  104025. snippetId: string;
  104026. /**
  104027. * Gets or sets data used by visual editor
  104028. * @see https://nme.babylonjs.com
  104029. */
  104030. editorData: any;
  104031. /**
  104032. * 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)
  104033. */
  104034. ignoreAlpha: boolean;
  104035. /**
  104036. * Defines the maximum number of lights that can be used in the material
  104037. */
  104038. maxSimultaneousLights: number;
  104039. /**
  104040. * Observable raised when the material is built
  104041. */
  104042. onBuildObservable: Observable<NodeMaterial>;
  104043. /**
  104044. * Gets or sets the root nodes of the material vertex shader
  104045. */
  104046. _vertexOutputNodes: NodeMaterialBlock[];
  104047. /**
  104048. * Gets or sets the root nodes of the material fragment (pixel) shader
  104049. */
  104050. _fragmentOutputNodes: NodeMaterialBlock[];
  104051. /** Gets or sets options to control the node material overall behavior */
  104052. get options(): INodeMaterialOptions;
  104053. set options(options: INodeMaterialOptions);
  104054. /**
  104055. * Default configuration related to image processing available in the standard Material.
  104056. */
  104057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104058. /**
  104059. * Gets the image processing configuration used either in this material.
  104060. */
  104061. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104062. /**
  104063. * Sets the Default image processing configuration used either in the this material.
  104064. *
  104065. * If sets to null, the scene one is in use.
  104066. */
  104067. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104068. /**
  104069. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  104070. */
  104071. attachedBlocks: NodeMaterialBlock[];
  104072. /**
  104073. * Specifies the mode of the node material
  104074. * @hidden
  104075. */
  104076. _mode: NodeMaterialModes;
  104077. /**
  104078. * Gets the mode property
  104079. */
  104080. get mode(): NodeMaterialModes;
  104081. /**
  104082. * A free comment about the material
  104083. */
  104084. comment: string;
  104085. /**
  104086. * Create a new node based material
  104087. * @param name defines the material name
  104088. * @param scene defines the hosting scene
  104089. * @param options defines creation option
  104090. */
  104091. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  104092. /**
  104093. * Gets the current class name of the material e.g. "NodeMaterial"
  104094. * @returns the class name
  104095. */
  104096. getClassName(): string;
  104097. /**
  104098. * Keep track of the image processing observer to allow dispose and replace.
  104099. */
  104100. private _imageProcessingObserver;
  104101. /**
  104102. * Attaches a new image processing configuration to the Standard Material.
  104103. * @param configuration
  104104. */
  104105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104106. /**
  104107. * Get a block by its name
  104108. * @param name defines the name of the block to retrieve
  104109. * @returns the required block or null if not found
  104110. */
  104111. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  104112. /**
  104113. * Get a block by its name
  104114. * @param predicate defines the predicate used to find the good candidate
  104115. * @returns the required block or null if not found
  104116. */
  104117. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  104118. /**
  104119. * Get an input block by its name
  104120. * @param predicate defines the predicate used to find the good candidate
  104121. * @returns the required input block or null if not found
  104122. */
  104123. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  104124. /**
  104125. * Gets the list of input blocks attached to this material
  104126. * @returns an array of InputBlocks
  104127. */
  104128. getInputBlocks(): InputBlock[];
  104129. /**
  104130. * Adds a new optimizer to the list of optimizers
  104131. * @param optimizer defines the optimizers to add
  104132. * @returns the current material
  104133. */
  104134. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104135. /**
  104136. * Remove an optimizer from the list of optimizers
  104137. * @param optimizer defines the optimizers to remove
  104138. * @returns the current material
  104139. */
  104140. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104141. /**
  104142. * Add a new block to the list of output nodes
  104143. * @param node defines the node to add
  104144. * @returns the current material
  104145. */
  104146. addOutputNode(node: NodeMaterialBlock): this;
  104147. /**
  104148. * Remove a block from the list of root nodes
  104149. * @param node defines the node to remove
  104150. * @returns the current material
  104151. */
  104152. removeOutputNode(node: NodeMaterialBlock): this;
  104153. private _addVertexOutputNode;
  104154. private _removeVertexOutputNode;
  104155. private _addFragmentOutputNode;
  104156. private _removeFragmentOutputNode;
  104157. /**
  104158. * Specifies if the material will require alpha blending
  104159. * @returns a boolean specifying if alpha blending is needed
  104160. */
  104161. needAlphaBlending(): boolean;
  104162. /**
  104163. * Specifies if this material should be rendered in alpha test mode
  104164. * @returns a boolean specifying if an alpha test is needed.
  104165. */
  104166. needAlphaTesting(): boolean;
  104167. private _initializeBlock;
  104168. private _resetDualBlocks;
  104169. /**
  104170. * Remove a block from the current node material
  104171. * @param block defines the block to remove
  104172. */
  104173. removeBlock(block: NodeMaterialBlock): void;
  104174. /**
  104175. * Build the material and generates the inner effect
  104176. * @param verbose defines if the build should log activity
  104177. */
  104178. build(verbose?: boolean): void;
  104179. /**
  104180. * Runs an otpimization phase to try to improve the shader code
  104181. */
  104182. optimize(): void;
  104183. private _prepareDefinesForAttributes;
  104184. /**
  104185. * Create a post process from the material
  104186. * @param camera The camera to apply the render pass to.
  104187. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104189. * @param engine The engine which the post process will be applied. (default: current engine)
  104190. * @param reusable If the post process can be reused on the same frame. (default: false)
  104191. * @param textureType Type of textures used when performing the post process. (default: 0)
  104192. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104193. * @returns the post process created
  104194. */
  104195. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  104196. /**
  104197. * Create the post process effect from the material
  104198. * @param postProcess The post process to create the effect for
  104199. */
  104200. createEffectForPostProcess(postProcess: PostProcess): void;
  104201. private _createEffectForPostProcess;
  104202. /**
  104203. * Create a new procedural texture based on this node material
  104204. * @param size defines the size of the texture
  104205. * @param scene defines the hosting scene
  104206. * @returns the new procedural texture attached to this node material
  104207. */
  104208. createProceduralTexture(size: number | {
  104209. width: number;
  104210. height: number;
  104211. layers?: number;
  104212. }, scene: Scene): Nullable<ProceduralTexture>;
  104213. private _createEffectForParticles;
  104214. private _checkInternals;
  104215. /**
  104216. * Create the effect to be used as the custom effect for a particle system
  104217. * @param particleSystem Particle system to create the effect for
  104218. * @param onCompiled defines a function to call when the effect creation is successful
  104219. * @param onError defines a function to call when the effect creation has failed
  104220. */
  104221. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104222. private _processDefines;
  104223. /**
  104224. * Get if the submesh is ready to be used and all its information available.
  104225. * Child classes can use it to update shaders
  104226. * @param mesh defines the mesh to check
  104227. * @param subMesh defines which submesh to check
  104228. * @param useInstances specifies that instances should be used
  104229. * @returns a boolean indicating that the submesh is ready or not
  104230. */
  104231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104232. /**
  104233. * Get a string representing the shaders built by the current node graph
  104234. */
  104235. get compiledShaders(): string;
  104236. /**
  104237. * Binds the world matrix to the material
  104238. * @param world defines the world transformation matrix
  104239. */
  104240. bindOnlyWorldMatrix(world: Matrix): void;
  104241. /**
  104242. * Binds the submesh to this material by preparing the effect and shader to draw
  104243. * @param world defines the world transformation matrix
  104244. * @param mesh defines the mesh containing the submesh
  104245. * @param subMesh defines the submesh to bind the material to
  104246. */
  104247. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104248. /**
  104249. * Gets the active textures from the material
  104250. * @returns an array of textures
  104251. */
  104252. getActiveTextures(): BaseTexture[];
  104253. /**
  104254. * Gets the list of texture blocks
  104255. * @returns an array of texture blocks
  104256. */
  104257. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  104258. /**
  104259. * Specifies if the material uses a texture
  104260. * @param texture defines the texture to check against the material
  104261. * @returns a boolean specifying if the material uses the texture
  104262. */
  104263. hasTexture(texture: BaseTexture): boolean;
  104264. /**
  104265. * Disposes the material
  104266. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104267. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104268. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104269. */
  104270. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104271. /** Creates the node editor window. */
  104272. private _createNodeEditor;
  104273. /**
  104274. * Launch the node material editor
  104275. * @param config Define the configuration of the editor
  104276. * @return a promise fulfilled when the node editor is visible
  104277. */
  104278. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  104279. /**
  104280. * Clear the current material
  104281. */
  104282. clear(): void;
  104283. /**
  104284. * Clear the current material and set it to a default state
  104285. */
  104286. setToDefault(): void;
  104287. /**
  104288. * Clear the current material and set it to a default state for post process
  104289. */
  104290. setToDefaultPostProcess(): void;
  104291. /**
  104292. * Clear the current material and set it to a default state for procedural texture
  104293. */
  104294. setToDefaultProceduralTexture(): void;
  104295. /**
  104296. * Clear the current material and set it to a default state for particle
  104297. */
  104298. setToDefaultParticle(): void;
  104299. /**
  104300. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  104301. * @param url defines the url to load from
  104302. * @returns a promise that will fullfil when the material is fully loaded
  104303. */
  104304. loadAsync(url: string): Promise<void>;
  104305. private _gatherBlocks;
  104306. /**
  104307. * Generate a string containing the code declaration required to create an equivalent of this material
  104308. * @returns a string
  104309. */
  104310. generateCode(): string;
  104311. /**
  104312. * Serializes this material in a JSON representation
  104313. * @returns the serialized material object
  104314. */
  104315. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  104316. private _restoreConnections;
  104317. /**
  104318. * Clear the current graph and load a new one from a serialization object
  104319. * @param source defines the JSON representation of the material
  104320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104321. * @param merge defines whether or not the source must be merged or replace the current content
  104322. */
  104323. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  104324. /**
  104325. * Makes a duplicate of the current material.
  104326. * @param name - name to use for the new material.
  104327. */
  104328. clone(name: string): NodeMaterial;
  104329. /**
  104330. * Creates a node material from parsed material data
  104331. * @param source defines the JSON representation of the material
  104332. * @param scene defines the hosting scene
  104333. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104334. * @returns a new node material
  104335. */
  104336. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  104337. /**
  104338. * Creates a node material from a snippet saved in a remote file
  104339. * @param name defines the name of the material to create
  104340. * @param url defines the url to load from
  104341. * @param scene defines the hosting scene
  104342. * @returns a promise that will resolve to the new node material
  104343. */
  104344. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  104345. /**
  104346. * Creates a node material from a snippet saved by the node material editor
  104347. * @param snippetId defines the snippet to load
  104348. * @param scene defines the hosting scene
  104349. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104350. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  104351. * @returns a promise that will resolve to the new node material
  104352. */
  104353. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  104354. /**
  104355. * Creates a new node material set to default basic configuration
  104356. * @param name defines the name of the material
  104357. * @param scene defines the hosting scene
  104358. * @returns a new NodeMaterial
  104359. */
  104360. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  104361. }
  104362. }
  104363. declare module BABYLON {
  104364. interface ThinEngine {
  104365. /**
  104366. * Unbind a list of render target textures from the webGL context
  104367. * This is used only when drawBuffer extension or webGL2 are active
  104368. * @param textures defines the render target textures to unbind
  104369. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104370. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104371. */
  104372. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104373. /**
  104374. * Create a multi render target texture
  104375. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104376. * @param size defines the size of the texture
  104377. * @param options defines the creation options
  104378. * @returns the cube texture as an InternalTexture
  104379. */
  104380. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104381. /**
  104382. * Update the sample count for a given multiple render target texture
  104383. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104384. * @param textures defines the textures to update
  104385. * @param samples defines the sample count to set
  104386. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104387. */
  104388. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104389. /**
  104390. * Select a subsets of attachments to draw to.
  104391. * @param attachments gl attachments
  104392. */
  104393. bindAttachments(attachments: number[]): void;
  104394. /**
  104395. * Creates a layout object to draw/clear on specific textures in a MRT
  104396. * @param textureStatus textureStatus[i] indicates if the i-th is active
  104397. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  104398. */
  104399. buildTextureLayout(textureStatus: boolean[]): number[];
  104400. /**
  104401. * Restores the webgl state to only draw on the main color attachment
  104402. */
  104403. restoreSingleAttachment(): void;
  104404. }
  104405. }
  104406. declare module BABYLON {
  104407. /**
  104408. * Creation options of the multi render target texture.
  104409. */
  104410. export interface IMultiRenderTargetOptions {
  104411. /**
  104412. * Define if the texture needs to create mip maps after render.
  104413. */
  104414. generateMipMaps?: boolean;
  104415. /**
  104416. * Define the types of all the draw buffers we want to create
  104417. */
  104418. types?: number[];
  104419. /**
  104420. * Define the sampling modes of all the draw buffers we want to create
  104421. */
  104422. samplingModes?: number[];
  104423. /**
  104424. * Define if a depth buffer is required
  104425. */
  104426. generateDepthBuffer?: boolean;
  104427. /**
  104428. * Define if a stencil buffer is required
  104429. */
  104430. generateStencilBuffer?: boolean;
  104431. /**
  104432. * Define if a depth texture is required instead of a depth buffer
  104433. */
  104434. generateDepthTexture?: boolean;
  104435. /**
  104436. * Define the number of desired draw buffers
  104437. */
  104438. textureCount?: number;
  104439. /**
  104440. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104441. */
  104442. doNotChangeAspectRatio?: boolean;
  104443. /**
  104444. * Define the default type of the buffers we are creating
  104445. */
  104446. defaultType?: number;
  104447. }
  104448. /**
  104449. * A multi render target, like a render target provides the ability to render to a texture.
  104450. * Unlike the render target, it can render to several draw buffers in one draw.
  104451. * This is specially interesting in deferred rendering or for any effects requiring more than
  104452. * just one color from a single pass.
  104453. */
  104454. export class MultiRenderTarget extends RenderTargetTexture {
  104455. private _internalTextures;
  104456. private _textures;
  104457. private _multiRenderTargetOptions;
  104458. private _count;
  104459. /**
  104460. * Get if draw buffers are currently supported by the used hardware and browser.
  104461. */
  104462. get isSupported(): boolean;
  104463. /**
  104464. * Get the list of textures generated by the multi render target.
  104465. */
  104466. get textures(): Texture[];
  104467. /**
  104468. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104469. */
  104470. get count(): number;
  104471. /**
  104472. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104473. */
  104474. get depthTexture(): Texture;
  104475. /**
  104476. * Set the wrapping mode on U of all the textures we are rendering to.
  104477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104478. */
  104479. set wrapU(wrap: number);
  104480. /**
  104481. * Set the wrapping mode on V of all the textures we are rendering to.
  104482. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104483. */
  104484. set wrapV(wrap: number);
  104485. /**
  104486. * Instantiate a new multi render target texture.
  104487. * A multi render target, like a render target provides the ability to render to a texture.
  104488. * Unlike the render target, it can render to several draw buffers in one draw.
  104489. * This is specially interesting in deferred rendering or for any effects requiring more than
  104490. * just one color from a single pass.
  104491. * @param name Define the name of the texture
  104492. * @param size Define the size of the buffers to render to
  104493. * @param count Define the number of target we are rendering into
  104494. * @param scene Define the scene the texture belongs to
  104495. * @param options Define the options used to create the multi render target
  104496. */
  104497. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104498. private _initTypes;
  104499. /** @hidden */
  104500. _rebuild(forceFullRebuild?: boolean): void;
  104501. private _createInternalTextures;
  104502. private _createTextures;
  104503. /**
  104504. * Replaces a texture within the MRT.
  104505. * @param texture The new texture to insert in the MRT
  104506. * @param index The index of the texture to replace
  104507. */
  104508. replaceTexture(texture: Texture, index: number): void;
  104509. /**
  104510. * Define the number of samples used if MSAA is enabled.
  104511. */
  104512. get samples(): number;
  104513. set samples(value: number);
  104514. /**
  104515. * Resize all the textures in the multi render target.
  104516. * Be careful as it will recreate all the data in the new texture.
  104517. * @param size Define the new size
  104518. */
  104519. resize(size: any): void;
  104520. /**
  104521. * Changes the number of render targets in this MRT
  104522. * Be careful as it will recreate all the data in the new texture.
  104523. * @param count new texture count
  104524. * @param options Specifies texture types and sampling modes for new textures
  104525. */
  104526. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104527. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104528. /**
  104529. * Dispose the render targets and their associated resources
  104530. */
  104531. dispose(): void;
  104532. /**
  104533. * Release all the underlying texture used as draw buffers.
  104534. */
  104535. releaseInternalTextures(): void;
  104536. }
  104537. }
  104538. declare module BABYLON {
  104539. /** @hidden */
  104540. export var imageProcessingPixelShader: {
  104541. name: string;
  104542. shader: string;
  104543. };
  104544. }
  104545. declare module BABYLON {
  104546. /**
  104547. * ImageProcessingPostProcess
  104548. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104549. */
  104550. export class ImageProcessingPostProcess extends PostProcess {
  104551. /**
  104552. * Default configuration related to image processing available in the PBR Material.
  104553. */
  104554. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104555. /**
  104556. * Gets the image processing configuration used either in this material.
  104557. */
  104558. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104559. /**
  104560. * Sets the Default image processing configuration used either in the this material.
  104561. *
  104562. * If sets to null, the scene one is in use.
  104563. */
  104564. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104565. /**
  104566. * Keep track of the image processing observer to allow dispose and replace.
  104567. */
  104568. private _imageProcessingObserver;
  104569. /**
  104570. * Attaches a new image processing configuration to the PBR Material.
  104571. * @param configuration
  104572. */
  104573. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104574. /**
  104575. * If the post process is supported.
  104576. */
  104577. get isSupported(): boolean;
  104578. /**
  104579. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104580. */
  104581. get colorCurves(): Nullable<ColorCurves>;
  104582. /**
  104583. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104584. */
  104585. set colorCurves(value: Nullable<ColorCurves>);
  104586. /**
  104587. * Gets wether the color curves effect is enabled.
  104588. */
  104589. get colorCurvesEnabled(): boolean;
  104590. /**
  104591. * Sets wether the color curves effect is enabled.
  104592. */
  104593. set colorCurvesEnabled(value: boolean);
  104594. /**
  104595. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104596. */
  104597. get colorGradingTexture(): Nullable<BaseTexture>;
  104598. /**
  104599. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104600. */
  104601. set colorGradingTexture(value: Nullable<BaseTexture>);
  104602. /**
  104603. * Gets wether the color grading effect is enabled.
  104604. */
  104605. get colorGradingEnabled(): boolean;
  104606. /**
  104607. * Gets wether the color grading effect is enabled.
  104608. */
  104609. set colorGradingEnabled(value: boolean);
  104610. /**
  104611. * Gets exposure used in the effect.
  104612. */
  104613. get exposure(): number;
  104614. /**
  104615. * Sets exposure used in the effect.
  104616. */
  104617. set exposure(value: number);
  104618. /**
  104619. * Gets wether tonemapping is enabled or not.
  104620. */
  104621. get toneMappingEnabled(): boolean;
  104622. /**
  104623. * Sets wether tonemapping is enabled or not
  104624. */
  104625. set toneMappingEnabled(value: boolean);
  104626. /**
  104627. * Gets the type of tone mapping effect.
  104628. */
  104629. get toneMappingType(): number;
  104630. /**
  104631. * Sets the type of tone mapping effect.
  104632. */
  104633. set toneMappingType(value: number);
  104634. /**
  104635. * Gets contrast used in the effect.
  104636. */
  104637. get contrast(): number;
  104638. /**
  104639. * Sets contrast used in the effect.
  104640. */
  104641. set contrast(value: number);
  104642. /**
  104643. * Gets Vignette stretch size.
  104644. */
  104645. get vignetteStretch(): number;
  104646. /**
  104647. * Sets Vignette stretch size.
  104648. */
  104649. set vignetteStretch(value: number);
  104650. /**
  104651. * Gets Vignette centre X Offset.
  104652. */
  104653. get vignetteCentreX(): number;
  104654. /**
  104655. * Sets Vignette centre X Offset.
  104656. */
  104657. set vignetteCentreX(value: number);
  104658. /**
  104659. * Gets Vignette centre Y Offset.
  104660. */
  104661. get vignetteCentreY(): number;
  104662. /**
  104663. * Sets Vignette centre Y Offset.
  104664. */
  104665. set vignetteCentreY(value: number);
  104666. /**
  104667. * Gets Vignette weight or intensity of the vignette effect.
  104668. */
  104669. get vignetteWeight(): number;
  104670. /**
  104671. * Sets Vignette weight or intensity of the vignette effect.
  104672. */
  104673. set vignetteWeight(value: number);
  104674. /**
  104675. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104676. * if vignetteEnabled is set to true.
  104677. */
  104678. get vignetteColor(): Color4;
  104679. /**
  104680. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104681. * if vignetteEnabled is set to true.
  104682. */
  104683. set vignetteColor(value: Color4);
  104684. /**
  104685. * Gets Camera field of view used by the Vignette effect.
  104686. */
  104687. get vignetteCameraFov(): number;
  104688. /**
  104689. * Sets Camera field of view used by the Vignette effect.
  104690. */
  104691. set vignetteCameraFov(value: number);
  104692. /**
  104693. * Gets the vignette blend mode allowing different kind of effect.
  104694. */
  104695. get vignetteBlendMode(): number;
  104696. /**
  104697. * Sets the vignette blend mode allowing different kind of effect.
  104698. */
  104699. set vignetteBlendMode(value: number);
  104700. /**
  104701. * Gets wether the vignette effect is enabled.
  104702. */
  104703. get vignetteEnabled(): boolean;
  104704. /**
  104705. * Sets wether the vignette effect is enabled.
  104706. */
  104707. set vignetteEnabled(value: boolean);
  104708. private _fromLinearSpace;
  104709. /**
  104710. * Gets wether the input of the processing is in Gamma or Linear Space.
  104711. */
  104712. get fromLinearSpace(): boolean;
  104713. /**
  104714. * Sets wether the input of the processing is in Gamma or Linear Space.
  104715. */
  104716. set fromLinearSpace(value: boolean);
  104717. /**
  104718. * Defines cache preventing GC.
  104719. */
  104720. private _defines;
  104721. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104722. /**
  104723. * "ImageProcessingPostProcess"
  104724. * @returns "ImageProcessingPostProcess"
  104725. */
  104726. getClassName(): string;
  104727. /**
  104728. * @hidden
  104729. */
  104730. _updateParameters(): void;
  104731. dispose(camera?: Camera): void;
  104732. }
  104733. }
  104734. declare module BABYLON {
  104735. /**
  104736. * Interface for defining prepass effects in the prepass post-process pipeline
  104737. */
  104738. export interface PrePassEffectConfiguration {
  104739. /**
  104740. * Name of the effect
  104741. */
  104742. name: string;
  104743. /**
  104744. * Post process to attach for this effect
  104745. */
  104746. postProcess?: PostProcess;
  104747. /**
  104748. * Textures required in the MRT
  104749. */
  104750. texturesRequired: number[];
  104751. /**
  104752. * Is the effect enabled
  104753. */
  104754. enabled: boolean;
  104755. /**
  104756. * Disposes the effect configuration
  104757. */
  104758. dispose?: () => void;
  104759. /**
  104760. * Creates the associated post process
  104761. */
  104762. createPostProcess?: () => PostProcess;
  104763. }
  104764. }
  104765. declare module BABYLON {
  104766. /**
  104767. * Options to be used when creating a FresnelParameters.
  104768. */
  104769. export type IFresnelParametersCreationOptions = {
  104770. /**
  104771. * Define the color used on edges (grazing angle)
  104772. */
  104773. leftColor?: Color3;
  104774. /**
  104775. * Define the color used on center
  104776. */
  104777. rightColor?: Color3;
  104778. /**
  104779. * Define bias applied to computed fresnel term
  104780. */
  104781. bias?: number;
  104782. /**
  104783. * Defined the power exponent applied to fresnel term
  104784. */
  104785. power?: number;
  104786. /**
  104787. * Define if the fresnel effect is enable or not.
  104788. */
  104789. isEnabled?: boolean;
  104790. };
  104791. /**
  104792. * Serialized format for FresnelParameters.
  104793. */
  104794. export type IFresnelParametersSerialized = {
  104795. /**
  104796. * Define the color used on edges (grazing angle) [as an array]
  104797. */
  104798. leftColor: number[];
  104799. /**
  104800. * Define the color used on center [as an array]
  104801. */
  104802. rightColor: number[];
  104803. /**
  104804. * Define bias applied to computed fresnel term
  104805. */
  104806. bias: number;
  104807. /**
  104808. * Defined the power exponent applied to fresnel term
  104809. */
  104810. power?: number;
  104811. /**
  104812. * Define if the fresnel effect is enable or not.
  104813. */
  104814. isEnabled: boolean;
  104815. };
  104816. /**
  104817. * This represents all the required information to add a fresnel effect on a material:
  104818. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104819. */
  104820. export class FresnelParameters {
  104821. private _isEnabled;
  104822. /**
  104823. * Define if the fresnel effect is enable or not.
  104824. */
  104825. get isEnabled(): boolean;
  104826. set isEnabled(value: boolean);
  104827. /**
  104828. * Define the color used on edges (grazing angle)
  104829. */
  104830. leftColor: Color3;
  104831. /**
  104832. * Define the color used on center
  104833. */
  104834. rightColor: Color3;
  104835. /**
  104836. * Define bias applied to computed fresnel term
  104837. */
  104838. bias: number;
  104839. /**
  104840. * Defined the power exponent applied to fresnel term
  104841. */
  104842. power: number;
  104843. /**
  104844. * Creates a new FresnelParameters object.
  104845. *
  104846. * @param options provide your own settings to optionally to override defaults
  104847. */
  104848. constructor(options?: IFresnelParametersCreationOptions);
  104849. /**
  104850. * Clones the current fresnel and its valuues
  104851. * @returns a clone fresnel configuration
  104852. */
  104853. clone(): FresnelParameters;
  104854. /**
  104855. * Determines equality between FresnelParameters objects
  104856. * @param otherFresnelParameters defines the second operand
  104857. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104858. */
  104859. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104860. /**
  104861. * Serializes the current fresnel parameters to a JSON representation.
  104862. * @return the JSON serialization
  104863. */
  104864. serialize(): IFresnelParametersSerialized;
  104865. /**
  104866. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104867. * @param parsedFresnelParameters Define the JSON representation
  104868. * @returns the parsed parameters
  104869. */
  104870. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104871. }
  104872. }
  104873. declare module BABYLON {
  104874. /**
  104875. * This groups all the flags used to control the materials channel.
  104876. */
  104877. export class MaterialFlags {
  104878. private static _DiffuseTextureEnabled;
  104879. /**
  104880. * Are diffuse textures enabled in the application.
  104881. */
  104882. static get DiffuseTextureEnabled(): boolean;
  104883. static set DiffuseTextureEnabled(value: boolean);
  104884. private static _DetailTextureEnabled;
  104885. /**
  104886. * Are detail textures enabled in the application.
  104887. */
  104888. static get DetailTextureEnabled(): boolean;
  104889. static set DetailTextureEnabled(value: boolean);
  104890. private static _AmbientTextureEnabled;
  104891. /**
  104892. * Are ambient textures enabled in the application.
  104893. */
  104894. static get AmbientTextureEnabled(): boolean;
  104895. static set AmbientTextureEnabled(value: boolean);
  104896. private static _OpacityTextureEnabled;
  104897. /**
  104898. * Are opacity textures enabled in the application.
  104899. */
  104900. static get OpacityTextureEnabled(): boolean;
  104901. static set OpacityTextureEnabled(value: boolean);
  104902. private static _ReflectionTextureEnabled;
  104903. /**
  104904. * Are reflection textures enabled in the application.
  104905. */
  104906. static get ReflectionTextureEnabled(): boolean;
  104907. static set ReflectionTextureEnabled(value: boolean);
  104908. private static _EmissiveTextureEnabled;
  104909. /**
  104910. * Are emissive textures enabled in the application.
  104911. */
  104912. static get EmissiveTextureEnabled(): boolean;
  104913. static set EmissiveTextureEnabled(value: boolean);
  104914. private static _SpecularTextureEnabled;
  104915. /**
  104916. * Are specular textures enabled in the application.
  104917. */
  104918. static get SpecularTextureEnabled(): boolean;
  104919. static set SpecularTextureEnabled(value: boolean);
  104920. private static _BumpTextureEnabled;
  104921. /**
  104922. * Are bump textures enabled in the application.
  104923. */
  104924. static get BumpTextureEnabled(): boolean;
  104925. static set BumpTextureEnabled(value: boolean);
  104926. private static _LightmapTextureEnabled;
  104927. /**
  104928. * Are lightmap textures enabled in the application.
  104929. */
  104930. static get LightmapTextureEnabled(): boolean;
  104931. static set LightmapTextureEnabled(value: boolean);
  104932. private static _RefractionTextureEnabled;
  104933. /**
  104934. * Are refraction textures enabled in the application.
  104935. */
  104936. static get RefractionTextureEnabled(): boolean;
  104937. static set RefractionTextureEnabled(value: boolean);
  104938. private static _ColorGradingTextureEnabled;
  104939. /**
  104940. * Are color grading textures enabled in the application.
  104941. */
  104942. static get ColorGradingTextureEnabled(): boolean;
  104943. static set ColorGradingTextureEnabled(value: boolean);
  104944. private static _FresnelEnabled;
  104945. /**
  104946. * Are fresnels enabled in the application.
  104947. */
  104948. static get FresnelEnabled(): boolean;
  104949. static set FresnelEnabled(value: boolean);
  104950. private static _ClearCoatTextureEnabled;
  104951. /**
  104952. * Are clear coat textures enabled in the application.
  104953. */
  104954. static get ClearCoatTextureEnabled(): boolean;
  104955. static set ClearCoatTextureEnabled(value: boolean);
  104956. private static _ClearCoatBumpTextureEnabled;
  104957. /**
  104958. * Are clear coat bump textures enabled in the application.
  104959. */
  104960. static get ClearCoatBumpTextureEnabled(): boolean;
  104961. static set ClearCoatBumpTextureEnabled(value: boolean);
  104962. private static _ClearCoatTintTextureEnabled;
  104963. /**
  104964. * Are clear coat tint textures enabled in the application.
  104965. */
  104966. static get ClearCoatTintTextureEnabled(): boolean;
  104967. static set ClearCoatTintTextureEnabled(value: boolean);
  104968. private static _SheenTextureEnabled;
  104969. /**
  104970. * Are sheen textures enabled in the application.
  104971. */
  104972. static get SheenTextureEnabled(): boolean;
  104973. static set SheenTextureEnabled(value: boolean);
  104974. private static _AnisotropicTextureEnabled;
  104975. /**
  104976. * Are anisotropic textures enabled in the application.
  104977. */
  104978. static get AnisotropicTextureEnabled(): boolean;
  104979. static set AnisotropicTextureEnabled(value: boolean);
  104980. private static _ThicknessTextureEnabled;
  104981. /**
  104982. * Are thickness textures enabled in the application.
  104983. */
  104984. static get ThicknessTextureEnabled(): boolean;
  104985. static set ThicknessTextureEnabled(value: boolean);
  104986. }
  104987. }
  104988. declare module BABYLON {
  104989. /** @hidden */
  104990. export var defaultFragmentDeclaration: {
  104991. name: string;
  104992. shader: string;
  104993. };
  104994. }
  104995. declare module BABYLON {
  104996. /** @hidden */
  104997. export var defaultUboDeclaration: {
  104998. name: string;
  104999. shader: string;
  105000. };
  105001. }
  105002. declare module BABYLON {
  105003. /** @hidden */
  105004. export var prePassDeclaration: {
  105005. name: string;
  105006. shader: string;
  105007. };
  105008. }
  105009. declare module BABYLON {
  105010. /** @hidden */
  105011. export var lightFragmentDeclaration: {
  105012. name: string;
  105013. shader: string;
  105014. };
  105015. }
  105016. declare module BABYLON {
  105017. /** @hidden */
  105018. export var lightUboDeclaration: {
  105019. name: string;
  105020. shader: string;
  105021. };
  105022. }
  105023. declare module BABYLON {
  105024. /** @hidden */
  105025. export var lightsFragmentFunctions: {
  105026. name: string;
  105027. shader: string;
  105028. };
  105029. }
  105030. declare module BABYLON {
  105031. /** @hidden */
  105032. export var shadowsFragmentFunctions: {
  105033. name: string;
  105034. shader: string;
  105035. };
  105036. }
  105037. declare module BABYLON {
  105038. /** @hidden */
  105039. export var fresnelFunction: {
  105040. name: string;
  105041. shader: string;
  105042. };
  105043. }
  105044. declare module BABYLON {
  105045. /** @hidden */
  105046. export var bumpFragmentMainFunctions: {
  105047. name: string;
  105048. shader: string;
  105049. };
  105050. }
  105051. declare module BABYLON {
  105052. /** @hidden */
  105053. export var bumpFragmentFunctions: {
  105054. name: string;
  105055. shader: string;
  105056. };
  105057. }
  105058. declare module BABYLON {
  105059. /** @hidden */
  105060. export var logDepthDeclaration: {
  105061. name: string;
  105062. shader: string;
  105063. };
  105064. }
  105065. declare module BABYLON {
  105066. /** @hidden */
  105067. export var bumpFragment: {
  105068. name: string;
  105069. shader: string;
  105070. };
  105071. }
  105072. declare module BABYLON {
  105073. /** @hidden */
  105074. export var depthPrePass: {
  105075. name: string;
  105076. shader: string;
  105077. };
  105078. }
  105079. declare module BABYLON {
  105080. /** @hidden */
  105081. export var lightFragment: {
  105082. name: string;
  105083. shader: string;
  105084. };
  105085. }
  105086. declare module BABYLON {
  105087. /** @hidden */
  105088. export var logDepthFragment: {
  105089. name: string;
  105090. shader: string;
  105091. };
  105092. }
  105093. declare module BABYLON {
  105094. /** @hidden */
  105095. export var defaultPixelShader: {
  105096. name: string;
  105097. shader: string;
  105098. };
  105099. }
  105100. declare module BABYLON {
  105101. /** @hidden */
  105102. export var defaultVertexDeclaration: {
  105103. name: string;
  105104. shader: string;
  105105. };
  105106. }
  105107. declare module BABYLON {
  105108. /** @hidden */
  105109. export var prePassVertexDeclaration: {
  105110. name: string;
  105111. shader: string;
  105112. };
  105113. }
  105114. declare module BABYLON {
  105115. /** @hidden */
  105116. export var bumpVertexDeclaration: {
  105117. name: string;
  105118. shader: string;
  105119. };
  105120. }
  105121. declare module BABYLON {
  105122. /** @hidden */
  105123. export var prePassVertex: {
  105124. name: string;
  105125. shader: string;
  105126. };
  105127. }
  105128. declare module BABYLON {
  105129. /** @hidden */
  105130. export var bumpVertex: {
  105131. name: string;
  105132. shader: string;
  105133. };
  105134. }
  105135. declare module BABYLON {
  105136. /** @hidden */
  105137. export var fogVertex: {
  105138. name: string;
  105139. shader: string;
  105140. };
  105141. }
  105142. declare module BABYLON {
  105143. /** @hidden */
  105144. export var shadowsVertex: {
  105145. name: string;
  105146. shader: string;
  105147. };
  105148. }
  105149. declare module BABYLON {
  105150. /** @hidden */
  105151. export var pointCloudVertex: {
  105152. name: string;
  105153. shader: string;
  105154. };
  105155. }
  105156. declare module BABYLON {
  105157. /** @hidden */
  105158. export var logDepthVertex: {
  105159. name: string;
  105160. shader: string;
  105161. };
  105162. }
  105163. declare module BABYLON {
  105164. /** @hidden */
  105165. export var defaultVertexShader: {
  105166. name: string;
  105167. shader: string;
  105168. };
  105169. }
  105170. declare module BABYLON {
  105171. /**
  105172. * @hidden
  105173. */
  105174. export interface IMaterialDetailMapDefines {
  105175. DETAIL: boolean;
  105176. DETAILDIRECTUV: number;
  105177. DETAIL_NORMALBLENDMETHOD: number;
  105178. /** @hidden */
  105179. _areTexturesDirty: boolean;
  105180. }
  105181. /**
  105182. * Define the code related to the detail map parameters of a material
  105183. *
  105184. * Inspired from:
  105185. * 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
  105186. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  105187. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  105188. */
  105189. export class DetailMapConfiguration {
  105190. private _texture;
  105191. /**
  105192. * The detail texture of the material.
  105193. */
  105194. texture: Nullable<BaseTexture>;
  105195. /**
  105196. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  105197. * Bigger values mean stronger blending
  105198. */
  105199. diffuseBlendLevel: number;
  105200. /**
  105201. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  105202. * Bigger values mean stronger blending. Only used with PBR materials
  105203. */
  105204. roughnessBlendLevel: number;
  105205. /**
  105206. * Defines how strong the bump effect from the detail map is
  105207. * Bigger values mean stronger effect
  105208. */
  105209. bumpLevel: number;
  105210. private _normalBlendMethod;
  105211. /**
  105212. * The method used to blend the bump and detail normals together
  105213. */
  105214. normalBlendMethod: number;
  105215. private _isEnabled;
  105216. /**
  105217. * Enable or disable the detail map on this material
  105218. */
  105219. isEnabled: boolean;
  105220. /** @hidden */
  105221. private _internalMarkAllSubMeshesAsTexturesDirty;
  105222. /** @hidden */
  105223. _markAllSubMeshesAsTexturesDirty(): void;
  105224. /**
  105225. * Instantiate a new detail map
  105226. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105227. */
  105228. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105229. /**
  105230. * Gets whether the submesh is ready to be used or not.
  105231. * @param defines the list of "defines" to update.
  105232. * @param scene defines the scene the material belongs to.
  105233. * @returns - boolean indicating that the submesh is ready or not.
  105234. */
  105235. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  105236. /**
  105237. * Update the defines for detail map usage
  105238. * @param defines the list of "defines" to update.
  105239. * @param scene defines the scene the material belongs to.
  105240. */
  105241. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  105242. /**
  105243. * Binds the material data.
  105244. * @param uniformBuffer defines the Uniform buffer to fill in.
  105245. * @param scene defines the scene the material belongs to.
  105246. * @param isFrozen defines whether the material is frozen or not.
  105247. */
  105248. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105249. /**
  105250. * Checks to see if a texture is used in the material.
  105251. * @param texture - Base texture to use.
  105252. * @returns - Boolean specifying if a texture is used in the material.
  105253. */
  105254. hasTexture(texture: BaseTexture): boolean;
  105255. /**
  105256. * Returns an array of the actively used textures.
  105257. * @param activeTextures Array of BaseTextures
  105258. */
  105259. getActiveTextures(activeTextures: BaseTexture[]): void;
  105260. /**
  105261. * Returns the animatable textures.
  105262. * @param animatables Array of animatable textures.
  105263. */
  105264. getAnimatables(animatables: IAnimatable[]): void;
  105265. /**
  105266. * Disposes the resources of the material.
  105267. * @param forceDisposeTextures - Forces the disposal of all textures.
  105268. */
  105269. dispose(forceDisposeTextures?: boolean): void;
  105270. /**
  105271. * Get the current class name useful for serialization or dynamic coding.
  105272. * @returns "DetailMap"
  105273. */
  105274. getClassName(): string;
  105275. /**
  105276. * Add the required uniforms to the current list.
  105277. * @param uniforms defines the current uniform list.
  105278. */
  105279. static AddUniforms(uniforms: string[]): void;
  105280. /**
  105281. * Add the required samplers to the current list.
  105282. * @param samplers defines the current sampler list.
  105283. */
  105284. static AddSamplers(samplers: string[]): void;
  105285. /**
  105286. * Add the required uniforms to the current buffer.
  105287. * @param uniformBuffer defines the current uniform buffer.
  105288. */
  105289. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105290. /**
  105291. * Makes a duplicate of the current instance into another one.
  105292. * @param detailMap define the instance where to copy the info
  105293. */
  105294. copyTo(detailMap: DetailMapConfiguration): void;
  105295. /**
  105296. * Serializes this detail map instance
  105297. * @returns - An object with the serialized instance.
  105298. */
  105299. serialize(): any;
  105300. /**
  105301. * Parses a detail map setting from a serialized object.
  105302. * @param source - Serialized object.
  105303. * @param scene Defines the scene we are parsing for
  105304. * @param rootUrl Defines the rootUrl to load from
  105305. */
  105306. parse(source: any, scene: Scene, rootUrl: string): void;
  105307. }
  105308. }
  105309. declare module BABYLON {
  105310. /** @hidden */
  105311. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  105312. MAINUV1: boolean;
  105313. MAINUV2: boolean;
  105314. DIFFUSE: boolean;
  105315. DIFFUSEDIRECTUV: number;
  105316. DETAIL: boolean;
  105317. DETAILDIRECTUV: number;
  105318. DETAIL_NORMALBLENDMETHOD: number;
  105319. AMBIENT: boolean;
  105320. AMBIENTDIRECTUV: number;
  105321. OPACITY: boolean;
  105322. OPACITYDIRECTUV: number;
  105323. OPACITYRGB: boolean;
  105324. REFLECTION: boolean;
  105325. EMISSIVE: boolean;
  105326. EMISSIVEDIRECTUV: number;
  105327. SPECULAR: boolean;
  105328. SPECULARDIRECTUV: number;
  105329. BUMP: boolean;
  105330. BUMPDIRECTUV: number;
  105331. PARALLAX: boolean;
  105332. PARALLAXOCCLUSION: boolean;
  105333. SPECULAROVERALPHA: boolean;
  105334. CLIPPLANE: boolean;
  105335. CLIPPLANE2: boolean;
  105336. CLIPPLANE3: boolean;
  105337. CLIPPLANE4: boolean;
  105338. CLIPPLANE5: boolean;
  105339. CLIPPLANE6: boolean;
  105340. ALPHATEST: boolean;
  105341. DEPTHPREPASS: boolean;
  105342. ALPHAFROMDIFFUSE: boolean;
  105343. POINTSIZE: boolean;
  105344. FOG: boolean;
  105345. SPECULARTERM: boolean;
  105346. DIFFUSEFRESNEL: boolean;
  105347. OPACITYFRESNEL: boolean;
  105348. REFLECTIONFRESNEL: boolean;
  105349. REFRACTIONFRESNEL: boolean;
  105350. EMISSIVEFRESNEL: boolean;
  105351. FRESNEL: boolean;
  105352. NORMAL: boolean;
  105353. UV1: boolean;
  105354. UV2: boolean;
  105355. VERTEXCOLOR: boolean;
  105356. VERTEXALPHA: boolean;
  105357. NUM_BONE_INFLUENCERS: number;
  105358. BonesPerMesh: number;
  105359. BONETEXTURE: boolean;
  105360. BONES_VELOCITY_ENABLED: boolean;
  105361. INSTANCES: boolean;
  105362. THIN_INSTANCES: boolean;
  105363. GLOSSINESS: boolean;
  105364. ROUGHNESS: boolean;
  105365. EMISSIVEASILLUMINATION: boolean;
  105366. LINKEMISSIVEWITHDIFFUSE: boolean;
  105367. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105368. LIGHTMAP: boolean;
  105369. LIGHTMAPDIRECTUV: number;
  105370. OBJECTSPACE_NORMALMAP: boolean;
  105371. USELIGHTMAPASSHADOWMAP: boolean;
  105372. REFLECTIONMAP_3D: boolean;
  105373. REFLECTIONMAP_SPHERICAL: boolean;
  105374. REFLECTIONMAP_PLANAR: boolean;
  105375. REFLECTIONMAP_CUBIC: boolean;
  105376. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105377. REFLECTIONMAP_PROJECTION: boolean;
  105378. REFLECTIONMAP_SKYBOX: boolean;
  105379. REFLECTIONMAP_EXPLICIT: boolean;
  105380. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105381. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105382. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105383. INVERTCUBICMAP: boolean;
  105384. LOGARITHMICDEPTH: boolean;
  105385. REFRACTION: boolean;
  105386. REFRACTIONMAP_3D: boolean;
  105387. REFLECTIONOVERALPHA: boolean;
  105388. TWOSIDEDLIGHTING: boolean;
  105389. SHADOWFLOAT: boolean;
  105390. MORPHTARGETS: boolean;
  105391. MORPHTARGETS_NORMAL: boolean;
  105392. MORPHTARGETS_TANGENT: boolean;
  105393. MORPHTARGETS_UV: boolean;
  105394. NUM_MORPH_INFLUENCERS: number;
  105395. NONUNIFORMSCALING: boolean;
  105396. PREMULTIPLYALPHA: boolean;
  105397. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  105398. ALPHABLEND: boolean;
  105399. PREPASS: boolean;
  105400. PREPASS_IRRADIANCE: boolean;
  105401. PREPASS_IRRADIANCE_INDEX: number;
  105402. PREPASS_ALBEDO: boolean;
  105403. PREPASS_ALBEDO_INDEX: number;
  105404. PREPASS_DEPTHNORMAL: boolean;
  105405. PREPASS_DEPTHNORMAL_INDEX: number;
  105406. PREPASS_POSITION: boolean;
  105407. PREPASS_POSITION_INDEX: number;
  105408. PREPASS_VELOCITY: boolean;
  105409. PREPASS_VELOCITY_INDEX: number;
  105410. PREPASS_REFLECTIVITY: boolean;
  105411. PREPASS_REFLECTIVITY_INDEX: number;
  105412. SCENE_MRT_COUNT: number;
  105413. RGBDLIGHTMAP: boolean;
  105414. RGBDREFLECTION: boolean;
  105415. RGBDREFRACTION: boolean;
  105416. IMAGEPROCESSING: boolean;
  105417. VIGNETTE: boolean;
  105418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105419. VIGNETTEBLENDMODEOPAQUE: boolean;
  105420. TONEMAPPING: boolean;
  105421. TONEMAPPING_ACES: boolean;
  105422. CONTRAST: boolean;
  105423. COLORCURVES: boolean;
  105424. COLORGRADING: boolean;
  105425. COLORGRADING3D: boolean;
  105426. SAMPLER3DGREENDEPTH: boolean;
  105427. SAMPLER3DBGRMAP: boolean;
  105428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105429. MULTIVIEW: boolean;
  105430. /**
  105431. * If the reflection texture on this material is in linear color space
  105432. * @hidden
  105433. */
  105434. IS_REFLECTION_LINEAR: boolean;
  105435. /**
  105436. * If the refraction texture on this material is in linear color space
  105437. * @hidden
  105438. */
  105439. IS_REFRACTION_LINEAR: boolean;
  105440. EXPOSURE: boolean;
  105441. constructor();
  105442. setReflectionMode(modeToEnable: string): void;
  105443. }
  105444. /**
  105445. * This is the default material used in Babylon. It is the best trade off between quality
  105446. * and performances.
  105447. * @see https://doc.babylonjs.com/babylon101/materials
  105448. */
  105449. export class StandardMaterial extends PushMaterial {
  105450. private _diffuseTexture;
  105451. /**
  105452. * The basic texture of the material as viewed under a light.
  105453. */
  105454. diffuseTexture: Nullable<BaseTexture>;
  105455. private _ambientTexture;
  105456. /**
  105457. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105458. */
  105459. ambientTexture: Nullable<BaseTexture>;
  105460. private _opacityTexture;
  105461. /**
  105462. * Define the transparency of the material from a texture.
  105463. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105464. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105465. */
  105466. opacityTexture: Nullable<BaseTexture>;
  105467. private _reflectionTexture;
  105468. /**
  105469. * Define the texture used to display the reflection.
  105470. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105471. */
  105472. reflectionTexture: Nullable<BaseTexture>;
  105473. private _emissiveTexture;
  105474. /**
  105475. * Define texture of the material as if self lit.
  105476. * This will be mixed in the final result even in the absence of light.
  105477. */
  105478. emissiveTexture: Nullable<BaseTexture>;
  105479. private _specularTexture;
  105480. /**
  105481. * Define how the color and intensity of the highlight given by the light in the material.
  105482. */
  105483. specularTexture: Nullable<BaseTexture>;
  105484. private _bumpTexture;
  105485. /**
  105486. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105487. * 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.
  105488. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  105489. */
  105490. bumpTexture: Nullable<BaseTexture>;
  105491. private _lightmapTexture;
  105492. /**
  105493. * Complex lighting can be computationally expensive to compute at runtime.
  105494. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105495. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  105496. */
  105497. lightmapTexture: Nullable<BaseTexture>;
  105498. private _refractionTexture;
  105499. /**
  105500. * Define the texture used to display the refraction.
  105501. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105502. */
  105503. refractionTexture: Nullable<BaseTexture>;
  105504. /**
  105505. * The color of the material lit by the environmental background lighting.
  105506. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105507. */
  105508. ambientColor: Color3;
  105509. /**
  105510. * The basic color of the material as viewed under a light.
  105511. */
  105512. diffuseColor: Color3;
  105513. /**
  105514. * Define how the color and intensity of the highlight given by the light in the material.
  105515. */
  105516. specularColor: Color3;
  105517. /**
  105518. * Define the color of the material as if self lit.
  105519. * This will be mixed in the final result even in the absence of light.
  105520. */
  105521. emissiveColor: Color3;
  105522. /**
  105523. * Defines how sharp are the highlights in the material.
  105524. * The bigger the value the sharper giving a more glossy feeling to the result.
  105525. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105526. */
  105527. specularPower: number;
  105528. private _useAlphaFromDiffuseTexture;
  105529. /**
  105530. * Does the transparency come from the diffuse texture alpha channel.
  105531. */
  105532. useAlphaFromDiffuseTexture: boolean;
  105533. private _useEmissiveAsIllumination;
  105534. /**
  105535. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105536. */
  105537. useEmissiveAsIllumination: boolean;
  105538. private _linkEmissiveWithDiffuse;
  105539. /**
  105540. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105541. * the emissive level when the final color is close to one.
  105542. */
  105543. linkEmissiveWithDiffuse: boolean;
  105544. private _useSpecularOverAlpha;
  105545. /**
  105546. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105547. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105548. */
  105549. useSpecularOverAlpha: boolean;
  105550. private _useReflectionOverAlpha;
  105551. /**
  105552. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105553. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105554. */
  105555. useReflectionOverAlpha: boolean;
  105556. private _disableLighting;
  105557. /**
  105558. * Does lights from the scene impacts this material.
  105559. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105560. */
  105561. disableLighting: boolean;
  105562. private _useObjectSpaceNormalMap;
  105563. /**
  105564. * Allows using an object space normal map (instead of tangent space).
  105565. */
  105566. useObjectSpaceNormalMap: boolean;
  105567. private _useParallax;
  105568. /**
  105569. * Is parallax enabled or not.
  105570. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105571. */
  105572. useParallax: boolean;
  105573. private _useParallaxOcclusion;
  105574. /**
  105575. * Is parallax occlusion enabled or not.
  105576. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105577. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105578. */
  105579. useParallaxOcclusion: boolean;
  105580. /**
  105581. * 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.
  105582. */
  105583. parallaxScaleBias: number;
  105584. private _roughness;
  105585. /**
  105586. * Helps to define how blurry the reflections should appears in the material.
  105587. */
  105588. roughness: number;
  105589. /**
  105590. * In case of refraction, define the value of the index of refraction.
  105591. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105592. */
  105593. indexOfRefraction: number;
  105594. /**
  105595. * Invert the refraction texture alongside the y axis.
  105596. * It can be useful with procedural textures or probe for instance.
  105597. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105598. */
  105599. invertRefractionY: boolean;
  105600. /**
  105601. * Defines the alpha limits in alpha test mode.
  105602. */
  105603. alphaCutOff: number;
  105604. private _useLightmapAsShadowmap;
  105605. /**
  105606. * In case of light mapping, define whether the map contains light or shadow informations.
  105607. */
  105608. useLightmapAsShadowmap: boolean;
  105609. private _diffuseFresnelParameters;
  105610. /**
  105611. * Define the diffuse fresnel parameters of the material.
  105612. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105613. */
  105614. diffuseFresnelParameters: FresnelParameters;
  105615. private _opacityFresnelParameters;
  105616. /**
  105617. * Define the opacity fresnel parameters of the material.
  105618. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105619. */
  105620. opacityFresnelParameters: FresnelParameters;
  105621. private _reflectionFresnelParameters;
  105622. /**
  105623. * Define the reflection fresnel parameters of the material.
  105624. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105625. */
  105626. reflectionFresnelParameters: FresnelParameters;
  105627. private _refractionFresnelParameters;
  105628. /**
  105629. * Define the refraction fresnel parameters of the material.
  105630. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105631. */
  105632. refractionFresnelParameters: FresnelParameters;
  105633. private _emissiveFresnelParameters;
  105634. /**
  105635. * Define the emissive fresnel parameters of the material.
  105636. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105637. */
  105638. emissiveFresnelParameters: FresnelParameters;
  105639. private _useReflectionFresnelFromSpecular;
  105640. /**
  105641. * If true automatically deducts the fresnels values from the material specularity.
  105642. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105643. */
  105644. useReflectionFresnelFromSpecular: boolean;
  105645. private _useGlossinessFromSpecularMapAlpha;
  105646. /**
  105647. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105648. */
  105649. useGlossinessFromSpecularMapAlpha: boolean;
  105650. private _maxSimultaneousLights;
  105651. /**
  105652. * Defines the maximum number of lights that can be used in the material
  105653. */
  105654. maxSimultaneousLights: number;
  105655. private _invertNormalMapX;
  105656. /**
  105657. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105658. */
  105659. invertNormalMapX: boolean;
  105660. private _invertNormalMapY;
  105661. /**
  105662. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105663. */
  105664. invertNormalMapY: boolean;
  105665. private _twoSidedLighting;
  105666. /**
  105667. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105668. */
  105669. twoSidedLighting: boolean;
  105670. /**
  105671. * Default configuration related to image processing available in the standard Material.
  105672. */
  105673. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105674. /**
  105675. * Gets the image processing configuration used either in this material.
  105676. */
  105677. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105678. /**
  105679. * Sets the Default image processing configuration used either in the this material.
  105680. *
  105681. * If sets to null, the scene one is in use.
  105682. */
  105683. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  105684. /**
  105685. * Keep track of the image processing observer to allow dispose and replace.
  105686. */
  105687. private _imageProcessingObserver;
  105688. /**
  105689. * Attaches a new image processing configuration to the Standard Material.
  105690. * @param configuration
  105691. */
  105692. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105693. /**
  105694. * Defines additionnal PrePass parameters for the material.
  105695. */
  105696. readonly prePassConfiguration: PrePassConfiguration;
  105697. /**
  105698. * Gets wether the color curves effect is enabled.
  105699. */
  105700. get cameraColorCurvesEnabled(): boolean;
  105701. /**
  105702. * Sets wether the color curves effect is enabled.
  105703. */
  105704. set cameraColorCurvesEnabled(value: boolean);
  105705. /**
  105706. * Gets wether the color grading effect is enabled.
  105707. */
  105708. get cameraColorGradingEnabled(): boolean;
  105709. /**
  105710. * Gets wether the color grading effect is enabled.
  105711. */
  105712. set cameraColorGradingEnabled(value: boolean);
  105713. /**
  105714. * Gets wether tonemapping is enabled or not.
  105715. */
  105716. get cameraToneMappingEnabled(): boolean;
  105717. /**
  105718. * Sets wether tonemapping is enabled or not
  105719. */
  105720. set cameraToneMappingEnabled(value: boolean);
  105721. /**
  105722. * The camera exposure used on this material.
  105723. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105724. * This corresponds to a photographic exposure.
  105725. */
  105726. get cameraExposure(): number;
  105727. /**
  105728. * The camera exposure used on this material.
  105729. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105730. * This corresponds to a photographic exposure.
  105731. */
  105732. set cameraExposure(value: number);
  105733. /**
  105734. * Gets The camera contrast used on this material.
  105735. */
  105736. get cameraContrast(): number;
  105737. /**
  105738. * Sets The camera contrast used on this material.
  105739. */
  105740. set cameraContrast(value: number);
  105741. /**
  105742. * Gets the Color Grading 2D Lookup Texture.
  105743. */
  105744. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105745. /**
  105746. * Sets the Color Grading 2D Lookup Texture.
  105747. */
  105748. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105749. /**
  105750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105752. * 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;
  105753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105754. */
  105755. get cameraColorCurves(): Nullable<ColorCurves>;
  105756. /**
  105757. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105758. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105759. * 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;
  105760. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105761. */
  105762. set cameraColorCurves(value: Nullable<ColorCurves>);
  105763. /**
  105764. * Can this material render to several textures at once
  105765. */
  105766. get canRenderToMRT(): boolean;
  105767. /**
  105768. * Defines the detail map parameters for the material.
  105769. */
  105770. readonly detailMap: DetailMapConfiguration;
  105771. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105772. protected _worldViewProjectionMatrix: Matrix;
  105773. protected _globalAmbientColor: Color3;
  105774. protected _useLogarithmicDepth: boolean;
  105775. protected _rebuildInParallel: boolean;
  105776. /**
  105777. * Instantiates a new standard material.
  105778. * This is the default material used in Babylon. It is the best trade off between quality
  105779. * and performances.
  105780. * @see https://doc.babylonjs.com/babylon101/materials
  105781. * @param name Define the name of the material in the scene
  105782. * @param scene Define the scene the material belong to
  105783. */
  105784. constructor(name: string, scene: Scene);
  105785. /**
  105786. * Gets a boolean indicating that current material needs to register RTT
  105787. */
  105788. get hasRenderTargetTextures(): boolean;
  105789. /**
  105790. * Gets the current class name of the material e.g. "StandardMaterial"
  105791. * Mainly use in serialization.
  105792. * @returns the class name
  105793. */
  105794. getClassName(): string;
  105795. /**
  105796. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105797. * You can try switching to logarithmic depth.
  105798. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105799. */
  105800. get useLogarithmicDepth(): boolean;
  105801. set useLogarithmicDepth(value: boolean);
  105802. /**
  105803. * Specifies if the material will require alpha blending
  105804. * @returns a boolean specifying if alpha blending is needed
  105805. */
  105806. needAlphaBlending(): boolean;
  105807. /**
  105808. * Specifies if this material should be rendered in alpha test mode
  105809. * @returns a boolean specifying if an alpha test is needed.
  105810. */
  105811. needAlphaTesting(): boolean;
  105812. /**
  105813. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105814. */
  105815. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105816. /**
  105817. * Specifies whether or not there is a usable alpha channel for transparency.
  105818. */
  105819. protected _hasAlphaChannel(): boolean;
  105820. /**
  105821. * Get the texture used for alpha test purpose.
  105822. * @returns the diffuse texture in case of the standard material.
  105823. */
  105824. getAlphaTestTexture(): Nullable<BaseTexture>;
  105825. /**
  105826. * Get if the submesh is ready to be used and all its information available.
  105827. * Child classes can use it to update shaders
  105828. * @param mesh defines the mesh to check
  105829. * @param subMesh defines which submesh to check
  105830. * @param useInstances specifies that instances should be used
  105831. * @returns a boolean indicating that the submesh is ready or not
  105832. */
  105833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105834. /**
  105835. * Builds the material UBO layouts.
  105836. * Used internally during the effect preparation.
  105837. */
  105838. buildUniformLayout(): void;
  105839. /**
  105840. * Unbinds the material from the mesh
  105841. */
  105842. unbind(): void;
  105843. /**
  105844. * Binds the submesh to this material by preparing the effect and shader to draw
  105845. * @param world defines the world transformation matrix
  105846. * @param mesh defines the mesh containing the submesh
  105847. * @param subMesh defines the submesh to bind the material to
  105848. */
  105849. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105850. /**
  105851. * Get the list of animatables in the material.
  105852. * @returns the list of animatables object used in the material
  105853. */
  105854. getAnimatables(): IAnimatable[];
  105855. /**
  105856. * Gets the active textures from the material
  105857. * @returns an array of textures
  105858. */
  105859. getActiveTextures(): BaseTexture[];
  105860. /**
  105861. * Specifies if the material uses a texture
  105862. * @param texture defines the texture to check against the material
  105863. * @returns a boolean specifying if the material uses the texture
  105864. */
  105865. hasTexture(texture: BaseTexture): boolean;
  105866. /**
  105867. * Disposes the material
  105868. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105869. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105870. */
  105871. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105872. /**
  105873. * Makes a duplicate of the material, and gives it a new name
  105874. * @param name defines the new name for the duplicated material
  105875. * @returns the cloned material
  105876. */
  105877. clone(name: string): StandardMaterial;
  105878. /**
  105879. * Serializes this material in a JSON representation
  105880. * @returns the serialized material object
  105881. */
  105882. serialize(): any;
  105883. /**
  105884. * Creates a standard material from parsed material data
  105885. * @param source defines the JSON representation of the material
  105886. * @param scene defines the hosting scene
  105887. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105888. * @returns a new standard material
  105889. */
  105890. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105891. /**
  105892. * Are diffuse textures enabled in the application.
  105893. */
  105894. static get DiffuseTextureEnabled(): boolean;
  105895. static set DiffuseTextureEnabled(value: boolean);
  105896. /**
  105897. * Are detail textures enabled in the application.
  105898. */
  105899. static get DetailTextureEnabled(): boolean;
  105900. static set DetailTextureEnabled(value: boolean);
  105901. /**
  105902. * Are ambient textures enabled in the application.
  105903. */
  105904. static get AmbientTextureEnabled(): boolean;
  105905. static set AmbientTextureEnabled(value: boolean);
  105906. /**
  105907. * Are opacity textures enabled in the application.
  105908. */
  105909. static get OpacityTextureEnabled(): boolean;
  105910. static set OpacityTextureEnabled(value: boolean);
  105911. /**
  105912. * Are reflection textures enabled in the application.
  105913. */
  105914. static get ReflectionTextureEnabled(): boolean;
  105915. static set ReflectionTextureEnabled(value: boolean);
  105916. /**
  105917. * Are emissive textures enabled in the application.
  105918. */
  105919. static get EmissiveTextureEnabled(): boolean;
  105920. static set EmissiveTextureEnabled(value: boolean);
  105921. /**
  105922. * Are specular textures enabled in the application.
  105923. */
  105924. static get SpecularTextureEnabled(): boolean;
  105925. static set SpecularTextureEnabled(value: boolean);
  105926. /**
  105927. * Are bump textures enabled in the application.
  105928. */
  105929. static get BumpTextureEnabled(): boolean;
  105930. static set BumpTextureEnabled(value: boolean);
  105931. /**
  105932. * Are lightmap textures enabled in the application.
  105933. */
  105934. static get LightmapTextureEnabled(): boolean;
  105935. static set LightmapTextureEnabled(value: boolean);
  105936. /**
  105937. * Are refraction textures enabled in the application.
  105938. */
  105939. static get RefractionTextureEnabled(): boolean;
  105940. static set RefractionTextureEnabled(value: boolean);
  105941. /**
  105942. * Are color grading textures enabled in the application.
  105943. */
  105944. static get ColorGradingTextureEnabled(): boolean;
  105945. static set ColorGradingTextureEnabled(value: boolean);
  105946. /**
  105947. * Are fresnels enabled in the application.
  105948. */
  105949. static get FresnelEnabled(): boolean;
  105950. static set FresnelEnabled(value: boolean);
  105951. }
  105952. }
  105953. declare module BABYLON {
  105954. /** @hidden */
  105955. export var rgbdDecodePixelShader: {
  105956. name: string;
  105957. shader: string;
  105958. };
  105959. }
  105960. declare module BABYLON {
  105961. /**
  105962. * Class used to host RGBD texture specific utilities
  105963. */
  105964. export class RGBDTextureTools {
  105965. /**
  105966. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105967. * @param texture the texture to expand.
  105968. */
  105969. static ExpandRGBDTexture(texture: Texture): void;
  105970. }
  105971. }
  105972. declare module BABYLON {
  105973. /**
  105974. * Class used to host texture specific utilities
  105975. */
  105976. export class BRDFTextureTools {
  105977. /**
  105978. * Prevents texture cache collision
  105979. */
  105980. private static _instanceNumber;
  105981. /**
  105982. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105983. * @param scene defines the hosting scene
  105984. * @returns the environment BRDF texture
  105985. */
  105986. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105987. private static _environmentBRDFBase64Texture;
  105988. }
  105989. }
  105990. declare module BABYLON {
  105991. /**
  105992. * @hidden
  105993. */
  105994. export interface IMaterialClearCoatDefines {
  105995. CLEARCOAT: boolean;
  105996. CLEARCOAT_DEFAULTIOR: boolean;
  105997. CLEARCOAT_TEXTURE: boolean;
  105998. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105999. CLEARCOAT_TEXTUREDIRECTUV: number;
  106000. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106001. CLEARCOAT_BUMP: boolean;
  106002. CLEARCOAT_BUMPDIRECTUV: number;
  106003. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106004. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106005. CLEARCOAT_REMAP_F0: boolean;
  106006. CLEARCOAT_TINT: boolean;
  106007. CLEARCOAT_TINT_TEXTURE: boolean;
  106008. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106009. /** @hidden */
  106010. _areTexturesDirty: boolean;
  106011. }
  106012. /**
  106013. * Define the code related to the clear coat parameters of the pbr material.
  106014. */
  106015. export class PBRClearCoatConfiguration {
  106016. /**
  106017. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106018. * The default fits with a polyurethane material.
  106019. */
  106020. private static readonly _DefaultIndexOfRefraction;
  106021. private _isEnabled;
  106022. /**
  106023. * Defines if the clear coat is enabled in the material.
  106024. */
  106025. isEnabled: boolean;
  106026. /**
  106027. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  106028. */
  106029. intensity: number;
  106030. /**
  106031. * Defines the clear coat layer roughness.
  106032. */
  106033. roughness: number;
  106034. private _indexOfRefraction;
  106035. /**
  106036. * Defines the index of refraction of the clear coat.
  106037. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106038. * The default fits with a polyurethane material.
  106039. * Changing the default value is more performance intensive.
  106040. */
  106041. indexOfRefraction: number;
  106042. private _texture;
  106043. /**
  106044. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  106045. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  106046. * if textureRoughness is not empty, else no texture roughness is used
  106047. */
  106048. texture: Nullable<BaseTexture>;
  106049. private _useRoughnessFromMainTexture;
  106050. /**
  106051. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  106052. * If false, the green channel from textureRoughness is used for roughness
  106053. */
  106054. useRoughnessFromMainTexture: boolean;
  106055. private _textureRoughness;
  106056. /**
  106057. * Stores the clear coat roughness in a texture (green channel)
  106058. * Not used if useRoughnessFromMainTexture is true
  106059. */
  106060. textureRoughness: Nullable<BaseTexture>;
  106061. private _remapF0OnInterfaceChange;
  106062. /**
  106063. * Defines if the F0 value should be remapped to account for the interface change in the material.
  106064. */
  106065. remapF0OnInterfaceChange: boolean;
  106066. private _bumpTexture;
  106067. /**
  106068. * Define the clear coat specific bump texture.
  106069. */
  106070. bumpTexture: Nullable<BaseTexture>;
  106071. private _isTintEnabled;
  106072. /**
  106073. * Defines if the clear coat tint is enabled in the material.
  106074. */
  106075. isTintEnabled: boolean;
  106076. /**
  106077. * Defines the clear coat tint of the material.
  106078. * This is only use if tint is enabled
  106079. */
  106080. tintColor: Color3;
  106081. /**
  106082. * Defines the distance at which the tint color should be found in the
  106083. * clear coat media.
  106084. * This is only use if tint is enabled
  106085. */
  106086. tintColorAtDistance: number;
  106087. /**
  106088. * Defines the clear coat layer thickness.
  106089. * This is only use if tint is enabled
  106090. */
  106091. tintThickness: number;
  106092. private _tintTexture;
  106093. /**
  106094. * Stores the clear tint values in a texture.
  106095. * rgb is tint
  106096. * a is a thickness factor
  106097. */
  106098. tintTexture: Nullable<BaseTexture>;
  106099. /** @hidden */
  106100. private _internalMarkAllSubMeshesAsTexturesDirty;
  106101. /** @hidden */
  106102. _markAllSubMeshesAsTexturesDirty(): void;
  106103. /**
  106104. * Instantiate a new istance of clear coat configuration.
  106105. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106106. */
  106107. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106108. /**
  106109. * Gets wehter the submesh is ready to be used or not.
  106110. * @param defines the list of "defines" to update.
  106111. * @param scene defines the scene the material belongs to.
  106112. * @param engine defines the engine the material belongs to.
  106113. * @param disableBumpMap defines wether the material disables bump or not.
  106114. * @returns - boolean indicating that the submesh is ready or not.
  106115. */
  106116. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106117. /**
  106118. * Checks to see if a texture is used in the material.
  106119. * @param defines the list of "defines" to update.
  106120. * @param scene defines the scene to the material belongs to.
  106121. */
  106122. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106123. /**
  106124. * Binds the material data.
  106125. * @param uniformBuffer defines the Uniform buffer to fill in.
  106126. * @param scene defines the scene the material belongs to.
  106127. * @param engine defines the engine the material belongs to.
  106128. * @param disableBumpMap defines wether the material disables bump or not.
  106129. * @param isFrozen defines wether the material is frozen or not.
  106130. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106131. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106132. * @param subMesh the submesh to bind data for
  106133. */
  106134. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  106135. /**
  106136. * Checks to see if a texture is used in the material.
  106137. * @param texture - Base texture to use.
  106138. * @returns - Boolean specifying if a texture is used in the material.
  106139. */
  106140. hasTexture(texture: BaseTexture): boolean;
  106141. /**
  106142. * Returns an array of the actively used textures.
  106143. * @param activeTextures Array of BaseTextures
  106144. */
  106145. getActiveTextures(activeTextures: BaseTexture[]): void;
  106146. /**
  106147. * Returns the animatable textures.
  106148. * @param animatables Array of animatable textures.
  106149. */
  106150. getAnimatables(animatables: IAnimatable[]): void;
  106151. /**
  106152. * Disposes the resources of the material.
  106153. * @param forceDisposeTextures - Forces the disposal of all textures.
  106154. */
  106155. dispose(forceDisposeTextures?: boolean): void;
  106156. /**
  106157. * Get the current class name of the texture useful for serialization or dynamic coding.
  106158. * @returns "PBRClearCoatConfiguration"
  106159. */
  106160. getClassName(): string;
  106161. /**
  106162. * Add fallbacks to the effect fallbacks list.
  106163. * @param defines defines the Base texture to use.
  106164. * @param fallbacks defines the current fallback list.
  106165. * @param currentRank defines the current fallback rank.
  106166. * @returns the new fallback rank.
  106167. */
  106168. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106169. /**
  106170. * Add the required uniforms to the current list.
  106171. * @param uniforms defines the current uniform list.
  106172. */
  106173. static AddUniforms(uniforms: string[]): void;
  106174. /**
  106175. * Add the required samplers to the current list.
  106176. * @param samplers defines the current sampler list.
  106177. */
  106178. static AddSamplers(samplers: string[]): void;
  106179. /**
  106180. * Add the required uniforms to the current buffer.
  106181. * @param uniformBuffer defines the current uniform buffer.
  106182. */
  106183. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106184. /**
  106185. * Makes a duplicate of the current configuration into another one.
  106186. * @param clearCoatConfiguration define the config where to copy the info
  106187. */
  106188. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106189. /**
  106190. * Serializes this clear coat configuration.
  106191. * @returns - An object with the serialized config.
  106192. */
  106193. serialize(): any;
  106194. /**
  106195. * Parses a anisotropy Configuration from a serialized object.
  106196. * @param source - Serialized object.
  106197. * @param scene Defines the scene we are parsing for
  106198. * @param rootUrl Defines the rootUrl to load from
  106199. */
  106200. parse(source: any, scene: Scene, rootUrl: string): void;
  106201. }
  106202. }
  106203. declare module BABYLON {
  106204. /**
  106205. * @hidden
  106206. */
  106207. export interface IMaterialAnisotropicDefines {
  106208. ANISOTROPIC: boolean;
  106209. ANISOTROPIC_TEXTURE: boolean;
  106210. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106211. MAINUV1: boolean;
  106212. _areTexturesDirty: boolean;
  106213. _needUVs: boolean;
  106214. }
  106215. /**
  106216. * Define the code related to the anisotropic parameters of the pbr material.
  106217. */
  106218. export class PBRAnisotropicConfiguration {
  106219. private _isEnabled;
  106220. /**
  106221. * Defines if the anisotropy is enabled in the material.
  106222. */
  106223. isEnabled: boolean;
  106224. /**
  106225. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106226. */
  106227. intensity: number;
  106228. /**
  106229. * Defines if the effect is along the tangents, bitangents or in between.
  106230. * By default, the effect is "strectching" the highlights along the tangents.
  106231. */
  106232. direction: Vector2;
  106233. private _texture;
  106234. /**
  106235. * Stores the anisotropy values in a texture.
  106236. * rg is direction (like normal from -1 to 1)
  106237. * b is a intensity
  106238. */
  106239. texture: Nullable<BaseTexture>;
  106240. /** @hidden */
  106241. private _internalMarkAllSubMeshesAsTexturesDirty;
  106242. /** @hidden */
  106243. _markAllSubMeshesAsTexturesDirty(): void;
  106244. /**
  106245. * Instantiate a new istance of anisotropy configuration.
  106246. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106247. */
  106248. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106249. /**
  106250. * Specifies that the submesh is ready to be used.
  106251. * @param defines the list of "defines" to update.
  106252. * @param scene defines the scene the material belongs to.
  106253. * @returns - boolean indicating that the submesh is ready or not.
  106254. */
  106255. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106256. /**
  106257. * Checks to see if a texture is used in the material.
  106258. * @param defines the list of "defines" to update.
  106259. * @param mesh the mesh we are preparing the defines for.
  106260. * @param scene defines the scene the material belongs to.
  106261. */
  106262. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106263. /**
  106264. * Binds the material data.
  106265. * @param uniformBuffer defines the Uniform buffer to fill in.
  106266. * @param scene defines the scene the material belongs to.
  106267. * @param isFrozen defines wether the material is frozen or not.
  106268. */
  106269. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106270. /**
  106271. * Checks to see if a texture is used in the material.
  106272. * @param texture - Base texture to use.
  106273. * @returns - Boolean specifying if a texture is used in the material.
  106274. */
  106275. hasTexture(texture: BaseTexture): boolean;
  106276. /**
  106277. * Returns an array of the actively used textures.
  106278. * @param activeTextures Array of BaseTextures
  106279. */
  106280. getActiveTextures(activeTextures: BaseTexture[]): void;
  106281. /**
  106282. * Returns the animatable textures.
  106283. * @param animatables Array of animatable textures.
  106284. */
  106285. getAnimatables(animatables: IAnimatable[]): void;
  106286. /**
  106287. * Disposes the resources of the material.
  106288. * @param forceDisposeTextures - Forces the disposal of all textures.
  106289. */
  106290. dispose(forceDisposeTextures?: boolean): void;
  106291. /**
  106292. * Get the current class name of the texture useful for serialization or dynamic coding.
  106293. * @returns "PBRAnisotropicConfiguration"
  106294. */
  106295. getClassName(): string;
  106296. /**
  106297. * Add fallbacks to the effect fallbacks list.
  106298. * @param defines defines the Base texture to use.
  106299. * @param fallbacks defines the current fallback list.
  106300. * @param currentRank defines the current fallback rank.
  106301. * @returns the new fallback rank.
  106302. */
  106303. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106304. /**
  106305. * Add the required uniforms to the current list.
  106306. * @param uniforms defines the current uniform list.
  106307. */
  106308. static AddUniforms(uniforms: string[]): void;
  106309. /**
  106310. * Add the required uniforms to the current buffer.
  106311. * @param uniformBuffer defines the current uniform buffer.
  106312. */
  106313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106314. /**
  106315. * Add the required samplers to the current list.
  106316. * @param samplers defines the current sampler list.
  106317. */
  106318. static AddSamplers(samplers: string[]): void;
  106319. /**
  106320. * Makes a duplicate of the current configuration into another one.
  106321. * @param anisotropicConfiguration define the config where to copy the info
  106322. */
  106323. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  106324. /**
  106325. * Serializes this anisotropy configuration.
  106326. * @returns - An object with the serialized config.
  106327. */
  106328. serialize(): any;
  106329. /**
  106330. * Parses a anisotropy Configuration from a serialized object.
  106331. * @param source - Serialized object.
  106332. * @param scene Defines the scene we are parsing for
  106333. * @param rootUrl Defines the rootUrl to load from
  106334. */
  106335. parse(source: any, scene: Scene, rootUrl: string): void;
  106336. }
  106337. }
  106338. declare module BABYLON {
  106339. /**
  106340. * @hidden
  106341. */
  106342. export interface IMaterialBRDFDefines {
  106343. BRDF_V_HEIGHT_CORRELATED: boolean;
  106344. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106345. SPHERICAL_HARMONICS: boolean;
  106346. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106347. /** @hidden */
  106348. _areMiscDirty: boolean;
  106349. }
  106350. /**
  106351. * Define the code related to the BRDF parameters of the pbr material.
  106352. */
  106353. export class PBRBRDFConfiguration {
  106354. /**
  106355. * Default value used for the energy conservation.
  106356. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106357. */
  106358. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  106359. /**
  106360. * Default value used for the Smith Visibility Height Correlated mode.
  106361. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106362. */
  106363. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  106364. /**
  106365. * Default value used for the IBL diffuse part.
  106366. * This can help switching back to the polynomials mode globally which is a tiny bit
  106367. * less GPU intensive at the drawback of a lower quality.
  106368. */
  106369. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  106370. /**
  106371. * Default value used for activating energy conservation for the specular workflow.
  106372. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106373. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106374. */
  106375. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  106376. private _useEnergyConservation;
  106377. /**
  106378. * Defines if the material uses energy conservation.
  106379. */
  106380. useEnergyConservation: boolean;
  106381. private _useSmithVisibilityHeightCorrelated;
  106382. /**
  106383. * LEGACY Mode set to false
  106384. * Defines if the material uses height smith correlated visibility term.
  106385. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  106386. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  106387. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  106388. * Not relying on height correlated will also disable energy conservation.
  106389. */
  106390. useSmithVisibilityHeightCorrelated: boolean;
  106391. private _useSphericalHarmonics;
  106392. /**
  106393. * LEGACY Mode set to false
  106394. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  106395. * diffuse part of the IBL.
  106396. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  106397. * to the ground truth.
  106398. */
  106399. useSphericalHarmonics: boolean;
  106400. private _useSpecularGlossinessInputEnergyConservation;
  106401. /**
  106402. * Defines if the material uses energy conservation, when the specular workflow is active.
  106403. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106404. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106405. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  106406. */
  106407. useSpecularGlossinessInputEnergyConservation: boolean;
  106408. /** @hidden */
  106409. private _internalMarkAllSubMeshesAsMiscDirty;
  106410. /** @hidden */
  106411. _markAllSubMeshesAsMiscDirty(): void;
  106412. /**
  106413. * Instantiate a new istance of clear coat configuration.
  106414. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  106415. */
  106416. constructor(markAllSubMeshesAsMiscDirty: () => void);
  106417. /**
  106418. * Checks to see if a texture is used in the material.
  106419. * @param defines the list of "defines" to update.
  106420. */
  106421. prepareDefines(defines: IMaterialBRDFDefines): void;
  106422. /**
  106423. * Get the current class name of the texture useful for serialization or dynamic coding.
  106424. * @returns "PBRClearCoatConfiguration"
  106425. */
  106426. getClassName(): string;
  106427. /**
  106428. * Makes a duplicate of the current configuration into another one.
  106429. * @param brdfConfiguration define the config where to copy the info
  106430. */
  106431. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  106432. /**
  106433. * Serializes this BRDF configuration.
  106434. * @returns - An object with the serialized config.
  106435. */
  106436. serialize(): any;
  106437. /**
  106438. * Parses a anisotropy Configuration from a serialized object.
  106439. * @param source - Serialized object.
  106440. * @param scene Defines the scene we are parsing for
  106441. * @param rootUrl Defines the rootUrl to load from
  106442. */
  106443. parse(source: any, scene: Scene, rootUrl: string): void;
  106444. }
  106445. }
  106446. declare module BABYLON {
  106447. /**
  106448. * @hidden
  106449. */
  106450. export interface IMaterialSheenDefines {
  106451. SHEEN: boolean;
  106452. SHEEN_TEXTURE: boolean;
  106453. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106454. SHEEN_TEXTUREDIRECTUV: number;
  106455. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106456. SHEEN_LINKWITHALBEDO: boolean;
  106457. SHEEN_ROUGHNESS: boolean;
  106458. SHEEN_ALBEDOSCALING: boolean;
  106459. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106460. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106461. /** @hidden */
  106462. _areTexturesDirty: boolean;
  106463. }
  106464. /**
  106465. * Define the code related to the Sheen parameters of the pbr material.
  106466. */
  106467. export class PBRSheenConfiguration {
  106468. private _isEnabled;
  106469. /**
  106470. * Defines if the material uses sheen.
  106471. */
  106472. isEnabled: boolean;
  106473. private _linkSheenWithAlbedo;
  106474. /**
  106475. * Defines if the sheen is linked to the sheen color.
  106476. */
  106477. linkSheenWithAlbedo: boolean;
  106478. /**
  106479. * Defines the sheen intensity.
  106480. */
  106481. intensity: number;
  106482. /**
  106483. * Defines the sheen color.
  106484. */
  106485. color: Color3;
  106486. private _texture;
  106487. /**
  106488. * Stores the sheen tint values in a texture.
  106489. * rgb is tint
  106490. * 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)
  106491. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  106492. */
  106493. texture: Nullable<BaseTexture>;
  106494. private _useRoughnessFromMainTexture;
  106495. /**
  106496. * Indicates that the alpha channel of the texture property will be used for roughness.
  106497. * Has no effect if the roughness (and texture!) property is not defined
  106498. */
  106499. useRoughnessFromMainTexture: boolean;
  106500. private _roughness;
  106501. /**
  106502. * Defines the sheen roughness.
  106503. * It is not taken into account if linkSheenWithAlbedo is true.
  106504. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  106505. */
  106506. roughness: Nullable<number>;
  106507. private _textureRoughness;
  106508. /**
  106509. * Stores the sheen roughness in a texture.
  106510. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  106511. */
  106512. textureRoughness: Nullable<BaseTexture>;
  106513. private _albedoScaling;
  106514. /**
  106515. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  106516. * It allows the strength of the sheen effect to not depend on the base color of the material,
  106517. * making it easier to setup and tweak the effect
  106518. */
  106519. albedoScaling: boolean;
  106520. /** @hidden */
  106521. private _internalMarkAllSubMeshesAsTexturesDirty;
  106522. /** @hidden */
  106523. _markAllSubMeshesAsTexturesDirty(): void;
  106524. /**
  106525. * Instantiate a new istance of clear coat configuration.
  106526. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106527. */
  106528. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106529. /**
  106530. * Specifies that the submesh is ready to be used.
  106531. * @param defines the list of "defines" to update.
  106532. * @param scene defines the scene the material belongs to.
  106533. * @returns - boolean indicating that the submesh is ready or not.
  106534. */
  106535. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  106536. /**
  106537. * Checks to see if a texture is used in the material.
  106538. * @param defines the list of "defines" to update.
  106539. * @param scene defines the scene the material belongs to.
  106540. */
  106541. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  106542. /**
  106543. * Binds the material data.
  106544. * @param uniformBuffer defines the Uniform buffer to fill in.
  106545. * @param scene defines the scene the material belongs to.
  106546. * @param isFrozen defines wether the material is frozen or not.
  106547. * @param subMesh the submesh to bind data for
  106548. */
  106549. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  106550. /**
  106551. * Checks to see if a texture is used in the material.
  106552. * @param texture - Base texture to use.
  106553. * @returns - Boolean specifying if a texture is used in the material.
  106554. */
  106555. hasTexture(texture: BaseTexture): boolean;
  106556. /**
  106557. * Returns an array of the actively used textures.
  106558. * @param activeTextures Array of BaseTextures
  106559. */
  106560. getActiveTextures(activeTextures: BaseTexture[]): void;
  106561. /**
  106562. * Returns the animatable textures.
  106563. * @param animatables Array of animatable textures.
  106564. */
  106565. getAnimatables(animatables: IAnimatable[]): void;
  106566. /**
  106567. * Disposes the resources of the material.
  106568. * @param forceDisposeTextures - Forces the disposal of all textures.
  106569. */
  106570. dispose(forceDisposeTextures?: boolean): void;
  106571. /**
  106572. * Get the current class name of the texture useful for serialization or dynamic coding.
  106573. * @returns "PBRSheenConfiguration"
  106574. */
  106575. getClassName(): string;
  106576. /**
  106577. * Add fallbacks to the effect fallbacks list.
  106578. * @param defines defines the Base texture to use.
  106579. * @param fallbacks defines the current fallback list.
  106580. * @param currentRank defines the current fallback rank.
  106581. * @returns the new fallback rank.
  106582. */
  106583. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106584. /**
  106585. * Add the required uniforms to the current list.
  106586. * @param uniforms defines the current uniform list.
  106587. */
  106588. static AddUniforms(uniforms: string[]): void;
  106589. /**
  106590. * Add the required uniforms to the current buffer.
  106591. * @param uniformBuffer defines the current uniform buffer.
  106592. */
  106593. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106594. /**
  106595. * Add the required samplers to the current list.
  106596. * @param samplers defines the current sampler list.
  106597. */
  106598. static AddSamplers(samplers: string[]): void;
  106599. /**
  106600. * Makes a duplicate of the current configuration into another one.
  106601. * @param sheenConfiguration define the config where to copy the info
  106602. */
  106603. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  106604. /**
  106605. * Serializes this BRDF configuration.
  106606. * @returns - An object with the serialized config.
  106607. */
  106608. serialize(): any;
  106609. /**
  106610. * Parses a anisotropy Configuration from a serialized object.
  106611. * @param source - Serialized object.
  106612. * @param scene Defines the scene we are parsing for
  106613. * @param rootUrl Defines the rootUrl to load from
  106614. */
  106615. parse(source: any, scene: Scene, rootUrl: string): void;
  106616. }
  106617. }
  106618. declare module BABYLON {
  106619. /**
  106620. * @hidden
  106621. */
  106622. export interface IMaterialSubSurfaceDefines {
  106623. SUBSURFACE: boolean;
  106624. SS_REFRACTION: boolean;
  106625. SS_TRANSLUCENCY: boolean;
  106626. SS_SCATTERING: boolean;
  106627. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106628. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106629. SS_REFRACTIONMAP_3D: boolean;
  106630. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106631. SS_LODINREFRACTIONALPHA: boolean;
  106632. SS_GAMMAREFRACTION: boolean;
  106633. SS_RGBDREFRACTION: boolean;
  106634. SS_LINEARSPECULARREFRACTION: boolean;
  106635. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106636. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106637. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106638. /** @hidden */
  106639. _areTexturesDirty: boolean;
  106640. }
  106641. /**
  106642. * Define the code related to the sub surface parameters of the pbr material.
  106643. */
  106644. export class PBRSubSurfaceConfiguration {
  106645. private _isRefractionEnabled;
  106646. /**
  106647. * Defines if the refraction is enabled in the material.
  106648. */
  106649. isRefractionEnabled: boolean;
  106650. private _isTranslucencyEnabled;
  106651. /**
  106652. * Defines if the translucency is enabled in the material.
  106653. */
  106654. isTranslucencyEnabled: boolean;
  106655. private _isScatteringEnabled;
  106656. /**
  106657. * Defines if the sub surface scattering is enabled in the material.
  106658. */
  106659. isScatteringEnabled: boolean;
  106660. private _scatteringDiffusionProfileIndex;
  106661. /**
  106662. * Diffusion profile for subsurface scattering.
  106663. * Useful for better scattering in the skins or foliages.
  106664. */
  106665. get scatteringDiffusionProfile(): Nullable<Color3>;
  106666. set scatteringDiffusionProfile(c: Nullable<Color3>);
  106667. /**
  106668. * Defines the refraction intensity of the material.
  106669. * The refraction when enabled replaces the Diffuse part of the material.
  106670. * The intensity helps transitionning between diffuse and refraction.
  106671. */
  106672. refractionIntensity: number;
  106673. /**
  106674. * Defines the translucency intensity of the material.
  106675. * When translucency has been enabled, this defines how much of the "translucency"
  106676. * is addded to the diffuse part of the material.
  106677. */
  106678. translucencyIntensity: number;
  106679. /**
  106680. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  106681. */
  106682. useAlbedoToTintRefraction: boolean;
  106683. private _thicknessTexture;
  106684. /**
  106685. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106686. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106687. * 0 would mean minimumThickness
  106688. * 1 would mean maximumThickness
  106689. * The other channels might be use as a mask to vary the different effects intensity.
  106690. */
  106691. thicknessTexture: Nullable<BaseTexture>;
  106692. private _refractionTexture;
  106693. /**
  106694. * Defines the texture to use for refraction.
  106695. */
  106696. refractionTexture: Nullable<BaseTexture>;
  106697. private _indexOfRefraction;
  106698. /**
  106699. * Index of refraction of the material base layer.
  106700. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106701. *
  106702. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106703. *
  106704. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106705. */
  106706. indexOfRefraction: number;
  106707. private _volumeIndexOfRefraction;
  106708. /**
  106709. * Index of refraction of the material's volume.
  106710. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106711. *
  106712. * This ONLY impacts refraction. If not provided or given a non-valid value,
  106713. * the volume will use the same IOR as the surface.
  106714. */
  106715. get volumeIndexOfRefraction(): number;
  106716. set volumeIndexOfRefraction(value: number);
  106717. private _invertRefractionY;
  106718. /**
  106719. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106720. */
  106721. invertRefractionY: boolean;
  106722. private _linkRefractionWithTransparency;
  106723. /**
  106724. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106725. * Materials half opaque for instance using refraction could benefit from this control.
  106726. */
  106727. linkRefractionWithTransparency: boolean;
  106728. /**
  106729. * Defines the minimum thickness stored in the thickness map.
  106730. * If no thickness map is defined, this value will be used to simulate thickness.
  106731. */
  106732. minimumThickness: number;
  106733. /**
  106734. * Defines the maximum thickness stored in the thickness map.
  106735. */
  106736. maximumThickness: number;
  106737. /**
  106738. * Defines the volume tint of the material.
  106739. * This is used for both translucency and scattering.
  106740. */
  106741. tintColor: Color3;
  106742. /**
  106743. * Defines the distance at which the tint color should be found in the media.
  106744. * This is used for refraction only.
  106745. */
  106746. tintColorAtDistance: number;
  106747. /**
  106748. * Defines how far each channel transmit through the media.
  106749. * It is defined as a color to simplify it selection.
  106750. */
  106751. diffusionDistance: Color3;
  106752. private _useMaskFromThicknessTexture;
  106753. /**
  106754. * Stores the intensity of the different subsurface effects in the thickness texture.
  106755. * * the green channel is the translucency intensity.
  106756. * * the blue channel is the scattering intensity.
  106757. * * the alpha channel is the refraction intensity.
  106758. */
  106759. useMaskFromThicknessTexture: boolean;
  106760. private _scene;
  106761. /** @hidden */
  106762. private _internalMarkAllSubMeshesAsTexturesDirty;
  106763. private _internalMarkScenePrePassDirty;
  106764. /** @hidden */
  106765. _markAllSubMeshesAsTexturesDirty(): void;
  106766. /** @hidden */
  106767. _markScenePrePassDirty(): void;
  106768. /**
  106769. * Instantiate a new istance of sub surface configuration.
  106770. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106771. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106772. * @param scene The scene
  106773. */
  106774. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106775. /**
  106776. * Gets wehter the submesh is ready to be used or not.
  106777. * @param defines the list of "defines" to update.
  106778. * @param scene defines the scene the material belongs to.
  106779. * @returns - boolean indicating that the submesh is ready or not.
  106780. */
  106781. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106782. /**
  106783. * Checks to see if a texture is used in the material.
  106784. * @param defines the list of "defines" to update.
  106785. * @param scene defines the scene to the material belongs to.
  106786. */
  106787. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106788. /**
  106789. * Binds the material data.
  106790. * @param uniformBuffer defines the Uniform buffer to fill in.
  106791. * @param scene defines the scene the material belongs to.
  106792. * @param engine defines the engine the material belongs to.
  106793. * @param isFrozen defines whether the material is frozen or not.
  106794. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106795. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106796. */
  106797. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106798. /**
  106799. * Unbinds the material from the mesh.
  106800. * @param activeEffect defines the effect that should be unbound from.
  106801. * @returns true if unbound, otherwise false
  106802. */
  106803. unbind(activeEffect: Effect): boolean;
  106804. /**
  106805. * Returns the texture used for refraction or null if none is used.
  106806. * @param scene defines the scene the material belongs to.
  106807. * @returns - Refraction texture if present. If no refraction texture and refraction
  106808. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106809. */
  106810. private _getRefractionTexture;
  106811. /**
  106812. * Returns true if alpha blending should be disabled.
  106813. */
  106814. get disableAlphaBlending(): boolean;
  106815. /**
  106816. * Fills the list of render target textures.
  106817. * @param renderTargets the list of render targets to update
  106818. */
  106819. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106820. /**
  106821. * Checks to see if a texture is used in the material.
  106822. * @param texture - Base texture to use.
  106823. * @returns - Boolean specifying if a texture is used in the material.
  106824. */
  106825. hasTexture(texture: BaseTexture): boolean;
  106826. /**
  106827. * Gets a boolean indicating that current material needs to register RTT
  106828. * @returns true if this uses a render target otherwise false.
  106829. */
  106830. hasRenderTargetTextures(): boolean;
  106831. /**
  106832. * Returns an array of the actively used textures.
  106833. * @param activeTextures Array of BaseTextures
  106834. */
  106835. getActiveTextures(activeTextures: BaseTexture[]): void;
  106836. /**
  106837. * Returns the animatable textures.
  106838. * @param animatables Array of animatable textures.
  106839. */
  106840. getAnimatables(animatables: IAnimatable[]): void;
  106841. /**
  106842. * Disposes the resources of the material.
  106843. * @param forceDisposeTextures - Forces the disposal of all textures.
  106844. */
  106845. dispose(forceDisposeTextures?: boolean): void;
  106846. /**
  106847. * Get the current class name of the texture useful for serialization or dynamic coding.
  106848. * @returns "PBRSubSurfaceConfiguration"
  106849. */
  106850. getClassName(): string;
  106851. /**
  106852. * Add fallbacks to the effect fallbacks list.
  106853. * @param defines defines the Base texture to use.
  106854. * @param fallbacks defines the current fallback list.
  106855. * @param currentRank defines the current fallback rank.
  106856. * @returns the new fallback rank.
  106857. */
  106858. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106859. /**
  106860. * Add the required uniforms to the current list.
  106861. * @param uniforms defines the current uniform list.
  106862. */
  106863. static AddUniforms(uniforms: string[]): void;
  106864. /**
  106865. * Add the required samplers to the current list.
  106866. * @param samplers defines the current sampler list.
  106867. */
  106868. static AddSamplers(samplers: string[]): void;
  106869. /**
  106870. * Add the required uniforms to the current buffer.
  106871. * @param uniformBuffer defines the current uniform buffer.
  106872. */
  106873. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106874. /**
  106875. * Makes a duplicate of the current configuration into another one.
  106876. * @param configuration define the config where to copy the info
  106877. */
  106878. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106879. /**
  106880. * Serializes this Sub Surface configuration.
  106881. * @returns - An object with the serialized config.
  106882. */
  106883. serialize(): any;
  106884. /**
  106885. * Parses a anisotropy Configuration from a serialized object.
  106886. * @param source - Serialized object.
  106887. * @param scene Defines the scene we are parsing for
  106888. * @param rootUrl Defines the rootUrl to load from
  106889. */
  106890. parse(source: any, scene: Scene, rootUrl: string): void;
  106891. }
  106892. }
  106893. declare module BABYLON {
  106894. /**
  106895. * Class representing spherical harmonics coefficients to the 3rd degree
  106896. */
  106897. export class SphericalHarmonics {
  106898. /**
  106899. * Defines whether or not the harmonics have been prescaled for rendering.
  106900. */
  106901. preScaled: boolean;
  106902. /**
  106903. * The l0,0 coefficients of the spherical harmonics
  106904. */
  106905. l00: Vector3;
  106906. /**
  106907. * The l1,-1 coefficients of the spherical harmonics
  106908. */
  106909. l1_1: Vector3;
  106910. /**
  106911. * The l1,0 coefficients of the spherical harmonics
  106912. */
  106913. l10: Vector3;
  106914. /**
  106915. * The l1,1 coefficients of the spherical harmonics
  106916. */
  106917. l11: Vector3;
  106918. /**
  106919. * The l2,-2 coefficients of the spherical harmonics
  106920. */
  106921. l2_2: Vector3;
  106922. /**
  106923. * The l2,-1 coefficients of the spherical harmonics
  106924. */
  106925. l2_1: Vector3;
  106926. /**
  106927. * The l2,0 coefficients of the spherical harmonics
  106928. */
  106929. l20: Vector3;
  106930. /**
  106931. * The l2,1 coefficients of the spherical harmonics
  106932. */
  106933. l21: Vector3;
  106934. /**
  106935. * The l2,2 coefficients of the spherical harmonics
  106936. */
  106937. l22: Vector3;
  106938. /**
  106939. * Adds a light to the spherical harmonics
  106940. * @param direction the direction of the light
  106941. * @param color the color of the light
  106942. * @param deltaSolidAngle the delta solid angle of the light
  106943. */
  106944. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106945. /**
  106946. * Scales the spherical harmonics by the given amount
  106947. * @param scale the amount to scale
  106948. */
  106949. scaleInPlace(scale: number): void;
  106950. /**
  106951. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106952. *
  106953. * ```
  106954. * E_lm = A_l * L_lm
  106955. * ```
  106956. *
  106957. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106958. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106959. * the scaling factors are given in equation 9.
  106960. */
  106961. convertIncidentRadianceToIrradiance(): void;
  106962. /**
  106963. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106964. *
  106965. * ```
  106966. * L = (1/pi) * E * rho
  106967. * ```
  106968. *
  106969. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106970. */
  106971. convertIrradianceToLambertianRadiance(): void;
  106972. /**
  106973. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106974. * required operations at run time.
  106975. *
  106976. * This is simply done by scaling back the SH with Ylm constants parameter.
  106977. * The trigonometric part being applied by the shader at run time.
  106978. */
  106979. preScaleForRendering(): void;
  106980. /**
  106981. * Constructs a spherical harmonics from an array.
  106982. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106983. * @returns the spherical harmonics
  106984. */
  106985. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106986. /**
  106987. * Gets the spherical harmonics from polynomial
  106988. * @param polynomial the spherical polynomial
  106989. * @returns the spherical harmonics
  106990. */
  106991. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106992. }
  106993. /**
  106994. * Class representing spherical polynomial coefficients to the 3rd degree
  106995. */
  106996. export class SphericalPolynomial {
  106997. private _harmonics;
  106998. /**
  106999. * The spherical harmonics used to create the polynomials.
  107000. */
  107001. get preScaledHarmonics(): SphericalHarmonics;
  107002. /**
  107003. * The x coefficients of the spherical polynomial
  107004. */
  107005. x: Vector3;
  107006. /**
  107007. * The y coefficients of the spherical polynomial
  107008. */
  107009. y: Vector3;
  107010. /**
  107011. * The z coefficients of the spherical polynomial
  107012. */
  107013. z: Vector3;
  107014. /**
  107015. * The xx coefficients of the spherical polynomial
  107016. */
  107017. xx: Vector3;
  107018. /**
  107019. * The yy coefficients of the spherical polynomial
  107020. */
  107021. yy: Vector3;
  107022. /**
  107023. * The zz coefficients of the spherical polynomial
  107024. */
  107025. zz: Vector3;
  107026. /**
  107027. * The xy coefficients of the spherical polynomial
  107028. */
  107029. xy: Vector3;
  107030. /**
  107031. * The yz coefficients of the spherical polynomial
  107032. */
  107033. yz: Vector3;
  107034. /**
  107035. * The zx coefficients of the spherical polynomial
  107036. */
  107037. zx: Vector3;
  107038. /**
  107039. * Adds an ambient color to the spherical polynomial
  107040. * @param color the color to add
  107041. */
  107042. addAmbient(color: Color3): void;
  107043. /**
  107044. * Scales the spherical polynomial by the given amount
  107045. * @param scale the amount to scale
  107046. */
  107047. scaleInPlace(scale: number): void;
  107048. /**
  107049. * Gets the spherical polynomial from harmonics
  107050. * @param harmonics the spherical harmonics
  107051. * @returns the spherical polynomial
  107052. */
  107053. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  107054. /**
  107055. * Constructs a spherical polynomial from an array.
  107056. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  107057. * @returns the spherical polynomial
  107058. */
  107059. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  107060. }
  107061. }
  107062. declare module BABYLON {
  107063. /**
  107064. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  107065. */
  107066. export interface CubeMapInfo {
  107067. /**
  107068. * The pixel array for the front face.
  107069. * This is stored in format, left to right, up to down format.
  107070. */
  107071. front: Nullable<ArrayBufferView>;
  107072. /**
  107073. * The pixel array for the back face.
  107074. * This is stored in format, left to right, up to down format.
  107075. */
  107076. back: Nullable<ArrayBufferView>;
  107077. /**
  107078. * The pixel array for the left face.
  107079. * This is stored in format, left to right, up to down format.
  107080. */
  107081. left: Nullable<ArrayBufferView>;
  107082. /**
  107083. * The pixel array for the right face.
  107084. * This is stored in format, left to right, up to down format.
  107085. */
  107086. right: Nullable<ArrayBufferView>;
  107087. /**
  107088. * The pixel array for the up face.
  107089. * This is stored in format, left to right, up to down format.
  107090. */
  107091. up: Nullable<ArrayBufferView>;
  107092. /**
  107093. * The pixel array for the down face.
  107094. * This is stored in format, left to right, up to down format.
  107095. */
  107096. down: Nullable<ArrayBufferView>;
  107097. /**
  107098. * The size of the cubemap stored.
  107099. *
  107100. * Each faces will be size * size pixels.
  107101. */
  107102. size: number;
  107103. /**
  107104. * The format of the texture.
  107105. *
  107106. * RGBA, RGB.
  107107. */
  107108. format: number;
  107109. /**
  107110. * The type of the texture data.
  107111. *
  107112. * UNSIGNED_INT, FLOAT.
  107113. */
  107114. type: number;
  107115. /**
  107116. * Specifies whether the texture is in gamma space.
  107117. */
  107118. gammaSpace: boolean;
  107119. }
  107120. /**
  107121. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  107122. */
  107123. export class PanoramaToCubeMapTools {
  107124. private static FACE_LEFT;
  107125. private static FACE_RIGHT;
  107126. private static FACE_FRONT;
  107127. private static FACE_BACK;
  107128. private static FACE_DOWN;
  107129. private static FACE_UP;
  107130. /**
  107131. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  107132. *
  107133. * @param float32Array The source data.
  107134. * @param inputWidth The width of the input panorama.
  107135. * @param inputHeight The height of the input panorama.
  107136. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  107137. * @return The cubemap data
  107138. */
  107139. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  107140. private static CreateCubemapTexture;
  107141. private static CalcProjectionSpherical;
  107142. }
  107143. }
  107144. declare module BABYLON {
  107145. /**
  107146. * Helper class dealing with the extraction of spherical polynomial dataArray
  107147. * from a cube map.
  107148. */
  107149. export class CubeMapToSphericalPolynomialTools {
  107150. private static FileFaces;
  107151. /**
  107152. * Converts a texture to the according Spherical Polynomial data.
  107153. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107154. *
  107155. * @param texture The texture to extract the information from.
  107156. * @return The Spherical Polynomial data.
  107157. */
  107158. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  107159. /**
  107160. * Converts a cubemap to the according Spherical Polynomial data.
  107161. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107162. *
  107163. * @param cubeInfo The Cube map to extract the information from.
  107164. * @return The Spherical Polynomial data.
  107165. */
  107166. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  107167. }
  107168. }
  107169. declare module BABYLON {
  107170. interface BaseTexture {
  107171. /**
  107172. * Get the polynomial representation of the texture data.
  107173. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  107174. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  107175. */
  107176. sphericalPolynomial: Nullable<SphericalPolynomial>;
  107177. }
  107178. }
  107179. declare module BABYLON {
  107180. /** @hidden */
  107181. export var pbrFragmentDeclaration: {
  107182. name: string;
  107183. shader: string;
  107184. };
  107185. }
  107186. declare module BABYLON {
  107187. /** @hidden */
  107188. export var pbrUboDeclaration: {
  107189. name: string;
  107190. shader: string;
  107191. };
  107192. }
  107193. declare module BABYLON {
  107194. /** @hidden */
  107195. export var pbrFragmentExtraDeclaration: {
  107196. name: string;
  107197. shader: string;
  107198. };
  107199. }
  107200. declare module BABYLON {
  107201. /** @hidden */
  107202. export var pbrFragmentSamplersDeclaration: {
  107203. name: string;
  107204. shader: string;
  107205. };
  107206. }
  107207. declare module BABYLON {
  107208. /** @hidden */
  107209. export var subSurfaceScatteringFunctions: {
  107210. name: string;
  107211. shader: string;
  107212. };
  107213. }
  107214. declare module BABYLON {
  107215. /** @hidden */
  107216. export var importanceSampling: {
  107217. name: string;
  107218. shader: string;
  107219. };
  107220. }
  107221. declare module BABYLON {
  107222. /** @hidden */
  107223. export var pbrHelperFunctions: {
  107224. name: string;
  107225. shader: string;
  107226. };
  107227. }
  107228. declare module BABYLON {
  107229. /** @hidden */
  107230. export var harmonicsFunctions: {
  107231. name: string;
  107232. shader: string;
  107233. };
  107234. }
  107235. declare module BABYLON {
  107236. /** @hidden */
  107237. export var pbrDirectLightingSetupFunctions: {
  107238. name: string;
  107239. shader: string;
  107240. };
  107241. }
  107242. declare module BABYLON {
  107243. /** @hidden */
  107244. export var pbrDirectLightingFalloffFunctions: {
  107245. name: string;
  107246. shader: string;
  107247. };
  107248. }
  107249. declare module BABYLON {
  107250. /** @hidden */
  107251. export var pbrBRDFFunctions: {
  107252. name: string;
  107253. shader: string;
  107254. };
  107255. }
  107256. declare module BABYLON {
  107257. /** @hidden */
  107258. export var hdrFilteringFunctions: {
  107259. name: string;
  107260. shader: string;
  107261. };
  107262. }
  107263. declare module BABYLON {
  107264. /** @hidden */
  107265. export var pbrDirectLightingFunctions: {
  107266. name: string;
  107267. shader: string;
  107268. };
  107269. }
  107270. declare module BABYLON {
  107271. /** @hidden */
  107272. export var pbrIBLFunctions: {
  107273. name: string;
  107274. shader: string;
  107275. };
  107276. }
  107277. declare module BABYLON {
  107278. /** @hidden */
  107279. export var pbrBlockAlbedoOpacity: {
  107280. name: string;
  107281. shader: string;
  107282. };
  107283. }
  107284. declare module BABYLON {
  107285. /** @hidden */
  107286. export var pbrBlockReflectivity: {
  107287. name: string;
  107288. shader: string;
  107289. };
  107290. }
  107291. declare module BABYLON {
  107292. /** @hidden */
  107293. export var pbrBlockAmbientOcclusion: {
  107294. name: string;
  107295. shader: string;
  107296. };
  107297. }
  107298. declare module BABYLON {
  107299. /** @hidden */
  107300. export var pbrBlockAlphaFresnel: {
  107301. name: string;
  107302. shader: string;
  107303. };
  107304. }
  107305. declare module BABYLON {
  107306. /** @hidden */
  107307. export var pbrBlockAnisotropic: {
  107308. name: string;
  107309. shader: string;
  107310. };
  107311. }
  107312. declare module BABYLON {
  107313. /** @hidden */
  107314. export var pbrBlockReflection: {
  107315. name: string;
  107316. shader: string;
  107317. };
  107318. }
  107319. declare module BABYLON {
  107320. /** @hidden */
  107321. export var pbrBlockSheen: {
  107322. name: string;
  107323. shader: string;
  107324. };
  107325. }
  107326. declare module BABYLON {
  107327. /** @hidden */
  107328. export var pbrBlockClearcoat: {
  107329. name: string;
  107330. shader: string;
  107331. };
  107332. }
  107333. declare module BABYLON {
  107334. /** @hidden */
  107335. export var pbrBlockSubSurface: {
  107336. name: string;
  107337. shader: string;
  107338. };
  107339. }
  107340. declare module BABYLON {
  107341. /** @hidden */
  107342. export var pbrBlockNormalGeometric: {
  107343. name: string;
  107344. shader: string;
  107345. };
  107346. }
  107347. declare module BABYLON {
  107348. /** @hidden */
  107349. export var pbrBlockNormalFinal: {
  107350. name: string;
  107351. shader: string;
  107352. };
  107353. }
  107354. declare module BABYLON {
  107355. /** @hidden */
  107356. export var pbrBlockLightmapInit: {
  107357. name: string;
  107358. shader: string;
  107359. };
  107360. }
  107361. declare module BABYLON {
  107362. /** @hidden */
  107363. export var pbrBlockGeometryInfo: {
  107364. name: string;
  107365. shader: string;
  107366. };
  107367. }
  107368. declare module BABYLON {
  107369. /** @hidden */
  107370. export var pbrBlockReflectance0: {
  107371. name: string;
  107372. shader: string;
  107373. };
  107374. }
  107375. declare module BABYLON {
  107376. /** @hidden */
  107377. export var pbrBlockReflectance: {
  107378. name: string;
  107379. shader: string;
  107380. };
  107381. }
  107382. declare module BABYLON {
  107383. /** @hidden */
  107384. export var pbrBlockDirectLighting: {
  107385. name: string;
  107386. shader: string;
  107387. };
  107388. }
  107389. declare module BABYLON {
  107390. /** @hidden */
  107391. export var pbrBlockFinalLitComponents: {
  107392. name: string;
  107393. shader: string;
  107394. };
  107395. }
  107396. declare module BABYLON {
  107397. /** @hidden */
  107398. export var pbrBlockFinalUnlitComponents: {
  107399. name: string;
  107400. shader: string;
  107401. };
  107402. }
  107403. declare module BABYLON {
  107404. /** @hidden */
  107405. export var pbrBlockFinalColorComposition: {
  107406. name: string;
  107407. shader: string;
  107408. };
  107409. }
  107410. declare module BABYLON {
  107411. /** @hidden */
  107412. export var pbrBlockImageProcessing: {
  107413. name: string;
  107414. shader: string;
  107415. };
  107416. }
  107417. declare module BABYLON {
  107418. /** @hidden */
  107419. export var pbrDebug: {
  107420. name: string;
  107421. shader: string;
  107422. };
  107423. }
  107424. declare module BABYLON {
  107425. /** @hidden */
  107426. export var pbrPixelShader: {
  107427. name: string;
  107428. shader: string;
  107429. };
  107430. }
  107431. declare module BABYLON {
  107432. /** @hidden */
  107433. export var pbrVertexDeclaration: {
  107434. name: string;
  107435. shader: string;
  107436. };
  107437. }
  107438. declare module BABYLON {
  107439. /** @hidden */
  107440. export var pbrVertexShader: {
  107441. name: string;
  107442. shader: string;
  107443. };
  107444. }
  107445. declare module BABYLON {
  107446. /**
  107447. * Manages the defines for the PBR Material.
  107448. * @hidden
  107449. */
  107450. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  107451. PBR: boolean;
  107452. NUM_SAMPLES: string;
  107453. REALTIME_FILTERING: boolean;
  107454. MAINUV1: boolean;
  107455. MAINUV2: boolean;
  107456. UV1: boolean;
  107457. UV2: boolean;
  107458. ALBEDO: boolean;
  107459. GAMMAALBEDO: boolean;
  107460. ALBEDODIRECTUV: number;
  107461. VERTEXCOLOR: boolean;
  107462. DETAIL: boolean;
  107463. DETAILDIRECTUV: number;
  107464. DETAIL_NORMALBLENDMETHOD: number;
  107465. AMBIENT: boolean;
  107466. AMBIENTDIRECTUV: number;
  107467. AMBIENTINGRAYSCALE: boolean;
  107468. OPACITY: boolean;
  107469. VERTEXALPHA: boolean;
  107470. OPACITYDIRECTUV: number;
  107471. OPACITYRGB: boolean;
  107472. ALPHATEST: boolean;
  107473. DEPTHPREPASS: boolean;
  107474. ALPHABLEND: boolean;
  107475. ALPHAFROMALBEDO: boolean;
  107476. ALPHATESTVALUE: string;
  107477. SPECULAROVERALPHA: boolean;
  107478. RADIANCEOVERALPHA: boolean;
  107479. ALPHAFRESNEL: boolean;
  107480. LINEARALPHAFRESNEL: boolean;
  107481. PREMULTIPLYALPHA: boolean;
  107482. EMISSIVE: boolean;
  107483. EMISSIVEDIRECTUV: number;
  107484. REFLECTIVITY: boolean;
  107485. REFLECTIVITYDIRECTUV: number;
  107486. SPECULARTERM: boolean;
  107487. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107488. MICROSURFACEAUTOMATIC: boolean;
  107489. LODBASEDMICROSFURACE: boolean;
  107490. MICROSURFACEMAP: boolean;
  107491. MICROSURFACEMAPDIRECTUV: number;
  107492. METALLICWORKFLOW: boolean;
  107493. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107494. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107495. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107496. AOSTOREINMETALMAPRED: boolean;
  107497. METALLIC_REFLECTANCE: boolean;
  107498. METALLIC_REFLECTANCEDIRECTUV: number;
  107499. ENVIRONMENTBRDF: boolean;
  107500. ENVIRONMENTBRDF_RGBD: boolean;
  107501. NORMAL: boolean;
  107502. TANGENT: boolean;
  107503. BUMP: boolean;
  107504. BUMPDIRECTUV: number;
  107505. OBJECTSPACE_NORMALMAP: boolean;
  107506. PARALLAX: boolean;
  107507. PARALLAXOCCLUSION: boolean;
  107508. NORMALXYSCALE: boolean;
  107509. LIGHTMAP: boolean;
  107510. LIGHTMAPDIRECTUV: number;
  107511. USELIGHTMAPASSHADOWMAP: boolean;
  107512. GAMMALIGHTMAP: boolean;
  107513. RGBDLIGHTMAP: boolean;
  107514. REFLECTION: boolean;
  107515. REFLECTIONMAP_3D: boolean;
  107516. REFLECTIONMAP_SPHERICAL: boolean;
  107517. REFLECTIONMAP_PLANAR: boolean;
  107518. REFLECTIONMAP_CUBIC: boolean;
  107519. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107520. REFLECTIONMAP_PROJECTION: boolean;
  107521. REFLECTIONMAP_SKYBOX: boolean;
  107522. REFLECTIONMAP_EXPLICIT: boolean;
  107523. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107524. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107525. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107526. INVERTCUBICMAP: boolean;
  107527. USESPHERICALFROMREFLECTIONMAP: boolean;
  107528. USEIRRADIANCEMAP: boolean;
  107529. SPHERICAL_HARMONICS: boolean;
  107530. USESPHERICALINVERTEX: boolean;
  107531. REFLECTIONMAP_OPPOSITEZ: boolean;
  107532. LODINREFLECTIONALPHA: boolean;
  107533. GAMMAREFLECTION: boolean;
  107534. RGBDREFLECTION: boolean;
  107535. LINEARSPECULARREFLECTION: boolean;
  107536. RADIANCEOCCLUSION: boolean;
  107537. HORIZONOCCLUSION: boolean;
  107538. INSTANCES: boolean;
  107539. THIN_INSTANCES: boolean;
  107540. PREPASS: boolean;
  107541. PREPASS_IRRADIANCE: boolean;
  107542. PREPASS_IRRADIANCE_INDEX: number;
  107543. PREPASS_ALBEDO: boolean;
  107544. PREPASS_ALBEDO_INDEX: number;
  107545. PREPASS_DEPTHNORMAL: boolean;
  107546. PREPASS_DEPTHNORMAL_INDEX: number;
  107547. PREPASS_POSITION: boolean;
  107548. PREPASS_POSITION_INDEX: number;
  107549. PREPASS_VELOCITY: boolean;
  107550. PREPASS_VELOCITY_INDEX: number;
  107551. PREPASS_REFLECTIVITY: boolean;
  107552. PREPASS_REFLECTIVITY_INDEX: number;
  107553. SCENE_MRT_COUNT: number;
  107554. NUM_BONE_INFLUENCERS: number;
  107555. BonesPerMesh: number;
  107556. BONETEXTURE: boolean;
  107557. BONES_VELOCITY_ENABLED: boolean;
  107558. NONUNIFORMSCALING: boolean;
  107559. MORPHTARGETS: boolean;
  107560. MORPHTARGETS_NORMAL: boolean;
  107561. MORPHTARGETS_TANGENT: boolean;
  107562. MORPHTARGETS_UV: boolean;
  107563. NUM_MORPH_INFLUENCERS: number;
  107564. IMAGEPROCESSING: boolean;
  107565. VIGNETTE: boolean;
  107566. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107567. VIGNETTEBLENDMODEOPAQUE: boolean;
  107568. TONEMAPPING: boolean;
  107569. TONEMAPPING_ACES: boolean;
  107570. CONTRAST: boolean;
  107571. COLORCURVES: boolean;
  107572. COLORGRADING: boolean;
  107573. COLORGRADING3D: boolean;
  107574. SAMPLER3DGREENDEPTH: boolean;
  107575. SAMPLER3DBGRMAP: boolean;
  107576. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107577. EXPOSURE: boolean;
  107578. MULTIVIEW: boolean;
  107579. USEPHYSICALLIGHTFALLOFF: boolean;
  107580. USEGLTFLIGHTFALLOFF: boolean;
  107581. TWOSIDEDLIGHTING: boolean;
  107582. SHADOWFLOAT: boolean;
  107583. CLIPPLANE: boolean;
  107584. CLIPPLANE2: boolean;
  107585. CLIPPLANE3: boolean;
  107586. CLIPPLANE4: boolean;
  107587. CLIPPLANE5: boolean;
  107588. CLIPPLANE6: boolean;
  107589. POINTSIZE: boolean;
  107590. FOG: boolean;
  107591. LOGARITHMICDEPTH: boolean;
  107592. FORCENORMALFORWARD: boolean;
  107593. SPECULARAA: boolean;
  107594. CLEARCOAT: boolean;
  107595. CLEARCOAT_DEFAULTIOR: boolean;
  107596. CLEARCOAT_TEXTURE: boolean;
  107597. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  107598. CLEARCOAT_TEXTUREDIRECTUV: number;
  107599. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  107600. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107601. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107602. CLEARCOAT_BUMP: boolean;
  107603. CLEARCOAT_BUMPDIRECTUV: number;
  107604. CLEARCOAT_REMAP_F0: boolean;
  107605. CLEARCOAT_TINT: boolean;
  107606. CLEARCOAT_TINT_TEXTURE: boolean;
  107607. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107608. ANISOTROPIC: boolean;
  107609. ANISOTROPIC_TEXTURE: boolean;
  107610. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107611. BRDF_V_HEIGHT_CORRELATED: boolean;
  107612. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107613. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  107614. SHEEN: boolean;
  107615. SHEEN_TEXTURE: boolean;
  107616. SHEEN_TEXTURE_ROUGHNESS: boolean;
  107617. SHEEN_TEXTUREDIRECTUV: number;
  107618. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  107619. SHEEN_LINKWITHALBEDO: boolean;
  107620. SHEEN_ROUGHNESS: boolean;
  107621. SHEEN_ALBEDOSCALING: boolean;
  107622. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107623. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107624. SUBSURFACE: boolean;
  107625. SS_REFRACTION: boolean;
  107626. SS_TRANSLUCENCY: boolean;
  107627. SS_SCATTERING: boolean;
  107628. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107629. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107630. SS_REFRACTIONMAP_3D: boolean;
  107631. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107632. SS_LODINREFRACTIONALPHA: boolean;
  107633. SS_GAMMAREFRACTION: boolean;
  107634. SS_RGBDREFRACTION: boolean;
  107635. SS_LINEARSPECULARREFRACTION: boolean;
  107636. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107637. SS_ALBEDOFORREFRACTIONTINT: boolean;
  107638. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107639. UNLIT: boolean;
  107640. DEBUGMODE: number;
  107641. /**
  107642. * Initializes the PBR Material defines.
  107643. */
  107644. constructor();
  107645. /**
  107646. * Resets the PBR Material defines.
  107647. */
  107648. reset(): void;
  107649. }
  107650. /**
  107651. * The Physically based material base class of BJS.
  107652. *
  107653. * This offers the main features of a standard PBR material.
  107654. * For more information, please refer to the documentation :
  107655. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107656. */
  107657. export abstract class PBRBaseMaterial extends PushMaterial {
  107658. /**
  107659. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107660. */
  107661. static readonly PBRMATERIAL_OPAQUE: number;
  107662. /**
  107663. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107664. */
  107665. static readonly PBRMATERIAL_ALPHATEST: number;
  107666. /**
  107667. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107668. */
  107669. static readonly PBRMATERIAL_ALPHABLEND: number;
  107670. /**
  107671. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107672. * They are also discarded below the alpha cutoff threshold to improve performances.
  107673. */
  107674. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107675. /**
  107676. * Defines the default value of how much AO map is occluding the analytical lights
  107677. * (point spot...).
  107678. */
  107679. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107680. /**
  107681. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107682. */
  107683. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107684. /**
  107685. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107686. * to enhance interoperability with other engines.
  107687. */
  107688. static readonly LIGHTFALLOFF_GLTF: number;
  107689. /**
  107690. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107691. * to enhance interoperability with other materials.
  107692. */
  107693. static readonly LIGHTFALLOFF_STANDARD: number;
  107694. /**
  107695. * Intensity of the direct lights e.g. the four lights available in your scene.
  107696. * This impacts both the direct diffuse and specular highlights.
  107697. */
  107698. protected _directIntensity: number;
  107699. /**
  107700. * Intensity of the emissive part of the material.
  107701. * This helps controlling the emissive effect without modifying the emissive color.
  107702. */
  107703. protected _emissiveIntensity: number;
  107704. /**
  107705. * Intensity of the environment e.g. how much the environment will light the object
  107706. * either through harmonics for rough material or through the refelction for shiny ones.
  107707. */
  107708. protected _environmentIntensity: number;
  107709. /**
  107710. * This is a special control allowing the reduction of the specular highlights coming from the
  107711. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107712. */
  107713. protected _specularIntensity: number;
  107714. /**
  107715. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107716. */
  107717. private _lightingInfos;
  107718. /**
  107719. * Debug Control allowing disabling the bump map on this material.
  107720. */
  107721. protected _disableBumpMap: boolean;
  107722. /**
  107723. * AKA Diffuse Texture in standard nomenclature.
  107724. */
  107725. protected _albedoTexture: Nullable<BaseTexture>;
  107726. /**
  107727. * AKA Occlusion Texture in other nomenclature.
  107728. */
  107729. protected _ambientTexture: Nullable<BaseTexture>;
  107730. /**
  107731. * AKA Occlusion Texture Intensity in other nomenclature.
  107732. */
  107733. protected _ambientTextureStrength: number;
  107734. /**
  107735. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107736. * 1 means it completely occludes it
  107737. * 0 mean it has no impact
  107738. */
  107739. protected _ambientTextureImpactOnAnalyticalLights: number;
  107740. /**
  107741. * Stores the alpha values in a texture.
  107742. */
  107743. protected _opacityTexture: Nullable<BaseTexture>;
  107744. /**
  107745. * Stores the reflection values in a texture.
  107746. */
  107747. protected _reflectionTexture: Nullable<BaseTexture>;
  107748. /**
  107749. * Stores the emissive values in a texture.
  107750. */
  107751. protected _emissiveTexture: Nullable<BaseTexture>;
  107752. /**
  107753. * AKA Specular texture in other nomenclature.
  107754. */
  107755. protected _reflectivityTexture: Nullable<BaseTexture>;
  107756. /**
  107757. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107758. */
  107759. protected _metallicTexture: Nullable<BaseTexture>;
  107760. /**
  107761. * Specifies the metallic scalar of the metallic/roughness workflow.
  107762. * Can also be used to scale the metalness values of the metallic texture.
  107763. */
  107764. protected _metallic: Nullable<number>;
  107765. /**
  107766. * Specifies the roughness scalar of the metallic/roughness workflow.
  107767. * Can also be used to scale the roughness values of the metallic texture.
  107768. */
  107769. protected _roughness: Nullable<number>;
  107770. /**
  107771. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107772. * By default the indexOfrefraction is used to compute F0;
  107773. *
  107774. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107775. *
  107776. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107777. * F90 = metallicReflectanceColor;
  107778. */
  107779. protected _metallicF0Factor: number;
  107780. /**
  107781. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107782. * By default the F90 is always 1;
  107783. *
  107784. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107785. *
  107786. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107787. * F90 = metallicReflectanceColor;
  107788. */
  107789. protected _metallicReflectanceColor: Color3;
  107790. /**
  107791. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107792. * This is multiply against the scalar values defined in the material.
  107793. */
  107794. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107795. /**
  107796. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107797. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107798. */
  107799. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107800. /**
  107801. * Stores surface normal data used to displace a mesh in a texture.
  107802. */
  107803. protected _bumpTexture: Nullable<BaseTexture>;
  107804. /**
  107805. * Stores the pre-calculated light information of a mesh in a texture.
  107806. */
  107807. protected _lightmapTexture: Nullable<BaseTexture>;
  107808. /**
  107809. * The color of a material in ambient lighting.
  107810. */
  107811. protected _ambientColor: Color3;
  107812. /**
  107813. * AKA Diffuse Color in other nomenclature.
  107814. */
  107815. protected _albedoColor: Color3;
  107816. /**
  107817. * AKA Specular Color in other nomenclature.
  107818. */
  107819. protected _reflectivityColor: Color3;
  107820. /**
  107821. * The color applied when light is reflected from a material.
  107822. */
  107823. protected _reflectionColor: Color3;
  107824. /**
  107825. * The color applied when light is emitted from a material.
  107826. */
  107827. protected _emissiveColor: Color3;
  107828. /**
  107829. * AKA Glossiness in other nomenclature.
  107830. */
  107831. protected _microSurface: number;
  107832. /**
  107833. * Specifies that the material will use the light map as a show map.
  107834. */
  107835. protected _useLightmapAsShadowmap: boolean;
  107836. /**
  107837. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107838. * makes the reflect vector face the model (under horizon).
  107839. */
  107840. protected _useHorizonOcclusion: boolean;
  107841. /**
  107842. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107843. * too much the area relying on ambient texture to define their ambient occlusion.
  107844. */
  107845. protected _useRadianceOcclusion: boolean;
  107846. /**
  107847. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107848. */
  107849. protected _useAlphaFromAlbedoTexture: boolean;
  107850. /**
  107851. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107852. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107853. */
  107854. protected _useSpecularOverAlpha: boolean;
  107855. /**
  107856. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107857. */
  107858. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107859. /**
  107860. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107861. */
  107862. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107863. /**
  107864. * Specifies if the metallic texture contains the roughness information in its green channel.
  107865. */
  107866. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107867. /**
  107868. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107869. */
  107870. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107871. /**
  107872. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107873. */
  107874. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107875. /**
  107876. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107877. */
  107878. protected _useAmbientInGrayScale: boolean;
  107879. /**
  107880. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107881. * The material will try to infer what glossiness each pixel should be.
  107882. */
  107883. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107884. /**
  107885. * Defines the falloff type used in this material.
  107886. * It by default is Physical.
  107887. */
  107888. protected _lightFalloff: number;
  107889. /**
  107890. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107891. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107892. */
  107893. protected _useRadianceOverAlpha: boolean;
  107894. /**
  107895. * Allows using an object space normal map (instead of tangent space).
  107896. */
  107897. protected _useObjectSpaceNormalMap: boolean;
  107898. /**
  107899. * Allows using the bump map in parallax mode.
  107900. */
  107901. protected _useParallax: boolean;
  107902. /**
  107903. * Allows using the bump map in parallax occlusion mode.
  107904. */
  107905. protected _useParallaxOcclusion: boolean;
  107906. /**
  107907. * Controls the scale bias of the parallax mode.
  107908. */
  107909. protected _parallaxScaleBias: number;
  107910. /**
  107911. * If sets to true, disables all the lights affecting the material.
  107912. */
  107913. protected _disableLighting: boolean;
  107914. /**
  107915. * Number of Simultaneous lights allowed on the material.
  107916. */
  107917. protected _maxSimultaneousLights: number;
  107918. /**
  107919. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107920. */
  107921. protected _invertNormalMapX: boolean;
  107922. /**
  107923. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107924. */
  107925. protected _invertNormalMapY: boolean;
  107926. /**
  107927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107928. */
  107929. protected _twoSidedLighting: boolean;
  107930. /**
  107931. * Defines the alpha limits in alpha test mode.
  107932. */
  107933. protected _alphaCutOff: number;
  107934. /**
  107935. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107936. */
  107937. protected _forceAlphaTest: boolean;
  107938. /**
  107939. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107940. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107941. */
  107942. protected _useAlphaFresnel: boolean;
  107943. /**
  107944. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107945. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107946. */
  107947. protected _useLinearAlphaFresnel: boolean;
  107948. /**
  107949. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107950. * from cos thetav and roughness:
  107951. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107952. */
  107953. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107954. /**
  107955. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107956. */
  107957. protected _forceIrradianceInFragment: boolean;
  107958. private _realTimeFiltering;
  107959. /**
  107960. * Enables realtime filtering on the texture.
  107961. */
  107962. get realTimeFiltering(): boolean;
  107963. set realTimeFiltering(b: boolean);
  107964. private _realTimeFilteringQuality;
  107965. /**
  107966. * Quality switch for realtime filtering
  107967. */
  107968. get realTimeFilteringQuality(): number;
  107969. set realTimeFilteringQuality(n: number);
  107970. /**
  107971. * Can this material render to several textures at once
  107972. */
  107973. get canRenderToMRT(): boolean;
  107974. /**
  107975. * Force normal to face away from face.
  107976. */
  107977. protected _forceNormalForward: boolean;
  107978. /**
  107979. * Enables specular anti aliasing in the PBR shader.
  107980. * It will both interacts on the Geometry for analytical and IBL lighting.
  107981. * It also prefilter the roughness map based on the bump values.
  107982. */
  107983. protected _enableSpecularAntiAliasing: boolean;
  107984. /**
  107985. * Default configuration related to image processing available in the PBR Material.
  107986. */
  107987. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107988. /**
  107989. * Keep track of the image processing observer to allow dispose and replace.
  107990. */
  107991. private _imageProcessingObserver;
  107992. /**
  107993. * Attaches a new image processing configuration to the PBR Material.
  107994. * @param configuration
  107995. */
  107996. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107997. /**
  107998. * Stores the available render targets.
  107999. */
  108000. private _renderTargets;
  108001. /**
  108002. * Sets the global ambient color for the material used in lighting calculations.
  108003. */
  108004. private _globalAmbientColor;
  108005. /**
  108006. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108007. */
  108008. private _useLogarithmicDepth;
  108009. /**
  108010. * If set to true, no lighting calculations will be applied.
  108011. */
  108012. private _unlit;
  108013. private _debugMode;
  108014. /**
  108015. * @hidden
  108016. * This is reserved for the inspector.
  108017. * Defines the material debug mode.
  108018. * It helps seeing only some components of the material while troubleshooting.
  108019. */
  108020. debugMode: number;
  108021. /**
  108022. * @hidden
  108023. * This is reserved for the inspector.
  108024. * Specify from where on screen the debug mode should start.
  108025. * The value goes from -1 (full screen) to 1 (not visible)
  108026. * It helps with side by side comparison against the final render
  108027. * This defaults to -1
  108028. */
  108029. private debugLimit;
  108030. /**
  108031. * @hidden
  108032. * This is reserved for the inspector.
  108033. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108034. * You can use the factor to better multiply the final value.
  108035. */
  108036. private debugFactor;
  108037. /**
  108038. * Defines the clear coat layer parameters for the material.
  108039. */
  108040. readonly clearCoat: PBRClearCoatConfiguration;
  108041. /**
  108042. * Defines the anisotropic parameters for the material.
  108043. */
  108044. readonly anisotropy: PBRAnisotropicConfiguration;
  108045. /**
  108046. * Defines the BRDF parameters for the material.
  108047. */
  108048. readonly brdf: PBRBRDFConfiguration;
  108049. /**
  108050. * Defines the Sheen parameters for the material.
  108051. */
  108052. readonly sheen: PBRSheenConfiguration;
  108053. /**
  108054. * Defines the SubSurface parameters for the material.
  108055. */
  108056. readonly subSurface: PBRSubSurfaceConfiguration;
  108057. /**
  108058. * Defines additionnal PrePass parameters for the material.
  108059. */
  108060. readonly prePassConfiguration: PrePassConfiguration;
  108061. /**
  108062. * Defines the detail map parameters for the material.
  108063. */
  108064. readonly detailMap: DetailMapConfiguration;
  108065. protected _rebuildInParallel: boolean;
  108066. /**
  108067. * Instantiates a new PBRMaterial instance.
  108068. *
  108069. * @param name The material name
  108070. * @param scene The scene the material will be use in.
  108071. */
  108072. constructor(name: string, scene: Scene);
  108073. /**
  108074. * Gets a boolean indicating that current material needs to register RTT
  108075. */
  108076. get hasRenderTargetTextures(): boolean;
  108077. /**
  108078. * Gets the name of the material class.
  108079. */
  108080. getClassName(): string;
  108081. /**
  108082. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108083. */
  108084. get useLogarithmicDepth(): boolean;
  108085. /**
  108086. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108087. */
  108088. set useLogarithmicDepth(value: boolean);
  108089. /**
  108090. * Returns true if alpha blending should be disabled.
  108091. */
  108092. protected get _disableAlphaBlending(): boolean;
  108093. /**
  108094. * Specifies whether or not this material should be rendered in alpha blend mode.
  108095. */
  108096. needAlphaBlending(): boolean;
  108097. /**
  108098. * Specifies whether or not this material should be rendered in alpha test mode.
  108099. */
  108100. needAlphaTesting(): boolean;
  108101. /**
  108102. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108103. */
  108104. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108105. /**
  108106. * Specifies whether or not there is a usable alpha channel for transparency.
  108107. */
  108108. protected _hasAlphaChannel(): boolean;
  108109. /**
  108110. * Gets the texture used for the alpha test.
  108111. */
  108112. getAlphaTestTexture(): Nullable<BaseTexture>;
  108113. /**
  108114. * Specifies that the submesh is ready to be used.
  108115. * @param mesh - BJS mesh.
  108116. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108117. * @param useInstances - Specifies that instances should be used.
  108118. * @returns - boolean indicating that the submesh is ready or not.
  108119. */
  108120. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108121. /**
  108122. * Specifies if the material uses metallic roughness workflow.
  108123. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108124. */
  108125. isMetallicWorkflow(): boolean;
  108126. private _prepareEffect;
  108127. private _prepareDefines;
  108128. /**
  108129. * Force shader compilation
  108130. */
  108131. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  108132. /**
  108133. * Initializes the uniform buffer layout for the shader.
  108134. */
  108135. buildUniformLayout(): void;
  108136. /**
  108137. * Unbinds the material from the mesh
  108138. */
  108139. unbind(): void;
  108140. /**
  108141. * Binds the submesh data.
  108142. * @param world - The world matrix.
  108143. * @param mesh - The BJS mesh.
  108144. * @param subMesh - A submesh of the BJS mesh.
  108145. */
  108146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108147. /**
  108148. * Returns the animatable textures.
  108149. * @returns - Array of animatable textures.
  108150. */
  108151. getAnimatables(): IAnimatable[];
  108152. /**
  108153. * Returns the texture used for reflections.
  108154. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108155. */
  108156. private _getReflectionTexture;
  108157. /**
  108158. * Returns an array of the actively used textures.
  108159. * @returns - Array of BaseTextures
  108160. */
  108161. getActiveTextures(): BaseTexture[];
  108162. /**
  108163. * Checks to see if a texture is used in the material.
  108164. * @param texture - Base texture to use.
  108165. * @returns - Boolean specifying if a texture is used in the material.
  108166. */
  108167. hasTexture(texture: BaseTexture): boolean;
  108168. /**
  108169. * Sets the required values to the prepass renderer.
  108170. * @param prePassRenderer defines the prepass renderer to setup
  108171. */
  108172. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108173. /**
  108174. * Disposes the resources of the material.
  108175. * @param forceDisposeEffect - Forces the disposal of effects.
  108176. * @param forceDisposeTextures - Forces the disposal of all textures.
  108177. */
  108178. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108179. }
  108180. }
  108181. declare module BABYLON {
  108182. /**
  108183. * The Physically based material of BJS.
  108184. *
  108185. * This offers the main features of a standard PBR material.
  108186. * For more information, please refer to the documentation :
  108187. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108188. */
  108189. export class PBRMaterial extends PBRBaseMaterial {
  108190. /**
  108191. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108192. */
  108193. static readonly PBRMATERIAL_OPAQUE: number;
  108194. /**
  108195. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108196. */
  108197. static readonly PBRMATERIAL_ALPHATEST: number;
  108198. /**
  108199. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108200. */
  108201. static readonly PBRMATERIAL_ALPHABLEND: number;
  108202. /**
  108203. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108204. * They are also discarded below the alpha cutoff threshold to improve performances.
  108205. */
  108206. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108207. /**
  108208. * Defines the default value of how much AO map is occluding the analytical lights
  108209. * (point spot...).
  108210. */
  108211. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108212. /**
  108213. * Intensity of the direct lights e.g. the four lights available in your scene.
  108214. * This impacts both the direct diffuse and specular highlights.
  108215. */
  108216. directIntensity: number;
  108217. /**
  108218. * Intensity of the emissive part of the material.
  108219. * This helps controlling the emissive effect without modifying the emissive color.
  108220. */
  108221. emissiveIntensity: number;
  108222. /**
  108223. * Intensity of the environment e.g. how much the environment will light the object
  108224. * either through harmonics for rough material or through the refelction for shiny ones.
  108225. */
  108226. environmentIntensity: number;
  108227. /**
  108228. * This is a special control allowing the reduction of the specular highlights coming from the
  108229. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108230. */
  108231. specularIntensity: number;
  108232. /**
  108233. * Debug Control allowing disabling the bump map on this material.
  108234. */
  108235. disableBumpMap: boolean;
  108236. /**
  108237. * AKA Diffuse Texture in standard nomenclature.
  108238. */
  108239. albedoTexture: BaseTexture;
  108240. /**
  108241. * AKA Occlusion Texture in other nomenclature.
  108242. */
  108243. ambientTexture: BaseTexture;
  108244. /**
  108245. * AKA Occlusion Texture Intensity in other nomenclature.
  108246. */
  108247. ambientTextureStrength: number;
  108248. /**
  108249. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108250. * 1 means it completely occludes it
  108251. * 0 mean it has no impact
  108252. */
  108253. ambientTextureImpactOnAnalyticalLights: number;
  108254. /**
  108255. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  108256. */
  108257. opacityTexture: BaseTexture;
  108258. /**
  108259. * Stores the reflection values in a texture.
  108260. */
  108261. reflectionTexture: Nullable<BaseTexture>;
  108262. /**
  108263. * Stores the emissive values in a texture.
  108264. */
  108265. emissiveTexture: BaseTexture;
  108266. /**
  108267. * AKA Specular texture in other nomenclature.
  108268. */
  108269. reflectivityTexture: BaseTexture;
  108270. /**
  108271. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108272. */
  108273. metallicTexture: BaseTexture;
  108274. /**
  108275. * Specifies the metallic scalar of the metallic/roughness workflow.
  108276. * Can also be used to scale the metalness values of the metallic texture.
  108277. */
  108278. metallic: Nullable<number>;
  108279. /**
  108280. * Specifies the roughness scalar of the metallic/roughness workflow.
  108281. * Can also be used to scale the roughness values of the metallic texture.
  108282. */
  108283. roughness: Nullable<number>;
  108284. /**
  108285. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  108286. * By default the indexOfrefraction is used to compute F0;
  108287. *
  108288. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  108289. *
  108290. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  108291. * F90 = metallicReflectanceColor;
  108292. */
  108293. metallicF0Factor: number;
  108294. /**
  108295. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  108296. * By default the F90 is always 1;
  108297. *
  108298. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  108299. *
  108300. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  108301. * F90 = metallicReflectanceColor;
  108302. */
  108303. metallicReflectanceColor: Color3;
  108304. /**
  108305. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  108306. * This is multiply against the scalar values defined in the material.
  108307. */
  108308. metallicReflectanceTexture: Nullable<BaseTexture>;
  108309. /**
  108310. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108311. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108312. */
  108313. microSurfaceTexture: BaseTexture;
  108314. /**
  108315. * Stores surface normal data used to displace a mesh in a texture.
  108316. */
  108317. bumpTexture: BaseTexture;
  108318. /**
  108319. * Stores the pre-calculated light information of a mesh in a texture.
  108320. */
  108321. lightmapTexture: BaseTexture;
  108322. /**
  108323. * Stores the refracted light information in a texture.
  108324. */
  108325. get refractionTexture(): Nullable<BaseTexture>;
  108326. set refractionTexture(value: Nullable<BaseTexture>);
  108327. /**
  108328. * The color of a material in ambient lighting.
  108329. */
  108330. ambientColor: Color3;
  108331. /**
  108332. * AKA Diffuse Color in other nomenclature.
  108333. */
  108334. albedoColor: Color3;
  108335. /**
  108336. * AKA Specular Color in other nomenclature.
  108337. */
  108338. reflectivityColor: Color3;
  108339. /**
  108340. * The color reflected from the material.
  108341. */
  108342. reflectionColor: Color3;
  108343. /**
  108344. * The color emitted from the material.
  108345. */
  108346. emissiveColor: Color3;
  108347. /**
  108348. * AKA Glossiness in other nomenclature.
  108349. */
  108350. microSurface: number;
  108351. /**
  108352. * Index of refraction of the material base layer.
  108353. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108354. *
  108355. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  108356. *
  108357. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  108358. */
  108359. get indexOfRefraction(): number;
  108360. set indexOfRefraction(value: number);
  108361. /**
  108362. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108363. */
  108364. get invertRefractionY(): boolean;
  108365. set invertRefractionY(value: boolean);
  108366. /**
  108367. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108368. * Materials half opaque for instance using refraction could benefit from this control.
  108369. */
  108370. get linkRefractionWithTransparency(): boolean;
  108371. set linkRefractionWithTransparency(value: boolean);
  108372. /**
  108373. * If true, the light map contains occlusion information instead of lighting info.
  108374. */
  108375. useLightmapAsShadowmap: boolean;
  108376. /**
  108377. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108378. */
  108379. useAlphaFromAlbedoTexture: boolean;
  108380. /**
  108381. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108382. */
  108383. forceAlphaTest: boolean;
  108384. /**
  108385. * Defines the alpha limits in alpha test mode.
  108386. */
  108387. alphaCutOff: number;
  108388. /**
  108389. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108390. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108391. */
  108392. useSpecularOverAlpha: boolean;
  108393. /**
  108394. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108395. */
  108396. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108397. /**
  108398. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108399. */
  108400. useRoughnessFromMetallicTextureAlpha: boolean;
  108401. /**
  108402. * Specifies if the metallic texture contains the roughness information in its green channel.
  108403. */
  108404. useRoughnessFromMetallicTextureGreen: boolean;
  108405. /**
  108406. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108407. */
  108408. useMetallnessFromMetallicTextureBlue: boolean;
  108409. /**
  108410. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108411. */
  108412. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108413. /**
  108414. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108415. */
  108416. useAmbientInGrayScale: boolean;
  108417. /**
  108418. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108419. * The material will try to infer what glossiness each pixel should be.
  108420. */
  108421. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108422. /**
  108423. * BJS is using an harcoded light falloff based on a manually sets up range.
  108424. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108425. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108426. */
  108427. get usePhysicalLightFalloff(): boolean;
  108428. /**
  108429. * BJS is using an harcoded light falloff based on a manually sets up range.
  108430. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108431. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108432. */
  108433. set usePhysicalLightFalloff(value: boolean);
  108434. /**
  108435. * In order to support the falloff compatibility with gltf, a special mode has been added
  108436. * to reproduce the gltf light falloff.
  108437. */
  108438. get useGLTFLightFalloff(): boolean;
  108439. /**
  108440. * In order to support the falloff compatibility with gltf, a special mode has been added
  108441. * to reproduce the gltf light falloff.
  108442. */
  108443. set useGLTFLightFalloff(value: boolean);
  108444. /**
  108445. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108446. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108447. */
  108448. useRadianceOverAlpha: boolean;
  108449. /**
  108450. * Allows using an object space normal map (instead of tangent space).
  108451. */
  108452. useObjectSpaceNormalMap: boolean;
  108453. /**
  108454. * Allows using the bump map in parallax mode.
  108455. */
  108456. useParallax: boolean;
  108457. /**
  108458. * Allows using the bump map in parallax occlusion mode.
  108459. */
  108460. useParallaxOcclusion: boolean;
  108461. /**
  108462. * Controls the scale bias of the parallax mode.
  108463. */
  108464. parallaxScaleBias: number;
  108465. /**
  108466. * If sets to true, disables all the lights affecting the material.
  108467. */
  108468. disableLighting: boolean;
  108469. /**
  108470. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108471. */
  108472. forceIrradianceInFragment: boolean;
  108473. /**
  108474. * Number of Simultaneous lights allowed on the material.
  108475. */
  108476. maxSimultaneousLights: number;
  108477. /**
  108478. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108479. */
  108480. invertNormalMapX: boolean;
  108481. /**
  108482. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108483. */
  108484. invertNormalMapY: boolean;
  108485. /**
  108486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108487. */
  108488. twoSidedLighting: boolean;
  108489. /**
  108490. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108491. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108492. */
  108493. useAlphaFresnel: boolean;
  108494. /**
  108495. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108496. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108497. */
  108498. useLinearAlphaFresnel: boolean;
  108499. /**
  108500. * Let user defines the brdf lookup texture used for IBL.
  108501. * A default 8bit version is embedded but you could point at :
  108502. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  108503. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108504. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  108505. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108506. */
  108507. environmentBRDFTexture: Nullable<BaseTexture>;
  108508. /**
  108509. * Force normal to face away from face.
  108510. */
  108511. forceNormalForward: boolean;
  108512. /**
  108513. * Enables specular anti aliasing in the PBR shader.
  108514. * It will both interacts on the Geometry for analytical and IBL lighting.
  108515. * It also prefilter the roughness map based on the bump values.
  108516. */
  108517. enableSpecularAntiAliasing: boolean;
  108518. /**
  108519. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108520. * makes the reflect vector face the model (under horizon).
  108521. */
  108522. useHorizonOcclusion: boolean;
  108523. /**
  108524. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108525. * too much the area relying on ambient texture to define their ambient occlusion.
  108526. */
  108527. useRadianceOcclusion: boolean;
  108528. /**
  108529. * If set to true, no lighting calculations will be applied.
  108530. */
  108531. unlit: boolean;
  108532. /**
  108533. * Gets the image processing configuration used either in this material.
  108534. */
  108535. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108536. /**
  108537. * Sets the Default image processing configuration used either in the this material.
  108538. *
  108539. * If sets to null, the scene one is in use.
  108540. */
  108541. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108542. /**
  108543. * Gets wether the color curves effect is enabled.
  108544. */
  108545. get cameraColorCurvesEnabled(): boolean;
  108546. /**
  108547. * Sets wether the color curves effect is enabled.
  108548. */
  108549. set cameraColorCurvesEnabled(value: boolean);
  108550. /**
  108551. * Gets wether the color grading effect is enabled.
  108552. */
  108553. get cameraColorGradingEnabled(): boolean;
  108554. /**
  108555. * Gets wether the color grading effect is enabled.
  108556. */
  108557. set cameraColorGradingEnabled(value: boolean);
  108558. /**
  108559. * Gets wether tonemapping is enabled or not.
  108560. */
  108561. get cameraToneMappingEnabled(): boolean;
  108562. /**
  108563. * Sets wether tonemapping is enabled or not
  108564. */
  108565. set cameraToneMappingEnabled(value: boolean);
  108566. /**
  108567. * The camera exposure used on this material.
  108568. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108569. * This corresponds to a photographic exposure.
  108570. */
  108571. get cameraExposure(): number;
  108572. /**
  108573. * The camera exposure used on this material.
  108574. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108575. * This corresponds to a photographic exposure.
  108576. */
  108577. set cameraExposure(value: number);
  108578. /**
  108579. * Gets The camera contrast used on this material.
  108580. */
  108581. get cameraContrast(): number;
  108582. /**
  108583. * Sets The camera contrast used on this material.
  108584. */
  108585. set cameraContrast(value: number);
  108586. /**
  108587. * Gets the Color Grading 2D Lookup Texture.
  108588. */
  108589. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108590. /**
  108591. * Sets the Color Grading 2D Lookup Texture.
  108592. */
  108593. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108594. /**
  108595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108597. * 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;
  108598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108599. */
  108600. get cameraColorCurves(): Nullable<ColorCurves>;
  108601. /**
  108602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108604. * 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;
  108605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108606. */
  108607. set cameraColorCurves(value: Nullable<ColorCurves>);
  108608. /**
  108609. * Instantiates a new PBRMaterial instance.
  108610. *
  108611. * @param name The material name
  108612. * @param scene The scene the material will be use in.
  108613. */
  108614. constructor(name: string, scene: Scene);
  108615. /**
  108616. * Returns the name of this material class.
  108617. */
  108618. getClassName(): string;
  108619. /**
  108620. * Makes a duplicate of the current material.
  108621. * @param name - name to use for the new material.
  108622. */
  108623. clone(name: string): PBRMaterial;
  108624. /**
  108625. * Serializes this PBR Material.
  108626. * @returns - An object with the serialized material.
  108627. */
  108628. serialize(): any;
  108629. /**
  108630. * Parses a PBR Material from a serialized object.
  108631. * @param source - Serialized object.
  108632. * @param scene - BJS scene instance.
  108633. * @param rootUrl - url for the scene object
  108634. * @returns - PBRMaterial
  108635. */
  108636. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108637. }
  108638. }
  108639. declare module BABYLON {
  108640. /** @hidden */
  108641. export var mrtFragmentDeclaration: {
  108642. name: string;
  108643. shader: string;
  108644. };
  108645. }
  108646. declare module BABYLON {
  108647. /** @hidden */
  108648. export var geometryPixelShader: {
  108649. name: string;
  108650. shader: string;
  108651. };
  108652. }
  108653. declare module BABYLON {
  108654. /** @hidden */
  108655. export var geometryVertexShader: {
  108656. name: string;
  108657. shader: string;
  108658. };
  108659. }
  108660. declare module BABYLON {
  108661. /** @hidden */
  108662. interface ISavedTransformationMatrix {
  108663. world: Matrix;
  108664. viewProjection: Matrix;
  108665. }
  108666. /**
  108667. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108668. */
  108669. export class GeometryBufferRenderer {
  108670. /**
  108671. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  108672. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  108673. */
  108674. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  108675. /**
  108676. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108677. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108678. */
  108679. static readonly POSITION_TEXTURE_TYPE: number;
  108680. /**
  108681. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108682. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108683. */
  108684. static readonly VELOCITY_TEXTURE_TYPE: number;
  108685. /**
  108686. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  108687. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  108688. */
  108689. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  108690. /**
  108691. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108692. * in order to compute objects velocities when enableVelocity is set to "true"
  108693. * @hidden
  108694. */
  108695. _previousTransformationMatrices: {
  108696. [index: number]: ISavedTransformationMatrix;
  108697. };
  108698. /**
  108699. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  108700. * in order to compute objects velocities when enableVelocity is set to "true"
  108701. * @hidden
  108702. */
  108703. _previousBonesTransformationMatrices: {
  108704. [index: number]: Float32Array;
  108705. };
  108706. /**
  108707. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  108708. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  108709. */
  108710. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  108711. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  108712. renderTransparentMeshes: boolean;
  108713. private _scene;
  108714. private _resizeObserver;
  108715. private _multiRenderTarget;
  108716. private _ratio;
  108717. private _enablePosition;
  108718. private _enableVelocity;
  108719. private _enableReflectivity;
  108720. private _positionIndex;
  108721. private _velocityIndex;
  108722. private _reflectivityIndex;
  108723. private _depthNormalIndex;
  108724. private _linkedWithPrePass;
  108725. private _prePassRenderer;
  108726. private _attachments;
  108727. protected _effect: Effect;
  108728. protected _cachedDefines: string;
  108729. /**
  108730. * @hidden
  108731. * Sets up internal structures to share outputs with PrePassRenderer
  108732. * This method should only be called by the PrePassRenderer itself
  108733. */
  108734. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108735. /**
  108736. * @hidden
  108737. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108738. * This method should only be called by the PrePassRenderer itself
  108739. */
  108740. _unlinkPrePassRenderer(): void;
  108741. /**
  108742. * @hidden
  108743. * Resets the geometry buffer layout
  108744. */
  108745. _resetLayout(): void;
  108746. /**
  108747. * @hidden
  108748. * Replaces a texture in the geometry buffer renderer
  108749. * Useful when linking textures of the prepass renderer
  108750. */
  108751. _forceTextureType(geometryBufferType: number, index: number): void;
  108752. /**
  108753. * @hidden
  108754. * Sets texture attachments
  108755. * Useful when linking textures of the prepass renderer
  108756. */
  108757. _setAttachments(attachments: number[]): void;
  108758. /**
  108759. * @hidden
  108760. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108761. * Useful when linking textures of the prepass renderer
  108762. */
  108763. _linkInternalTexture(internalTexture: InternalTexture): void;
  108764. /**
  108765. * Gets the render list (meshes to be rendered) used in the G buffer.
  108766. */
  108767. get renderList(): Nullable<AbstractMesh[]>;
  108768. /**
  108769. * Set the render list (meshes to be rendered) used in the G buffer.
  108770. */
  108771. set renderList(meshes: Nullable<AbstractMesh[]>);
  108772. /**
  108773. * Gets wether or not G buffer are supported by the running hardware.
  108774. * This requires draw buffer supports
  108775. */
  108776. get isSupported(): boolean;
  108777. /**
  108778. * Returns the index of the given texture type in the G-Buffer textures array
  108779. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108780. * @returns the index of the given texture type in the G-Buffer textures array
  108781. */
  108782. getTextureIndex(textureType: number): number;
  108783. /**
  108784. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108785. */
  108786. get enablePosition(): boolean;
  108787. /**
  108788. * Sets whether or not objects positions are enabled for the G buffer.
  108789. */
  108790. set enablePosition(enable: boolean);
  108791. /**
  108792. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108793. */
  108794. get enableVelocity(): boolean;
  108795. /**
  108796. * Sets wether or not objects velocities are enabled for the G buffer.
  108797. */
  108798. set enableVelocity(enable: boolean);
  108799. /**
  108800. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108801. */
  108802. get enableReflectivity(): boolean;
  108803. /**
  108804. * Sets wether or not objects roughness are enabled for the G buffer.
  108805. */
  108806. set enableReflectivity(enable: boolean);
  108807. /**
  108808. * Gets the scene associated with the buffer.
  108809. */
  108810. get scene(): Scene;
  108811. /**
  108812. * Gets the ratio used by the buffer during its creation.
  108813. * How big is the buffer related to the main canvas.
  108814. */
  108815. get ratio(): number;
  108816. /** @hidden */
  108817. static _SceneComponentInitialization: (scene: Scene) => void;
  108818. /**
  108819. * Creates a new G Buffer for the scene
  108820. * @param scene The scene the buffer belongs to
  108821. * @param ratio How big is the buffer related to the main canvas.
  108822. */
  108823. constructor(scene: Scene, ratio?: number);
  108824. /**
  108825. * Checks wether everything is ready to render a submesh to the G buffer.
  108826. * @param subMesh the submesh to check readiness for
  108827. * @param useInstances is the mesh drawn using instance or not
  108828. * @returns true if ready otherwise false
  108829. */
  108830. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108831. /**
  108832. * Gets the current underlying G Buffer.
  108833. * @returns the buffer
  108834. */
  108835. getGBuffer(): MultiRenderTarget;
  108836. /**
  108837. * Gets the number of samples used to render the buffer (anti aliasing).
  108838. */
  108839. get samples(): number;
  108840. /**
  108841. * Sets the number of samples used to render the buffer (anti aliasing).
  108842. */
  108843. set samples(value: number);
  108844. /**
  108845. * Disposes the renderer and frees up associated resources.
  108846. */
  108847. dispose(): void;
  108848. private _assignRenderTargetIndices;
  108849. protected _createRenderTargets(): void;
  108850. private _copyBonesTransformationMatrices;
  108851. }
  108852. }
  108853. declare module BABYLON {
  108854. /**
  108855. * Renders a pre pass of the scene
  108856. * This means every mesh in the scene will be rendered to a render target texture
  108857. * And then this texture will be composited to the rendering canvas with post processes
  108858. * It is necessary for effects like subsurface scattering or deferred shading
  108859. */
  108860. export class PrePassRenderer {
  108861. /** @hidden */
  108862. static _SceneComponentInitialization: (scene: Scene) => void;
  108863. private _textureFormats;
  108864. /**
  108865. * To save performance, we can excluded skinned meshes from the prepass
  108866. */
  108867. excludedSkinnedMesh: AbstractMesh[];
  108868. /**
  108869. * Force material to be excluded from the prepass
  108870. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108871. * and you don't want a material to show in the effect.
  108872. */
  108873. excludedMaterials: Material[];
  108874. private _textureIndices;
  108875. private _scene;
  108876. private _engine;
  108877. private _isDirty;
  108878. /**
  108879. * Number of textures in the multi render target texture where the scene is directly rendered
  108880. */
  108881. mrtCount: number;
  108882. /**
  108883. * The render target where the scene is directly rendered
  108884. */
  108885. prePassRT: MultiRenderTarget;
  108886. private _multiRenderAttachments;
  108887. private _defaultAttachments;
  108888. private _clearAttachments;
  108889. private _postProcesses;
  108890. private readonly _clearColor;
  108891. /**
  108892. * Image processing post process for composition
  108893. */
  108894. imageProcessingPostProcess: ImageProcessingPostProcess;
  108895. /**
  108896. * Configuration for prepass effects
  108897. */
  108898. private _effectConfigurations;
  108899. private _mrtFormats;
  108900. private _mrtLayout;
  108901. private _enabled;
  108902. /**
  108903. * Indicates if the prepass is enabled
  108904. */
  108905. get enabled(): boolean;
  108906. /**
  108907. * How many samples are used for MSAA of the scene render target
  108908. */
  108909. get samples(): number;
  108910. set samples(n: number);
  108911. private _geometryBuffer;
  108912. private _useGeometryBufferFallback;
  108913. /**
  108914. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108915. */
  108916. get useGeometryBufferFallback(): boolean;
  108917. set useGeometryBufferFallback(value: boolean);
  108918. /**
  108919. * Instanciates a prepass renderer
  108920. * @param scene The scene
  108921. */
  108922. constructor(scene: Scene);
  108923. private _initializeAttachments;
  108924. private _createCompositionEffect;
  108925. /**
  108926. * Indicates if rendering a prepass is supported
  108927. */
  108928. get isSupported(): boolean;
  108929. /**
  108930. * Sets the proper output textures to draw in the engine.
  108931. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108932. * @param subMesh Submesh on which the effect is applied
  108933. */
  108934. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108935. /**
  108936. * @hidden
  108937. */
  108938. _beforeCameraDraw(): void;
  108939. /**
  108940. * @hidden
  108941. */
  108942. _afterCameraDraw(): void;
  108943. private _checkRTSize;
  108944. private _bindFrameBuffer;
  108945. /**
  108946. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108947. */
  108948. clear(): void;
  108949. private _setState;
  108950. private _updateGeometryBufferLayout;
  108951. /**
  108952. * Adds an effect configuration to the prepass.
  108953. * If an effect has already been added, it won't add it twice and will return the configuration
  108954. * already present.
  108955. * @param cfg the effect configuration
  108956. * @return the effect configuration now used by the prepass
  108957. */
  108958. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108959. /**
  108960. * Returns the index of a texture in the multi render target texture array.
  108961. * @param type Texture type
  108962. * @return The index
  108963. */
  108964. getIndex(type: number): number;
  108965. private _enable;
  108966. private _disable;
  108967. private _resetLayout;
  108968. private _resetPostProcessChain;
  108969. private _bindPostProcessChain;
  108970. /**
  108971. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108972. */
  108973. markAsDirty(): void;
  108974. /**
  108975. * Enables a texture on the MultiRenderTarget for prepass
  108976. */
  108977. private _enableTextures;
  108978. private _update;
  108979. private _markAllMaterialsAsPrePassDirty;
  108980. /**
  108981. * Disposes the prepass renderer.
  108982. */
  108983. dispose(): void;
  108984. }
  108985. }
  108986. declare module BABYLON {
  108987. /**
  108988. * Size options for a post process
  108989. */
  108990. export type PostProcessOptions = {
  108991. width: number;
  108992. height: number;
  108993. };
  108994. /**
  108995. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108996. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108997. */
  108998. export class PostProcess {
  108999. /**
  109000. * Gets or sets the unique id of the post process
  109001. */
  109002. uniqueId: number;
  109003. /** Name of the PostProcess. */
  109004. name: string;
  109005. /**
  109006. * Width of the texture to apply the post process on
  109007. */
  109008. width: number;
  109009. /**
  109010. * Height of the texture to apply the post process on
  109011. */
  109012. height: number;
  109013. /**
  109014. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  109015. */
  109016. nodeMaterialSource: Nullable<NodeMaterial>;
  109017. /**
  109018. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  109019. * @hidden
  109020. */
  109021. _outputTexture: Nullable<InternalTexture>;
  109022. /**
  109023. * Sampling mode used by the shader
  109024. * See https://doc.babylonjs.com/classes/3.1/texture
  109025. */
  109026. renderTargetSamplingMode: number;
  109027. /**
  109028. * Clear color to use when screen clearing
  109029. */
  109030. clearColor: Color4;
  109031. /**
  109032. * If the buffer needs to be cleared before applying the post process. (default: true)
  109033. * Should be set to false if shader will overwrite all previous pixels.
  109034. */
  109035. autoClear: boolean;
  109036. /**
  109037. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  109038. */
  109039. alphaMode: number;
  109040. /**
  109041. * Sets the setAlphaBlendConstants of the babylon engine
  109042. */
  109043. alphaConstants: Color4;
  109044. /**
  109045. * Animations to be used for the post processing
  109046. */
  109047. animations: Animation[];
  109048. /**
  109049. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  109050. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  109051. */
  109052. enablePixelPerfectMode: boolean;
  109053. /**
  109054. * Force the postprocess to be applied without taking in account viewport
  109055. */
  109056. forceFullscreenViewport: boolean;
  109057. /**
  109058. * List of inspectable custom properties (used by the Inspector)
  109059. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109060. */
  109061. inspectableCustomProperties: IInspectable[];
  109062. /**
  109063. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  109064. *
  109065. * | Value | Type | Description |
  109066. * | ----- | ----------------------------------- | ----------- |
  109067. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  109068. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  109069. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  109070. *
  109071. */
  109072. scaleMode: number;
  109073. /**
  109074. * Force textures to be a power of two (default: false)
  109075. */
  109076. alwaysForcePOT: boolean;
  109077. private _samples;
  109078. /**
  109079. * Number of sample textures (default: 1)
  109080. */
  109081. get samples(): number;
  109082. set samples(n: number);
  109083. /**
  109084. * Modify the scale of the post process to be the same as the viewport (default: false)
  109085. */
  109086. adaptScaleToCurrentViewport: boolean;
  109087. private _camera;
  109088. protected _scene: Scene;
  109089. private _engine;
  109090. private _options;
  109091. private _reusable;
  109092. private _textureType;
  109093. private _textureFormat;
  109094. /**
  109095. * Smart array of input and output textures for the post process.
  109096. * @hidden
  109097. */
  109098. _textures: SmartArray<InternalTexture>;
  109099. /**
  109100. * The index in _textures that corresponds to the output texture.
  109101. * @hidden
  109102. */
  109103. _currentRenderTextureInd: number;
  109104. private _effect;
  109105. private _samplers;
  109106. private _fragmentUrl;
  109107. private _vertexUrl;
  109108. private _parameters;
  109109. private _scaleRatio;
  109110. protected _indexParameters: any;
  109111. private _shareOutputWithPostProcess;
  109112. private _texelSize;
  109113. private _forcedOutputTexture;
  109114. /**
  109115. * Prepass configuration in case this post process needs a texture from prepass
  109116. * @hidden
  109117. */
  109118. _prePassEffectConfiguration: PrePassEffectConfiguration;
  109119. /**
  109120. * Returns the fragment url or shader name used in the post process.
  109121. * @returns the fragment url or name in the shader store.
  109122. */
  109123. getEffectName(): string;
  109124. /**
  109125. * An event triggered when the postprocess is activated.
  109126. */
  109127. onActivateObservable: Observable<Camera>;
  109128. private _onActivateObserver;
  109129. /**
  109130. * A function that is added to the onActivateObservable
  109131. */
  109132. set onActivate(callback: Nullable<(camera: Camera) => void>);
  109133. /**
  109134. * An event triggered when the postprocess changes its size.
  109135. */
  109136. onSizeChangedObservable: Observable<PostProcess>;
  109137. private _onSizeChangedObserver;
  109138. /**
  109139. * A function that is added to the onSizeChangedObservable
  109140. */
  109141. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  109142. /**
  109143. * An event triggered when the postprocess applies its effect.
  109144. */
  109145. onApplyObservable: Observable<Effect>;
  109146. private _onApplyObserver;
  109147. /**
  109148. * A function that is added to the onApplyObservable
  109149. */
  109150. set onApply(callback: (effect: Effect) => void);
  109151. /**
  109152. * An event triggered before rendering the postprocess
  109153. */
  109154. onBeforeRenderObservable: Observable<Effect>;
  109155. private _onBeforeRenderObserver;
  109156. /**
  109157. * A function that is added to the onBeforeRenderObservable
  109158. */
  109159. set onBeforeRender(callback: (effect: Effect) => void);
  109160. /**
  109161. * An event triggered after rendering the postprocess
  109162. */
  109163. onAfterRenderObservable: Observable<Effect>;
  109164. private _onAfterRenderObserver;
  109165. /**
  109166. * A function that is added to the onAfterRenderObservable
  109167. */
  109168. set onAfterRender(callback: (efect: Effect) => void);
  109169. /**
  109170. * 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
  109171. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  109172. */
  109173. get inputTexture(): InternalTexture;
  109174. set inputTexture(value: InternalTexture);
  109175. /**
  109176. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  109177. * the only way to unset it is to use this function to restore its internal state
  109178. */
  109179. restoreDefaultInputTexture(): void;
  109180. /**
  109181. * Gets the camera which post process is applied to.
  109182. * @returns The camera the post process is applied to.
  109183. */
  109184. getCamera(): Camera;
  109185. /**
  109186. * Gets the texel size of the postprocess.
  109187. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  109188. */
  109189. get texelSize(): Vector2;
  109190. /**
  109191. * Creates a new instance PostProcess
  109192. * @param name The name of the PostProcess.
  109193. * @param fragmentUrl The url of the fragment shader to be used.
  109194. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  109195. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  109196. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109197. * @param camera The camera to apply the render pass to.
  109198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109199. * @param engine The engine which the post process will be applied. (default: current engine)
  109200. * @param reusable If the post process can be reused on the same frame. (default: false)
  109201. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  109202. * @param textureType Type of textures used when performing the post process. (default: 0)
  109203. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  109204. * @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
  109205. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  109206. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  109207. */
  109208. 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);
  109209. /**
  109210. * Gets a string identifying the name of the class
  109211. * @returns "PostProcess" string
  109212. */
  109213. getClassName(): string;
  109214. /**
  109215. * Gets the engine which this post process belongs to.
  109216. * @returns The engine the post process was enabled with.
  109217. */
  109218. getEngine(): Engine;
  109219. /**
  109220. * The effect that is created when initializing the post process.
  109221. * @returns The created effect corresponding the the postprocess.
  109222. */
  109223. getEffect(): Effect;
  109224. /**
  109225. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  109226. * @param postProcess The post process to share the output with.
  109227. * @returns This post process.
  109228. */
  109229. shareOutputWith(postProcess: PostProcess): PostProcess;
  109230. /**
  109231. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  109232. * This should be called if the post process that shares output with this post process is disabled/disposed.
  109233. */
  109234. useOwnOutput(): void;
  109235. /**
  109236. * Updates the effect with the current post process compile time values and recompiles the shader.
  109237. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109238. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109239. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109240. * @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
  109241. * @param onCompiled Called when the shader has been compiled.
  109242. * @param onError Called if there is an error when compiling a shader.
  109243. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  109244. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  109245. */
  109246. 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;
  109247. /**
  109248. * The post process is reusable if it can be used multiple times within one frame.
  109249. * @returns If the post process is reusable
  109250. */
  109251. isReusable(): boolean;
  109252. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  109253. markTextureDirty(): void;
  109254. /**
  109255. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  109256. * 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.
  109257. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  109258. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  109259. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  109260. * @returns The target texture that was bound to be written to.
  109261. */
  109262. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  109263. /**
  109264. * If the post process is supported.
  109265. */
  109266. get isSupported(): boolean;
  109267. /**
  109268. * The aspect ratio of the output texture.
  109269. */
  109270. get aspectRatio(): number;
  109271. /**
  109272. * Get a value indicating if the post-process is ready to be used
  109273. * @returns true if the post-process is ready (shader is compiled)
  109274. */
  109275. isReady(): boolean;
  109276. /**
  109277. * Binds all textures and uniforms to the shader, this will be run on every pass.
  109278. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  109279. */
  109280. apply(): Nullable<Effect>;
  109281. private _disposeTextures;
  109282. /**
  109283. * Sets the required values to the prepass renderer.
  109284. * @param prePassRenderer defines the prepass renderer to setup.
  109285. * @returns true if the pre pass is needed.
  109286. */
  109287. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  109288. /**
  109289. * Disposes the post process.
  109290. * @param camera The camera to dispose the post process on.
  109291. */
  109292. dispose(camera?: Camera): void;
  109293. /**
  109294. * Serializes the particle system to a JSON object
  109295. * @returns the JSON object
  109296. */
  109297. serialize(): any;
  109298. /**
  109299. * Creates a material from parsed material data
  109300. * @param parsedPostProcess defines parsed post process data
  109301. * @param scene defines the hosting scene
  109302. * @param rootUrl defines the root URL to use to load textures
  109303. * @returns a new post process
  109304. */
  109305. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  109306. }
  109307. }
  109308. declare module BABYLON {
  109309. /** @hidden */
  109310. export var kernelBlurVaryingDeclaration: {
  109311. name: string;
  109312. shader: string;
  109313. };
  109314. }
  109315. declare module BABYLON {
  109316. /** @hidden */
  109317. export var kernelBlurFragment: {
  109318. name: string;
  109319. shader: string;
  109320. };
  109321. }
  109322. declare module BABYLON {
  109323. /** @hidden */
  109324. export var kernelBlurFragment2: {
  109325. name: string;
  109326. shader: string;
  109327. };
  109328. }
  109329. declare module BABYLON {
  109330. /** @hidden */
  109331. export var kernelBlurPixelShader: {
  109332. name: string;
  109333. shader: string;
  109334. };
  109335. }
  109336. declare module BABYLON {
  109337. /** @hidden */
  109338. export var kernelBlurVertex: {
  109339. name: string;
  109340. shader: string;
  109341. };
  109342. }
  109343. declare module BABYLON {
  109344. /** @hidden */
  109345. export var kernelBlurVertexShader: {
  109346. name: string;
  109347. shader: string;
  109348. };
  109349. }
  109350. declare module BABYLON {
  109351. /**
  109352. * The Blur Post Process which blurs an image based on a kernel and direction.
  109353. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  109354. */
  109355. export class BlurPostProcess extends PostProcess {
  109356. private blockCompilation;
  109357. protected _kernel: number;
  109358. protected _idealKernel: number;
  109359. protected _packedFloat: boolean;
  109360. private _staticDefines;
  109361. /** The direction in which to blur the image. */
  109362. direction: Vector2;
  109363. /**
  109364. * Sets the length in pixels of the blur sample region
  109365. */
  109366. set kernel(v: number);
  109367. /**
  109368. * Gets the length in pixels of the blur sample region
  109369. */
  109370. get kernel(): number;
  109371. /**
  109372. * Sets wether or not the blur needs to unpack/repack floats
  109373. */
  109374. set packedFloat(v: boolean);
  109375. /**
  109376. * Gets wether or not the blur is unpacking/repacking floats
  109377. */
  109378. get packedFloat(): boolean;
  109379. /**
  109380. * Gets a string identifying the name of the class
  109381. * @returns "BlurPostProcess" string
  109382. */
  109383. getClassName(): string;
  109384. /**
  109385. * Creates a new instance BlurPostProcess
  109386. * @param name The name of the effect.
  109387. * @param direction The direction in which to blur the image.
  109388. * @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.
  109389. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109390. * @param camera The camera to apply the render pass to.
  109391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109392. * @param engine The engine which the post process will be applied. (default: current engine)
  109393. * @param reusable If the post process can be reused on the same frame. (default: false)
  109394. * @param textureType Type of textures used when performing the post process. (default: 0)
  109395. * @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)
  109396. */
  109397. 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);
  109398. /**
  109399. * Updates the effect with the current post process compile time values and recompiles the shader.
  109400. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109401. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109402. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109403. * @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
  109404. * @param onCompiled Called when the shader has been compiled.
  109405. * @param onError Called if there is an error when compiling a shader.
  109406. */
  109407. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109408. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109409. /**
  109410. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  109411. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  109412. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  109413. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  109414. * The gaps between physical kernels are compensated for in the weighting of the samples
  109415. * @param idealKernel Ideal blur kernel.
  109416. * @return Nearest best kernel.
  109417. */
  109418. protected _nearestBestKernel(idealKernel: number): number;
  109419. /**
  109420. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  109421. * @param x The point on the Gaussian distribution to sample.
  109422. * @return the value of the Gaussian function at x.
  109423. */
  109424. protected _gaussianWeight(x: number): number;
  109425. /**
  109426. * Generates a string that can be used as a floating point number in GLSL.
  109427. * @param x Value to print.
  109428. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  109429. * @return GLSL float string.
  109430. */
  109431. protected _glslFloat(x: number, decimalFigures?: number): string;
  109432. /** @hidden */
  109433. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  109434. }
  109435. }
  109436. declare module BABYLON {
  109437. /**
  109438. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109439. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109440. * You can then easily use it as a reflectionTexture on a flat surface.
  109441. * In case the surface is not a plane, please consider relying on reflection probes.
  109442. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109443. */
  109444. export class MirrorTexture extends RenderTargetTexture {
  109445. private scene;
  109446. /**
  109447. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  109448. * 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.
  109449. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109450. */
  109451. mirrorPlane: Plane;
  109452. /**
  109453. * Define the blur ratio used to blur the reflection if needed.
  109454. */
  109455. set blurRatio(value: number);
  109456. get blurRatio(): number;
  109457. /**
  109458. * Define the adaptive blur kernel used to blur the reflection if needed.
  109459. * This will autocompute the closest best match for the `blurKernel`
  109460. */
  109461. set adaptiveBlurKernel(value: number);
  109462. /**
  109463. * Define the blur kernel used to blur the reflection if needed.
  109464. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109465. */
  109466. set blurKernel(value: number);
  109467. /**
  109468. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  109469. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109470. */
  109471. set blurKernelX(value: number);
  109472. get blurKernelX(): number;
  109473. /**
  109474. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  109475. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109476. */
  109477. set blurKernelY(value: number);
  109478. get blurKernelY(): number;
  109479. private _autoComputeBlurKernel;
  109480. protected _onRatioRescale(): void;
  109481. private _updateGammaSpace;
  109482. private _imageProcessingConfigChangeObserver;
  109483. private _transformMatrix;
  109484. private _mirrorMatrix;
  109485. private _savedViewMatrix;
  109486. private _blurX;
  109487. private _blurY;
  109488. private _adaptiveBlurKernel;
  109489. private _blurKernelX;
  109490. private _blurKernelY;
  109491. private _blurRatio;
  109492. /**
  109493. * Instantiates a Mirror Texture.
  109494. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109495. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109496. * You can then easily use it as a reflectionTexture on a flat surface.
  109497. * In case the surface is not a plane, please consider relying on reflection probes.
  109498. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109499. * @param name
  109500. * @param size
  109501. * @param scene
  109502. * @param generateMipMaps
  109503. * @param type
  109504. * @param samplingMode
  109505. * @param generateDepthBuffer
  109506. */
  109507. constructor(name: string, size: number | {
  109508. width: number;
  109509. height: number;
  109510. } | {
  109511. ratio: number;
  109512. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  109513. private _preparePostProcesses;
  109514. /**
  109515. * Clone the mirror texture.
  109516. * @returns the cloned texture
  109517. */
  109518. clone(): MirrorTexture;
  109519. /**
  109520. * Serialize the texture to a JSON representation you could use in Parse later on
  109521. * @returns the serialized JSON representation
  109522. */
  109523. serialize(): any;
  109524. /**
  109525. * Dispose the texture and release its associated resources.
  109526. */
  109527. dispose(): void;
  109528. }
  109529. }
  109530. declare module BABYLON {
  109531. /**
  109532. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109533. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109534. */
  109535. export class Texture extends BaseTexture {
  109536. /**
  109537. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  109538. */
  109539. static SerializeBuffers: boolean;
  109540. /**
  109541. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  109542. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  109543. */
  109544. static ForceSerializeBuffers: boolean;
  109545. /** @hidden */
  109546. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  109547. /** @hidden */
  109548. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  109549. /** @hidden */
  109550. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  109551. /** nearest is mag = nearest and min = nearest and mip = linear */
  109552. static readonly NEAREST_SAMPLINGMODE: number;
  109553. /** nearest is mag = nearest and min = nearest and mip = linear */
  109554. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  109555. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109556. static readonly BILINEAR_SAMPLINGMODE: number;
  109557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109558. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  109559. /** Trilinear is mag = linear and min = linear and mip = linear */
  109560. static readonly TRILINEAR_SAMPLINGMODE: number;
  109561. /** Trilinear is mag = linear and min = linear and mip = linear */
  109562. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  109563. /** mag = nearest and min = nearest and mip = nearest */
  109564. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  109565. /** mag = nearest and min = linear and mip = nearest */
  109566. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  109567. /** mag = nearest and min = linear and mip = linear */
  109568. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  109569. /** mag = nearest and min = linear and mip = none */
  109570. static readonly NEAREST_LINEAR: number;
  109571. /** mag = nearest and min = nearest and mip = none */
  109572. static readonly NEAREST_NEAREST: number;
  109573. /** mag = linear and min = nearest and mip = nearest */
  109574. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  109575. /** mag = linear and min = nearest and mip = linear */
  109576. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  109577. /** mag = linear and min = linear and mip = none */
  109578. static readonly LINEAR_LINEAR: number;
  109579. /** mag = linear and min = nearest and mip = none */
  109580. static readonly LINEAR_NEAREST: number;
  109581. /** Explicit coordinates mode */
  109582. static readonly EXPLICIT_MODE: number;
  109583. /** Spherical coordinates mode */
  109584. static readonly SPHERICAL_MODE: number;
  109585. /** Planar coordinates mode */
  109586. static readonly PLANAR_MODE: number;
  109587. /** Cubic coordinates mode */
  109588. static readonly CUBIC_MODE: number;
  109589. /** Projection coordinates mode */
  109590. static readonly PROJECTION_MODE: number;
  109591. /** Inverse Cubic coordinates mode */
  109592. static readonly SKYBOX_MODE: number;
  109593. /** Inverse Cubic coordinates mode */
  109594. static readonly INVCUBIC_MODE: number;
  109595. /** Equirectangular coordinates mode */
  109596. static readonly EQUIRECTANGULAR_MODE: number;
  109597. /** Equirectangular Fixed coordinates mode */
  109598. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  109599. /** Equirectangular Fixed Mirrored coordinates mode */
  109600. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109601. /** Texture is not repeating outside of 0..1 UVs */
  109602. static readonly CLAMP_ADDRESSMODE: number;
  109603. /** Texture is repeating outside of 0..1 UVs */
  109604. static readonly WRAP_ADDRESSMODE: number;
  109605. /** Texture is repeating and mirrored */
  109606. static readonly MIRROR_ADDRESSMODE: number;
  109607. /**
  109608. * 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
  109609. */
  109610. static UseSerializedUrlIfAny: boolean;
  109611. /**
  109612. * Define the url of the texture.
  109613. */
  109614. url: Nullable<string>;
  109615. /**
  109616. * Define an offset on the texture to offset the u coordinates of the UVs
  109617. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109618. */
  109619. uOffset: number;
  109620. /**
  109621. * Define an offset on the texture to offset the v coordinates of the UVs
  109622. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109623. */
  109624. vOffset: number;
  109625. /**
  109626. * Define an offset on the texture to scale the u coordinates of the UVs
  109627. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109628. */
  109629. uScale: number;
  109630. /**
  109631. * Define an offset on the texture to scale the v coordinates of the UVs
  109632. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109633. */
  109634. vScale: number;
  109635. /**
  109636. * Define an offset on the texture to rotate around the u coordinates of the UVs
  109637. * @see https://doc.babylonjs.com/how_to/more_materials
  109638. */
  109639. uAng: number;
  109640. /**
  109641. * Define an offset on the texture to rotate around the v coordinates of the UVs
  109642. * @see https://doc.babylonjs.com/how_to/more_materials
  109643. */
  109644. vAng: number;
  109645. /**
  109646. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  109647. * @see https://doc.babylonjs.com/how_to/more_materials
  109648. */
  109649. wAng: number;
  109650. /**
  109651. * Defines the center of rotation (U)
  109652. */
  109653. uRotationCenter: number;
  109654. /**
  109655. * Defines the center of rotation (V)
  109656. */
  109657. vRotationCenter: number;
  109658. /**
  109659. * Defines the center of rotation (W)
  109660. */
  109661. wRotationCenter: number;
  109662. /**
  109663. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  109664. */
  109665. homogeneousRotationInUVTransform: boolean;
  109666. /**
  109667. * Are mip maps generated for this texture or not.
  109668. */
  109669. get noMipmap(): boolean;
  109670. /**
  109671. * List of inspectable custom properties (used by the Inspector)
  109672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109673. */
  109674. inspectableCustomProperties: Nullable<IInspectable[]>;
  109675. private _noMipmap;
  109676. /** @hidden */
  109677. _invertY: boolean;
  109678. private _rowGenerationMatrix;
  109679. private _cachedTextureMatrix;
  109680. private _projectionModeMatrix;
  109681. private _t0;
  109682. private _t1;
  109683. private _t2;
  109684. private _cachedUOffset;
  109685. private _cachedVOffset;
  109686. private _cachedUScale;
  109687. private _cachedVScale;
  109688. private _cachedUAng;
  109689. private _cachedVAng;
  109690. private _cachedWAng;
  109691. private _cachedProjectionMatrixId;
  109692. private _cachedURotationCenter;
  109693. private _cachedVRotationCenter;
  109694. private _cachedWRotationCenter;
  109695. private _cachedHomogeneousRotationInUVTransform;
  109696. private _cachedCoordinatesMode;
  109697. /** @hidden */
  109698. protected _initialSamplingMode: number;
  109699. /** @hidden */
  109700. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109701. private _deleteBuffer;
  109702. protected _format: Nullable<number>;
  109703. private _delayedOnLoad;
  109704. private _delayedOnError;
  109705. private _mimeType?;
  109706. private _loaderOptions?;
  109707. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  109708. get mimeType(): string | undefined;
  109709. /**
  109710. * Observable triggered once the texture has been loaded.
  109711. */
  109712. onLoadObservable: Observable<Texture>;
  109713. protected _isBlocking: boolean;
  109714. /**
  109715. * Is the texture preventing material to render while loading.
  109716. * If false, a default texture will be used instead of the loading one during the preparation step.
  109717. */
  109718. set isBlocking(value: boolean);
  109719. get isBlocking(): boolean;
  109720. /**
  109721. * Get the current sampling mode associated with the texture.
  109722. */
  109723. get samplingMode(): number;
  109724. /**
  109725. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109726. */
  109727. get invertY(): boolean;
  109728. /**
  109729. * Instantiates a new texture.
  109730. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109731. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109732. * @param url defines the url of the picture to load as a texture
  109733. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109734. * @param noMipmap defines if the texture will require mip maps or not
  109735. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109736. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109737. * @param onLoad defines a callback triggered when the texture has been loaded
  109738. * @param onError defines a callback triggered when an error occurred during the loading session
  109739. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109740. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109741. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109742. * @param mimeType defines an optional mime type information
  109743. * @param loaderOptions options to be passed to the loader
  109744. */
  109745. 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);
  109746. /**
  109747. * Update the url (and optional buffer) of this texture if url was null during construction.
  109748. * @param url the url of the texture
  109749. * @param buffer the buffer of the texture (defaults to null)
  109750. * @param onLoad callback called when the texture is loaded (defaults to null)
  109751. */
  109752. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109753. /**
  109754. * Finish the loading sequence of a texture flagged as delayed load.
  109755. * @hidden
  109756. */
  109757. delayLoad(): void;
  109758. private _prepareRowForTextureGeneration;
  109759. /**
  109760. * Checks if the texture has the same transform matrix than another texture
  109761. * @param texture texture to check against
  109762. * @returns true if the transforms are the same, else false
  109763. */
  109764. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109765. /**
  109766. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109767. * @returns the transform matrix of the texture.
  109768. */
  109769. getTextureMatrix(uBase?: number): Matrix;
  109770. /**
  109771. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109772. * @returns The reflection texture transform
  109773. */
  109774. getReflectionTextureMatrix(): Matrix;
  109775. /**
  109776. * Clones the texture.
  109777. * @returns the cloned texture
  109778. */
  109779. clone(): Texture;
  109780. /**
  109781. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109782. * @returns The JSON representation of the texture
  109783. */
  109784. serialize(): any;
  109785. /**
  109786. * Get the current class name of the texture useful for serialization or dynamic coding.
  109787. * @returns "Texture"
  109788. */
  109789. getClassName(): string;
  109790. /**
  109791. * Dispose the texture and release its associated resources.
  109792. */
  109793. dispose(): void;
  109794. /**
  109795. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109796. * @param parsedTexture Define the JSON representation of the texture
  109797. * @param scene Define the scene the parsed texture should be instantiated in
  109798. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109799. * @returns The parsed texture if successful
  109800. */
  109801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109802. /**
  109803. * Creates a texture from its base 64 representation.
  109804. * @param data Define the base64 payload without the data: prefix
  109805. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109806. * @param scene Define the scene the texture should belong to
  109807. * @param noMipmap Forces the texture to not create mip map information if true
  109808. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109809. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109810. * @param onLoad define a callback triggered when the texture has been loaded
  109811. * @param onError define a callback triggered when an error occurred during the loading session
  109812. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109813. * @returns the created texture
  109814. */
  109815. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109816. /**
  109817. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109818. * @param data Define the base64 payload without the data: prefix
  109819. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109820. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109821. * @param scene Define the scene the texture should belong to
  109822. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109823. * @param noMipmap Forces the texture to not create mip map information if true
  109824. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109825. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109826. * @param onLoad define a callback triggered when the texture has been loaded
  109827. * @param onError define a callback triggered when an error occurred during the loading session
  109828. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109829. * @returns the created texture
  109830. */
  109831. 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;
  109832. }
  109833. }
  109834. declare module BABYLON {
  109835. /**
  109836. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109837. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109838. */
  109839. export class PostProcessManager {
  109840. private _scene;
  109841. private _indexBuffer;
  109842. private _vertexBuffers;
  109843. /**
  109844. * Creates a new instance PostProcess
  109845. * @param scene The scene that the post process is associated with.
  109846. */
  109847. constructor(scene: Scene);
  109848. private _prepareBuffers;
  109849. private _buildIndexBuffer;
  109850. /**
  109851. * Rebuilds the vertex buffers of the manager.
  109852. * @hidden
  109853. */
  109854. _rebuild(): void;
  109855. /**
  109856. * Prepares a frame to be run through a post process.
  109857. * @param sourceTexture The input texture to the post procesess. (default: null)
  109858. * @param postProcesses An array of post processes to be run. (default: null)
  109859. * @returns True if the post processes were able to be run.
  109860. * @hidden
  109861. */
  109862. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109863. /**
  109864. * Manually render a set of post processes to a texture.
  109865. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109866. * @param postProcesses An array of post processes to be run.
  109867. * @param targetTexture The target texture to render to.
  109868. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109869. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109870. * @param lodLevel defines which lod of the texture to render to
  109871. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109872. */
  109873. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109874. /**
  109875. * Finalize the result of the output of the postprocesses.
  109876. * @param doNotPresent If true the result will not be displayed to the screen.
  109877. * @param targetTexture The target texture to render to.
  109878. * @param faceIndex The index of the face to bind the target texture to.
  109879. * @param postProcesses The array of post processes to render.
  109880. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109881. * @hidden
  109882. */
  109883. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109884. /**
  109885. * Disposes of the post process manager.
  109886. */
  109887. dispose(): void;
  109888. }
  109889. }
  109890. declare module BABYLON {
  109891. /**
  109892. * This Helps creating a texture that will be created from a camera in your scene.
  109893. * It is basically a dynamic texture that could be used to create special effects for instance.
  109894. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109895. */
  109896. export class RenderTargetTexture extends Texture {
  109897. /**
  109898. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109899. */
  109900. static readonly REFRESHRATE_RENDER_ONCE: number;
  109901. /**
  109902. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109903. */
  109904. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109905. /**
  109906. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109907. * the central point of your effect and can save a lot of performances.
  109908. */
  109909. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109910. /**
  109911. * Use this predicate to dynamically define the list of mesh you want to render.
  109912. * If set, the renderList property will be overwritten.
  109913. */
  109914. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109915. private _renderList;
  109916. /**
  109917. * Use this list to define the list of mesh you want to render.
  109918. */
  109919. get renderList(): Nullable<Array<AbstractMesh>>;
  109920. set renderList(value: Nullable<Array<AbstractMesh>>);
  109921. /**
  109922. * Use this function to overload the renderList array at rendering time.
  109923. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109924. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109925. * the cube (if the RTT is a cube, else layerOrFace=0).
  109926. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109927. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109928. * hold dummy elements!
  109929. */
  109930. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109931. private _hookArray;
  109932. /**
  109933. * Define if particles should be rendered in your texture.
  109934. */
  109935. renderParticles: boolean;
  109936. /**
  109937. * Define if sprites should be rendered in your texture.
  109938. */
  109939. renderSprites: boolean;
  109940. /**
  109941. * Define the camera used to render the texture.
  109942. */
  109943. activeCamera: Nullable<Camera>;
  109944. /**
  109945. * Override the mesh isReady function with your own one.
  109946. */
  109947. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109948. /**
  109949. * Override the render function of the texture with your own one.
  109950. */
  109951. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109952. /**
  109953. * Define if camera post processes should be use while rendering the texture.
  109954. */
  109955. useCameraPostProcesses: boolean;
  109956. /**
  109957. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109958. */
  109959. ignoreCameraViewport: boolean;
  109960. private _postProcessManager;
  109961. private _postProcesses;
  109962. private _resizeObserver;
  109963. /**
  109964. * An event triggered when the texture is unbind.
  109965. */
  109966. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109967. /**
  109968. * An event triggered when the texture is unbind.
  109969. */
  109970. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109971. private _onAfterUnbindObserver;
  109972. /**
  109973. * Set a after unbind callback in the texture.
  109974. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109975. */
  109976. set onAfterUnbind(callback: () => void);
  109977. /**
  109978. * An event triggered before rendering the texture
  109979. */
  109980. onBeforeRenderObservable: Observable<number>;
  109981. private _onBeforeRenderObserver;
  109982. /**
  109983. * Set a before render callback in the texture.
  109984. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109985. */
  109986. set onBeforeRender(callback: (faceIndex: number) => void);
  109987. /**
  109988. * An event triggered after rendering the texture
  109989. */
  109990. onAfterRenderObservable: Observable<number>;
  109991. private _onAfterRenderObserver;
  109992. /**
  109993. * Set a after render callback in the texture.
  109994. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109995. */
  109996. set onAfterRender(callback: (faceIndex: number) => void);
  109997. /**
  109998. * An event triggered after the texture clear
  109999. */
  110000. onClearObservable: Observable<Engine>;
  110001. private _onClearObserver;
  110002. /**
  110003. * Set a clear callback in the texture.
  110004. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  110005. */
  110006. set onClear(callback: (Engine: Engine) => void);
  110007. /**
  110008. * An event triggered when the texture is resized.
  110009. */
  110010. onResizeObservable: Observable<RenderTargetTexture>;
  110011. /**
  110012. * Define the clear color of the Render Target if it should be different from the scene.
  110013. */
  110014. clearColor: Color4;
  110015. protected _size: number | {
  110016. width: number;
  110017. height: number;
  110018. layers?: number;
  110019. };
  110020. protected _initialSizeParameter: number | {
  110021. width: number;
  110022. height: number;
  110023. } | {
  110024. ratio: number;
  110025. };
  110026. protected _sizeRatio: Nullable<number>;
  110027. /** @hidden */
  110028. _generateMipMaps: boolean;
  110029. protected _renderingManager: RenderingManager;
  110030. /** @hidden */
  110031. _waitingRenderList?: string[];
  110032. protected _doNotChangeAspectRatio: boolean;
  110033. protected _currentRefreshId: number;
  110034. protected _refreshRate: number;
  110035. protected _textureMatrix: Matrix;
  110036. protected _samples: number;
  110037. protected _renderTargetOptions: RenderTargetCreationOptions;
  110038. /**
  110039. * Gets render target creation options that were used.
  110040. */
  110041. get renderTargetOptions(): RenderTargetCreationOptions;
  110042. protected _onRatioRescale(): void;
  110043. /**
  110044. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  110045. * It must define where the camera used to render the texture is set
  110046. */
  110047. boundingBoxPosition: Vector3;
  110048. private _boundingBoxSize;
  110049. /**
  110050. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  110051. * When defined, the cubemap will switch to local mode
  110052. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  110053. * @example https://www.babylonjs-playground.com/#RNASML
  110054. */
  110055. set boundingBoxSize(value: Vector3);
  110056. get boundingBoxSize(): Vector3;
  110057. /**
  110058. * In case the RTT has been created with a depth texture, get the associated
  110059. * depth texture.
  110060. * Otherwise, return null.
  110061. */
  110062. get depthStencilTexture(): Nullable<InternalTexture>;
  110063. /**
  110064. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  110065. * or used a shadow, depth texture...
  110066. * @param name The friendly name of the texture
  110067. * @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)
  110068. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  110069. * @param generateMipMaps True if mip maps need to be generated after render.
  110070. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  110071. * @param type The type of the buffer in the RTT (int, half float, float...)
  110072. * @param isCube True if a cube texture needs to be created
  110073. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  110074. * @param generateDepthBuffer True to generate a depth buffer
  110075. * @param generateStencilBuffer True to generate a stencil buffer
  110076. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  110077. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  110078. * @param delayAllocation if the texture allocation should be delayed (default: false)
  110079. */
  110080. constructor(name: string, size: number | {
  110081. width: number;
  110082. height: number;
  110083. layers?: number;
  110084. } | {
  110085. ratio: number;
  110086. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  110087. /**
  110088. * Creates a depth stencil texture.
  110089. * This is only available in WebGL 2 or with the depth texture extension available.
  110090. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  110091. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  110092. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  110093. */
  110094. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  110095. private _processSizeParameter;
  110096. /**
  110097. * Define the number of samples to use in case of MSAA.
  110098. * It defaults to one meaning no MSAA has been enabled.
  110099. */
  110100. get samples(): number;
  110101. set samples(value: number);
  110102. /**
  110103. * Resets the refresh counter of the texture and start bak from scratch.
  110104. * Could be useful to regenerate the texture if it is setup to render only once.
  110105. */
  110106. resetRefreshCounter(): void;
  110107. /**
  110108. * Define the refresh rate of the texture or the rendering frequency.
  110109. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  110110. */
  110111. get refreshRate(): number;
  110112. set refreshRate(value: number);
  110113. /**
  110114. * Adds a post process to the render target rendering passes.
  110115. * @param postProcess define the post process to add
  110116. */
  110117. addPostProcess(postProcess: PostProcess): void;
  110118. /**
  110119. * Clear all the post processes attached to the render target
  110120. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  110121. */
  110122. clearPostProcesses(dispose?: boolean): void;
  110123. /**
  110124. * Remove one of the post process from the list of attached post processes to the texture
  110125. * @param postProcess define the post process to remove from the list
  110126. */
  110127. removePostProcess(postProcess: PostProcess): void;
  110128. /** @hidden */
  110129. _shouldRender(): boolean;
  110130. /**
  110131. * Gets the actual render size of the texture.
  110132. * @returns the width of the render size
  110133. */
  110134. getRenderSize(): number;
  110135. /**
  110136. * Gets the actual render width of the texture.
  110137. * @returns the width of the render size
  110138. */
  110139. getRenderWidth(): number;
  110140. /**
  110141. * Gets the actual render height of the texture.
  110142. * @returns the height of the render size
  110143. */
  110144. getRenderHeight(): number;
  110145. /**
  110146. * Gets the actual number of layers of the texture.
  110147. * @returns the number of layers
  110148. */
  110149. getRenderLayers(): number;
  110150. /**
  110151. * Get if the texture can be rescaled or not.
  110152. */
  110153. get canRescale(): boolean;
  110154. /**
  110155. * Resize the texture using a ratio.
  110156. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  110157. */
  110158. scale(ratio: number): void;
  110159. /**
  110160. * Get the texture reflection matrix used to rotate/transform the reflection.
  110161. * @returns the reflection matrix
  110162. */
  110163. getReflectionTextureMatrix(): Matrix;
  110164. /**
  110165. * Resize the texture to a new desired size.
  110166. * Be carrefull as it will recreate all the data in the new texture.
  110167. * @param size Define the new size. It can be:
  110168. * - a number for squared texture,
  110169. * - an object containing { width: number, height: number }
  110170. * - or an object containing a ratio { ratio: number }
  110171. */
  110172. resize(size: number | {
  110173. width: number;
  110174. height: number;
  110175. } | {
  110176. ratio: number;
  110177. }): void;
  110178. private _defaultRenderListPrepared;
  110179. /**
  110180. * Renders all the objects from the render list into the texture.
  110181. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  110182. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  110183. */
  110184. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  110185. private _bestReflectionRenderTargetDimension;
  110186. private _prepareRenderingManager;
  110187. /**
  110188. * @hidden
  110189. * @param faceIndex face index to bind to if this is a cubetexture
  110190. * @param layer defines the index of the texture to bind in the array
  110191. */
  110192. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  110193. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110194. private renderToTarget;
  110195. /**
  110196. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110197. * This allowed control for front to back rendering or reversly depending of the special needs.
  110198. *
  110199. * @param renderingGroupId The rendering group id corresponding to its index
  110200. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110201. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110202. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110203. */
  110204. 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;
  110205. /**
  110206. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110207. *
  110208. * @param renderingGroupId The rendering group id corresponding to its index
  110209. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110210. */
  110211. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  110212. /**
  110213. * Clones the texture.
  110214. * @returns the cloned texture
  110215. */
  110216. clone(): RenderTargetTexture;
  110217. /**
  110218. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  110219. * @returns The JSON representation of the texture
  110220. */
  110221. serialize(): any;
  110222. /**
  110223. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  110224. */
  110225. disposeFramebufferObjects(): void;
  110226. /**
  110227. * Dispose the texture and release its associated resources.
  110228. */
  110229. dispose(): void;
  110230. /** @hidden */
  110231. _rebuild(): void;
  110232. /**
  110233. * Clear the info related to rendering groups preventing retention point in material dispose.
  110234. */
  110235. freeRenderingGroups(): void;
  110236. /**
  110237. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  110238. * @returns the view count
  110239. */
  110240. getViewCount(): number;
  110241. }
  110242. }
  110243. declare module BABYLON {
  110244. /**
  110245. * Class used to manipulate GUIDs
  110246. */
  110247. export class GUID {
  110248. /**
  110249. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110250. * Be aware Math.random() could cause collisions, but:
  110251. * "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"
  110252. * @returns a pseudo random id
  110253. */
  110254. static RandomId(): string;
  110255. }
  110256. }
  110257. declare module BABYLON {
  110258. /**
  110259. * Options to be used when creating a shadow depth material
  110260. */
  110261. export interface IIOptionShadowDepthMaterial {
  110262. /** Variables in the vertex shader code that need to have their names remapped.
  110263. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110264. * "var_name" should be either: worldPos or vNormalW
  110265. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110266. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110267. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110268. */
  110269. remappedVariables?: string[];
  110270. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110271. standalone?: boolean;
  110272. }
  110273. /**
  110274. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110275. */
  110276. export class ShadowDepthWrapper {
  110277. private _scene;
  110278. private _options?;
  110279. private _baseMaterial;
  110280. private _onEffectCreatedObserver;
  110281. private _subMeshToEffect;
  110282. private _subMeshToDepthEffect;
  110283. private _meshes;
  110284. /** @hidden */
  110285. _matriceNames: any;
  110286. /** Gets the standalone status of the wrapper */
  110287. get standalone(): boolean;
  110288. /** Gets the base material the wrapper is built upon */
  110289. get baseMaterial(): Material;
  110290. /**
  110291. * Instantiate a new shadow depth wrapper.
  110292. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110293. * generate the shadow depth map. For more information, please refer to the documentation:
  110294. * https://doc.babylonjs.com/babylon101/shadows
  110295. * @param baseMaterial Material to wrap
  110296. * @param scene Define the scene the material belongs to
  110297. * @param options Options used to create the wrapper
  110298. */
  110299. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110300. /**
  110301. * Gets the effect to use to generate the depth map
  110302. * @param subMesh subMesh to get the effect for
  110303. * @param shadowGenerator shadow generator to get the effect for
  110304. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110305. */
  110306. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110307. /**
  110308. * Specifies that the submesh is ready to be used for depth rendering
  110309. * @param subMesh submesh to check
  110310. * @param defines the list of defines to take into account when checking the effect
  110311. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110312. * @param useInstances specifies that instances should be used
  110313. * @returns a boolean indicating that the submesh is ready or not
  110314. */
  110315. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110316. /**
  110317. * Disposes the resources
  110318. */
  110319. dispose(): void;
  110320. private _makeEffect;
  110321. }
  110322. }
  110323. declare module BABYLON {
  110324. /**
  110325. * Options for compiling materials.
  110326. */
  110327. export interface IMaterialCompilationOptions {
  110328. /**
  110329. * Defines whether clip planes are enabled.
  110330. */
  110331. clipPlane: boolean;
  110332. /**
  110333. * Defines whether instances are enabled.
  110334. */
  110335. useInstances: boolean;
  110336. }
  110337. /**
  110338. * Options passed when calling customShaderNameResolve
  110339. */
  110340. export interface ICustomShaderNameResolveOptions {
  110341. /**
  110342. * 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
  110343. */
  110344. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110345. }
  110346. /**
  110347. * Base class for the main features of a material in Babylon.js
  110348. */
  110349. export class Material implements IAnimatable {
  110350. /**
  110351. * Returns the triangle fill mode
  110352. */
  110353. static readonly TriangleFillMode: number;
  110354. /**
  110355. * Returns the wireframe mode
  110356. */
  110357. static readonly WireFrameFillMode: number;
  110358. /**
  110359. * Returns the point fill mode
  110360. */
  110361. static readonly PointFillMode: number;
  110362. /**
  110363. * Returns the point list draw mode
  110364. */
  110365. static readonly PointListDrawMode: number;
  110366. /**
  110367. * Returns the line list draw mode
  110368. */
  110369. static readonly LineListDrawMode: number;
  110370. /**
  110371. * Returns the line loop draw mode
  110372. */
  110373. static readonly LineLoopDrawMode: number;
  110374. /**
  110375. * Returns the line strip draw mode
  110376. */
  110377. static readonly LineStripDrawMode: number;
  110378. /**
  110379. * Returns the triangle strip draw mode
  110380. */
  110381. static readonly TriangleStripDrawMode: number;
  110382. /**
  110383. * Returns the triangle fan draw mode
  110384. */
  110385. static readonly TriangleFanDrawMode: number;
  110386. /**
  110387. * Stores the clock-wise side orientation
  110388. */
  110389. static readonly ClockWiseSideOrientation: number;
  110390. /**
  110391. * Stores the counter clock-wise side orientation
  110392. */
  110393. static readonly CounterClockWiseSideOrientation: number;
  110394. /**
  110395. * The dirty texture flag value
  110396. */
  110397. static readonly TextureDirtyFlag: number;
  110398. /**
  110399. * The dirty light flag value
  110400. */
  110401. static readonly LightDirtyFlag: number;
  110402. /**
  110403. * The dirty fresnel flag value
  110404. */
  110405. static readonly FresnelDirtyFlag: number;
  110406. /**
  110407. * The dirty attribute flag value
  110408. */
  110409. static readonly AttributesDirtyFlag: number;
  110410. /**
  110411. * The dirty misc flag value
  110412. */
  110413. static readonly MiscDirtyFlag: number;
  110414. /**
  110415. * The dirty prepass flag value
  110416. */
  110417. static readonly PrePassDirtyFlag: number;
  110418. /**
  110419. * The all dirty flag value
  110420. */
  110421. static readonly AllDirtyFlag: number;
  110422. /**
  110423. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110424. */
  110425. static readonly MATERIAL_OPAQUE: number;
  110426. /**
  110427. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110428. */
  110429. static readonly MATERIAL_ALPHATEST: number;
  110430. /**
  110431. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110432. */
  110433. static readonly MATERIAL_ALPHABLEND: number;
  110434. /**
  110435. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110436. * They are also discarded below the alpha cutoff threshold to improve performances.
  110437. */
  110438. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  110439. /**
  110440. * The Whiteout method is used to blend normals.
  110441. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110442. */
  110443. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  110444. /**
  110445. * The Reoriented Normal Mapping method is used to blend normals.
  110446. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110447. */
  110448. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  110449. /**
  110450. * Custom callback helping to override the default shader used in the material.
  110451. */
  110452. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  110453. /**
  110454. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  110455. */
  110456. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  110457. /**
  110458. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  110459. * This means that the material can keep using a previous shader while a new one is being compiled.
  110460. * This is mostly used when shader parallel compilation is supported (true by default)
  110461. */
  110462. allowShaderHotSwapping: boolean;
  110463. /**
  110464. * The ID of the material
  110465. */
  110466. id: string;
  110467. /**
  110468. * Gets or sets the unique id of the material
  110469. */
  110470. uniqueId: number;
  110471. /**
  110472. * The name of the material
  110473. */
  110474. name: string;
  110475. /**
  110476. * Gets or sets user defined metadata
  110477. */
  110478. metadata: any;
  110479. /**
  110480. * For internal use only. Please do not use.
  110481. */
  110482. reservedDataStore: any;
  110483. /**
  110484. * Specifies if the ready state should be checked on each call
  110485. */
  110486. checkReadyOnEveryCall: boolean;
  110487. /**
  110488. * Specifies if the ready state should be checked once
  110489. */
  110490. checkReadyOnlyOnce: boolean;
  110491. /**
  110492. * The state of the material
  110493. */
  110494. state: string;
  110495. /**
  110496. * If the material can be rendered to several textures with MRT extension
  110497. */
  110498. get canRenderToMRT(): boolean;
  110499. /**
  110500. * The alpha value of the material
  110501. */
  110502. protected _alpha: number;
  110503. /**
  110504. * List of inspectable custom properties (used by the Inspector)
  110505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110506. */
  110507. inspectableCustomProperties: IInspectable[];
  110508. /**
  110509. * Sets the alpha value of the material
  110510. */
  110511. set alpha(value: number);
  110512. /**
  110513. * Gets the alpha value of the material
  110514. */
  110515. get alpha(): number;
  110516. /**
  110517. * Specifies if back face culling is enabled
  110518. */
  110519. protected _backFaceCulling: boolean;
  110520. /**
  110521. * Sets the back-face culling state
  110522. */
  110523. set backFaceCulling(value: boolean);
  110524. /**
  110525. * Gets the back-face culling state
  110526. */
  110527. get backFaceCulling(): boolean;
  110528. /**
  110529. * Stores the value for side orientation
  110530. */
  110531. sideOrientation: number;
  110532. /**
  110533. * Callback triggered when the material is compiled
  110534. */
  110535. onCompiled: Nullable<(effect: Effect) => void>;
  110536. /**
  110537. * Callback triggered when an error occurs
  110538. */
  110539. onError: Nullable<(effect: Effect, errors: string) => void>;
  110540. /**
  110541. * Callback triggered to get the render target textures
  110542. */
  110543. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  110544. /**
  110545. * Gets a boolean indicating that current material needs to register RTT
  110546. */
  110547. get hasRenderTargetTextures(): boolean;
  110548. /**
  110549. * Specifies if the material should be serialized
  110550. */
  110551. doNotSerialize: boolean;
  110552. /**
  110553. * @hidden
  110554. */
  110555. _storeEffectOnSubMeshes: boolean;
  110556. /**
  110557. * Stores the animations for the material
  110558. */
  110559. animations: Nullable<Array<Animation>>;
  110560. /**
  110561. * An event triggered when the material is disposed
  110562. */
  110563. onDisposeObservable: Observable<Material>;
  110564. /**
  110565. * An observer which watches for dispose events
  110566. */
  110567. private _onDisposeObserver;
  110568. private _onUnBindObservable;
  110569. /**
  110570. * Called during a dispose event
  110571. */
  110572. set onDispose(callback: () => void);
  110573. private _onBindObservable;
  110574. /**
  110575. * An event triggered when the material is bound
  110576. */
  110577. get onBindObservable(): Observable<AbstractMesh>;
  110578. /**
  110579. * An observer which watches for bind events
  110580. */
  110581. private _onBindObserver;
  110582. /**
  110583. * Called during a bind event
  110584. */
  110585. set onBind(callback: (Mesh: AbstractMesh) => void);
  110586. /**
  110587. * An event triggered when the material is unbound
  110588. */
  110589. get onUnBindObservable(): Observable<Material>;
  110590. protected _onEffectCreatedObservable: Nullable<Observable<{
  110591. effect: Effect;
  110592. subMesh: Nullable<SubMesh>;
  110593. }>>;
  110594. /**
  110595. * An event triggered when the effect is (re)created
  110596. */
  110597. get onEffectCreatedObservable(): Observable<{
  110598. effect: Effect;
  110599. subMesh: Nullable<SubMesh>;
  110600. }>;
  110601. /**
  110602. * Stores the value of the alpha mode
  110603. */
  110604. private _alphaMode;
  110605. /**
  110606. * Sets the value of the alpha mode.
  110607. *
  110608. * | Value | Type | Description |
  110609. * | --- | --- | --- |
  110610. * | 0 | ALPHA_DISABLE | |
  110611. * | 1 | ALPHA_ADD | |
  110612. * | 2 | ALPHA_COMBINE | |
  110613. * | 3 | ALPHA_SUBTRACT | |
  110614. * | 4 | ALPHA_MULTIPLY | |
  110615. * | 5 | ALPHA_MAXIMIZED | |
  110616. * | 6 | ALPHA_ONEONE | |
  110617. * | 7 | ALPHA_PREMULTIPLIED | |
  110618. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  110619. * | 9 | ALPHA_INTERPOLATE | |
  110620. * | 10 | ALPHA_SCREENMODE | |
  110621. *
  110622. */
  110623. set alphaMode(value: number);
  110624. /**
  110625. * Gets the value of the alpha mode
  110626. */
  110627. get alphaMode(): number;
  110628. /**
  110629. * Stores the state of the need depth pre-pass value
  110630. */
  110631. private _needDepthPrePass;
  110632. /**
  110633. * Sets the need depth pre-pass value
  110634. */
  110635. set needDepthPrePass(value: boolean);
  110636. /**
  110637. * Gets the depth pre-pass value
  110638. */
  110639. get needDepthPrePass(): boolean;
  110640. /**
  110641. * Specifies if depth writing should be disabled
  110642. */
  110643. disableDepthWrite: boolean;
  110644. /**
  110645. * Specifies if color writing should be disabled
  110646. */
  110647. disableColorWrite: boolean;
  110648. /**
  110649. * Specifies if depth writing should be forced
  110650. */
  110651. forceDepthWrite: boolean;
  110652. /**
  110653. * Specifies the depth function that should be used. 0 means the default engine function
  110654. */
  110655. depthFunction: number;
  110656. /**
  110657. * Specifies if there should be a separate pass for culling
  110658. */
  110659. separateCullingPass: boolean;
  110660. /**
  110661. * Stores the state specifing if fog should be enabled
  110662. */
  110663. private _fogEnabled;
  110664. /**
  110665. * Sets the state for enabling fog
  110666. */
  110667. set fogEnabled(value: boolean);
  110668. /**
  110669. * Gets the value of the fog enabled state
  110670. */
  110671. get fogEnabled(): boolean;
  110672. /**
  110673. * Stores the size of points
  110674. */
  110675. pointSize: number;
  110676. /**
  110677. * Stores the z offset value
  110678. */
  110679. zOffset: number;
  110680. get wireframe(): boolean;
  110681. /**
  110682. * Sets the state of wireframe mode
  110683. */
  110684. set wireframe(value: boolean);
  110685. /**
  110686. * Gets the value specifying if point clouds are enabled
  110687. */
  110688. get pointsCloud(): boolean;
  110689. /**
  110690. * Sets the state of point cloud mode
  110691. */
  110692. set pointsCloud(value: boolean);
  110693. /**
  110694. * Gets the material fill mode
  110695. */
  110696. get fillMode(): number;
  110697. /**
  110698. * Sets the material fill mode
  110699. */
  110700. set fillMode(value: number);
  110701. /**
  110702. * @hidden
  110703. * Stores the effects for the material
  110704. */
  110705. _effect: Nullable<Effect>;
  110706. /**
  110707. * Specifies if uniform buffers should be used
  110708. */
  110709. private _useUBO;
  110710. /**
  110711. * Stores a reference to the scene
  110712. */
  110713. private _scene;
  110714. /**
  110715. * Stores the fill mode state
  110716. */
  110717. private _fillMode;
  110718. /**
  110719. * Specifies if the depth write state should be cached
  110720. */
  110721. private _cachedDepthWriteState;
  110722. /**
  110723. * Specifies if the color write state should be cached
  110724. */
  110725. private _cachedColorWriteState;
  110726. /**
  110727. * Specifies if the depth function state should be cached
  110728. */
  110729. private _cachedDepthFunctionState;
  110730. /**
  110731. * Stores the uniform buffer
  110732. */
  110733. protected _uniformBuffer: UniformBuffer;
  110734. /** @hidden */
  110735. _indexInSceneMaterialArray: number;
  110736. /** @hidden */
  110737. meshMap: Nullable<{
  110738. [id: string]: AbstractMesh | undefined;
  110739. }>;
  110740. /**
  110741. * Creates a material instance
  110742. * @param name defines the name of the material
  110743. * @param scene defines the scene to reference
  110744. * @param doNotAdd specifies if the material should be added to the scene
  110745. */
  110746. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110747. /**
  110748. * Returns a string representation of the current material
  110749. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110750. * @returns a string with material information
  110751. */
  110752. toString(fullDetails?: boolean): string;
  110753. /**
  110754. * Gets the class name of the material
  110755. * @returns a string with the class name of the material
  110756. */
  110757. getClassName(): string;
  110758. /**
  110759. * Specifies if updates for the material been locked
  110760. */
  110761. get isFrozen(): boolean;
  110762. /**
  110763. * Locks updates for the material
  110764. */
  110765. freeze(): void;
  110766. /**
  110767. * Unlocks updates for the material
  110768. */
  110769. unfreeze(): void;
  110770. /**
  110771. * Specifies if the material is ready to be used
  110772. * @param mesh defines the mesh to check
  110773. * @param useInstances specifies if instances should be used
  110774. * @returns a boolean indicating if the material is ready to be used
  110775. */
  110776. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110777. /**
  110778. * Specifies that the submesh is ready to be used
  110779. * @param mesh defines the mesh to check
  110780. * @param subMesh defines which submesh to check
  110781. * @param useInstances specifies that instances should be used
  110782. * @returns a boolean indicating that the submesh is ready or not
  110783. */
  110784. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110785. /**
  110786. * Returns the material effect
  110787. * @returns the effect associated with the material
  110788. */
  110789. getEffect(): Nullable<Effect>;
  110790. /**
  110791. * Returns the current scene
  110792. * @returns a Scene
  110793. */
  110794. getScene(): Scene;
  110795. /**
  110796. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110797. */
  110798. protected _forceAlphaTest: boolean;
  110799. /**
  110800. * The transparency mode of the material.
  110801. */
  110802. protected _transparencyMode: Nullable<number>;
  110803. /**
  110804. * Gets the current transparency mode.
  110805. */
  110806. get transparencyMode(): Nullable<number>;
  110807. /**
  110808. * Sets the transparency mode of the material.
  110809. *
  110810. * | Value | Type | Description |
  110811. * | ----- | ----------------------------------- | ----------- |
  110812. * | 0 | OPAQUE | |
  110813. * | 1 | ALPHATEST | |
  110814. * | 2 | ALPHABLEND | |
  110815. * | 3 | ALPHATESTANDBLEND | |
  110816. *
  110817. */
  110818. set transparencyMode(value: Nullable<number>);
  110819. /**
  110820. * Returns true if alpha blending should be disabled.
  110821. */
  110822. protected get _disableAlphaBlending(): boolean;
  110823. /**
  110824. * Specifies whether or not this material should be rendered in alpha blend mode.
  110825. * @returns a boolean specifying if alpha blending is needed
  110826. */
  110827. needAlphaBlending(): boolean;
  110828. /**
  110829. * Specifies if the mesh will require alpha blending
  110830. * @param mesh defines the mesh to check
  110831. * @returns a boolean specifying if alpha blending is needed for the mesh
  110832. */
  110833. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110834. /**
  110835. * Specifies whether or not this material should be rendered in alpha test mode.
  110836. * @returns a boolean specifying if an alpha test is needed.
  110837. */
  110838. needAlphaTesting(): boolean;
  110839. /**
  110840. * Specifies if material alpha testing should be turned on for the mesh
  110841. * @param mesh defines the mesh to check
  110842. */
  110843. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110844. /**
  110845. * Gets the texture used for the alpha test
  110846. * @returns the texture to use for alpha testing
  110847. */
  110848. getAlphaTestTexture(): Nullable<BaseTexture>;
  110849. /**
  110850. * Marks the material to indicate that it needs to be re-calculated
  110851. */
  110852. markDirty(): void;
  110853. /** @hidden */
  110854. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110855. /**
  110856. * Binds the material to the mesh
  110857. * @param world defines the world transformation matrix
  110858. * @param mesh defines the mesh to bind the material to
  110859. */
  110860. bind(world: Matrix, mesh?: Mesh): void;
  110861. /**
  110862. * Binds the submesh to the material
  110863. * @param world defines the world transformation matrix
  110864. * @param mesh defines the mesh containing the submesh
  110865. * @param subMesh defines the submesh to bind the material to
  110866. */
  110867. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110868. /**
  110869. * Binds the world matrix to the material
  110870. * @param world defines the world transformation matrix
  110871. */
  110872. bindOnlyWorldMatrix(world: Matrix): void;
  110873. /**
  110874. * Binds the scene's uniform buffer to the effect.
  110875. * @param effect defines the effect to bind to the scene uniform buffer
  110876. * @param sceneUbo defines the uniform buffer storing scene data
  110877. */
  110878. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110879. /**
  110880. * Binds the view matrix to the effect
  110881. * @param effect defines the effect to bind the view matrix to
  110882. */
  110883. bindView(effect: Effect): void;
  110884. /**
  110885. * Binds the view projection matrix to the effect
  110886. * @param effect defines the effect to bind the view projection matrix to
  110887. */
  110888. bindViewProjection(effect: Effect): void;
  110889. /**
  110890. * Processes to execute after binding the material to a mesh
  110891. * @param mesh defines the rendered mesh
  110892. */
  110893. protected _afterBind(mesh?: Mesh): void;
  110894. /**
  110895. * Unbinds the material from the mesh
  110896. */
  110897. unbind(): void;
  110898. /**
  110899. * Gets the active textures from the material
  110900. * @returns an array of textures
  110901. */
  110902. getActiveTextures(): BaseTexture[];
  110903. /**
  110904. * Specifies if the material uses a texture
  110905. * @param texture defines the texture to check against the material
  110906. * @returns a boolean specifying if the material uses the texture
  110907. */
  110908. hasTexture(texture: BaseTexture): boolean;
  110909. /**
  110910. * Makes a duplicate of the material, and gives it a new name
  110911. * @param name defines the new name for the duplicated material
  110912. * @returns the cloned material
  110913. */
  110914. clone(name: string): Nullable<Material>;
  110915. /**
  110916. * Gets the meshes bound to the material
  110917. * @returns an array of meshes bound to the material
  110918. */
  110919. getBindedMeshes(): AbstractMesh[];
  110920. /**
  110921. * Force shader compilation
  110922. * @param mesh defines the mesh associated with this material
  110923. * @param onCompiled defines a function to execute once the material is compiled
  110924. * @param options defines the options to configure the compilation
  110925. * @param onError defines a function to execute if the material fails compiling
  110926. */
  110927. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110928. /**
  110929. * Force shader compilation
  110930. * @param mesh defines the mesh that will use this material
  110931. * @param options defines additional options for compiling the shaders
  110932. * @returns a promise that resolves when the compilation completes
  110933. */
  110934. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110935. private static readonly _AllDirtyCallBack;
  110936. private static readonly _ImageProcessingDirtyCallBack;
  110937. private static readonly _TextureDirtyCallBack;
  110938. private static readonly _FresnelDirtyCallBack;
  110939. private static readonly _MiscDirtyCallBack;
  110940. private static readonly _PrePassDirtyCallBack;
  110941. private static readonly _LightsDirtyCallBack;
  110942. private static readonly _AttributeDirtyCallBack;
  110943. private static _FresnelAndMiscDirtyCallBack;
  110944. private static _TextureAndMiscDirtyCallBack;
  110945. private static readonly _DirtyCallbackArray;
  110946. private static readonly _RunDirtyCallBacks;
  110947. /**
  110948. * Marks a define in the material to indicate that it needs to be re-computed
  110949. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110950. */
  110951. markAsDirty(flag: number): void;
  110952. /**
  110953. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110954. * @param func defines a function which checks material defines against the submeshes
  110955. */
  110956. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110957. /**
  110958. * Indicates that the scene should check if the rendering now needs a prepass
  110959. */
  110960. protected _markScenePrePassDirty(): void;
  110961. /**
  110962. * Indicates that we need to re-calculated for all submeshes
  110963. */
  110964. protected _markAllSubMeshesAsAllDirty(): void;
  110965. /**
  110966. * Indicates that image processing needs to be re-calculated for all submeshes
  110967. */
  110968. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110969. /**
  110970. * Indicates that textures need to be re-calculated for all submeshes
  110971. */
  110972. protected _markAllSubMeshesAsTexturesDirty(): void;
  110973. /**
  110974. * Indicates that fresnel needs to be re-calculated for all submeshes
  110975. */
  110976. protected _markAllSubMeshesAsFresnelDirty(): void;
  110977. /**
  110978. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110979. */
  110980. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110981. /**
  110982. * Indicates that lights need to be re-calculated for all submeshes
  110983. */
  110984. protected _markAllSubMeshesAsLightsDirty(): void;
  110985. /**
  110986. * Indicates that attributes need to be re-calculated for all submeshes
  110987. */
  110988. protected _markAllSubMeshesAsAttributesDirty(): void;
  110989. /**
  110990. * Indicates that misc needs to be re-calculated for all submeshes
  110991. */
  110992. protected _markAllSubMeshesAsMiscDirty(): void;
  110993. /**
  110994. * Indicates that prepass needs to be re-calculated for all submeshes
  110995. */
  110996. protected _markAllSubMeshesAsPrePassDirty(): void;
  110997. /**
  110998. * Indicates that textures and misc need to be re-calculated for all submeshes
  110999. */
  111000. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  111001. /**
  111002. * Sets the required values to the prepass renderer.
  111003. * @param prePassRenderer defines the prepass renderer to setup.
  111004. * @returns true if the pre pass is needed.
  111005. */
  111006. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  111007. /**
  111008. * Disposes the material
  111009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111011. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  111012. */
  111013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  111014. /** @hidden */
  111015. private releaseVertexArrayObject;
  111016. /**
  111017. * Serializes this material
  111018. * @returns the serialized material object
  111019. */
  111020. serialize(): any;
  111021. /**
  111022. * Creates a material from parsed material data
  111023. * @param parsedMaterial defines parsed material data
  111024. * @param scene defines the hosting scene
  111025. * @param rootUrl defines the root URL to use to load textures
  111026. * @returns a new material
  111027. */
  111028. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111029. }
  111030. }
  111031. declare module BABYLON {
  111032. /**
  111033. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111034. * separate meshes. This can be use to improve performances.
  111035. * @see https://doc.babylonjs.com/how_to/multi_materials
  111036. */
  111037. export class MultiMaterial extends Material {
  111038. private _subMaterials;
  111039. /**
  111040. * Gets or Sets the list of Materials used within the multi material.
  111041. * They need to be ordered according to the submeshes order in the associated mesh
  111042. */
  111043. get subMaterials(): Nullable<Material>[];
  111044. set subMaterials(value: Nullable<Material>[]);
  111045. /**
  111046. * Function used to align with Node.getChildren()
  111047. * @returns the list of Materials used within the multi material
  111048. */
  111049. getChildren(): Nullable<Material>[];
  111050. /**
  111051. * Instantiates a new Multi Material
  111052. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111053. * separate meshes. This can be use to improve performances.
  111054. * @see https://doc.babylonjs.com/how_to/multi_materials
  111055. * @param name Define the name in the scene
  111056. * @param scene Define the scene the material belongs to
  111057. */
  111058. constructor(name: string, scene: Scene);
  111059. private _hookArray;
  111060. /**
  111061. * Get one of the submaterial by its index in the submaterials array
  111062. * @param index The index to look the sub material at
  111063. * @returns The Material if the index has been defined
  111064. */
  111065. getSubMaterial(index: number): Nullable<Material>;
  111066. /**
  111067. * Get the list of active textures for the whole sub materials list.
  111068. * @returns All the textures that will be used during the rendering
  111069. */
  111070. getActiveTextures(): BaseTexture[];
  111071. /**
  111072. * Gets the current class name of the material e.g. "MultiMaterial"
  111073. * Mainly use in serialization.
  111074. * @returns the class name
  111075. */
  111076. getClassName(): string;
  111077. /**
  111078. * Checks if the material is ready to render the requested sub mesh
  111079. * @param mesh Define the mesh the submesh belongs to
  111080. * @param subMesh Define the sub mesh to look readyness for
  111081. * @param useInstances Define whether or not the material is used with instances
  111082. * @returns true if ready, otherwise false
  111083. */
  111084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111085. /**
  111086. * Clones the current material and its related sub materials
  111087. * @param name Define the name of the newly cloned material
  111088. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111089. * @returns the cloned material
  111090. */
  111091. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111092. /**
  111093. * Serializes the materials into a JSON representation.
  111094. * @returns the JSON representation
  111095. */
  111096. serialize(): any;
  111097. /**
  111098. * Dispose the material and release its associated resources
  111099. * @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)
  111100. * @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)
  111101. * @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)
  111102. */
  111103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111104. /**
  111105. * Creates a MultiMaterial from parsed MultiMaterial data.
  111106. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111107. * @param scene defines the hosting scene
  111108. * @returns a new MultiMaterial
  111109. */
  111110. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111111. }
  111112. }
  111113. declare module BABYLON {
  111114. /**
  111115. * Defines a subdivision inside a mesh
  111116. */
  111117. export class SubMesh implements ICullable {
  111118. /** the material index to use */
  111119. materialIndex: number;
  111120. /** vertex index start */
  111121. verticesStart: number;
  111122. /** vertices count */
  111123. verticesCount: number;
  111124. /** index start */
  111125. indexStart: number;
  111126. /** indices count */
  111127. indexCount: number;
  111128. /** @hidden */
  111129. _materialDefines: Nullable<MaterialDefines>;
  111130. /** @hidden */
  111131. _materialEffect: Nullable<Effect>;
  111132. /** @hidden */
  111133. _effectOverride: Nullable<Effect>;
  111134. /**
  111135. * Gets material defines used by the effect associated to the sub mesh
  111136. */
  111137. get materialDefines(): Nullable<MaterialDefines>;
  111138. /**
  111139. * Sets material defines used by the effect associated to the sub mesh
  111140. */
  111141. set materialDefines(defines: Nullable<MaterialDefines>);
  111142. /**
  111143. * Gets associated effect
  111144. */
  111145. get effect(): Nullable<Effect>;
  111146. /**
  111147. * Sets associated effect (effect used to render this submesh)
  111148. * @param effect defines the effect to associate with
  111149. * @param defines defines the set of defines used to compile this effect
  111150. */
  111151. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111152. /** @hidden */
  111153. _linesIndexCount: number;
  111154. private _mesh;
  111155. private _renderingMesh;
  111156. private _boundingInfo;
  111157. private _linesIndexBuffer;
  111158. /** @hidden */
  111159. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111160. /** @hidden */
  111161. _trianglePlanes: Plane[];
  111162. /** @hidden */
  111163. _lastColliderTransformMatrix: Nullable<Matrix>;
  111164. /** @hidden */
  111165. _renderId: number;
  111166. /** @hidden */
  111167. _alphaIndex: number;
  111168. /** @hidden */
  111169. _distanceToCamera: number;
  111170. /** @hidden */
  111171. _id: number;
  111172. private _currentMaterial;
  111173. /**
  111174. * Add a new submesh to a mesh
  111175. * @param materialIndex defines the material index to use
  111176. * @param verticesStart defines vertex index start
  111177. * @param verticesCount defines vertices count
  111178. * @param indexStart defines index start
  111179. * @param indexCount defines indices count
  111180. * @param mesh defines the parent mesh
  111181. * @param renderingMesh defines an optional rendering mesh
  111182. * @param createBoundingBox defines if bounding box should be created for this submesh
  111183. * @returns the new submesh
  111184. */
  111185. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111186. /**
  111187. * Creates a new submesh
  111188. * @param materialIndex defines the material index to use
  111189. * @param verticesStart defines vertex index start
  111190. * @param verticesCount defines vertices count
  111191. * @param indexStart defines index start
  111192. * @param indexCount defines indices count
  111193. * @param mesh defines the parent mesh
  111194. * @param renderingMesh defines an optional rendering mesh
  111195. * @param createBoundingBox defines if bounding box should be created for this submesh
  111196. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111197. */
  111198. constructor(
  111199. /** the material index to use */
  111200. materialIndex: number,
  111201. /** vertex index start */
  111202. verticesStart: number,
  111203. /** vertices count */
  111204. verticesCount: number,
  111205. /** index start */
  111206. indexStart: number,
  111207. /** indices count */
  111208. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111209. /**
  111210. * Returns true if this submesh covers the entire parent mesh
  111211. * @ignorenaming
  111212. */
  111213. get IsGlobal(): boolean;
  111214. /**
  111215. * Returns the submesh BoudingInfo object
  111216. * @returns current bounding info (or mesh's one if the submesh is global)
  111217. */
  111218. getBoundingInfo(): BoundingInfo;
  111219. /**
  111220. * Sets the submesh BoundingInfo
  111221. * @param boundingInfo defines the new bounding info to use
  111222. * @returns the SubMesh
  111223. */
  111224. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111225. /**
  111226. * Returns the mesh of the current submesh
  111227. * @return the parent mesh
  111228. */
  111229. getMesh(): AbstractMesh;
  111230. /**
  111231. * Returns the rendering mesh of the submesh
  111232. * @returns the rendering mesh (could be different from parent mesh)
  111233. */
  111234. getRenderingMesh(): Mesh;
  111235. /**
  111236. * Returns the replacement mesh of the submesh
  111237. * @returns the replacement mesh (could be different from parent mesh)
  111238. */
  111239. getReplacementMesh(): Nullable<AbstractMesh>;
  111240. /**
  111241. * Returns the effective mesh of the submesh
  111242. * @returns the effective mesh (could be different from parent mesh)
  111243. */
  111244. getEffectiveMesh(): AbstractMesh;
  111245. /**
  111246. * Returns the submesh material
  111247. * @returns null or the current material
  111248. */
  111249. getMaterial(): Nullable<Material>;
  111250. private _IsMultiMaterial;
  111251. /**
  111252. * Sets a new updated BoundingInfo object to the submesh
  111253. * @param data defines an optional position array to use to determine the bounding info
  111254. * @returns the SubMesh
  111255. */
  111256. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111257. /** @hidden */
  111258. _checkCollision(collider: Collider): boolean;
  111259. /**
  111260. * Updates the submesh BoundingInfo
  111261. * @param world defines the world matrix to use to update the bounding info
  111262. * @returns the submesh
  111263. */
  111264. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111265. /**
  111266. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111267. * @param frustumPlanes defines the frustum planes
  111268. * @returns true if the submesh is intersecting with the frustum
  111269. */
  111270. isInFrustum(frustumPlanes: Plane[]): boolean;
  111271. /**
  111272. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111273. * @param frustumPlanes defines the frustum planes
  111274. * @returns true if the submesh is inside the frustum
  111275. */
  111276. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111277. /**
  111278. * Renders the submesh
  111279. * @param enableAlphaMode defines if alpha needs to be used
  111280. * @returns the submesh
  111281. */
  111282. render(enableAlphaMode: boolean): SubMesh;
  111283. /**
  111284. * @hidden
  111285. */
  111286. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111287. /**
  111288. * Checks if the submesh intersects with a ray
  111289. * @param ray defines the ray to test
  111290. * @returns true is the passed ray intersects the submesh bounding box
  111291. */
  111292. canIntersects(ray: Ray): boolean;
  111293. /**
  111294. * Intersects current submesh with a ray
  111295. * @param ray defines the ray to test
  111296. * @param positions defines mesh's positions array
  111297. * @param indices defines mesh's indices array
  111298. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111299. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111300. * @returns intersection info or null if no intersection
  111301. */
  111302. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111303. /** @hidden */
  111304. private _intersectLines;
  111305. /** @hidden */
  111306. private _intersectUnIndexedLines;
  111307. /** @hidden */
  111308. private _intersectTriangles;
  111309. /** @hidden */
  111310. private _intersectUnIndexedTriangles;
  111311. /** @hidden */
  111312. _rebuild(): void;
  111313. /**
  111314. * Creates a new submesh from the passed mesh
  111315. * @param newMesh defines the new hosting mesh
  111316. * @param newRenderingMesh defines an optional rendering mesh
  111317. * @returns the new submesh
  111318. */
  111319. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111320. /**
  111321. * Release associated resources
  111322. */
  111323. dispose(): void;
  111324. /**
  111325. * Gets the class name
  111326. * @returns the string "SubMesh".
  111327. */
  111328. getClassName(): string;
  111329. /**
  111330. * Creates a new submesh from indices data
  111331. * @param materialIndex the index of the main mesh material
  111332. * @param startIndex the index where to start the copy in the mesh indices array
  111333. * @param indexCount the number of indices to copy then from the startIndex
  111334. * @param mesh the main mesh to create the submesh from
  111335. * @param renderingMesh the optional rendering mesh
  111336. * @returns a new submesh
  111337. */
  111338. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111339. }
  111340. }
  111341. declare module BABYLON {
  111342. /**
  111343. * Class used to represent data loading progression
  111344. */
  111345. export class SceneLoaderFlags {
  111346. private static _ForceFullSceneLoadingForIncremental;
  111347. private static _ShowLoadingScreen;
  111348. private static _CleanBoneMatrixWeights;
  111349. private static _loggingLevel;
  111350. /**
  111351. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111352. */
  111353. static get ForceFullSceneLoadingForIncremental(): boolean;
  111354. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111355. /**
  111356. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111357. */
  111358. static get ShowLoadingScreen(): boolean;
  111359. static set ShowLoadingScreen(value: boolean);
  111360. /**
  111361. * Defines the current logging level (while loading the scene)
  111362. * @ignorenaming
  111363. */
  111364. static get loggingLevel(): number;
  111365. static set loggingLevel(value: number);
  111366. /**
  111367. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111368. */
  111369. static get CleanBoneMatrixWeights(): boolean;
  111370. static set CleanBoneMatrixWeights(value: boolean);
  111371. }
  111372. }
  111373. declare module BABYLON {
  111374. /**
  111375. * Class used to store geometry data (vertex buffers + index buffer)
  111376. */
  111377. export class Geometry implements IGetSetVerticesData {
  111378. /**
  111379. * Gets or sets the ID of the geometry
  111380. */
  111381. id: string;
  111382. /**
  111383. * Gets or sets the unique ID of the geometry
  111384. */
  111385. uniqueId: number;
  111386. /**
  111387. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111388. */
  111389. delayLoadState: number;
  111390. /**
  111391. * Gets the file containing the data to load when running in delay load state
  111392. */
  111393. delayLoadingFile: Nullable<string>;
  111394. /**
  111395. * Callback called when the geometry is updated
  111396. */
  111397. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111398. private _scene;
  111399. private _engine;
  111400. private _meshes;
  111401. private _totalVertices;
  111402. /** @hidden */
  111403. _indices: IndicesArray;
  111404. /** @hidden */
  111405. _vertexBuffers: {
  111406. [key: string]: VertexBuffer;
  111407. };
  111408. private _isDisposed;
  111409. private _extend;
  111410. private _boundingBias;
  111411. /** @hidden */
  111412. _delayInfo: Array<string>;
  111413. private _indexBuffer;
  111414. private _indexBufferIsUpdatable;
  111415. /** @hidden */
  111416. _boundingInfo: Nullable<BoundingInfo>;
  111417. /** @hidden */
  111418. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111419. /** @hidden */
  111420. _softwareSkinningFrameId: number;
  111421. private _vertexArrayObjects;
  111422. private _updatable;
  111423. /** @hidden */
  111424. _positions: Nullable<Vector3[]>;
  111425. private _positionsCache;
  111426. /**
  111427. * 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
  111428. */
  111429. get boundingBias(): Vector2;
  111430. /**
  111431. * 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
  111432. */
  111433. set boundingBias(value: Vector2);
  111434. /**
  111435. * Static function used to attach a new empty geometry to a mesh
  111436. * @param mesh defines the mesh to attach the geometry to
  111437. * @returns the new Geometry
  111438. */
  111439. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  111440. /** Get the list of meshes using this geometry */
  111441. get meshes(): Mesh[];
  111442. /**
  111443. * 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
  111444. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  111445. */
  111446. useBoundingInfoFromGeometry: boolean;
  111447. /**
  111448. * Creates a new geometry
  111449. * @param id defines the unique ID
  111450. * @param scene defines the hosting scene
  111451. * @param vertexData defines the VertexData used to get geometry data
  111452. * @param updatable defines if geometry must be updatable (false by default)
  111453. * @param mesh defines the mesh that will be associated with the geometry
  111454. */
  111455. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  111456. /**
  111457. * Gets the current extend of the geometry
  111458. */
  111459. get extend(): {
  111460. minimum: Vector3;
  111461. maximum: Vector3;
  111462. };
  111463. /**
  111464. * Gets the hosting scene
  111465. * @returns the hosting Scene
  111466. */
  111467. getScene(): Scene;
  111468. /**
  111469. * Gets the hosting engine
  111470. * @returns the hosting Engine
  111471. */
  111472. getEngine(): Engine;
  111473. /**
  111474. * Defines if the geometry is ready to use
  111475. * @returns true if the geometry is ready to be used
  111476. */
  111477. isReady(): boolean;
  111478. /**
  111479. * Gets a value indicating that the geometry should not be serialized
  111480. */
  111481. get doNotSerialize(): boolean;
  111482. /** @hidden */
  111483. _rebuild(): void;
  111484. /**
  111485. * Affects all geometry data in one call
  111486. * @param vertexData defines the geometry data
  111487. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  111488. */
  111489. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  111490. /**
  111491. * Set specific vertex data
  111492. * @param kind defines the data kind (Position, normal, etc...)
  111493. * @param data defines the vertex data to use
  111494. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111495. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111496. */
  111497. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  111498. /**
  111499. * Removes a specific vertex data
  111500. * @param kind defines the data kind (Position, normal, etc...)
  111501. */
  111502. removeVerticesData(kind: string): void;
  111503. /**
  111504. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  111505. * @param buffer defines the vertex buffer to use
  111506. * @param totalVertices defines the total number of vertices for position kind (could be null)
  111507. */
  111508. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  111509. /**
  111510. * Update a specific vertex buffer
  111511. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  111512. * It will do nothing if the buffer is not updatable
  111513. * @param kind defines the data kind (Position, normal, etc...)
  111514. * @param data defines the data to use
  111515. * @param offset defines the offset in the target buffer where to store the data
  111516. * @param useBytes set to true if the offset is in bytes
  111517. */
  111518. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  111519. /**
  111520. * Update a specific vertex buffer
  111521. * This function will create a new buffer if the current one is not updatable
  111522. * @param kind defines the data kind (Position, normal, etc...)
  111523. * @param data defines the data to use
  111524. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  111525. */
  111526. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  111527. private _updateBoundingInfo;
  111528. /** @hidden */
  111529. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  111530. /**
  111531. * Gets total number of vertices
  111532. * @returns the total number of vertices
  111533. */
  111534. getTotalVertices(): number;
  111535. /**
  111536. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111537. * @param kind defines the data kind (Position, normal, etc...)
  111538. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111539. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111540. * @returns a float array containing vertex data
  111541. */
  111542. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111543. /**
  111544. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  111545. * @param kind defines the data kind (Position, normal, etc...)
  111546. * @returns true if the vertex buffer with the specified kind is updatable
  111547. */
  111548. isVertexBufferUpdatable(kind: string): boolean;
  111549. /**
  111550. * Gets a specific vertex buffer
  111551. * @param kind defines the data kind (Position, normal, etc...)
  111552. * @returns a VertexBuffer
  111553. */
  111554. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  111555. /**
  111556. * Returns all vertex buffers
  111557. * @return an object holding all vertex buffers indexed by kind
  111558. */
  111559. getVertexBuffers(): Nullable<{
  111560. [key: string]: VertexBuffer;
  111561. }>;
  111562. /**
  111563. * Gets a boolean indicating if specific vertex buffer is present
  111564. * @param kind defines the data kind (Position, normal, etc...)
  111565. * @returns true if data is present
  111566. */
  111567. isVerticesDataPresent(kind: string): boolean;
  111568. /**
  111569. * Gets a list of all attached data kinds (Position, normal, etc...)
  111570. * @returns a list of string containing all kinds
  111571. */
  111572. getVerticesDataKinds(): string[];
  111573. /**
  111574. * Update index buffer
  111575. * @param indices defines the indices to store in the index buffer
  111576. * @param offset defines the offset in the target buffer where to store the data
  111577. * @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)
  111578. */
  111579. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  111580. /**
  111581. * Creates a new index buffer
  111582. * @param indices defines the indices to store in the index buffer
  111583. * @param totalVertices defines the total number of vertices (could be null)
  111584. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111585. */
  111586. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  111587. /**
  111588. * Return the total number of indices
  111589. * @returns the total number of indices
  111590. */
  111591. getTotalIndices(): number;
  111592. /**
  111593. * Gets the index buffer array
  111594. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111595. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111596. * @returns the index buffer array
  111597. */
  111598. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111599. /**
  111600. * Gets the index buffer
  111601. * @return the index buffer
  111602. */
  111603. getIndexBuffer(): Nullable<DataBuffer>;
  111604. /** @hidden */
  111605. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  111606. /**
  111607. * Release the associated resources for a specific mesh
  111608. * @param mesh defines the source mesh
  111609. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  111610. */
  111611. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  111612. /**
  111613. * Apply current geometry to a given mesh
  111614. * @param mesh defines the mesh to apply geometry to
  111615. */
  111616. applyToMesh(mesh: Mesh): void;
  111617. private _updateExtend;
  111618. private _applyToMesh;
  111619. private notifyUpdate;
  111620. /**
  111621. * Load the geometry if it was flagged as delay loaded
  111622. * @param scene defines the hosting scene
  111623. * @param onLoaded defines a callback called when the geometry is loaded
  111624. */
  111625. load(scene: Scene, onLoaded?: () => void): void;
  111626. private _queueLoad;
  111627. /**
  111628. * Invert the geometry to move from a right handed system to a left handed one.
  111629. */
  111630. toLeftHanded(): void;
  111631. /** @hidden */
  111632. _resetPointsArrayCache(): void;
  111633. /** @hidden */
  111634. _generatePointsArray(): boolean;
  111635. /**
  111636. * Gets a value indicating if the geometry is disposed
  111637. * @returns true if the geometry was disposed
  111638. */
  111639. isDisposed(): boolean;
  111640. private _disposeVertexArrayObjects;
  111641. /**
  111642. * Free all associated resources
  111643. */
  111644. dispose(): void;
  111645. /**
  111646. * Clone the current geometry into a new geometry
  111647. * @param id defines the unique ID of the new geometry
  111648. * @returns a new geometry object
  111649. */
  111650. copy(id: string): Geometry;
  111651. /**
  111652. * Serialize the current geometry info (and not the vertices data) into a JSON object
  111653. * @return a JSON representation of the current geometry data (without the vertices data)
  111654. */
  111655. serialize(): any;
  111656. private toNumberArray;
  111657. /**
  111658. * Serialize all vertices data into a JSON oject
  111659. * @returns a JSON representation of the current geometry data
  111660. */
  111661. serializeVerticeData(): any;
  111662. /**
  111663. * Extracts a clone of a mesh geometry
  111664. * @param mesh defines the source mesh
  111665. * @param id defines the unique ID of the new geometry object
  111666. * @returns the new geometry object
  111667. */
  111668. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  111669. /**
  111670. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  111671. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111672. * Be aware Math.random() could cause collisions, but:
  111673. * "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"
  111674. * @returns a string containing a new GUID
  111675. */
  111676. static RandomId(): string;
  111677. /** @hidden */
  111678. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  111679. private static _CleanMatricesWeights;
  111680. /**
  111681. * Create a new geometry from persisted data (Using .babylon file format)
  111682. * @param parsedVertexData defines the persisted data
  111683. * @param scene defines the hosting scene
  111684. * @param rootUrl defines the root url to use to load assets (like delayed data)
  111685. * @returns the new geometry object
  111686. */
  111687. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * Define an interface for all classes that will get and set the data on vertices
  111693. */
  111694. export interface IGetSetVerticesData {
  111695. /**
  111696. * Gets a boolean indicating if specific vertex data is present
  111697. * @param kind defines the vertex data kind to use
  111698. * @returns true is data kind is present
  111699. */
  111700. isVerticesDataPresent(kind: string): boolean;
  111701. /**
  111702. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111703. * @param kind defines the data kind (Position, normal, etc...)
  111704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111706. * @returns a float array containing vertex data
  111707. */
  111708. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111709. /**
  111710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  111711. * @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.
  111712. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111713. * @returns the indices array or an empty array if the mesh has no geometry
  111714. */
  111715. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111716. /**
  111717. * Set specific vertex data
  111718. * @param kind defines the data kind (Position, normal, etc...)
  111719. * @param data defines the vertex data to use
  111720. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111721. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111722. */
  111723. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  111724. /**
  111725. * Update a specific associated vertex buffer
  111726. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  111727. * - VertexBuffer.PositionKind
  111728. * - VertexBuffer.UVKind
  111729. * - VertexBuffer.UV2Kind
  111730. * - VertexBuffer.UV3Kind
  111731. * - VertexBuffer.UV4Kind
  111732. * - VertexBuffer.UV5Kind
  111733. * - VertexBuffer.UV6Kind
  111734. * - VertexBuffer.ColorKind
  111735. * - VertexBuffer.MatricesIndicesKind
  111736. * - VertexBuffer.MatricesIndicesExtraKind
  111737. * - VertexBuffer.MatricesWeightsKind
  111738. * - VertexBuffer.MatricesWeightsExtraKind
  111739. * @param data defines the data source
  111740. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  111741. * @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)
  111742. */
  111743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111744. /**
  111745. * Creates a new index buffer
  111746. * @param indices defines the indices to store in the index buffer
  111747. * @param totalVertices defines the total number of vertices (could be null)
  111748. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111749. */
  111750. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111751. }
  111752. /**
  111753. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111754. */
  111755. export class VertexData {
  111756. /**
  111757. * Mesh side orientation : usually the external or front surface
  111758. */
  111759. static readonly FRONTSIDE: number;
  111760. /**
  111761. * Mesh side orientation : usually the internal or back surface
  111762. */
  111763. static readonly BACKSIDE: number;
  111764. /**
  111765. * Mesh side orientation : both internal and external or front and back surfaces
  111766. */
  111767. static readonly DOUBLESIDE: number;
  111768. /**
  111769. * Mesh side orientation : by default, `FRONTSIDE`
  111770. */
  111771. static readonly DEFAULTSIDE: number;
  111772. /**
  111773. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111774. */
  111775. positions: Nullable<FloatArray>;
  111776. /**
  111777. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111778. */
  111779. normals: Nullable<FloatArray>;
  111780. /**
  111781. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111782. */
  111783. tangents: Nullable<FloatArray>;
  111784. /**
  111785. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111786. */
  111787. uvs: Nullable<FloatArray>;
  111788. /**
  111789. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111790. */
  111791. uvs2: Nullable<FloatArray>;
  111792. /**
  111793. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111794. */
  111795. uvs3: Nullable<FloatArray>;
  111796. /**
  111797. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111798. */
  111799. uvs4: Nullable<FloatArray>;
  111800. /**
  111801. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111802. */
  111803. uvs5: Nullable<FloatArray>;
  111804. /**
  111805. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111806. */
  111807. uvs6: Nullable<FloatArray>;
  111808. /**
  111809. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111810. */
  111811. colors: Nullable<FloatArray>;
  111812. /**
  111813. * 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).
  111814. */
  111815. matricesIndices: Nullable<FloatArray>;
  111816. /**
  111817. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111818. */
  111819. matricesWeights: Nullable<FloatArray>;
  111820. /**
  111821. * An array extending the number of possible indices
  111822. */
  111823. matricesIndicesExtra: Nullable<FloatArray>;
  111824. /**
  111825. * An array extending the number of possible weights when the number of indices is extended
  111826. */
  111827. matricesWeightsExtra: Nullable<FloatArray>;
  111828. /**
  111829. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111830. */
  111831. indices: Nullable<IndicesArray>;
  111832. /**
  111833. * Uses the passed data array to set the set the values for the specified kind of data
  111834. * @param data a linear array of floating numbers
  111835. * @param kind the type of data that is being set, eg positions, colors etc
  111836. */
  111837. set(data: FloatArray, kind: string): void;
  111838. /**
  111839. * Associates the vertexData to the passed Mesh.
  111840. * Sets it as updatable or not (default `false`)
  111841. * @param mesh the mesh the vertexData is applied to
  111842. * @param updatable when used and having the value true allows new data to update the vertexData
  111843. * @returns the VertexData
  111844. */
  111845. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111846. /**
  111847. * Associates the vertexData to the passed Geometry.
  111848. * Sets it as updatable or not (default `false`)
  111849. * @param geometry the geometry the vertexData is applied to
  111850. * @param updatable when used and having the value true allows new data to update the vertexData
  111851. * @returns VertexData
  111852. */
  111853. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111854. /**
  111855. * Updates the associated mesh
  111856. * @param mesh the mesh to be updated
  111857. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111858. * @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
  111859. * @returns VertexData
  111860. */
  111861. updateMesh(mesh: Mesh): VertexData;
  111862. /**
  111863. * Updates the associated geometry
  111864. * @param geometry the geometry to be updated
  111865. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111866. * @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
  111867. * @returns VertexData.
  111868. */
  111869. updateGeometry(geometry: Geometry): VertexData;
  111870. private _applyTo;
  111871. private _update;
  111872. /**
  111873. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111874. * @param matrix the transforming matrix
  111875. * @returns the VertexData
  111876. */
  111877. transform(matrix: Matrix): VertexData;
  111878. /**
  111879. * Merges the passed VertexData into the current one
  111880. * @param other the VertexData to be merged into the current one
  111881. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111882. * @returns the modified VertexData
  111883. */
  111884. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111885. private _mergeElement;
  111886. private _validate;
  111887. /**
  111888. * Serializes the VertexData
  111889. * @returns a serialized object
  111890. */
  111891. serialize(): any;
  111892. /**
  111893. * Extracts the vertexData from a mesh
  111894. * @param mesh the mesh from which to extract the VertexData
  111895. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111897. * @returns the object VertexData associated to the passed mesh
  111898. */
  111899. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111900. /**
  111901. * Extracts the vertexData from the geometry
  111902. * @param geometry the geometry from which to extract the VertexData
  111903. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111904. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111905. * @returns the object VertexData associated to the passed mesh
  111906. */
  111907. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111908. private static _ExtractFrom;
  111909. /**
  111910. * Creates the VertexData for a Ribbon
  111911. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111912. * * pathArray array of paths, each of which an array of successive Vector3
  111913. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111914. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111915. * * 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
  111916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111917. * * 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)
  111918. * * 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)
  111919. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111920. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111921. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111922. * @returns the VertexData of the ribbon
  111923. */
  111924. static CreateRibbon(options: {
  111925. pathArray: Vector3[][];
  111926. closeArray?: boolean;
  111927. closePath?: boolean;
  111928. offset?: number;
  111929. sideOrientation?: number;
  111930. frontUVs?: Vector4;
  111931. backUVs?: Vector4;
  111932. invertUV?: boolean;
  111933. uvs?: Vector2[];
  111934. colors?: Color4[];
  111935. }): VertexData;
  111936. /**
  111937. * Creates the VertexData for a box
  111938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111939. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111940. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111941. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111942. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111943. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111944. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111946. * * 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)
  111947. * * 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)
  111948. * @returns the VertexData of the box
  111949. */
  111950. static CreateBox(options: {
  111951. size?: number;
  111952. width?: number;
  111953. height?: number;
  111954. depth?: number;
  111955. faceUV?: Vector4[];
  111956. faceColors?: Color4[];
  111957. sideOrientation?: number;
  111958. frontUVs?: Vector4;
  111959. backUVs?: Vector4;
  111960. }): VertexData;
  111961. /**
  111962. * Creates the VertexData for a tiled box
  111963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111964. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111965. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111966. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111968. * @returns the VertexData of the box
  111969. */
  111970. static CreateTiledBox(options: {
  111971. pattern?: number;
  111972. width?: number;
  111973. height?: number;
  111974. depth?: number;
  111975. tileSize?: number;
  111976. tileWidth?: number;
  111977. tileHeight?: number;
  111978. alignHorizontal?: number;
  111979. alignVertical?: number;
  111980. faceUV?: Vector4[];
  111981. faceColors?: Color4[];
  111982. sideOrientation?: number;
  111983. }): VertexData;
  111984. /**
  111985. * Creates the VertexData for a tiled plane
  111986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111987. * * pattern a limited pattern arrangement depending on the number
  111988. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111989. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111990. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111992. * * 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)
  111993. * * 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)
  111994. * @returns the VertexData of the tiled plane
  111995. */
  111996. static CreateTiledPlane(options: {
  111997. pattern?: number;
  111998. tileSize?: number;
  111999. tileWidth?: number;
  112000. tileHeight?: number;
  112001. size?: number;
  112002. width?: number;
  112003. height?: number;
  112004. alignHorizontal?: number;
  112005. alignVertical?: number;
  112006. sideOrientation?: number;
  112007. frontUVs?: Vector4;
  112008. backUVs?: Vector4;
  112009. }): VertexData;
  112010. /**
  112011. * Creates the VertexData for an ellipsoid, defaults to a sphere
  112012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  112013. * * segments sets the number of horizontal strips optional, default 32
  112014. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  112015. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  112016. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  112017. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  112018. * * 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
  112019. * * 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
  112020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112021. * * 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)
  112022. * * 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)
  112023. * @returns the VertexData of the ellipsoid
  112024. */
  112025. static CreateSphere(options: {
  112026. segments?: number;
  112027. diameter?: number;
  112028. diameterX?: number;
  112029. diameterY?: number;
  112030. diameterZ?: number;
  112031. arc?: number;
  112032. slice?: number;
  112033. sideOrientation?: number;
  112034. frontUVs?: Vector4;
  112035. backUVs?: Vector4;
  112036. }): VertexData;
  112037. /**
  112038. * Creates the VertexData for a cylinder, cone or prism
  112039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  112040. * * height sets the height (y direction) of the cylinder, optional, default 2
  112041. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  112042. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  112043. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  112044. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  112045. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  112046. * * 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
  112047. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112048. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112049. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  112050. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  112051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112052. * * 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)
  112053. * * 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)
  112054. * @returns the VertexData of the cylinder, cone or prism
  112055. */
  112056. static CreateCylinder(options: {
  112057. height?: number;
  112058. diameterTop?: number;
  112059. diameterBottom?: number;
  112060. diameter?: number;
  112061. tessellation?: number;
  112062. subdivisions?: number;
  112063. arc?: number;
  112064. faceColors?: Color4[];
  112065. faceUV?: Vector4[];
  112066. hasRings?: boolean;
  112067. enclose?: boolean;
  112068. sideOrientation?: number;
  112069. frontUVs?: Vector4;
  112070. backUVs?: Vector4;
  112071. }): VertexData;
  112072. /**
  112073. * Creates the VertexData for a torus
  112074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  112075. * * diameter the diameter of the torus, optional default 1
  112076. * * thickness the diameter of the tube forming the torus, optional default 0.5
  112077. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  112078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112079. * * 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)
  112080. * * 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)
  112081. * @returns the VertexData of the torus
  112082. */
  112083. static CreateTorus(options: {
  112084. diameter?: number;
  112085. thickness?: number;
  112086. tessellation?: number;
  112087. sideOrientation?: number;
  112088. frontUVs?: Vector4;
  112089. backUVs?: Vector4;
  112090. }): VertexData;
  112091. /**
  112092. * Creates the VertexData of the LineSystem
  112093. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  112094. * - lines an array of lines, each line being an array of successive Vector3
  112095. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  112096. * @returns the VertexData of the LineSystem
  112097. */
  112098. static CreateLineSystem(options: {
  112099. lines: Vector3[][];
  112100. colors?: Nullable<Color4[][]>;
  112101. }): VertexData;
  112102. /**
  112103. * Create the VertexData for a DashedLines
  112104. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  112105. * - points an array successive Vector3
  112106. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  112107. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  112108. * - dashNb the intended total number of dashes, optional, default 200
  112109. * @returns the VertexData for the DashedLines
  112110. */
  112111. static CreateDashedLines(options: {
  112112. points: Vector3[];
  112113. dashSize?: number;
  112114. gapSize?: number;
  112115. dashNb?: number;
  112116. }): VertexData;
  112117. /**
  112118. * Creates the VertexData for a Ground
  112119. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112120. * - width the width (x direction) of the ground, optional, default 1
  112121. * - height the height (z direction) of the ground, optional, default 1
  112122. * - subdivisions the number of subdivisions per side, optional, default 1
  112123. * @returns the VertexData of the Ground
  112124. */
  112125. static CreateGround(options: {
  112126. width?: number;
  112127. height?: number;
  112128. subdivisions?: number;
  112129. subdivisionsX?: number;
  112130. subdivisionsY?: number;
  112131. }): VertexData;
  112132. /**
  112133. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  112134. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112135. * * xmin the ground minimum X coordinate, optional, default -1
  112136. * * zmin the ground minimum Z coordinate, optional, default -1
  112137. * * xmax the ground maximum X coordinate, optional, default 1
  112138. * * zmax the ground maximum Z coordinate, optional, default 1
  112139. * * 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}
  112140. * * 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}
  112141. * @returns the VertexData of the TiledGround
  112142. */
  112143. static CreateTiledGround(options: {
  112144. xmin: number;
  112145. zmin: number;
  112146. xmax: number;
  112147. zmax: number;
  112148. subdivisions?: {
  112149. w: number;
  112150. h: number;
  112151. };
  112152. precision?: {
  112153. w: number;
  112154. h: number;
  112155. };
  112156. }): VertexData;
  112157. /**
  112158. * Creates the VertexData of the Ground designed from a heightmap
  112159. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  112160. * * width the width (x direction) of the ground
  112161. * * height the height (z direction) of the ground
  112162. * * subdivisions the number of subdivisions per side
  112163. * * minHeight the minimum altitude on the ground, optional, default 0
  112164. * * maxHeight the maximum altitude on the ground, optional default 1
  112165. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  112166. * * buffer the array holding the image color data
  112167. * * bufferWidth the width of image
  112168. * * bufferHeight the height of image
  112169. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  112170. * @returns the VertexData of the Ground designed from a heightmap
  112171. */
  112172. static CreateGroundFromHeightMap(options: {
  112173. width: number;
  112174. height: number;
  112175. subdivisions: number;
  112176. minHeight: number;
  112177. maxHeight: number;
  112178. colorFilter: Color3;
  112179. buffer: Uint8Array;
  112180. bufferWidth: number;
  112181. bufferHeight: number;
  112182. alphaFilter: number;
  112183. }): VertexData;
  112184. /**
  112185. * Creates the VertexData for a Plane
  112186. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  112187. * * size sets the width and height of the plane to the value of size, optional default 1
  112188. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  112189. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  112190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112191. * * 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)
  112192. * * 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)
  112193. * @returns the VertexData of the box
  112194. */
  112195. static CreatePlane(options: {
  112196. size?: number;
  112197. width?: number;
  112198. height?: number;
  112199. sideOrientation?: number;
  112200. frontUVs?: Vector4;
  112201. backUVs?: Vector4;
  112202. }): VertexData;
  112203. /**
  112204. * Creates the VertexData of the Disc or regular Polygon
  112205. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  112206. * * radius the radius of the disc, optional default 0.5
  112207. * * tessellation the number of polygon sides, optional, default 64
  112208. * * 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
  112209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112210. * * 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)
  112211. * * 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)
  112212. * @returns the VertexData of the box
  112213. */
  112214. static CreateDisc(options: {
  112215. radius?: number;
  112216. tessellation?: number;
  112217. arc?: number;
  112218. sideOrientation?: number;
  112219. frontUVs?: Vector4;
  112220. backUVs?: Vector4;
  112221. }): VertexData;
  112222. /**
  112223. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  112224. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  112225. * @param polygon a mesh built from polygonTriangulation.build()
  112226. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112227. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112228. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112229. * @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)
  112230. * @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)
  112231. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  112232. * @returns the VertexData of the Polygon
  112233. */
  112234. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  112235. /**
  112236. * Creates the VertexData of the IcoSphere
  112237. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  112238. * * radius the radius of the IcoSphere, optional default 1
  112239. * * radiusX allows stretching in the x direction, optional, default radius
  112240. * * radiusY allows stretching in the y direction, optional, default radius
  112241. * * radiusZ allows stretching in the z direction, optional, default radius
  112242. * * flat when true creates a flat shaded mesh, optional, default true
  112243. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112245. * * 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)
  112246. * * 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)
  112247. * @returns the VertexData of the IcoSphere
  112248. */
  112249. static CreateIcoSphere(options: {
  112250. radius?: number;
  112251. radiusX?: number;
  112252. radiusY?: number;
  112253. radiusZ?: number;
  112254. flat?: boolean;
  112255. subdivisions?: number;
  112256. sideOrientation?: number;
  112257. frontUVs?: Vector4;
  112258. backUVs?: Vector4;
  112259. }): VertexData;
  112260. /**
  112261. * Creates the VertexData for a Polyhedron
  112262. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  112263. * * type provided types are:
  112264. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  112265. * * 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)
  112266. * * size the size of the IcoSphere, optional default 1
  112267. * * sizeX allows stretching in the x direction, optional, default size
  112268. * * sizeY allows stretching in the y direction, optional, default size
  112269. * * sizeZ allows stretching in the z direction, optional, default size
  112270. * * 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
  112271. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112272. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112273. * * flat when true creates a flat shaded mesh, optional, default true
  112274. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112276. * * 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)
  112277. * * 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)
  112278. * @returns the VertexData of the Polyhedron
  112279. */
  112280. static CreatePolyhedron(options: {
  112281. type?: number;
  112282. size?: number;
  112283. sizeX?: number;
  112284. sizeY?: number;
  112285. sizeZ?: number;
  112286. custom?: any;
  112287. faceUV?: Vector4[];
  112288. faceColors?: Color4[];
  112289. flat?: boolean;
  112290. sideOrientation?: number;
  112291. frontUVs?: Vector4;
  112292. backUVs?: Vector4;
  112293. }): VertexData;
  112294. /**
  112295. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  112296. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  112297. * @returns the VertexData of the Capsule
  112298. */
  112299. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  112300. /**
  112301. * Creates the VertexData for a TorusKnot
  112302. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  112303. * * radius the radius of the torus knot, optional, default 2
  112304. * * tube the thickness of the tube, optional, default 0.5
  112305. * * radialSegments the number of sides on each tube segments, optional, default 32
  112306. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  112307. * * p the number of windings around the z axis, optional, default 2
  112308. * * q the number of windings around the x axis, optional, default 3
  112309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112310. * * 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)
  112311. * * 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)
  112312. * @returns the VertexData of the Torus Knot
  112313. */
  112314. static CreateTorusKnot(options: {
  112315. radius?: number;
  112316. tube?: number;
  112317. radialSegments?: number;
  112318. tubularSegments?: number;
  112319. p?: number;
  112320. q?: number;
  112321. sideOrientation?: number;
  112322. frontUVs?: Vector4;
  112323. backUVs?: Vector4;
  112324. }): VertexData;
  112325. /**
  112326. * Compute normals for given positions and indices
  112327. * @param positions an array of vertex positions, [...., x, y, z, ......]
  112328. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  112329. * @param normals an array of vertex normals, [...., x, y, z, ......]
  112330. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  112331. * * facetNormals : optional array of facet normals (vector3)
  112332. * * facetPositions : optional array of facet positions (vector3)
  112333. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  112334. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  112335. * * bInfo : optional bounding info, required for facetPartitioning computation
  112336. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  112337. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  112338. * * useRightHandedSystem: optional boolean to for right handed system computation
  112339. * * depthSort : optional boolean to enable the facet depth sort computation
  112340. * * distanceTo : optional Vector3 to compute the facet depth from this location
  112341. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  112342. */
  112343. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  112344. facetNormals?: any;
  112345. facetPositions?: any;
  112346. facetPartitioning?: any;
  112347. ratio?: number;
  112348. bInfo?: any;
  112349. bbSize?: Vector3;
  112350. subDiv?: any;
  112351. useRightHandedSystem?: boolean;
  112352. depthSort?: boolean;
  112353. distanceTo?: Vector3;
  112354. depthSortedFacets?: any;
  112355. }): void;
  112356. /** @hidden */
  112357. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  112358. /**
  112359. * Applies VertexData created from the imported parameters to the geometry
  112360. * @param parsedVertexData the parsed data from an imported file
  112361. * @param geometry the geometry to apply the VertexData to
  112362. */
  112363. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  112364. }
  112365. }
  112366. declare module BABYLON {
  112367. /**
  112368. * Defines a target to use with MorphTargetManager
  112369. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112370. */
  112371. export class MorphTarget implements IAnimatable {
  112372. /** defines the name of the target */
  112373. name: string;
  112374. /**
  112375. * Gets or sets the list of animations
  112376. */
  112377. animations: Animation[];
  112378. private _scene;
  112379. private _positions;
  112380. private _normals;
  112381. private _tangents;
  112382. private _uvs;
  112383. private _influence;
  112384. private _uniqueId;
  112385. /**
  112386. * Observable raised when the influence changes
  112387. */
  112388. onInfluenceChanged: Observable<boolean>;
  112389. /** @hidden */
  112390. _onDataLayoutChanged: Observable<void>;
  112391. /**
  112392. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112393. */
  112394. get influence(): number;
  112395. set influence(influence: number);
  112396. /**
  112397. * Gets or sets the id of the morph Target
  112398. */
  112399. id: string;
  112400. private _animationPropertiesOverride;
  112401. /**
  112402. * Gets or sets the animation properties override
  112403. */
  112404. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112405. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112406. /**
  112407. * Creates a new MorphTarget
  112408. * @param name defines the name of the target
  112409. * @param influence defines the influence to use
  112410. * @param scene defines the scene the morphtarget belongs to
  112411. */
  112412. constructor(
  112413. /** defines the name of the target */
  112414. name: string, influence?: number, scene?: Nullable<Scene>);
  112415. /**
  112416. * Gets the unique ID of this manager
  112417. */
  112418. get uniqueId(): number;
  112419. /**
  112420. * Gets a boolean defining if the target contains position data
  112421. */
  112422. get hasPositions(): boolean;
  112423. /**
  112424. * Gets a boolean defining if the target contains normal data
  112425. */
  112426. get hasNormals(): boolean;
  112427. /**
  112428. * Gets a boolean defining if the target contains tangent data
  112429. */
  112430. get hasTangents(): boolean;
  112431. /**
  112432. * Gets a boolean defining if the target contains texture coordinates data
  112433. */
  112434. get hasUVs(): boolean;
  112435. /**
  112436. * Affects position data to this target
  112437. * @param data defines the position data to use
  112438. */
  112439. setPositions(data: Nullable<FloatArray>): void;
  112440. /**
  112441. * Gets the position data stored in this target
  112442. * @returns a FloatArray containing the position data (or null if not present)
  112443. */
  112444. getPositions(): Nullable<FloatArray>;
  112445. /**
  112446. * Affects normal data to this target
  112447. * @param data defines the normal data to use
  112448. */
  112449. setNormals(data: Nullable<FloatArray>): void;
  112450. /**
  112451. * Gets the normal data stored in this target
  112452. * @returns a FloatArray containing the normal data (or null if not present)
  112453. */
  112454. getNormals(): Nullable<FloatArray>;
  112455. /**
  112456. * Affects tangent data to this target
  112457. * @param data defines the tangent data to use
  112458. */
  112459. setTangents(data: Nullable<FloatArray>): void;
  112460. /**
  112461. * Gets the tangent data stored in this target
  112462. * @returns a FloatArray containing the tangent data (or null if not present)
  112463. */
  112464. getTangents(): Nullable<FloatArray>;
  112465. /**
  112466. * Affects texture coordinates data to this target
  112467. * @param data defines the texture coordinates data to use
  112468. */
  112469. setUVs(data: Nullable<FloatArray>): void;
  112470. /**
  112471. * Gets the texture coordinates data stored in this target
  112472. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112473. */
  112474. getUVs(): Nullable<FloatArray>;
  112475. /**
  112476. * Clone the current target
  112477. * @returns a new MorphTarget
  112478. */
  112479. clone(): MorphTarget;
  112480. /**
  112481. * Serializes the current target into a Serialization object
  112482. * @returns the serialized object
  112483. */
  112484. serialize(): any;
  112485. /**
  112486. * Returns the string "MorphTarget"
  112487. * @returns "MorphTarget"
  112488. */
  112489. getClassName(): string;
  112490. /**
  112491. * Creates a new target from serialized data
  112492. * @param serializationObject defines the serialized data to use
  112493. * @returns a new MorphTarget
  112494. */
  112495. static Parse(serializationObject: any): MorphTarget;
  112496. /**
  112497. * Creates a MorphTarget from mesh data
  112498. * @param mesh defines the source mesh
  112499. * @param name defines the name to use for the new target
  112500. * @param influence defines the influence to attach to the target
  112501. * @returns a new MorphTarget
  112502. */
  112503. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112504. }
  112505. }
  112506. declare module BABYLON {
  112507. /**
  112508. * This class is used to deform meshes using morphing between different targets
  112509. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112510. */
  112511. export class MorphTargetManager {
  112512. private _targets;
  112513. private _targetInfluenceChangedObservers;
  112514. private _targetDataLayoutChangedObservers;
  112515. private _activeTargets;
  112516. private _scene;
  112517. private _influences;
  112518. private _supportsNormals;
  112519. private _supportsTangents;
  112520. private _supportsUVs;
  112521. private _vertexCount;
  112522. private _uniqueId;
  112523. private _tempInfluences;
  112524. /**
  112525. * Gets or sets a boolean indicating if normals must be morphed
  112526. */
  112527. enableNormalMorphing: boolean;
  112528. /**
  112529. * Gets or sets a boolean indicating if tangents must be morphed
  112530. */
  112531. enableTangentMorphing: boolean;
  112532. /**
  112533. * Gets or sets a boolean indicating if UV must be morphed
  112534. */
  112535. enableUVMorphing: boolean;
  112536. /**
  112537. * Creates a new MorphTargetManager
  112538. * @param scene defines the current scene
  112539. */
  112540. constructor(scene?: Nullable<Scene>);
  112541. /**
  112542. * Gets the unique ID of this manager
  112543. */
  112544. get uniqueId(): number;
  112545. /**
  112546. * Gets the number of vertices handled by this manager
  112547. */
  112548. get vertexCount(): number;
  112549. /**
  112550. * Gets a boolean indicating if this manager supports morphing of normals
  112551. */
  112552. get supportsNormals(): boolean;
  112553. /**
  112554. * Gets a boolean indicating if this manager supports morphing of tangents
  112555. */
  112556. get supportsTangents(): boolean;
  112557. /**
  112558. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112559. */
  112560. get supportsUVs(): boolean;
  112561. /**
  112562. * Gets the number of targets stored in this manager
  112563. */
  112564. get numTargets(): number;
  112565. /**
  112566. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112567. */
  112568. get numInfluencers(): number;
  112569. /**
  112570. * Gets the list of influences (one per target)
  112571. */
  112572. get influences(): Float32Array;
  112573. /**
  112574. * Gets the active target at specified index. An active target is a target with an influence > 0
  112575. * @param index defines the index to check
  112576. * @returns the requested target
  112577. */
  112578. getActiveTarget(index: number): MorphTarget;
  112579. /**
  112580. * Gets the target at specified index
  112581. * @param index defines the index to check
  112582. * @returns the requested target
  112583. */
  112584. getTarget(index: number): MorphTarget;
  112585. /**
  112586. * Add a new target to this manager
  112587. * @param target defines the target to add
  112588. */
  112589. addTarget(target: MorphTarget): void;
  112590. /**
  112591. * Removes a target from the manager
  112592. * @param target defines the target to remove
  112593. */
  112594. removeTarget(target: MorphTarget): void;
  112595. /**
  112596. * Clone the current manager
  112597. * @returns a new MorphTargetManager
  112598. */
  112599. clone(): MorphTargetManager;
  112600. /**
  112601. * Serializes the current manager into a Serialization object
  112602. * @returns the serialized object
  112603. */
  112604. serialize(): any;
  112605. private _syncActiveTargets;
  112606. /**
  112607. * Syncrhonize the targets with all the meshes using this morph target manager
  112608. */
  112609. synchronize(): void;
  112610. /**
  112611. * Creates a new MorphTargetManager from serialized data
  112612. * @param serializationObject defines the serialized data
  112613. * @param scene defines the hosting scene
  112614. * @returns the new MorphTargetManager
  112615. */
  112616. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112617. }
  112618. }
  112619. declare module BABYLON {
  112620. /**
  112621. * Class used to represent a specific level of detail of a mesh
  112622. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112623. */
  112624. export class MeshLODLevel {
  112625. /** Defines the distance where this level should start being displayed */
  112626. distance: number;
  112627. /** Defines the mesh to use to render this level */
  112628. mesh: Nullable<Mesh>;
  112629. /**
  112630. * Creates a new LOD level
  112631. * @param distance defines the distance where this level should star being displayed
  112632. * @param mesh defines the mesh to use to render this level
  112633. */
  112634. constructor(
  112635. /** Defines the distance where this level should start being displayed */
  112636. distance: number,
  112637. /** Defines the mesh to use to render this level */
  112638. mesh: Nullable<Mesh>);
  112639. }
  112640. }
  112641. declare module BABYLON {
  112642. /**
  112643. * Helper class used to generate a canvas to manipulate images
  112644. */
  112645. export class CanvasGenerator {
  112646. /**
  112647. * Create a new canvas (or offscreen canvas depending on the context)
  112648. * @param width defines the expected width
  112649. * @param height defines the expected height
  112650. * @return a new canvas or offscreen canvas
  112651. */
  112652. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112653. }
  112654. }
  112655. declare module BABYLON {
  112656. /**
  112657. * Mesh representing the gorund
  112658. */
  112659. export class GroundMesh extends Mesh {
  112660. /** If octree should be generated */
  112661. generateOctree: boolean;
  112662. private _heightQuads;
  112663. /** @hidden */
  112664. _subdivisionsX: number;
  112665. /** @hidden */
  112666. _subdivisionsY: number;
  112667. /** @hidden */
  112668. _width: number;
  112669. /** @hidden */
  112670. _height: number;
  112671. /** @hidden */
  112672. _minX: number;
  112673. /** @hidden */
  112674. _maxX: number;
  112675. /** @hidden */
  112676. _minZ: number;
  112677. /** @hidden */
  112678. _maxZ: number;
  112679. constructor(name: string, scene: Scene);
  112680. /**
  112681. * "GroundMesh"
  112682. * @returns "GroundMesh"
  112683. */
  112684. getClassName(): string;
  112685. /**
  112686. * The minimum of x and y subdivisions
  112687. */
  112688. get subdivisions(): number;
  112689. /**
  112690. * X subdivisions
  112691. */
  112692. get subdivisionsX(): number;
  112693. /**
  112694. * Y subdivisions
  112695. */
  112696. get subdivisionsY(): number;
  112697. /**
  112698. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112699. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112700. * @param chunksCount the number of subdivisions for x and y
  112701. * @param octreeBlocksSize (Default: 32)
  112702. */
  112703. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112704. /**
  112705. * Returns a height (y) value in the Worl system :
  112706. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112707. * @param x x coordinate
  112708. * @param z z coordinate
  112709. * @returns the ground y position if (x, z) are outside the ground surface.
  112710. */
  112711. getHeightAtCoordinates(x: number, z: number): number;
  112712. /**
  112713. * Returns a normalized vector (Vector3) orthogonal to the ground
  112714. * at the ground coordinates (x, z) expressed in the World system.
  112715. * @param x x coordinate
  112716. * @param z z coordinate
  112717. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112718. */
  112719. getNormalAtCoordinates(x: number, z: number): Vector3;
  112720. /**
  112721. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112722. * at the ground coordinates (x, z) expressed in the World system.
  112723. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112724. * @param x x coordinate
  112725. * @param z z coordinate
  112726. * @param ref vector to store the result
  112727. * @returns the GroundMesh.
  112728. */
  112729. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112730. /**
  112731. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112732. * if the ground has been updated.
  112733. * This can be used in the render loop.
  112734. * @returns the GroundMesh.
  112735. */
  112736. updateCoordinateHeights(): GroundMesh;
  112737. private _getFacetAt;
  112738. private _initHeightQuads;
  112739. private _computeHeightQuads;
  112740. /**
  112741. * Serializes this ground mesh
  112742. * @param serializationObject object to write serialization to
  112743. */
  112744. serialize(serializationObject: any): void;
  112745. /**
  112746. * Parses a serialized ground mesh
  112747. * @param parsedMesh the serialized mesh
  112748. * @param scene the scene to create the ground mesh in
  112749. * @returns the created ground mesh
  112750. */
  112751. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112752. }
  112753. }
  112754. declare module BABYLON {
  112755. /**
  112756. * Interface for Physics-Joint data
  112757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112758. */
  112759. export interface PhysicsJointData {
  112760. /**
  112761. * The main pivot of the joint
  112762. */
  112763. mainPivot?: Vector3;
  112764. /**
  112765. * The connected pivot of the joint
  112766. */
  112767. connectedPivot?: Vector3;
  112768. /**
  112769. * The main axis of the joint
  112770. */
  112771. mainAxis?: Vector3;
  112772. /**
  112773. * The connected axis of the joint
  112774. */
  112775. connectedAxis?: Vector3;
  112776. /**
  112777. * The collision of the joint
  112778. */
  112779. collision?: boolean;
  112780. /**
  112781. * Native Oimo/Cannon/Energy data
  112782. */
  112783. nativeParams?: any;
  112784. }
  112785. /**
  112786. * This is a holder class for the physics joint created by the physics plugin
  112787. * It holds a set of functions to control the underlying joint
  112788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112789. */
  112790. export class PhysicsJoint {
  112791. /**
  112792. * The type of the physics joint
  112793. */
  112794. type: number;
  112795. /**
  112796. * The data for the physics joint
  112797. */
  112798. jointData: PhysicsJointData;
  112799. private _physicsJoint;
  112800. protected _physicsPlugin: IPhysicsEnginePlugin;
  112801. /**
  112802. * Initializes the physics joint
  112803. * @param type The type of the physics joint
  112804. * @param jointData The data for the physics joint
  112805. */
  112806. constructor(
  112807. /**
  112808. * The type of the physics joint
  112809. */
  112810. type: number,
  112811. /**
  112812. * The data for the physics joint
  112813. */
  112814. jointData: PhysicsJointData);
  112815. /**
  112816. * Gets the physics joint
  112817. */
  112818. get physicsJoint(): any;
  112819. /**
  112820. * Sets the physics joint
  112821. */
  112822. set physicsJoint(newJoint: any);
  112823. /**
  112824. * Sets the physics plugin
  112825. */
  112826. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112827. /**
  112828. * Execute a function that is physics-plugin specific.
  112829. * @param {Function} func the function that will be executed.
  112830. * It accepts two parameters: the physics world and the physics joint
  112831. */
  112832. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112833. /**
  112834. * Distance-Joint type
  112835. */
  112836. static DistanceJoint: number;
  112837. /**
  112838. * Hinge-Joint type
  112839. */
  112840. static HingeJoint: number;
  112841. /**
  112842. * Ball-and-Socket joint type
  112843. */
  112844. static BallAndSocketJoint: number;
  112845. /**
  112846. * Wheel-Joint type
  112847. */
  112848. static WheelJoint: number;
  112849. /**
  112850. * Slider-Joint type
  112851. */
  112852. static SliderJoint: number;
  112853. /**
  112854. * Prismatic-Joint type
  112855. */
  112856. static PrismaticJoint: number;
  112857. /**
  112858. * Universal-Joint type
  112859. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112860. */
  112861. static UniversalJoint: number;
  112862. /**
  112863. * Hinge-Joint 2 type
  112864. */
  112865. static Hinge2Joint: number;
  112866. /**
  112867. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112868. */
  112869. static PointToPointJoint: number;
  112870. /**
  112871. * Spring-Joint type
  112872. */
  112873. static SpringJoint: number;
  112874. /**
  112875. * Lock-Joint type
  112876. */
  112877. static LockJoint: number;
  112878. }
  112879. /**
  112880. * A class representing a physics distance joint
  112881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112882. */
  112883. export class DistanceJoint extends PhysicsJoint {
  112884. /**
  112885. *
  112886. * @param jointData The data for the Distance-Joint
  112887. */
  112888. constructor(jointData: DistanceJointData);
  112889. /**
  112890. * Update the predefined distance.
  112891. * @param maxDistance The maximum preferred distance
  112892. * @param minDistance The minimum preferred distance
  112893. */
  112894. updateDistance(maxDistance: number, minDistance?: number): void;
  112895. }
  112896. /**
  112897. * Represents a Motor-Enabled Joint
  112898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112899. */
  112900. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112901. /**
  112902. * Initializes the Motor-Enabled Joint
  112903. * @param type The type of the joint
  112904. * @param jointData The physica joint data for the joint
  112905. */
  112906. constructor(type: number, jointData: PhysicsJointData);
  112907. /**
  112908. * Set the motor values.
  112909. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112910. * @param force the force to apply
  112911. * @param maxForce max force for this motor.
  112912. */
  112913. setMotor(force?: number, maxForce?: number): void;
  112914. /**
  112915. * Set the motor's limits.
  112916. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112917. * @param upperLimit The upper limit of the motor
  112918. * @param lowerLimit The lower limit of the motor
  112919. */
  112920. setLimit(upperLimit: number, lowerLimit?: number): void;
  112921. }
  112922. /**
  112923. * This class represents a single physics Hinge-Joint
  112924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112925. */
  112926. export class HingeJoint extends MotorEnabledJoint {
  112927. /**
  112928. * Initializes the Hinge-Joint
  112929. * @param jointData The joint data for the Hinge-Joint
  112930. */
  112931. constructor(jointData: PhysicsJointData);
  112932. /**
  112933. * Set the motor values.
  112934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112935. * @param {number} force the force to apply
  112936. * @param {number} maxForce max force for this motor.
  112937. */
  112938. setMotor(force?: number, maxForce?: number): void;
  112939. /**
  112940. * Set the motor's limits.
  112941. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112942. * @param upperLimit The upper limit of the motor
  112943. * @param lowerLimit The lower limit of the motor
  112944. */
  112945. setLimit(upperLimit: number, lowerLimit?: number): void;
  112946. }
  112947. /**
  112948. * This class represents a dual hinge physics joint (same as wheel joint)
  112949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112950. */
  112951. export class Hinge2Joint extends MotorEnabledJoint {
  112952. /**
  112953. * Initializes the Hinge2-Joint
  112954. * @param jointData The joint data for the Hinge2-Joint
  112955. */
  112956. constructor(jointData: PhysicsJointData);
  112957. /**
  112958. * Set the motor values.
  112959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112960. * @param {number} targetSpeed the speed the motor is to reach
  112961. * @param {number} maxForce max force for this motor.
  112962. * @param {motorIndex} the motor's index, 0 or 1.
  112963. */
  112964. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112965. /**
  112966. * Set the motor limits.
  112967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112968. * @param {number} upperLimit the upper limit
  112969. * @param {number} lowerLimit lower limit
  112970. * @param {motorIndex} the motor's index, 0 or 1.
  112971. */
  112972. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112973. }
  112974. /**
  112975. * Interface for a motor enabled joint
  112976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112977. */
  112978. export interface IMotorEnabledJoint {
  112979. /**
  112980. * Physics joint
  112981. */
  112982. physicsJoint: any;
  112983. /**
  112984. * Sets the motor of the motor-enabled joint
  112985. * @param force The force of the motor
  112986. * @param maxForce The maximum force of the motor
  112987. * @param motorIndex The index of the motor
  112988. */
  112989. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112990. /**
  112991. * Sets the limit of the motor
  112992. * @param upperLimit The upper limit of the motor
  112993. * @param lowerLimit The lower limit of the motor
  112994. * @param motorIndex The index of the motor
  112995. */
  112996. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112997. }
  112998. /**
  112999. * Joint data for a Distance-Joint
  113000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113001. */
  113002. export interface DistanceJointData extends PhysicsJointData {
  113003. /**
  113004. * Max distance the 2 joint objects can be apart
  113005. */
  113006. maxDistance: number;
  113007. }
  113008. /**
  113009. * Joint data from a spring joint
  113010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113011. */
  113012. export interface SpringJointData extends PhysicsJointData {
  113013. /**
  113014. * Length of the spring
  113015. */
  113016. length: number;
  113017. /**
  113018. * Stiffness of the spring
  113019. */
  113020. stiffness: number;
  113021. /**
  113022. * Damping of the spring
  113023. */
  113024. damping: number;
  113025. /** this callback will be called when applying the force to the impostors. */
  113026. forceApplicationCallback: () => void;
  113027. }
  113028. }
  113029. declare module BABYLON {
  113030. /**
  113031. * Holds the data for the raycast result
  113032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113033. */
  113034. export class PhysicsRaycastResult {
  113035. private _hasHit;
  113036. private _hitDistance;
  113037. private _hitNormalWorld;
  113038. private _hitPointWorld;
  113039. private _rayFromWorld;
  113040. private _rayToWorld;
  113041. /**
  113042. * Gets if there was a hit
  113043. */
  113044. get hasHit(): boolean;
  113045. /**
  113046. * Gets the distance from the hit
  113047. */
  113048. get hitDistance(): number;
  113049. /**
  113050. * Gets the hit normal/direction in the world
  113051. */
  113052. get hitNormalWorld(): Vector3;
  113053. /**
  113054. * Gets the hit point in the world
  113055. */
  113056. get hitPointWorld(): Vector3;
  113057. /**
  113058. * Gets the ray "start point" of the ray in the world
  113059. */
  113060. get rayFromWorld(): Vector3;
  113061. /**
  113062. * Gets the ray "end point" of the ray in the world
  113063. */
  113064. get rayToWorld(): Vector3;
  113065. /**
  113066. * Sets the hit data (normal & point in world space)
  113067. * @param hitNormalWorld defines the normal in world space
  113068. * @param hitPointWorld defines the point in world space
  113069. */
  113070. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  113071. /**
  113072. * Sets the distance from the start point to the hit point
  113073. * @param distance
  113074. */
  113075. setHitDistance(distance: number): void;
  113076. /**
  113077. * Calculates the distance manually
  113078. */
  113079. calculateHitDistance(): void;
  113080. /**
  113081. * Resets all the values to default
  113082. * @param from The from point on world space
  113083. * @param to The to point on world space
  113084. */
  113085. reset(from?: Vector3, to?: Vector3): void;
  113086. }
  113087. /**
  113088. * Interface for the size containing width and height
  113089. */
  113090. interface IXYZ {
  113091. /**
  113092. * X
  113093. */
  113094. x: number;
  113095. /**
  113096. * Y
  113097. */
  113098. y: number;
  113099. /**
  113100. * Z
  113101. */
  113102. z: number;
  113103. }
  113104. }
  113105. declare module BABYLON {
  113106. /**
  113107. * Interface used to describe a physics joint
  113108. */
  113109. export interface PhysicsImpostorJoint {
  113110. /** Defines the main impostor to which the joint is linked */
  113111. mainImpostor: PhysicsImpostor;
  113112. /** Defines the impostor that is connected to the main impostor using this joint */
  113113. connectedImpostor: PhysicsImpostor;
  113114. /** Defines the joint itself */
  113115. joint: PhysicsJoint;
  113116. }
  113117. /** @hidden */
  113118. export interface IPhysicsEnginePlugin {
  113119. world: any;
  113120. name: string;
  113121. setGravity(gravity: Vector3): void;
  113122. setTimeStep(timeStep: number): void;
  113123. getTimeStep(): number;
  113124. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113125. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113127. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113128. removePhysicsBody(impostor: PhysicsImpostor): void;
  113129. generateJoint(joint: PhysicsImpostorJoint): void;
  113130. removeJoint(joint: PhysicsImpostorJoint): void;
  113131. isSupported(): boolean;
  113132. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113133. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113134. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113135. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113136. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113137. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113138. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113139. getBodyMass(impostor: PhysicsImpostor): number;
  113140. getBodyFriction(impostor: PhysicsImpostor): number;
  113141. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113142. getBodyRestitution(impostor: PhysicsImpostor): number;
  113143. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113144. getBodyPressure?(impostor: PhysicsImpostor): number;
  113145. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  113146. getBodyStiffness?(impostor: PhysicsImpostor): number;
  113147. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  113148. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  113149. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  113150. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  113151. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  113152. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113153. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113154. sleepBody(impostor: PhysicsImpostor): void;
  113155. wakeUpBody(impostor: PhysicsImpostor): void;
  113156. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113157. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113158. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  113159. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113160. getRadius(impostor: PhysicsImpostor): number;
  113161. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113162. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113163. dispose(): void;
  113164. }
  113165. /**
  113166. * Interface used to define a physics engine
  113167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113168. */
  113169. export interface IPhysicsEngine {
  113170. /**
  113171. * Gets the gravity vector used by the simulation
  113172. */
  113173. gravity: Vector3;
  113174. /**
  113175. * Sets the gravity vector used by the simulation
  113176. * @param gravity defines the gravity vector to use
  113177. */
  113178. setGravity(gravity: Vector3): void;
  113179. /**
  113180. * Set the time step of the physics engine.
  113181. * Default is 1/60.
  113182. * To slow it down, enter 1/600 for example.
  113183. * To speed it up, 1/30
  113184. * @param newTimeStep the new timestep to apply to this world.
  113185. */
  113186. setTimeStep(newTimeStep: number): void;
  113187. /**
  113188. * Get the time step of the physics engine.
  113189. * @returns the current time step
  113190. */
  113191. getTimeStep(): number;
  113192. /**
  113193. * Set the sub time step of the physics engine.
  113194. * Default is 0 meaning there is no sub steps
  113195. * To increase physics resolution precision, set a small value (like 1 ms)
  113196. * @param subTimeStep defines the new sub timestep used for physics resolution.
  113197. */
  113198. setSubTimeStep(subTimeStep: number): void;
  113199. /**
  113200. * Get the sub time step of the physics engine.
  113201. * @returns the current sub time step
  113202. */
  113203. getSubTimeStep(): number;
  113204. /**
  113205. * Release all resources
  113206. */
  113207. dispose(): void;
  113208. /**
  113209. * Gets the name of the current physics plugin
  113210. * @returns the name of the plugin
  113211. */
  113212. getPhysicsPluginName(): string;
  113213. /**
  113214. * Adding a new impostor for the impostor tracking.
  113215. * This will be done by the impostor itself.
  113216. * @param impostor the impostor to add
  113217. */
  113218. addImpostor(impostor: PhysicsImpostor): void;
  113219. /**
  113220. * Remove an impostor from the engine.
  113221. * This impostor and its mesh will not longer be updated by the physics engine.
  113222. * @param impostor the impostor to remove
  113223. */
  113224. removeImpostor(impostor: PhysicsImpostor): void;
  113225. /**
  113226. * Add a joint to the physics engine
  113227. * @param mainImpostor defines the main impostor to which the joint is added.
  113228. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113229. * @param joint defines the joint that will connect both impostors.
  113230. */
  113231. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113232. /**
  113233. * Removes a joint from the simulation
  113234. * @param mainImpostor defines the impostor used with the joint
  113235. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113236. * @param joint defines the joint to remove
  113237. */
  113238. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113239. /**
  113240. * Gets the current plugin used to run the simulation
  113241. * @returns current plugin
  113242. */
  113243. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113244. /**
  113245. * Gets the list of physic impostors
  113246. * @returns an array of PhysicsImpostor
  113247. */
  113248. getImpostors(): Array<PhysicsImpostor>;
  113249. /**
  113250. * Gets the impostor for a physics enabled object
  113251. * @param object defines the object impersonated by the impostor
  113252. * @returns the PhysicsImpostor or null if not found
  113253. */
  113254. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113255. /**
  113256. * Gets the impostor for a physics body object
  113257. * @param body defines physics body used by the impostor
  113258. * @returns the PhysicsImpostor or null if not found
  113259. */
  113260. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113261. /**
  113262. * Does a raycast in the physics world
  113263. * @param from when should the ray start?
  113264. * @param to when should the ray end?
  113265. * @returns PhysicsRaycastResult
  113266. */
  113267. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113268. /**
  113269. * Called by the scene. No need to call it.
  113270. * @param delta defines the timespam between frames
  113271. */
  113272. _step(delta: number): void;
  113273. }
  113274. }
  113275. declare module BABYLON {
  113276. /**
  113277. * The interface for the physics imposter parameters
  113278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113279. */
  113280. export interface PhysicsImpostorParameters {
  113281. /**
  113282. * The mass of the physics imposter
  113283. */
  113284. mass: number;
  113285. /**
  113286. * The friction of the physics imposter
  113287. */
  113288. friction?: number;
  113289. /**
  113290. * The coefficient of restitution of the physics imposter
  113291. */
  113292. restitution?: number;
  113293. /**
  113294. * The native options of the physics imposter
  113295. */
  113296. nativeOptions?: any;
  113297. /**
  113298. * Specifies if the parent should be ignored
  113299. */
  113300. ignoreParent?: boolean;
  113301. /**
  113302. * Specifies if bi-directional transformations should be disabled
  113303. */
  113304. disableBidirectionalTransformation?: boolean;
  113305. /**
  113306. * The pressure inside the physics imposter, soft object only
  113307. */
  113308. pressure?: number;
  113309. /**
  113310. * The stiffness the physics imposter, soft object only
  113311. */
  113312. stiffness?: number;
  113313. /**
  113314. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113315. */
  113316. velocityIterations?: number;
  113317. /**
  113318. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113319. */
  113320. positionIterations?: number;
  113321. /**
  113322. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113323. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113324. * Add to fix multiple points
  113325. */
  113326. fixedPoints?: number;
  113327. /**
  113328. * The collision margin around a soft object
  113329. */
  113330. margin?: number;
  113331. /**
  113332. * The collision margin around a soft object
  113333. */
  113334. damping?: number;
  113335. /**
  113336. * The path for a rope based on an extrusion
  113337. */
  113338. path?: any;
  113339. /**
  113340. * The shape of an extrusion used for a rope based on an extrusion
  113341. */
  113342. shape?: any;
  113343. }
  113344. /**
  113345. * Interface for a physics-enabled object
  113346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113347. */
  113348. export interface IPhysicsEnabledObject {
  113349. /**
  113350. * The position of the physics-enabled object
  113351. */
  113352. position: Vector3;
  113353. /**
  113354. * The rotation of the physics-enabled object
  113355. */
  113356. rotationQuaternion: Nullable<Quaternion>;
  113357. /**
  113358. * The scale of the physics-enabled object
  113359. */
  113360. scaling: Vector3;
  113361. /**
  113362. * The rotation of the physics-enabled object
  113363. */
  113364. rotation?: Vector3;
  113365. /**
  113366. * The parent of the physics-enabled object
  113367. */
  113368. parent?: any;
  113369. /**
  113370. * The bounding info of the physics-enabled object
  113371. * @returns The bounding info of the physics-enabled object
  113372. */
  113373. getBoundingInfo(): BoundingInfo;
  113374. /**
  113375. * Computes the world matrix
  113376. * @param force Specifies if the world matrix should be computed by force
  113377. * @returns A world matrix
  113378. */
  113379. computeWorldMatrix(force: boolean): Matrix;
  113380. /**
  113381. * Gets the world matrix
  113382. * @returns A world matrix
  113383. */
  113384. getWorldMatrix?(): Matrix;
  113385. /**
  113386. * Gets the child meshes
  113387. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113388. * @returns An array of abstract meshes
  113389. */
  113390. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113391. /**
  113392. * Gets the vertex data
  113393. * @param kind The type of vertex data
  113394. * @returns A nullable array of numbers, or a float32 array
  113395. */
  113396. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113397. /**
  113398. * Gets the indices from the mesh
  113399. * @returns A nullable array of index arrays
  113400. */
  113401. getIndices?(): Nullable<IndicesArray>;
  113402. /**
  113403. * Gets the scene from the mesh
  113404. * @returns the indices array or null
  113405. */
  113406. getScene?(): Scene;
  113407. /**
  113408. * Gets the absolute position from the mesh
  113409. * @returns the absolute position
  113410. */
  113411. getAbsolutePosition(): Vector3;
  113412. /**
  113413. * Gets the absolute pivot point from the mesh
  113414. * @returns the absolute pivot point
  113415. */
  113416. getAbsolutePivotPoint(): Vector3;
  113417. /**
  113418. * Rotates the mesh
  113419. * @param axis The axis of rotation
  113420. * @param amount The amount of rotation
  113421. * @param space The space of the rotation
  113422. * @returns The rotation transform node
  113423. */
  113424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113425. /**
  113426. * Translates the mesh
  113427. * @param axis The axis of translation
  113428. * @param distance The distance of translation
  113429. * @param space The space of the translation
  113430. * @returns The transform node
  113431. */
  113432. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113433. /**
  113434. * Sets the absolute position of the mesh
  113435. * @param absolutePosition The absolute position of the mesh
  113436. * @returns The transform node
  113437. */
  113438. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113439. /**
  113440. * Gets the class name of the mesh
  113441. * @returns The class name
  113442. */
  113443. getClassName(): string;
  113444. }
  113445. /**
  113446. * Represents a physics imposter
  113447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113448. */
  113449. export class PhysicsImpostor {
  113450. /**
  113451. * The physics-enabled object used as the physics imposter
  113452. */
  113453. object: IPhysicsEnabledObject;
  113454. /**
  113455. * The type of the physics imposter
  113456. */
  113457. type: number;
  113458. private _options;
  113459. private _scene?;
  113460. /**
  113461. * The default object size of the imposter
  113462. */
  113463. static DEFAULT_OBJECT_SIZE: Vector3;
  113464. /**
  113465. * The identity quaternion of the imposter
  113466. */
  113467. static IDENTITY_QUATERNION: Quaternion;
  113468. /** @hidden */
  113469. _pluginData: any;
  113470. private _physicsEngine;
  113471. private _physicsBody;
  113472. private _bodyUpdateRequired;
  113473. private _onBeforePhysicsStepCallbacks;
  113474. private _onAfterPhysicsStepCallbacks;
  113475. /** @hidden */
  113476. _onPhysicsCollideCallbacks: Array<{
  113477. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113478. otherImpostors: Array<PhysicsImpostor>;
  113479. }>;
  113480. private _deltaPosition;
  113481. private _deltaRotation;
  113482. private _deltaRotationConjugated;
  113483. /** @hidden */
  113484. _isFromLine: boolean;
  113485. private _parent;
  113486. private _isDisposed;
  113487. private static _tmpVecs;
  113488. private static _tmpQuat;
  113489. /**
  113490. * Specifies if the physics imposter is disposed
  113491. */
  113492. get isDisposed(): boolean;
  113493. /**
  113494. * Gets the mass of the physics imposter
  113495. */
  113496. get mass(): number;
  113497. set mass(value: number);
  113498. /**
  113499. * Gets the coefficient of friction
  113500. */
  113501. get friction(): number;
  113502. /**
  113503. * Sets the coefficient of friction
  113504. */
  113505. set friction(value: number);
  113506. /**
  113507. * Gets the coefficient of restitution
  113508. */
  113509. get restitution(): number;
  113510. /**
  113511. * Sets the coefficient of restitution
  113512. */
  113513. set restitution(value: number);
  113514. /**
  113515. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113516. */
  113517. get pressure(): number;
  113518. /**
  113519. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113520. */
  113521. set pressure(value: number);
  113522. /**
  113523. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113524. */
  113525. get stiffness(): number;
  113526. /**
  113527. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113528. */
  113529. set stiffness(value: number);
  113530. /**
  113531. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113532. */
  113533. get velocityIterations(): number;
  113534. /**
  113535. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113536. */
  113537. set velocityIterations(value: number);
  113538. /**
  113539. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113540. */
  113541. get positionIterations(): number;
  113542. /**
  113543. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113544. */
  113545. set positionIterations(value: number);
  113546. /**
  113547. * The unique id of the physics imposter
  113548. * set by the physics engine when adding this impostor to the array
  113549. */
  113550. uniqueId: number;
  113551. /**
  113552. * @hidden
  113553. */
  113554. soft: boolean;
  113555. /**
  113556. * @hidden
  113557. */
  113558. segments: number;
  113559. private _joints;
  113560. /**
  113561. * Initializes the physics imposter
  113562. * @param object The physics-enabled object used as the physics imposter
  113563. * @param type The type of the physics imposter
  113564. * @param _options The options for the physics imposter
  113565. * @param _scene The Babylon scene
  113566. */
  113567. constructor(
  113568. /**
  113569. * The physics-enabled object used as the physics imposter
  113570. */
  113571. object: IPhysicsEnabledObject,
  113572. /**
  113573. * The type of the physics imposter
  113574. */
  113575. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113576. /**
  113577. * This function will completly initialize this impostor.
  113578. * It will create a new body - but only if this mesh has no parent.
  113579. * If it has, this impostor will not be used other than to define the impostor
  113580. * of the child mesh.
  113581. * @hidden
  113582. */
  113583. _init(): void;
  113584. private _getPhysicsParent;
  113585. /**
  113586. * Should a new body be generated.
  113587. * @returns boolean specifying if body initialization is required
  113588. */
  113589. isBodyInitRequired(): boolean;
  113590. /**
  113591. * Sets the updated scaling
  113592. * @param updated Specifies if the scaling is updated
  113593. */
  113594. setScalingUpdated(): void;
  113595. /**
  113596. * Force a regeneration of this or the parent's impostor's body.
  113597. * Use under cautious - This will remove all joints already implemented.
  113598. */
  113599. forceUpdate(): void;
  113600. /**
  113601. * Gets the body that holds this impostor. Either its own, or its parent.
  113602. */
  113603. get physicsBody(): any;
  113604. /**
  113605. * Get the parent of the physics imposter
  113606. * @returns Physics imposter or null
  113607. */
  113608. get parent(): Nullable<PhysicsImpostor>;
  113609. /**
  113610. * Sets the parent of the physics imposter
  113611. */
  113612. set parent(value: Nullable<PhysicsImpostor>);
  113613. /**
  113614. * Set the physics body. Used mainly by the physics engine/plugin
  113615. */
  113616. set physicsBody(physicsBody: any);
  113617. /**
  113618. * Resets the update flags
  113619. */
  113620. resetUpdateFlags(): void;
  113621. /**
  113622. * Gets the object extend size
  113623. * @returns the object extend size
  113624. */
  113625. getObjectExtendSize(): Vector3;
  113626. /**
  113627. * Gets the object center
  113628. * @returns The object center
  113629. */
  113630. getObjectCenter(): Vector3;
  113631. /**
  113632. * Get a specific parameter from the options parameters
  113633. * @param paramName The object parameter name
  113634. * @returns The object parameter
  113635. */
  113636. getParam(paramName: string): any;
  113637. /**
  113638. * Sets a specific parameter in the options given to the physics plugin
  113639. * @param paramName The parameter name
  113640. * @param value The value of the parameter
  113641. */
  113642. setParam(paramName: string, value: number): void;
  113643. /**
  113644. * Specifically change the body's mass option. Won't recreate the physics body object
  113645. * @param mass The mass of the physics imposter
  113646. */
  113647. setMass(mass: number): void;
  113648. /**
  113649. * Gets the linear velocity
  113650. * @returns linear velocity or null
  113651. */
  113652. getLinearVelocity(): Nullable<Vector3>;
  113653. /**
  113654. * Sets the linear velocity
  113655. * @param velocity linear velocity or null
  113656. */
  113657. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113658. /**
  113659. * Gets the angular velocity
  113660. * @returns angular velocity or null
  113661. */
  113662. getAngularVelocity(): Nullable<Vector3>;
  113663. /**
  113664. * Sets the angular velocity
  113665. * @param velocity The velocity or null
  113666. */
  113667. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113668. /**
  113669. * Execute a function with the physics plugin native code
  113670. * Provide a function the will have two variables - the world object and the physics body object
  113671. * @param func The function to execute with the physics plugin native code
  113672. */
  113673. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113674. /**
  113675. * Register a function that will be executed before the physics world is stepping forward
  113676. * @param func The function to execute before the physics world is stepped forward
  113677. */
  113678. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113679. /**
  113680. * Unregister a function that will be executed before the physics world is stepping forward
  113681. * @param func The function to execute before the physics world is stepped forward
  113682. */
  113683. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113684. /**
  113685. * Register a function that will be executed after the physics step
  113686. * @param func The function to execute after physics step
  113687. */
  113688. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113689. /**
  113690. * Unregisters a function that will be executed after the physics step
  113691. * @param func The function to execute after physics step
  113692. */
  113693. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113694. /**
  113695. * register a function that will be executed when this impostor collides against a different body
  113696. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113697. * @param func Callback that is executed on collision
  113698. */
  113699. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113700. /**
  113701. * Unregisters the physics imposter on contact
  113702. * @param collideAgainst The physics object to collide against
  113703. * @param func Callback to execute on collision
  113704. */
  113705. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113706. private _tmpQuat;
  113707. private _tmpQuat2;
  113708. /**
  113709. * Get the parent rotation
  113710. * @returns The parent rotation
  113711. */
  113712. getParentsRotation(): Quaternion;
  113713. /**
  113714. * this function is executed by the physics engine.
  113715. */
  113716. beforeStep: () => void;
  113717. /**
  113718. * this function is executed by the physics engine
  113719. */
  113720. afterStep: () => void;
  113721. /**
  113722. * Legacy collision detection event support
  113723. */
  113724. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113725. /**
  113726. * event and body object due to cannon's event-based architecture.
  113727. */
  113728. onCollide: (e: {
  113729. body: any;
  113730. point: Nullable<Vector3>;
  113731. }) => void;
  113732. /**
  113733. * Apply a force
  113734. * @param force The force to apply
  113735. * @param contactPoint The contact point for the force
  113736. * @returns The physics imposter
  113737. */
  113738. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113739. /**
  113740. * Apply an impulse
  113741. * @param force The impulse force
  113742. * @param contactPoint The contact point for the impulse force
  113743. * @returns The physics imposter
  113744. */
  113745. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113746. /**
  113747. * A help function to create a joint
  113748. * @param otherImpostor A physics imposter used to create a joint
  113749. * @param jointType The type of joint
  113750. * @param jointData The data for the joint
  113751. * @returns The physics imposter
  113752. */
  113753. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113754. /**
  113755. * Add a joint to this impostor with a different impostor
  113756. * @param otherImpostor A physics imposter used to add a joint
  113757. * @param joint The joint to add
  113758. * @returns The physics imposter
  113759. */
  113760. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113761. /**
  113762. * Add an anchor to a cloth impostor
  113763. * @param otherImpostor rigid impostor to anchor to
  113764. * @param width ratio across width from 0 to 1
  113765. * @param height ratio up height from 0 to 1
  113766. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113767. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113768. * @returns impostor the soft imposter
  113769. */
  113770. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113771. /**
  113772. * Add a hook to a rope impostor
  113773. * @param otherImpostor rigid impostor to anchor to
  113774. * @param length ratio across rope from 0 to 1
  113775. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113776. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113777. * @returns impostor the rope imposter
  113778. */
  113779. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113780. /**
  113781. * Will keep this body still, in a sleep mode.
  113782. * @returns the physics imposter
  113783. */
  113784. sleep(): PhysicsImpostor;
  113785. /**
  113786. * Wake the body up.
  113787. * @returns The physics imposter
  113788. */
  113789. wakeUp(): PhysicsImpostor;
  113790. /**
  113791. * Clones the physics imposter
  113792. * @param newObject The physics imposter clones to this physics-enabled object
  113793. * @returns A nullable physics imposter
  113794. */
  113795. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113796. /**
  113797. * Disposes the physics imposter
  113798. */
  113799. dispose(): void;
  113800. /**
  113801. * Sets the delta position
  113802. * @param position The delta position amount
  113803. */
  113804. setDeltaPosition(position: Vector3): void;
  113805. /**
  113806. * Sets the delta rotation
  113807. * @param rotation The delta rotation amount
  113808. */
  113809. setDeltaRotation(rotation: Quaternion): void;
  113810. /**
  113811. * Gets the box size of the physics imposter and stores the result in the input parameter
  113812. * @param result Stores the box size
  113813. * @returns The physics imposter
  113814. */
  113815. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113816. /**
  113817. * Gets the radius of the physics imposter
  113818. * @returns Radius of the physics imposter
  113819. */
  113820. getRadius(): number;
  113821. /**
  113822. * Sync a bone with this impostor
  113823. * @param bone The bone to sync to the impostor.
  113824. * @param boneMesh The mesh that the bone is influencing.
  113825. * @param jointPivot The pivot of the joint / bone in local space.
  113826. * @param distToJoint Optional distance from the impostor to the joint.
  113827. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113828. */
  113829. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113830. /**
  113831. * Sync impostor to a bone
  113832. * @param bone The bone that the impostor will be synced to.
  113833. * @param boneMesh The mesh that the bone is influencing.
  113834. * @param jointPivot The pivot of the joint / bone in local space.
  113835. * @param distToJoint Optional distance from the impostor to the joint.
  113836. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113837. * @param boneAxis Optional vector3 axis the bone is aligned with
  113838. */
  113839. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113840. /**
  113841. * No-Imposter type
  113842. */
  113843. static NoImpostor: number;
  113844. /**
  113845. * Sphere-Imposter type
  113846. */
  113847. static SphereImpostor: number;
  113848. /**
  113849. * Box-Imposter type
  113850. */
  113851. static BoxImpostor: number;
  113852. /**
  113853. * Plane-Imposter type
  113854. */
  113855. static PlaneImpostor: number;
  113856. /**
  113857. * Mesh-imposter type
  113858. */
  113859. static MeshImpostor: number;
  113860. /**
  113861. * Capsule-Impostor type (Ammo.js plugin only)
  113862. */
  113863. static CapsuleImpostor: number;
  113864. /**
  113865. * Cylinder-Imposter type
  113866. */
  113867. static CylinderImpostor: number;
  113868. /**
  113869. * Particle-Imposter type
  113870. */
  113871. static ParticleImpostor: number;
  113872. /**
  113873. * Heightmap-Imposter type
  113874. */
  113875. static HeightmapImpostor: number;
  113876. /**
  113877. * ConvexHull-Impostor type (Ammo.js plugin only)
  113878. */
  113879. static ConvexHullImpostor: number;
  113880. /**
  113881. * Custom-Imposter type (Ammo.js plugin only)
  113882. */
  113883. static CustomImpostor: number;
  113884. /**
  113885. * Rope-Imposter type
  113886. */
  113887. static RopeImpostor: number;
  113888. /**
  113889. * Cloth-Imposter type
  113890. */
  113891. static ClothImpostor: number;
  113892. /**
  113893. * Softbody-Imposter type
  113894. */
  113895. static SoftbodyImpostor: number;
  113896. }
  113897. }
  113898. declare module BABYLON {
  113899. /**
  113900. * @hidden
  113901. **/
  113902. export class _CreationDataStorage {
  113903. closePath?: boolean;
  113904. closeArray?: boolean;
  113905. idx: number[];
  113906. dashSize: number;
  113907. gapSize: number;
  113908. path3D: Path3D;
  113909. pathArray: Vector3[][];
  113910. arc: number;
  113911. radius: number;
  113912. cap: number;
  113913. tessellation: number;
  113914. }
  113915. /**
  113916. * @hidden
  113917. **/
  113918. class _InstanceDataStorage {
  113919. visibleInstances: any;
  113920. batchCache: _InstancesBatch;
  113921. instancesBufferSize: number;
  113922. instancesBuffer: Nullable<Buffer>;
  113923. instancesData: Float32Array;
  113924. overridenInstanceCount: number;
  113925. isFrozen: boolean;
  113926. previousBatch: Nullable<_InstancesBatch>;
  113927. hardwareInstancedRendering: boolean;
  113928. sideOrientation: number;
  113929. manualUpdate: boolean;
  113930. previousRenderId: number;
  113931. }
  113932. /**
  113933. * @hidden
  113934. **/
  113935. export class _InstancesBatch {
  113936. mustReturn: boolean;
  113937. visibleInstances: Nullable<InstancedMesh[]>[];
  113938. renderSelf: boolean[];
  113939. hardwareInstancedRendering: boolean[];
  113940. }
  113941. /**
  113942. * @hidden
  113943. **/
  113944. class _ThinInstanceDataStorage {
  113945. instancesCount: number;
  113946. matrixBuffer: Nullable<Buffer>;
  113947. matrixBufferSize: number;
  113948. matrixData: Nullable<Float32Array>;
  113949. boundingVectors: Array<Vector3>;
  113950. worldMatrices: Nullable<Matrix[]>;
  113951. }
  113952. /**
  113953. * Class used to represent renderable models
  113954. */
  113955. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113956. /**
  113957. * Mesh side orientation : usually the external or front surface
  113958. */
  113959. static readonly FRONTSIDE: number;
  113960. /**
  113961. * Mesh side orientation : usually the internal or back surface
  113962. */
  113963. static readonly BACKSIDE: number;
  113964. /**
  113965. * Mesh side orientation : both internal and external or front and back surfaces
  113966. */
  113967. static readonly DOUBLESIDE: number;
  113968. /**
  113969. * Mesh side orientation : by default, `FRONTSIDE`
  113970. */
  113971. static readonly DEFAULTSIDE: number;
  113972. /**
  113973. * Mesh cap setting : no cap
  113974. */
  113975. static readonly NO_CAP: number;
  113976. /**
  113977. * Mesh cap setting : one cap at the beginning of the mesh
  113978. */
  113979. static readonly CAP_START: number;
  113980. /**
  113981. * Mesh cap setting : one cap at the end of the mesh
  113982. */
  113983. static readonly CAP_END: number;
  113984. /**
  113985. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113986. */
  113987. static readonly CAP_ALL: number;
  113988. /**
  113989. * Mesh pattern setting : no flip or rotate
  113990. */
  113991. static readonly NO_FLIP: number;
  113992. /**
  113993. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113994. */
  113995. static readonly FLIP_TILE: number;
  113996. /**
  113997. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113998. */
  113999. static readonly ROTATE_TILE: number;
  114000. /**
  114001. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  114002. */
  114003. static readonly FLIP_ROW: number;
  114004. /**
  114005. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  114006. */
  114007. static readonly ROTATE_ROW: number;
  114008. /**
  114009. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  114010. */
  114011. static readonly FLIP_N_ROTATE_TILE: number;
  114012. /**
  114013. * Mesh pattern setting : rotate pattern and rotate
  114014. */
  114015. static readonly FLIP_N_ROTATE_ROW: number;
  114016. /**
  114017. * Mesh tile positioning : part tiles same on left/right or top/bottom
  114018. */
  114019. static readonly CENTER: number;
  114020. /**
  114021. * Mesh tile positioning : part tiles on left
  114022. */
  114023. static readonly LEFT: number;
  114024. /**
  114025. * Mesh tile positioning : part tiles on right
  114026. */
  114027. static readonly RIGHT: number;
  114028. /**
  114029. * Mesh tile positioning : part tiles on top
  114030. */
  114031. static readonly TOP: number;
  114032. /**
  114033. * Mesh tile positioning : part tiles on bottom
  114034. */
  114035. static readonly BOTTOM: number;
  114036. /**
  114037. * Gets the default side orientation.
  114038. * @param orientation the orientation to value to attempt to get
  114039. * @returns the default orientation
  114040. * @hidden
  114041. */
  114042. static _GetDefaultSideOrientation(orientation?: number): number;
  114043. private _internalMeshDataInfo;
  114044. get computeBonesUsingShaders(): boolean;
  114045. set computeBonesUsingShaders(value: boolean);
  114046. /**
  114047. * An event triggered before rendering the mesh
  114048. */
  114049. get onBeforeRenderObservable(): Observable<Mesh>;
  114050. /**
  114051. * An event triggered before binding the mesh
  114052. */
  114053. get onBeforeBindObservable(): Observable<Mesh>;
  114054. /**
  114055. * An event triggered after rendering the mesh
  114056. */
  114057. get onAfterRenderObservable(): Observable<Mesh>;
  114058. /**
  114059. * An event triggered before drawing the mesh
  114060. */
  114061. get onBeforeDrawObservable(): Observable<Mesh>;
  114062. private _onBeforeDrawObserver;
  114063. /**
  114064. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  114065. */
  114066. set onBeforeDraw(callback: () => void);
  114067. get hasInstances(): boolean;
  114068. get hasThinInstances(): boolean;
  114069. /**
  114070. * Gets the delay loading state of the mesh (when delay loading is turned on)
  114071. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  114072. */
  114073. delayLoadState: number;
  114074. /**
  114075. * Gets the list of instances created from this mesh
  114076. * it is not supposed to be modified manually.
  114077. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  114078. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114079. */
  114080. instances: InstancedMesh[];
  114081. /**
  114082. * Gets the file containing delay loading data for this mesh
  114083. */
  114084. delayLoadingFile: string;
  114085. /** @hidden */
  114086. _binaryInfo: any;
  114087. /**
  114088. * User defined function used to change how LOD level selection is done
  114089. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114090. */
  114091. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  114092. /**
  114093. * Gets or sets the morph target manager
  114094. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  114095. */
  114096. get morphTargetManager(): Nullable<MorphTargetManager>;
  114097. set morphTargetManager(value: Nullable<MorphTargetManager>);
  114098. /** @hidden */
  114099. _creationDataStorage: Nullable<_CreationDataStorage>;
  114100. /** @hidden */
  114101. _geometry: Nullable<Geometry>;
  114102. /** @hidden */
  114103. _delayInfo: Array<string>;
  114104. /** @hidden */
  114105. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  114106. /** @hidden */
  114107. _instanceDataStorage: _InstanceDataStorage;
  114108. /** @hidden */
  114109. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  114110. private _effectiveMaterial;
  114111. /** @hidden */
  114112. _shouldGenerateFlatShading: boolean;
  114113. /** @hidden */
  114114. _originalBuilderSideOrientation: number;
  114115. /**
  114116. * Use this property to change the original side orientation defined at construction time
  114117. */
  114118. overrideMaterialSideOrientation: Nullable<number>;
  114119. /**
  114120. * Gets the source mesh (the one used to clone this one from)
  114121. */
  114122. get source(): Nullable<Mesh>;
  114123. /**
  114124. * Gets the list of clones of this mesh
  114125. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  114126. * Note that useClonedMeshMap=true is the default setting
  114127. */
  114128. get cloneMeshMap(): Nullable<{
  114129. [id: string]: Mesh | undefined;
  114130. }>;
  114131. /**
  114132. * Gets or sets a boolean indicating that this mesh does not use index buffer
  114133. */
  114134. get isUnIndexed(): boolean;
  114135. set isUnIndexed(value: boolean);
  114136. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  114137. get worldMatrixInstancedBuffer(): Float32Array;
  114138. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  114139. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  114140. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  114141. /**
  114142. * @constructor
  114143. * @param name The value used by scene.getMeshByName() to do a lookup.
  114144. * @param scene The scene to add this mesh to.
  114145. * @param parent The parent of this mesh, if it has one
  114146. * @param source An optional Mesh from which geometry is shared, cloned.
  114147. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114148. * When false, achieved by calling a clone(), also passing False.
  114149. * This will make creation of children, recursive.
  114150. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  114151. */
  114152. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  114153. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  114154. doNotInstantiate: boolean;
  114155. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  114156. /**
  114157. * Gets the class name
  114158. * @returns the string "Mesh".
  114159. */
  114160. getClassName(): string;
  114161. /** @hidden */
  114162. get _isMesh(): boolean;
  114163. /**
  114164. * Returns a description of this mesh
  114165. * @param fullDetails define if full details about this mesh must be used
  114166. * @returns a descriptive string representing this mesh
  114167. */
  114168. toString(fullDetails?: boolean): string;
  114169. /** @hidden */
  114170. _unBindEffect(): void;
  114171. /**
  114172. * Gets a boolean indicating if this mesh has LOD
  114173. */
  114174. get hasLODLevels(): boolean;
  114175. /**
  114176. * Gets the list of MeshLODLevel associated with the current mesh
  114177. * @returns an array of MeshLODLevel
  114178. */
  114179. getLODLevels(): MeshLODLevel[];
  114180. private _sortLODLevels;
  114181. /**
  114182. * Add a mesh as LOD level triggered at the given distance.
  114183. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114184. * @param distance The distance from the center of the object to show this level
  114185. * @param mesh The mesh to be added as LOD level (can be null)
  114186. * @return This mesh (for chaining)
  114187. */
  114188. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  114189. /**
  114190. * Returns the LOD level mesh at the passed distance or null if not found.
  114191. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114192. * @param distance The distance from the center of the object to show this level
  114193. * @returns a Mesh or `null`
  114194. */
  114195. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  114196. /**
  114197. * Remove a mesh from the LOD array
  114198. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114199. * @param mesh defines the mesh to be removed
  114200. * @return This mesh (for chaining)
  114201. */
  114202. removeLODLevel(mesh: Mesh): Mesh;
  114203. /**
  114204. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  114205. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114206. * @param camera defines the camera to use to compute distance
  114207. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  114208. * @return This mesh (for chaining)
  114209. */
  114210. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  114211. /**
  114212. * Gets the mesh internal Geometry object
  114213. */
  114214. get geometry(): Nullable<Geometry>;
  114215. /**
  114216. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  114217. * @returns the total number of vertices
  114218. */
  114219. getTotalVertices(): number;
  114220. /**
  114221. * Returns the content of an associated vertex buffer
  114222. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114223. * - VertexBuffer.PositionKind
  114224. * - VertexBuffer.UVKind
  114225. * - VertexBuffer.UV2Kind
  114226. * - VertexBuffer.UV3Kind
  114227. * - VertexBuffer.UV4Kind
  114228. * - VertexBuffer.UV5Kind
  114229. * - VertexBuffer.UV6Kind
  114230. * - VertexBuffer.ColorKind
  114231. * - VertexBuffer.MatricesIndicesKind
  114232. * - VertexBuffer.MatricesIndicesExtraKind
  114233. * - VertexBuffer.MatricesWeightsKind
  114234. * - VertexBuffer.MatricesWeightsExtraKind
  114235. * @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
  114236. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114237. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114238. */
  114239. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114240. /**
  114241. * Returns the mesh VertexBuffer object from the requested `kind`
  114242. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114243. * - VertexBuffer.PositionKind
  114244. * - VertexBuffer.NormalKind
  114245. * - VertexBuffer.UVKind
  114246. * - VertexBuffer.UV2Kind
  114247. * - VertexBuffer.UV3Kind
  114248. * - VertexBuffer.UV4Kind
  114249. * - VertexBuffer.UV5Kind
  114250. * - VertexBuffer.UV6Kind
  114251. * - VertexBuffer.ColorKind
  114252. * - VertexBuffer.MatricesIndicesKind
  114253. * - VertexBuffer.MatricesIndicesExtraKind
  114254. * - VertexBuffer.MatricesWeightsKind
  114255. * - VertexBuffer.MatricesWeightsExtraKind
  114256. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114257. */
  114258. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114259. /**
  114260. * Tests if a specific vertex buffer is associated with this mesh
  114261. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114262. * - VertexBuffer.PositionKind
  114263. * - VertexBuffer.NormalKind
  114264. * - VertexBuffer.UVKind
  114265. * - VertexBuffer.UV2Kind
  114266. * - VertexBuffer.UV3Kind
  114267. * - VertexBuffer.UV4Kind
  114268. * - VertexBuffer.UV5Kind
  114269. * - VertexBuffer.UV6Kind
  114270. * - VertexBuffer.ColorKind
  114271. * - VertexBuffer.MatricesIndicesKind
  114272. * - VertexBuffer.MatricesIndicesExtraKind
  114273. * - VertexBuffer.MatricesWeightsKind
  114274. * - VertexBuffer.MatricesWeightsExtraKind
  114275. * @returns a boolean
  114276. */
  114277. isVerticesDataPresent(kind: string): boolean;
  114278. /**
  114279. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114280. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114281. * - VertexBuffer.PositionKind
  114282. * - VertexBuffer.UVKind
  114283. * - VertexBuffer.UV2Kind
  114284. * - VertexBuffer.UV3Kind
  114285. * - VertexBuffer.UV4Kind
  114286. * - VertexBuffer.UV5Kind
  114287. * - VertexBuffer.UV6Kind
  114288. * - VertexBuffer.ColorKind
  114289. * - VertexBuffer.MatricesIndicesKind
  114290. * - VertexBuffer.MatricesIndicesExtraKind
  114291. * - VertexBuffer.MatricesWeightsKind
  114292. * - VertexBuffer.MatricesWeightsExtraKind
  114293. * @returns a boolean
  114294. */
  114295. isVertexBufferUpdatable(kind: string): boolean;
  114296. /**
  114297. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114298. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114299. * - VertexBuffer.PositionKind
  114300. * - VertexBuffer.NormalKind
  114301. * - VertexBuffer.UVKind
  114302. * - VertexBuffer.UV2Kind
  114303. * - VertexBuffer.UV3Kind
  114304. * - VertexBuffer.UV4Kind
  114305. * - VertexBuffer.UV5Kind
  114306. * - VertexBuffer.UV6Kind
  114307. * - VertexBuffer.ColorKind
  114308. * - VertexBuffer.MatricesIndicesKind
  114309. * - VertexBuffer.MatricesIndicesExtraKind
  114310. * - VertexBuffer.MatricesWeightsKind
  114311. * - VertexBuffer.MatricesWeightsExtraKind
  114312. * @returns an array of strings
  114313. */
  114314. getVerticesDataKinds(): string[];
  114315. /**
  114316. * Returns a positive integer : the total number of indices in this mesh geometry.
  114317. * @returns the numner of indices or zero if the mesh has no geometry.
  114318. */
  114319. getTotalIndices(): number;
  114320. /**
  114321. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114322. * @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.
  114323. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114324. * @returns the indices array or an empty array if the mesh has no geometry
  114325. */
  114326. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114327. get isBlocked(): boolean;
  114328. /**
  114329. * Determine if the current mesh is ready to be rendered
  114330. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114331. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114332. * @returns true if all associated assets are ready (material, textures, shaders)
  114333. */
  114334. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114335. /**
  114336. * 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.
  114337. */
  114338. get areNormalsFrozen(): boolean;
  114339. /**
  114340. * 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.
  114341. * @returns the current mesh
  114342. */
  114343. freezeNormals(): Mesh;
  114344. /**
  114345. * 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
  114346. * @returns the current mesh
  114347. */
  114348. unfreezeNormals(): Mesh;
  114349. /**
  114350. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114351. */
  114352. set overridenInstanceCount(count: number);
  114353. /** @hidden */
  114354. _preActivate(): Mesh;
  114355. /** @hidden */
  114356. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114357. /** @hidden */
  114358. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114359. protected _afterComputeWorldMatrix(): void;
  114360. /** @hidden */
  114361. _postActivate(): void;
  114362. /**
  114363. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114364. * This means the mesh underlying bounding box and sphere are recomputed.
  114365. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114366. * @returns the current mesh
  114367. */
  114368. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114369. /** @hidden */
  114370. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114371. /**
  114372. * This function will subdivide the mesh into multiple submeshes
  114373. * @param count defines the expected number of submeshes
  114374. */
  114375. subdivide(count: number): void;
  114376. /**
  114377. * Copy a FloatArray into a specific associated vertex buffer
  114378. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114379. * - VertexBuffer.PositionKind
  114380. * - VertexBuffer.UVKind
  114381. * - VertexBuffer.UV2Kind
  114382. * - VertexBuffer.UV3Kind
  114383. * - VertexBuffer.UV4Kind
  114384. * - VertexBuffer.UV5Kind
  114385. * - VertexBuffer.UV6Kind
  114386. * - VertexBuffer.ColorKind
  114387. * - VertexBuffer.MatricesIndicesKind
  114388. * - VertexBuffer.MatricesIndicesExtraKind
  114389. * - VertexBuffer.MatricesWeightsKind
  114390. * - VertexBuffer.MatricesWeightsExtraKind
  114391. * @param data defines the data source
  114392. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114393. * @param stride defines the data stride size (can be null)
  114394. * @returns the current mesh
  114395. */
  114396. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114397. /**
  114398. * Delete a vertex buffer associated with this mesh
  114399. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114400. * - VertexBuffer.PositionKind
  114401. * - VertexBuffer.UVKind
  114402. * - VertexBuffer.UV2Kind
  114403. * - VertexBuffer.UV3Kind
  114404. * - VertexBuffer.UV4Kind
  114405. * - VertexBuffer.UV5Kind
  114406. * - VertexBuffer.UV6Kind
  114407. * - VertexBuffer.ColorKind
  114408. * - VertexBuffer.MatricesIndicesKind
  114409. * - VertexBuffer.MatricesIndicesExtraKind
  114410. * - VertexBuffer.MatricesWeightsKind
  114411. * - VertexBuffer.MatricesWeightsExtraKind
  114412. */
  114413. removeVerticesData(kind: string): void;
  114414. /**
  114415. * Flags an associated vertex buffer as updatable
  114416. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114417. * - VertexBuffer.PositionKind
  114418. * - VertexBuffer.UVKind
  114419. * - VertexBuffer.UV2Kind
  114420. * - VertexBuffer.UV3Kind
  114421. * - VertexBuffer.UV4Kind
  114422. * - VertexBuffer.UV5Kind
  114423. * - VertexBuffer.UV6Kind
  114424. * - VertexBuffer.ColorKind
  114425. * - VertexBuffer.MatricesIndicesKind
  114426. * - VertexBuffer.MatricesIndicesExtraKind
  114427. * - VertexBuffer.MatricesWeightsKind
  114428. * - VertexBuffer.MatricesWeightsExtraKind
  114429. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114430. */
  114431. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114432. /**
  114433. * Sets the mesh global Vertex Buffer
  114434. * @param buffer defines the buffer to use
  114435. * @returns the current mesh
  114436. */
  114437. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114438. /**
  114439. * Update a specific associated vertex buffer
  114440. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114441. * - VertexBuffer.PositionKind
  114442. * - VertexBuffer.UVKind
  114443. * - VertexBuffer.UV2Kind
  114444. * - VertexBuffer.UV3Kind
  114445. * - VertexBuffer.UV4Kind
  114446. * - VertexBuffer.UV5Kind
  114447. * - VertexBuffer.UV6Kind
  114448. * - VertexBuffer.ColorKind
  114449. * - VertexBuffer.MatricesIndicesKind
  114450. * - VertexBuffer.MatricesIndicesExtraKind
  114451. * - VertexBuffer.MatricesWeightsKind
  114452. * - VertexBuffer.MatricesWeightsExtraKind
  114453. * @param data defines the data source
  114454. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114455. * @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)
  114456. * @returns the current mesh
  114457. */
  114458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114459. /**
  114460. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114461. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114462. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114463. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114464. * @returns the current mesh
  114465. */
  114466. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114467. /**
  114468. * Creates a un-shared specific occurence of the geometry for the mesh.
  114469. * @returns the current mesh
  114470. */
  114471. makeGeometryUnique(): Mesh;
  114472. /**
  114473. * Set the index buffer of this mesh
  114474. * @param indices defines the source data
  114475. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114476. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114477. * @returns the current mesh
  114478. */
  114479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114480. /**
  114481. * Update the current index buffer
  114482. * @param indices defines the source data
  114483. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114484. * @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)
  114485. * @returns the current mesh
  114486. */
  114487. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114488. /**
  114489. * Invert the geometry to move from a right handed system to a left handed one.
  114490. * @returns the current mesh
  114491. */
  114492. toLeftHanded(): Mesh;
  114493. /** @hidden */
  114494. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114495. /** @hidden */
  114496. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114497. /**
  114498. * Registers for this mesh a javascript function called just before the rendering process
  114499. * @param func defines the function to call before rendering this mesh
  114500. * @returns the current mesh
  114501. */
  114502. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114503. /**
  114504. * Disposes a previously registered javascript function called before the rendering
  114505. * @param func defines the function to remove
  114506. * @returns the current mesh
  114507. */
  114508. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114509. /**
  114510. * Registers for this mesh a javascript function called just after the rendering is complete
  114511. * @param func defines the function to call after rendering this mesh
  114512. * @returns the current mesh
  114513. */
  114514. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114515. /**
  114516. * Disposes a previously registered javascript function called after the rendering.
  114517. * @param func defines the function to remove
  114518. * @returns the current mesh
  114519. */
  114520. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114521. /** @hidden */
  114522. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114523. /** @hidden */
  114524. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114525. /** @hidden */
  114526. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114527. /** @hidden */
  114528. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114529. /** @hidden */
  114530. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114531. /** @hidden */
  114532. _rebuild(): void;
  114533. /** @hidden */
  114534. _freeze(): void;
  114535. /** @hidden */
  114536. _unFreeze(): void;
  114537. /**
  114538. * 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
  114539. * @param subMesh defines the subMesh to render
  114540. * @param enableAlphaMode defines if alpha mode can be changed
  114541. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114542. * @returns the current mesh
  114543. */
  114544. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114545. private _onBeforeDraw;
  114546. /**
  114547. * Renormalize the mesh and patch it up if there are no weights
  114548. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114549. * However in the case of zero weights then we set just a single influence to 1.
  114550. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114551. */
  114552. cleanMatrixWeights(): void;
  114553. private normalizeSkinFourWeights;
  114554. private normalizeSkinWeightsAndExtra;
  114555. /**
  114556. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114557. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114558. * the user know there was an issue with importing the mesh
  114559. * @returns a validation object with skinned, valid and report string
  114560. */
  114561. validateSkinning(): {
  114562. skinned: boolean;
  114563. valid: boolean;
  114564. report: string;
  114565. };
  114566. /** @hidden */
  114567. _checkDelayState(): Mesh;
  114568. private _queueLoad;
  114569. /**
  114570. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114571. * A mesh is in the frustum if its bounding box intersects the frustum
  114572. * @param frustumPlanes defines the frustum to test
  114573. * @returns true if the mesh is in the frustum planes
  114574. */
  114575. isInFrustum(frustumPlanes: Plane[]): boolean;
  114576. /**
  114577. * Sets the mesh material by the material or multiMaterial `id` property
  114578. * @param id is a string identifying the material or the multiMaterial
  114579. * @returns the current mesh
  114580. */
  114581. setMaterialByID(id: string): Mesh;
  114582. /**
  114583. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114584. * @returns an array of IAnimatable
  114585. */
  114586. getAnimatables(): IAnimatable[];
  114587. /**
  114588. * Modifies the mesh geometry according to the passed transformation matrix.
  114589. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114590. * The mesh normals are modified using the same transformation.
  114591. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114592. * @param transform defines the transform matrix to use
  114593. * @see https://doc.babylonjs.com/resources/baking_transformations
  114594. * @returns the current mesh
  114595. */
  114596. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114597. /**
  114598. * Modifies the mesh geometry according to its own current World Matrix.
  114599. * The mesh World Matrix is then reset.
  114600. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114601. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114602. * @see https://doc.babylonjs.com/resources/baking_transformations
  114603. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114604. * @returns the current mesh
  114605. */
  114606. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114607. /** @hidden */
  114608. get _positions(): Nullable<Vector3[]>;
  114609. /** @hidden */
  114610. _resetPointsArrayCache(): Mesh;
  114611. /** @hidden */
  114612. _generatePointsArray(): boolean;
  114613. /**
  114614. * Returns a new Mesh object generated from the current mesh properties.
  114615. * This method must not get confused with createInstance()
  114616. * @param name is a string, the name given to the new mesh
  114617. * @param newParent can be any Node object (default `null`)
  114618. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114619. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114620. * @returns a new mesh
  114621. */
  114622. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114623. /**
  114624. * Releases resources associated with this mesh.
  114625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114627. */
  114628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114629. /** @hidden */
  114630. _disposeInstanceSpecificData(): void;
  114631. /** @hidden */
  114632. _disposeThinInstanceSpecificData(): void;
  114633. /**
  114634. * Modifies the mesh geometry according to a displacement map.
  114635. * 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.
  114636. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114637. * @param url is a string, the URL from the image file is to be downloaded.
  114638. * @param minHeight is the lower limit of the displacement.
  114639. * @param maxHeight is the upper limit of the displacement.
  114640. * @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.
  114641. * @param uvOffset is an optional vector2 used to offset UV.
  114642. * @param uvScale is an optional vector2 used to scale UV.
  114643. * @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.
  114644. * @returns the Mesh.
  114645. */
  114646. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114647. /**
  114648. * Modifies the mesh geometry according to a displacementMap buffer.
  114649. * 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.
  114650. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114651. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114652. * @param heightMapWidth is the width of the buffer image.
  114653. * @param heightMapHeight is the height of the buffer image.
  114654. * @param minHeight is the lower limit of the displacement.
  114655. * @param maxHeight is the upper limit of the displacement.
  114656. * @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.
  114657. * @param uvOffset is an optional vector2 used to offset UV.
  114658. * @param uvScale is an optional vector2 used to scale UV.
  114659. * @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.
  114660. * @returns the Mesh.
  114661. */
  114662. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114663. /**
  114664. * Modify the mesh to get a flat shading rendering.
  114665. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114666. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114667. * @returns current mesh
  114668. */
  114669. convertToFlatShadedMesh(): Mesh;
  114670. /**
  114671. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114672. * In other words, more vertices, no more indices and a single bigger VBO.
  114673. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114674. * @returns current mesh
  114675. */
  114676. convertToUnIndexedMesh(): Mesh;
  114677. /**
  114678. * Inverses facet orientations.
  114679. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114680. * @param flipNormals will also inverts the normals
  114681. * @returns current mesh
  114682. */
  114683. flipFaces(flipNormals?: boolean): Mesh;
  114684. /**
  114685. * Increase the number of facets and hence vertices in a mesh
  114686. * Vertex normals are interpolated from existing vertex normals
  114687. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114688. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114689. */
  114690. increaseVertices(numberPerEdge: number): void;
  114691. /**
  114692. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114693. * This will undo any application of covertToFlatShadedMesh
  114694. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114695. */
  114696. forceSharedVertices(): void;
  114697. /** @hidden */
  114698. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114699. /** @hidden */
  114700. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114701. /**
  114702. * Creates a new InstancedMesh object from the mesh model.
  114703. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114704. * @param name defines the name of the new instance
  114705. * @returns a new InstancedMesh
  114706. */
  114707. createInstance(name: string): InstancedMesh;
  114708. /**
  114709. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114710. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114711. * @returns the current mesh
  114712. */
  114713. synchronizeInstances(): Mesh;
  114714. /**
  114715. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114716. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114717. * This should be used together with the simplification to avoid disappearing triangles.
  114718. * @param successCallback an optional success callback to be called after the optimization finished.
  114719. * @returns the current mesh
  114720. */
  114721. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114722. /**
  114723. * Serialize current mesh
  114724. * @param serializationObject defines the object which will receive the serialization data
  114725. */
  114726. serialize(serializationObject: any): void;
  114727. /** @hidden */
  114728. _syncGeometryWithMorphTargetManager(): void;
  114729. /** @hidden */
  114730. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114731. /**
  114732. * Returns a new Mesh object parsed from the source provided.
  114733. * @param parsedMesh is the source
  114734. * @param scene defines the hosting scene
  114735. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114736. * @returns a new Mesh
  114737. */
  114738. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114739. /**
  114740. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114742. * @param name defines the name of the mesh to create
  114743. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114744. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114745. * @param closePath creates a seam between the first and the last points of each path of the path array
  114746. * @param offset is taken in account only if the `pathArray` is containing a single path
  114747. * @param scene defines the hosting scene
  114748. * @param updatable defines if the mesh must be flagged as updatable
  114749. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114750. * @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)
  114751. * @returns a new Mesh
  114752. */
  114753. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114754. /**
  114755. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114756. * @param name defines the name of the mesh to create
  114757. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114758. * @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
  114759. * @param scene defines the hosting scene
  114760. * @param updatable defines if the mesh must be flagged as updatable
  114761. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114762. * @returns a new Mesh
  114763. */
  114764. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114765. /**
  114766. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114767. * @param name defines the name of the mesh to create
  114768. * @param size sets the size (float) of each box side (default 1)
  114769. * @param scene defines the hosting scene
  114770. * @param updatable defines if the mesh must be flagged as updatable
  114771. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114772. * @returns a new Mesh
  114773. */
  114774. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114775. /**
  114776. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114777. * @param name defines the name of the mesh to create
  114778. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114779. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114780. * @param scene defines the hosting scene
  114781. * @param updatable defines if the mesh must be flagged as updatable
  114782. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114783. * @returns a new Mesh
  114784. */
  114785. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114786. /**
  114787. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114788. * @param name defines the name of the mesh to create
  114789. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114790. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114791. * @param scene defines the hosting scene
  114792. * @returns a new Mesh
  114793. */
  114794. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114795. /**
  114796. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114797. * @param name defines the name of the mesh to create
  114798. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114799. * @param diameterTop set the top cap diameter (floats, default 1)
  114800. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114801. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114802. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114803. * @param scene defines the hosting scene
  114804. * @param updatable defines if the mesh must be flagged as updatable
  114805. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114806. * @returns a new Mesh
  114807. */
  114808. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114809. /**
  114810. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114811. * @param name defines the name of the mesh to create
  114812. * @param diameter sets the diameter size (float) of the torus (default 1)
  114813. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114814. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114815. * @param scene defines the hosting scene
  114816. * @param updatable defines if the mesh must be flagged as updatable
  114817. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114818. * @returns a new Mesh
  114819. */
  114820. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114821. /**
  114822. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114823. * @param name defines the name of the mesh to create
  114824. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114825. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114826. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114827. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114828. * @param p the number of windings on X axis (positive integers, default 2)
  114829. * @param q the number of windings on Y axis (positive integers, default 3)
  114830. * @param scene defines the hosting scene
  114831. * @param updatable defines if the mesh must be flagged as updatable
  114832. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114833. * @returns a new Mesh
  114834. */
  114835. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114836. /**
  114837. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114838. * @param name defines the name of the mesh to create
  114839. * @param points is an array successive Vector3
  114840. * @param scene defines the hosting scene
  114841. * @param updatable defines if the mesh must be flagged as updatable
  114842. * @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).
  114843. * @returns a new Mesh
  114844. */
  114845. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114846. /**
  114847. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114848. * @param name defines the name of the mesh to create
  114849. * @param points is an array successive Vector3
  114850. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114851. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114852. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114853. * @param scene defines the hosting scene
  114854. * @param updatable defines if the mesh must be flagged as updatable
  114855. * @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)
  114856. * @returns a new Mesh
  114857. */
  114858. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114859. /**
  114860. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114861. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114862. * 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.
  114863. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114864. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114865. * Remember you can only change the shape positions, not their number when updating a polygon.
  114866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114867. * @param name defines the name of the mesh to create
  114868. * @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
  114869. * @param scene defines the hosting scene
  114870. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114871. * @param updatable defines if the mesh must be flagged as updatable
  114872. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114873. * @param earcutInjection can be used to inject your own earcut reference
  114874. * @returns a new Mesh
  114875. */
  114876. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114877. /**
  114878. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114880. * @param name defines the name of the mesh to create
  114881. * @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
  114882. * @param depth defines the height of extrusion
  114883. * @param scene defines the hosting scene
  114884. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114885. * @param updatable defines if the mesh must be flagged as updatable
  114886. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114887. * @param earcutInjection can be used to inject your own earcut reference
  114888. * @returns a new Mesh
  114889. */
  114890. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114891. /**
  114892. * Creates an extruded shape mesh.
  114893. * 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
  114894. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114896. * @param name defines the name of the mesh to create
  114897. * @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
  114898. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114899. * @param scale is the value to scale the shape
  114900. * @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
  114901. * @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
  114902. * @param scene defines the hosting scene
  114903. * @param updatable defines if the mesh must be flagged as updatable
  114904. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114905. * @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)
  114906. * @returns a new Mesh
  114907. */
  114908. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114909. /**
  114910. * Creates an custom extruded shape mesh.
  114911. * The custom extrusion is a parametric shape.
  114912. * It has no predefined shape. Its final shape will depend on the input parameters.
  114913. * Please consider using the same method from the MeshBuilder class instead
  114914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114915. * @param name defines the name of the mesh to create
  114916. * @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
  114917. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114918. * @param scaleFunction is a custom Javascript function called on each path point
  114919. * @param rotationFunction is a custom Javascript function called on each path point
  114920. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114921. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114922. * @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
  114923. * @param scene defines the hosting scene
  114924. * @param updatable defines if the mesh must be flagged as updatable
  114925. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114926. * @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)
  114927. * @returns a new Mesh
  114928. */
  114929. 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;
  114930. /**
  114931. * Creates lathe mesh.
  114932. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114933. * Please consider using the same method from the MeshBuilder class instead
  114934. * @param name defines the name of the mesh to create
  114935. * @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
  114936. * @param radius is the radius value of the lathe
  114937. * @param tessellation is the side number of the lathe.
  114938. * @param scene defines the hosting scene
  114939. * @param updatable defines if the mesh must be flagged as updatable
  114940. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114941. * @returns a new Mesh
  114942. */
  114943. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114944. /**
  114945. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114946. * @param name defines the name of the mesh to create
  114947. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114948. * @param scene defines the hosting scene
  114949. * @param updatable defines if the mesh must be flagged as updatable
  114950. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114951. * @returns a new Mesh
  114952. */
  114953. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114954. /**
  114955. * Creates a ground mesh.
  114956. * Please consider using the same method from the MeshBuilder class instead
  114957. * @param name defines the name of the mesh to create
  114958. * @param width set the width of the ground
  114959. * @param height set the height of the ground
  114960. * @param subdivisions sets the number of subdivisions per side
  114961. * @param scene defines the hosting scene
  114962. * @param updatable defines if the mesh must be flagged as updatable
  114963. * @returns a new Mesh
  114964. */
  114965. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114966. /**
  114967. * Creates a tiled ground mesh.
  114968. * Please consider using the same method from the MeshBuilder class instead
  114969. * @param name defines the name of the mesh to create
  114970. * @param xmin set the ground minimum X coordinate
  114971. * @param zmin set the ground minimum Y coordinate
  114972. * @param xmax set the ground maximum X coordinate
  114973. * @param zmax set the ground maximum Z coordinate
  114974. * @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
  114975. * @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
  114976. * @param scene defines the hosting scene
  114977. * @param updatable defines if the mesh must be flagged as updatable
  114978. * @returns a new Mesh
  114979. */
  114980. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114981. w: number;
  114982. h: number;
  114983. }, precision: {
  114984. w: number;
  114985. h: number;
  114986. }, scene: Scene, updatable?: boolean): Mesh;
  114987. /**
  114988. * Creates a ground mesh from a height map.
  114989. * Please consider using the same method from the MeshBuilder class instead
  114990. * @see https://doc.babylonjs.com/babylon101/height_map
  114991. * @param name defines the name of the mesh to create
  114992. * @param url sets the URL of the height map image resource
  114993. * @param width set the ground width size
  114994. * @param height set the ground height size
  114995. * @param subdivisions sets the number of subdivision per side
  114996. * @param minHeight is the minimum altitude on the ground
  114997. * @param maxHeight is the maximum altitude on the ground
  114998. * @param scene defines the hosting scene
  114999. * @param updatable defines if the mesh must be flagged as updatable
  115000. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  115001. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115002. * @returns a new Mesh
  115003. */
  115004. 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;
  115005. /**
  115006. * Creates a tube mesh.
  115007. * The tube is a parametric shape.
  115008. * It has no predefined shape. Its final shape will depend on the input parameters.
  115009. * Please consider using the same method from the MeshBuilder class instead
  115010. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115011. * @param name defines the name of the mesh to create
  115012. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  115013. * @param radius sets the tube radius size
  115014. * @param tessellation is the number of sides on the tubular surface
  115015. * @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
  115016. * @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
  115017. * @param scene defines the hosting scene
  115018. * @param updatable defines if the mesh must be flagged as updatable
  115019. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  115020. * @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)
  115021. * @returns a new Mesh
  115022. */
  115023. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  115024. (i: number, distance: number): number;
  115025. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  115026. /**
  115027. * Creates a polyhedron mesh.
  115028. * Please consider using the same method from the MeshBuilder class instead.
  115029. * * 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
  115030. * * The parameter `size` (positive float, default 1) sets the polygon size
  115031. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115032. * * 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`
  115033. * * 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
  115034. * * 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)`)
  115035. * * 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
  115036. * * 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
  115037. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115040. * @param name defines the name of the mesh to create
  115041. * @param options defines the options used to create the mesh
  115042. * @param scene defines the hosting scene
  115043. * @returns a new Mesh
  115044. */
  115045. static CreatePolyhedron(name: string, options: {
  115046. type?: number;
  115047. size?: number;
  115048. sizeX?: number;
  115049. sizeY?: number;
  115050. sizeZ?: number;
  115051. custom?: any;
  115052. faceUV?: Vector4[];
  115053. faceColors?: Color4[];
  115054. updatable?: boolean;
  115055. sideOrientation?: number;
  115056. }, scene: Scene): Mesh;
  115057. /**
  115058. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115059. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115060. * * 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`)
  115061. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115062. * * 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
  115063. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115066. * @param name defines the name of the mesh
  115067. * @param options defines the options used to create the mesh
  115068. * @param scene defines the hosting scene
  115069. * @returns a new Mesh
  115070. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115071. */
  115072. static CreateIcoSphere(name: string, options: {
  115073. radius?: number;
  115074. flat?: boolean;
  115075. subdivisions?: number;
  115076. sideOrientation?: number;
  115077. updatable?: boolean;
  115078. }, scene: Scene): Mesh;
  115079. /**
  115080. * Creates a decal mesh.
  115081. * Please consider using the same method from the MeshBuilder class instead.
  115082. * A decal is a mesh usually applied as a model onto the surface of another mesh
  115083. * @param name defines the name of the mesh
  115084. * @param sourceMesh defines the mesh receiving the decal
  115085. * @param position sets the position of the decal in world coordinates
  115086. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  115087. * @param size sets the decal scaling
  115088. * @param angle sets the angle to rotate the decal
  115089. * @returns a new Mesh
  115090. */
  115091. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  115092. /** Creates a Capsule Mesh
  115093. * @param name defines the name of the mesh.
  115094. * @param options the constructors options used to shape the mesh.
  115095. * @param scene defines the scene the mesh is scoped to.
  115096. * @returns the capsule mesh
  115097. * @see https://doc.babylonjs.com/how_to/capsule_shape
  115098. */
  115099. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  115100. /**
  115101. * Prepare internal position array for software CPU skinning
  115102. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  115103. */
  115104. setPositionsForCPUSkinning(): Float32Array;
  115105. /**
  115106. * Prepare internal normal array for software CPU skinning
  115107. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  115108. */
  115109. setNormalsForCPUSkinning(): Float32Array;
  115110. /**
  115111. * Updates the vertex buffer by applying transformation from the bones
  115112. * @param skeleton defines the skeleton to apply to current mesh
  115113. * @returns the current mesh
  115114. */
  115115. applySkeleton(skeleton: Skeleton): Mesh;
  115116. /**
  115117. * 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
  115118. * @param meshes defines the list of meshes to scan
  115119. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  115120. */
  115121. static MinMax(meshes: AbstractMesh[]): {
  115122. min: Vector3;
  115123. max: Vector3;
  115124. };
  115125. /**
  115126. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  115127. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  115128. * @returns a vector3
  115129. */
  115130. static Center(meshesOrMinMaxVector: {
  115131. min: Vector3;
  115132. max: Vector3;
  115133. } | AbstractMesh[]): Vector3;
  115134. /**
  115135. * Merge the array of meshes into a single mesh for performance reasons.
  115136. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  115137. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  115138. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  115139. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  115140. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  115141. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  115142. * @returns a new mesh
  115143. */
  115144. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  115145. /** @hidden */
  115146. addInstance(instance: InstancedMesh): void;
  115147. /** @hidden */
  115148. removeInstance(instance: InstancedMesh): void;
  115149. }
  115150. }
  115151. declare module BABYLON {
  115152. /**
  115153. * This is the base class of all the camera used in the application.
  115154. * @see https://doc.babylonjs.com/features/cameras
  115155. */
  115156. export class Camera extends Node {
  115157. /** @hidden */
  115158. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  115159. /**
  115160. * This is the default projection mode used by the cameras.
  115161. * It helps recreating a feeling of perspective and better appreciate depth.
  115162. * This is the best way to simulate real life cameras.
  115163. */
  115164. static readonly PERSPECTIVE_CAMERA: number;
  115165. /**
  115166. * This helps creating camera with an orthographic mode.
  115167. * 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.
  115168. */
  115169. static readonly ORTHOGRAPHIC_CAMERA: number;
  115170. /**
  115171. * This is the default FOV mode for perspective cameras.
  115172. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  115173. */
  115174. static readonly FOVMODE_VERTICAL_FIXED: number;
  115175. /**
  115176. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  115177. */
  115178. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  115179. /**
  115180. * This specifies ther is no need for a camera rig.
  115181. * Basically only one eye is rendered corresponding to the camera.
  115182. */
  115183. static readonly RIG_MODE_NONE: number;
  115184. /**
  115185. * Simulates a camera Rig with one blue eye and one red eye.
  115186. * This can be use with 3d blue and red glasses.
  115187. */
  115188. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  115189. /**
  115190. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  115191. */
  115192. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  115193. /**
  115194. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  115195. */
  115196. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  115197. /**
  115198. * Defines that both eyes of the camera will be rendered over under each other.
  115199. */
  115200. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  115201. /**
  115202. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  115203. */
  115204. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  115205. /**
  115206. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  115207. */
  115208. static readonly RIG_MODE_VR: number;
  115209. /**
  115210. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  115211. */
  115212. static readonly RIG_MODE_WEBVR: number;
  115213. /**
  115214. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  115215. */
  115216. static readonly RIG_MODE_CUSTOM: number;
  115217. /**
  115218. * Defines if by default attaching controls should prevent the default javascript event to continue.
  115219. */
  115220. static ForceAttachControlToAlwaysPreventDefault: boolean;
  115221. /**
  115222. * Define the input manager associated with the camera.
  115223. */
  115224. inputs: CameraInputsManager<Camera>;
  115225. /** @hidden */
  115226. _position: Vector3;
  115227. /**
  115228. * Define the current local position of the camera in the scene
  115229. */
  115230. get position(): Vector3;
  115231. set position(newPosition: Vector3);
  115232. protected _upVector: Vector3;
  115233. /**
  115234. * The vector the camera should consider as up.
  115235. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  115236. */
  115237. set upVector(vec: Vector3);
  115238. get upVector(): Vector3;
  115239. /**
  115240. * Define the current limit on the left side for an orthographic camera
  115241. * In scene unit
  115242. */
  115243. orthoLeft: Nullable<number>;
  115244. /**
  115245. * Define the current limit on the right side for an orthographic camera
  115246. * In scene unit
  115247. */
  115248. orthoRight: Nullable<number>;
  115249. /**
  115250. * Define the current limit on the bottom side for an orthographic camera
  115251. * In scene unit
  115252. */
  115253. orthoBottom: Nullable<number>;
  115254. /**
  115255. * Define the current limit on the top side for an orthographic camera
  115256. * In scene unit
  115257. */
  115258. orthoTop: Nullable<number>;
  115259. /**
  115260. * Field Of View is set in Radians. (default is 0.8)
  115261. */
  115262. fov: number;
  115263. /**
  115264. * Define the minimum distance the camera can see from.
  115265. * This is important to note that the depth buffer are not infinite and the closer it starts
  115266. * the more your scene might encounter depth fighting issue.
  115267. */
  115268. minZ: number;
  115269. /**
  115270. * Define the maximum distance the camera can see to.
  115271. * This is important to note that the depth buffer are not infinite and the further it end
  115272. * the more your scene might encounter depth fighting issue.
  115273. */
  115274. maxZ: number;
  115275. /**
  115276. * Define the default inertia of the camera.
  115277. * This helps giving a smooth feeling to the camera movement.
  115278. */
  115279. inertia: number;
  115280. /**
  115281. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  115282. */
  115283. mode: number;
  115284. /**
  115285. * Define whether the camera is intermediate.
  115286. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  115287. */
  115288. isIntermediate: boolean;
  115289. /**
  115290. * Define the viewport of the camera.
  115291. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  115292. */
  115293. viewport: Viewport;
  115294. /**
  115295. * Restricts the camera to viewing objects with the same layerMask.
  115296. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  115297. */
  115298. layerMask: number;
  115299. /**
  115300. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  115301. */
  115302. fovMode: number;
  115303. /**
  115304. * Rig mode of the camera.
  115305. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  115306. * This is normally controlled byt the camera themselves as internal use.
  115307. */
  115308. cameraRigMode: number;
  115309. /**
  115310. * Defines the distance between both "eyes" in case of a RIG
  115311. */
  115312. interaxialDistance: number;
  115313. /**
  115314. * Defines if stereoscopic rendering is done side by side or over under.
  115315. */
  115316. isStereoscopicSideBySide: boolean;
  115317. /**
  115318. * 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
  115319. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  115320. * else in the scene. (Eg. security camera)
  115321. *
  115322. * 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)
  115323. */
  115324. customRenderTargets: RenderTargetTexture[];
  115325. /**
  115326. * When set, the camera will render to this render target instead of the default canvas
  115327. *
  115328. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  115329. */
  115330. outputRenderTarget: Nullable<RenderTargetTexture>;
  115331. /**
  115332. * Observable triggered when the camera view matrix has changed.
  115333. */
  115334. onViewMatrixChangedObservable: Observable<Camera>;
  115335. /**
  115336. * Observable triggered when the camera Projection matrix has changed.
  115337. */
  115338. onProjectionMatrixChangedObservable: Observable<Camera>;
  115339. /**
  115340. * Observable triggered when the inputs have been processed.
  115341. */
  115342. onAfterCheckInputsObservable: Observable<Camera>;
  115343. /**
  115344. * Observable triggered when reset has been called and applied to the camera.
  115345. */
  115346. onRestoreStateObservable: Observable<Camera>;
  115347. /**
  115348. * Is this camera a part of a rig system?
  115349. */
  115350. isRigCamera: boolean;
  115351. /**
  115352. * If isRigCamera set to true this will be set with the parent camera.
  115353. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  115354. */
  115355. rigParent?: Camera;
  115356. /** @hidden */
  115357. _cameraRigParams: any;
  115358. /** @hidden */
  115359. _rigCameras: Camera[];
  115360. /** @hidden */
  115361. _rigPostProcess: Nullable<PostProcess>;
  115362. protected _webvrViewMatrix: Matrix;
  115363. /** @hidden */
  115364. _skipRendering: boolean;
  115365. /** @hidden */
  115366. _projectionMatrix: Matrix;
  115367. /** @hidden */
  115368. _postProcesses: Nullable<PostProcess>[];
  115369. /** @hidden */
  115370. _activeMeshes: SmartArray<AbstractMesh>;
  115371. protected _globalPosition: Vector3;
  115372. /** @hidden */
  115373. _computedViewMatrix: Matrix;
  115374. private _doNotComputeProjectionMatrix;
  115375. private _transformMatrix;
  115376. private _frustumPlanes;
  115377. private _refreshFrustumPlanes;
  115378. private _storedFov;
  115379. private _stateStored;
  115380. /**
  115381. * Instantiates a new camera object.
  115382. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  115383. * @see https://doc.babylonjs.com/features/cameras
  115384. * @param name Defines the name of the camera in the scene
  115385. * @param position Defines the position of the camera
  115386. * @param scene Defines the scene the camera belongs too
  115387. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  115388. */
  115389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115390. /**
  115391. * Store current camera state (fov, position, etc..)
  115392. * @returns the camera
  115393. */
  115394. storeState(): Camera;
  115395. /**
  115396. * Restores the camera state values if it has been stored. You must call storeState() first
  115397. */
  115398. protected _restoreStateValues(): boolean;
  115399. /**
  115400. * Restored camera state. You must call storeState() first.
  115401. * @returns true if restored and false otherwise
  115402. */
  115403. restoreState(): boolean;
  115404. /**
  115405. * Gets the class name of the camera.
  115406. * @returns the class name
  115407. */
  115408. getClassName(): string;
  115409. /** @hidden */
  115410. readonly _isCamera: boolean;
  115411. /**
  115412. * Gets a string representation of the camera useful for debug purpose.
  115413. * @param fullDetails Defines that a more verboe level of logging is required
  115414. * @returns the string representation
  115415. */
  115416. toString(fullDetails?: boolean): string;
  115417. /**
  115418. * Gets the current world space position of the camera.
  115419. */
  115420. get globalPosition(): Vector3;
  115421. /**
  115422. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  115423. * @returns the active meshe list
  115424. */
  115425. getActiveMeshes(): SmartArray<AbstractMesh>;
  115426. /**
  115427. * Check whether a mesh is part of the current active mesh list of the camera
  115428. * @param mesh Defines the mesh to check
  115429. * @returns true if active, false otherwise
  115430. */
  115431. isActiveMesh(mesh: Mesh): boolean;
  115432. /**
  115433. * Is this camera ready to be used/rendered
  115434. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  115435. * @return true if the camera is ready
  115436. */
  115437. isReady(completeCheck?: boolean): boolean;
  115438. /** @hidden */
  115439. _initCache(): void;
  115440. /** @hidden */
  115441. _updateCache(ignoreParentClass?: boolean): void;
  115442. /** @hidden */
  115443. _isSynchronized(): boolean;
  115444. /** @hidden */
  115445. _isSynchronizedViewMatrix(): boolean;
  115446. /** @hidden */
  115447. _isSynchronizedProjectionMatrix(): boolean;
  115448. /**
  115449. * Attach the input controls to a specific dom element to get the input from.
  115450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115451. */
  115452. attachControl(noPreventDefault?: boolean): void;
  115453. /**
  115454. * Detach the current controls from the specified dom element.
  115455. */
  115456. detachControl(): void;
  115457. /**
  115458. * Update the camera state according to the different inputs gathered during the frame.
  115459. */
  115460. update(): void;
  115461. /** @hidden */
  115462. _checkInputs(): void;
  115463. /** @hidden */
  115464. get rigCameras(): Camera[];
  115465. /**
  115466. * Gets the post process used by the rig cameras
  115467. */
  115468. get rigPostProcess(): Nullable<PostProcess>;
  115469. /**
  115470. * Internal, gets the first post proces.
  115471. * @returns the first post process to be run on this camera.
  115472. */
  115473. _getFirstPostProcess(): Nullable<PostProcess>;
  115474. private _cascadePostProcessesToRigCams;
  115475. /**
  115476. * Attach a post process to the camera.
  115477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115478. * @param postProcess The post process to attach to the camera
  115479. * @param insertAt The position of the post process in case several of them are in use in the scene
  115480. * @returns the position the post process has been inserted at
  115481. */
  115482. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  115483. /**
  115484. * Detach a post process to the camera.
  115485. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115486. * @param postProcess The post process to detach from the camera
  115487. */
  115488. detachPostProcess(postProcess: PostProcess): void;
  115489. /**
  115490. * Gets the current world matrix of the camera
  115491. */
  115492. getWorldMatrix(): Matrix;
  115493. /** @hidden */
  115494. _getViewMatrix(): Matrix;
  115495. /**
  115496. * Gets the current view matrix of the camera.
  115497. * @param force forces the camera to recompute the matrix without looking at the cached state
  115498. * @returns the view matrix
  115499. */
  115500. getViewMatrix(force?: boolean): Matrix;
  115501. /**
  115502. * Freeze the projection matrix.
  115503. * It will prevent the cache check of the camera projection compute and can speed up perf
  115504. * if no parameter of the camera are meant to change
  115505. * @param projection Defines manually a projection if necessary
  115506. */
  115507. freezeProjectionMatrix(projection?: Matrix): void;
  115508. /**
  115509. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  115510. */
  115511. unfreezeProjectionMatrix(): void;
  115512. /**
  115513. * Gets the current projection matrix of the camera.
  115514. * @param force forces the camera to recompute the matrix without looking at the cached state
  115515. * @returns the projection matrix
  115516. */
  115517. getProjectionMatrix(force?: boolean): Matrix;
  115518. /**
  115519. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  115520. * @returns a Matrix
  115521. */
  115522. getTransformationMatrix(): Matrix;
  115523. private _updateFrustumPlanes;
  115524. /**
  115525. * Checks if a cullable object (mesh...) is in the camera frustum
  115526. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  115527. * @param target The object to check
  115528. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  115529. * @returns true if the object is in frustum otherwise false
  115530. */
  115531. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  115532. /**
  115533. * Checks if a cullable object (mesh...) is in the camera frustum
  115534. * Unlike isInFrustum this cheks the full bounding box
  115535. * @param target The object to check
  115536. * @returns true if the object is in frustum otherwise false
  115537. */
  115538. isCompletelyInFrustum(target: ICullable): boolean;
  115539. /**
  115540. * Gets a ray in the forward direction from the camera.
  115541. * @param length Defines the length of the ray to create
  115542. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115543. * @param origin Defines the start point of the ray which defaults to the camera position
  115544. * @returns the forward ray
  115545. */
  115546. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115547. /**
  115548. * Gets a ray in the forward direction from the camera.
  115549. * @param refRay the ray to (re)use when setting the values
  115550. * @param length Defines the length of the ray to create
  115551. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115552. * @param origin Defines the start point of the ray which defaults to the camera position
  115553. * @returns the forward ray
  115554. */
  115555. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115556. /**
  115557. * Releases resources associated with this node.
  115558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115560. */
  115561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115562. /** @hidden */
  115563. _isLeftCamera: boolean;
  115564. /**
  115565. * Gets the left camera of a rig setup in case of Rigged Camera
  115566. */
  115567. get isLeftCamera(): boolean;
  115568. /** @hidden */
  115569. _isRightCamera: boolean;
  115570. /**
  115571. * Gets the right camera of a rig setup in case of Rigged Camera
  115572. */
  115573. get isRightCamera(): boolean;
  115574. /**
  115575. * Gets the left camera of a rig setup in case of Rigged Camera
  115576. */
  115577. get leftCamera(): Nullable<FreeCamera>;
  115578. /**
  115579. * Gets the right camera of a rig setup in case of Rigged Camera
  115580. */
  115581. get rightCamera(): Nullable<FreeCamera>;
  115582. /**
  115583. * Gets the left camera target of a rig setup in case of Rigged Camera
  115584. * @returns the target position
  115585. */
  115586. getLeftTarget(): Nullable<Vector3>;
  115587. /**
  115588. * Gets the right camera target of a rig setup in case of Rigged Camera
  115589. * @returns the target position
  115590. */
  115591. getRightTarget(): Nullable<Vector3>;
  115592. /**
  115593. * @hidden
  115594. */
  115595. setCameraRigMode(mode: number, rigParams: any): void;
  115596. /** @hidden */
  115597. static _setStereoscopicRigMode(camera: Camera): void;
  115598. /** @hidden */
  115599. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  115600. /** @hidden */
  115601. static _setVRRigMode(camera: Camera, rigParams: any): void;
  115602. /** @hidden */
  115603. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  115604. /** @hidden */
  115605. _getVRProjectionMatrix(): Matrix;
  115606. protected _updateCameraRotationMatrix(): void;
  115607. protected _updateWebVRCameraRotationMatrix(): void;
  115608. /**
  115609. * This function MUST be overwritten by the different WebVR cameras available.
  115610. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115611. * @hidden
  115612. */
  115613. _getWebVRProjectionMatrix(): Matrix;
  115614. /**
  115615. * This function MUST be overwritten by the different WebVR cameras available.
  115616. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115617. * @hidden
  115618. */
  115619. _getWebVRViewMatrix(): Matrix;
  115620. /** @hidden */
  115621. setCameraRigParameter(name: string, value: any): void;
  115622. /**
  115623. * needs to be overridden by children so sub has required properties to be copied
  115624. * @hidden
  115625. */
  115626. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  115627. /**
  115628. * May need to be overridden by children
  115629. * @hidden
  115630. */
  115631. _updateRigCameras(): void;
  115632. /** @hidden */
  115633. _setupInputs(): void;
  115634. /**
  115635. * Serialiaze the camera setup to a json represention
  115636. * @returns the JSON representation
  115637. */
  115638. serialize(): any;
  115639. /**
  115640. * Clones the current camera.
  115641. * @param name The cloned camera name
  115642. * @returns the cloned camera
  115643. */
  115644. clone(name: string): Camera;
  115645. /**
  115646. * Gets the direction of the camera relative to a given local axis.
  115647. * @param localAxis Defines the reference axis to provide a relative direction.
  115648. * @return the direction
  115649. */
  115650. getDirection(localAxis: Vector3): Vector3;
  115651. /**
  115652. * Returns the current camera absolute rotation
  115653. */
  115654. get absoluteRotation(): Quaternion;
  115655. /**
  115656. * Gets the direction of the camera relative to a given local axis into a passed vector.
  115657. * @param localAxis Defines the reference axis to provide a relative direction.
  115658. * @param result Defines the vector to store the result in
  115659. */
  115660. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  115661. /**
  115662. * Gets a camera constructor for a given camera type
  115663. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  115664. * @param name The name of the camera the result will be able to instantiate
  115665. * @param scene The scene the result will construct the camera in
  115666. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  115667. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  115668. * @returns a factory method to construc the camera
  115669. */
  115670. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  115671. /**
  115672. * Compute the world matrix of the camera.
  115673. * @returns the camera world matrix
  115674. */
  115675. computeWorldMatrix(): Matrix;
  115676. /**
  115677. * Parse a JSON and creates the camera from the parsed information
  115678. * @param parsedCamera The JSON to parse
  115679. * @param scene The scene to instantiate the camera in
  115680. * @returns the newly constructed camera
  115681. */
  115682. static Parse(parsedCamera: any, scene: Scene): Camera;
  115683. }
  115684. }
  115685. declare module BABYLON {
  115686. /**
  115687. * Class containing static functions to help procedurally build meshes
  115688. */
  115689. export class DiscBuilder {
  115690. /**
  115691. * Creates a plane polygonal mesh. By default, this is a disc
  115692. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115693. * * 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
  115694. * * 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
  115695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115698. * @param name defines the name of the mesh
  115699. * @param options defines the options used to create the mesh
  115700. * @param scene defines the hosting scene
  115701. * @returns the plane polygonal mesh
  115702. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115703. */
  115704. static CreateDisc(name: string, options: {
  115705. radius?: number;
  115706. tessellation?: number;
  115707. arc?: number;
  115708. updatable?: boolean;
  115709. sideOrientation?: number;
  115710. frontUVs?: Vector4;
  115711. backUVs?: Vector4;
  115712. }, scene?: Nullable<Scene>): Mesh;
  115713. }
  115714. }
  115715. declare module BABYLON {
  115716. /**
  115717. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115718. *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.
  115719. * The SPS is also a particle system. It provides some methods to manage the particles.
  115720. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115721. *
  115722. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115723. */
  115724. export class SolidParticleSystem implements IDisposable {
  115725. /**
  115726. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115727. * Example : var p = SPS.particles[i];
  115728. */
  115729. particles: SolidParticle[];
  115730. /**
  115731. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115732. */
  115733. nbParticles: number;
  115734. /**
  115735. * If the particles must ever face the camera (default false). Useful for planar particles.
  115736. */
  115737. billboard: boolean;
  115738. /**
  115739. * Recompute normals when adding a shape
  115740. */
  115741. recomputeNormals: boolean;
  115742. /**
  115743. * This a counter ofr your own usage. It's not set by any SPS functions.
  115744. */
  115745. counter: number;
  115746. /**
  115747. * The SPS name. This name is also given to the underlying mesh.
  115748. */
  115749. name: string;
  115750. /**
  115751. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115752. */
  115753. mesh: Mesh;
  115754. /**
  115755. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115756. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115757. */
  115758. vars: any;
  115759. /**
  115760. * This array is populated when the SPS is set as 'pickable'.
  115761. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115762. * Each element of this array is an object `{idx: int, faceId: int}`.
  115763. * `idx` is the picked particle index in the `SPS.particles` array
  115764. * `faceId` is the picked face index counted within this particle.
  115765. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115766. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115767. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115768. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115769. */
  115770. pickedParticles: {
  115771. idx: number;
  115772. faceId: number;
  115773. }[];
  115774. /**
  115775. * This array is populated when the SPS is set as 'pickable'
  115776. * Each key of this array is a submesh index.
  115777. * Each element of this array is a second array defined like this :
  115778. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115779. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115780. * `idx` is the picked particle index in the `SPS.particles` array
  115781. * `faceId` is the picked face index counted within this particle.
  115782. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115783. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115784. */
  115785. pickedBySubMesh: {
  115786. idx: number;
  115787. faceId: number;
  115788. }[][];
  115789. /**
  115790. * This array is populated when `enableDepthSort` is set to true.
  115791. * Each element of this array is an instance of the class DepthSortedParticle.
  115792. */
  115793. depthSortedParticles: DepthSortedParticle[];
  115794. /**
  115795. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115796. * @hidden
  115797. */
  115798. _bSphereOnly: boolean;
  115799. /**
  115800. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115801. * @hidden
  115802. */
  115803. _bSphereRadiusFactor: number;
  115804. private _scene;
  115805. private _positions;
  115806. private _indices;
  115807. private _normals;
  115808. private _colors;
  115809. private _uvs;
  115810. private _indices32;
  115811. private _positions32;
  115812. private _normals32;
  115813. private _fixedNormal32;
  115814. private _colors32;
  115815. private _uvs32;
  115816. private _index;
  115817. private _updatable;
  115818. private _pickable;
  115819. private _isVisibilityBoxLocked;
  115820. private _alwaysVisible;
  115821. private _depthSort;
  115822. private _expandable;
  115823. private _shapeCounter;
  115824. private _copy;
  115825. private _color;
  115826. private _computeParticleColor;
  115827. private _computeParticleTexture;
  115828. private _computeParticleRotation;
  115829. private _computeParticleVertex;
  115830. private _computeBoundingBox;
  115831. private _depthSortParticles;
  115832. private _camera;
  115833. private _mustUnrotateFixedNormals;
  115834. private _particlesIntersect;
  115835. private _needs32Bits;
  115836. private _isNotBuilt;
  115837. private _lastParticleId;
  115838. private _idxOfId;
  115839. private _multimaterialEnabled;
  115840. private _useModelMaterial;
  115841. private _indicesByMaterial;
  115842. private _materialIndexes;
  115843. private _depthSortFunction;
  115844. private _materialSortFunction;
  115845. private _materials;
  115846. private _multimaterial;
  115847. private _materialIndexesById;
  115848. private _defaultMaterial;
  115849. private _autoUpdateSubMeshes;
  115850. private _tmpVertex;
  115851. /**
  115852. * Creates a SPS (Solid Particle System) object.
  115853. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115854. * @param scene (Scene) is the scene in which the SPS is added.
  115855. * @param options defines the options of the sps e.g.
  115856. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115857. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115858. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115859. * * 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.
  115860. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115861. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115862. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115863. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115864. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115865. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115866. */
  115867. constructor(name: string, scene: Scene, options?: {
  115868. updatable?: boolean;
  115869. isPickable?: boolean;
  115870. enableDepthSort?: boolean;
  115871. particleIntersection?: boolean;
  115872. boundingSphereOnly?: boolean;
  115873. bSphereRadiusFactor?: number;
  115874. expandable?: boolean;
  115875. useModelMaterial?: boolean;
  115876. enableMultiMaterial?: boolean;
  115877. });
  115878. /**
  115879. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115880. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115881. * @returns the created mesh
  115882. */
  115883. buildMesh(): Mesh;
  115884. /**
  115885. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115886. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115887. * Thus the particles generated from `digest()` have their property `position` set yet.
  115888. * @param mesh ( Mesh ) is the mesh to be digested
  115889. * @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
  115890. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115891. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115892. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115893. * @returns the current SPS
  115894. */
  115895. digest(mesh: Mesh, options?: {
  115896. facetNb?: number;
  115897. number?: number;
  115898. delta?: number;
  115899. storage?: [];
  115900. }): SolidParticleSystem;
  115901. /**
  115902. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115903. * @hidden
  115904. */
  115905. private _unrotateFixedNormals;
  115906. /**
  115907. * Resets the temporary working copy particle
  115908. * @hidden
  115909. */
  115910. private _resetCopy;
  115911. /**
  115912. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115913. * @param p the current index in the positions array to be updated
  115914. * @param ind the current index in the indices array
  115915. * @param shape a Vector3 array, the shape geometry
  115916. * @param positions the positions array to be updated
  115917. * @param meshInd the shape indices array
  115918. * @param indices the indices array to be updated
  115919. * @param meshUV the shape uv array
  115920. * @param uvs the uv array to be updated
  115921. * @param meshCol the shape color array
  115922. * @param colors the color array to be updated
  115923. * @param meshNor the shape normals array
  115924. * @param normals the normals array to be updated
  115925. * @param idx the particle index
  115926. * @param idxInShape the particle index in its shape
  115927. * @param options the addShape() method passed options
  115928. * @model the particle model
  115929. * @hidden
  115930. */
  115931. private _meshBuilder;
  115932. /**
  115933. * Returns a shape Vector3 array from positions float array
  115934. * @param positions float array
  115935. * @returns a vector3 array
  115936. * @hidden
  115937. */
  115938. private _posToShape;
  115939. /**
  115940. * Returns a shapeUV array from a float uvs (array deep copy)
  115941. * @param uvs as a float array
  115942. * @returns a shapeUV array
  115943. * @hidden
  115944. */
  115945. private _uvsToShapeUV;
  115946. /**
  115947. * Adds a new particle object in the particles array
  115948. * @param idx particle index in particles array
  115949. * @param id particle id
  115950. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115951. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115952. * @param model particle ModelShape object
  115953. * @param shapeId model shape identifier
  115954. * @param idxInShape index of the particle in the current model
  115955. * @param bInfo model bounding info object
  115956. * @param storage target storage array, if any
  115957. * @hidden
  115958. */
  115959. private _addParticle;
  115960. /**
  115961. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115962. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115963. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115964. * @param nb (positive integer) the number of particles to be created from this model
  115965. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115966. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115967. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115968. * @returns the number of shapes in the system
  115969. */
  115970. addShape(mesh: Mesh, nb: number, options?: {
  115971. positionFunction?: any;
  115972. vertexFunction?: any;
  115973. storage?: [];
  115974. }): number;
  115975. /**
  115976. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115977. * @hidden
  115978. */
  115979. private _rebuildParticle;
  115980. /**
  115981. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115982. * @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.
  115983. * @returns the SPS.
  115984. */
  115985. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115986. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115987. * Returns an array with the removed particles.
  115988. * 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.
  115989. * The SPS can't be empty so at least one particle needs to remain in place.
  115990. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115991. * @param start index of the first particle to remove
  115992. * @param end index of the last particle to remove (included)
  115993. * @returns an array populated with the removed particles
  115994. */
  115995. removeParticles(start: number, end: number): SolidParticle[];
  115996. /**
  115997. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115998. * @param solidParticleArray an array populated with Solid Particles objects
  115999. * @returns the SPS
  116000. */
  116001. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  116002. /**
  116003. * Creates a new particle and modifies the SPS mesh geometry :
  116004. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  116005. * - calls _addParticle() to populate the particle array
  116006. * factorized code from addShape() and insertParticlesFromArray()
  116007. * @param idx particle index in the particles array
  116008. * @param i particle index in its shape
  116009. * @param modelShape particle ModelShape object
  116010. * @param shape shape vertex array
  116011. * @param meshInd shape indices array
  116012. * @param meshUV shape uv array
  116013. * @param meshCol shape color array
  116014. * @param meshNor shape normals array
  116015. * @param bbInfo shape bounding info
  116016. * @param storage target particle storage
  116017. * @options addShape() passed options
  116018. * @hidden
  116019. */
  116020. private _insertNewParticle;
  116021. /**
  116022. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  116023. * This method calls `updateParticle()` for each particle of the SPS.
  116024. * For an animated SPS, it is usually called within the render loop.
  116025. * 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.
  116026. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  116027. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  116028. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  116029. * @returns the SPS.
  116030. */
  116031. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  116032. /**
  116033. * Disposes the SPS.
  116034. */
  116035. dispose(): void;
  116036. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  116037. * idx is the particle index in the SPS
  116038. * faceId is the picked face index counted within this particle.
  116039. * Returns null if the pickInfo can't identify a picked particle.
  116040. * @param pickingInfo (PickingInfo object)
  116041. * @returns {idx: number, faceId: number} or null
  116042. */
  116043. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  116044. idx: number;
  116045. faceId: number;
  116046. }>;
  116047. /**
  116048. * Returns a SolidParticle object from its identifier : particle.id
  116049. * @param id (integer) the particle Id
  116050. * @returns the searched particle or null if not found in the SPS.
  116051. */
  116052. getParticleById(id: number): Nullable<SolidParticle>;
  116053. /**
  116054. * Returns a new array populated with the particles having the passed shapeId.
  116055. * @param shapeId (integer) the shape identifier
  116056. * @returns a new solid particle array
  116057. */
  116058. getParticlesByShapeId(shapeId: number): SolidParticle[];
  116059. /**
  116060. * Populates the passed array "ref" with the particles having the passed shapeId.
  116061. * @param shapeId the shape identifier
  116062. * @returns the SPS
  116063. * @param ref
  116064. */
  116065. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  116066. /**
  116067. * Computes the required SubMeshes according the materials assigned to the particles.
  116068. * @returns the solid particle system.
  116069. * Does nothing if called before the SPS mesh is built.
  116070. */
  116071. computeSubMeshes(): SolidParticleSystem;
  116072. /**
  116073. * Sorts the solid particles by material when MultiMaterial is enabled.
  116074. * Updates the indices32 array.
  116075. * Updates the indicesByMaterial array.
  116076. * Updates the mesh indices array.
  116077. * @returns the SPS
  116078. * @hidden
  116079. */
  116080. private _sortParticlesByMaterial;
  116081. /**
  116082. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  116083. * @hidden
  116084. */
  116085. private _setMaterialIndexesById;
  116086. /**
  116087. * Returns an array with unique values of Materials from the passed array
  116088. * @param array the material array to be checked and filtered
  116089. * @hidden
  116090. */
  116091. private _filterUniqueMaterialId;
  116092. /**
  116093. * Sets a new Standard Material as _defaultMaterial if not already set.
  116094. * @hidden
  116095. */
  116096. private _setDefaultMaterial;
  116097. /**
  116098. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116099. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116100. * @returns the SPS.
  116101. */
  116102. refreshVisibleSize(): SolidParticleSystem;
  116103. /**
  116104. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116105. * @param size the size (float) of the visibility box
  116106. * note : this doesn't lock the SPS mesh bounding box.
  116107. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116108. */
  116109. setVisibilityBox(size: number): void;
  116110. /**
  116111. * Gets whether the SPS as always visible or not
  116112. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116113. */
  116114. get isAlwaysVisible(): boolean;
  116115. /**
  116116. * Sets the SPS as always visible or not
  116117. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116118. */
  116119. set isAlwaysVisible(val: boolean);
  116120. /**
  116121. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116122. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116123. */
  116124. set isVisibilityBoxLocked(val: boolean);
  116125. /**
  116126. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116127. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116128. */
  116129. get isVisibilityBoxLocked(): boolean;
  116130. /**
  116131. * Tells to `setParticles()` to compute the particle rotations or not.
  116132. * Default value : true. The SPS is faster when it's set to false.
  116133. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116134. */
  116135. set computeParticleRotation(val: boolean);
  116136. /**
  116137. * Tells to `setParticles()` to compute the particle colors or not.
  116138. * Default value : true. The SPS is faster when it's set to false.
  116139. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116140. */
  116141. set computeParticleColor(val: boolean);
  116142. set computeParticleTexture(val: boolean);
  116143. /**
  116144. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116145. * Default value : false. The SPS is faster when it's set to false.
  116146. * Note : the particle custom vertex positions aren't stored values.
  116147. */
  116148. set computeParticleVertex(val: boolean);
  116149. /**
  116150. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116151. */
  116152. set computeBoundingBox(val: boolean);
  116153. /**
  116154. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116155. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116156. * Default : `true`
  116157. */
  116158. set depthSortParticles(val: boolean);
  116159. /**
  116160. * Gets if `setParticles()` computes the particle rotations or not.
  116161. * Default value : true. The SPS is faster when it's set to false.
  116162. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116163. */
  116164. get computeParticleRotation(): boolean;
  116165. /**
  116166. * Gets if `setParticles()` computes the particle colors or not.
  116167. * Default value : true. The SPS is faster when it's set to false.
  116168. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116169. */
  116170. get computeParticleColor(): boolean;
  116171. /**
  116172. * Gets if `setParticles()` computes the particle textures or not.
  116173. * Default value : true. The SPS is faster when it's set to false.
  116174. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116175. */
  116176. get computeParticleTexture(): boolean;
  116177. /**
  116178. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116179. * Default value : false. The SPS is faster when it's set to false.
  116180. * Note : the particle custom vertex positions aren't stored values.
  116181. */
  116182. get computeParticleVertex(): boolean;
  116183. /**
  116184. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116185. */
  116186. get computeBoundingBox(): boolean;
  116187. /**
  116188. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116189. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116190. * Default : `true`
  116191. */
  116192. get depthSortParticles(): boolean;
  116193. /**
  116194. * Gets if the SPS is created as expandable at construction time.
  116195. * Default : `false`
  116196. */
  116197. get expandable(): boolean;
  116198. /**
  116199. * Gets if the SPS supports the Multi Materials
  116200. */
  116201. get multimaterialEnabled(): boolean;
  116202. /**
  116203. * Gets if the SPS uses the model materials for its own multimaterial.
  116204. */
  116205. get useModelMaterial(): boolean;
  116206. /**
  116207. * The SPS used material array.
  116208. */
  116209. get materials(): Material[];
  116210. /**
  116211. * Sets the SPS MultiMaterial from the passed materials.
  116212. * Note : the passed array is internally copied and not used then by reference.
  116213. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116214. */
  116215. setMultiMaterial(materials: Material[]): void;
  116216. /**
  116217. * The SPS computed multimaterial object
  116218. */
  116219. get multimaterial(): MultiMaterial;
  116220. set multimaterial(mm: MultiMaterial);
  116221. /**
  116222. * If the subMeshes must be updated on the next call to setParticles()
  116223. */
  116224. get autoUpdateSubMeshes(): boolean;
  116225. set autoUpdateSubMeshes(val: boolean);
  116226. /**
  116227. * This function does nothing. It may be overwritten to set all the particle first values.
  116228. * The SPS doesn't call this function, you may have to call it by your own.
  116229. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116230. */
  116231. initParticles(): void;
  116232. /**
  116233. * This function does nothing. It may be overwritten to recycle a particle.
  116234. * The SPS doesn't call this function, you may have to call it by your own.
  116235. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116236. * @param particle The particle to recycle
  116237. * @returns the recycled particle
  116238. */
  116239. recycleParticle(particle: SolidParticle): SolidParticle;
  116240. /**
  116241. * Updates a particle : this function should be overwritten by the user.
  116242. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116243. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116244. * @example : just set a particle position or velocity and recycle conditions
  116245. * @param particle The particle to update
  116246. * @returns the updated particle
  116247. */
  116248. updateParticle(particle: SolidParticle): SolidParticle;
  116249. /**
  116250. * Updates a vertex of a particle : it can be overwritten by the user.
  116251. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116252. * @param particle the current particle
  116253. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116254. * @param pt the index of the current vertex in the particle shape
  116255. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116256. * @example : just set a vertex particle position or color
  116257. * @returns the sps
  116258. */
  116259. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116260. /**
  116261. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116262. * This does nothing and may be overwritten by the user.
  116263. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116264. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116265. * @param update the boolean update value actually passed to setParticles()
  116266. */
  116267. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116268. /**
  116269. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116270. * This will be passed three parameters.
  116271. * This does nothing and may be overwritten by the user.
  116272. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116273. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116274. * @param update the boolean update value actually passed to setParticles()
  116275. */
  116276. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116277. }
  116278. }
  116279. declare module BABYLON {
  116280. /**
  116281. * Represents one particle of a solid particle system.
  116282. */
  116283. export class SolidParticle {
  116284. /**
  116285. * particle global index
  116286. */
  116287. idx: number;
  116288. /**
  116289. * particle identifier
  116290. */
  116291. id: number;
  116292. /**
  116293. * The color of the particle
  116294. */
  116295. color: Nullable<Color4>;
  116296. /**
  116297. * The world space position of the particle.
  116298. */
  116299. position: Vector3;
  116300. /**
  116301. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116302. */
  116303. rotation: Vector3;
  116304. /**
  116305. * The world space rotation quaternion of the particle.
  116306. */
  116307. rotationQuaternion: Nullable<Quaternion>;
  116308. /**
  116309. * The scaling of the particle.
  116310. */
  116311. scaling: Vector3;
  116312. /**
  116313. * The uvs of the particle.
  116314. */
  116315. uvs: Vector4;
  116316. /**
  116317. * The current speed of the particle.
  116318. */
  116319. velocity: Vector3;
  116320. /**
  116321. * The pivot point in the particle local space.
  116322. */
  116323. pivot: Vector3;
  116324. /**
  116325. * Must the particle be translated from its pivot point in its local space ?
  116326. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116327. * Default : false
  116328. */
  116329. translateFromPivot: boolean;
  116330. /**
  116331. * Is the particle active or not ?
  116332. */
  116333. alive: boolean;
  116334. /**
  116335. * Is the particle visible or not ?
  116336. */
  116337. isVisible: boolean;
  116338. /**
  116339. * Index of this particle in the global "positions" array (Internal use)
  116340. * @hidden
  116341. */
  116342. _pos: number;
  116343. /**
  116344. * @hidden Index of this particle in the global "indices" array (Internal use)
  116345. */
  116346. _ind: number;
  116347. /**
  116348. * @hidden ModelShape of this particle (Internal use)
  116349. */
  116350. _model: ModelShape;
  116351. /**
  116352. * ModelShape id of this particle
  116353. */
  116354. shapeId: number;
  116355. /**
  116356. * Index of the particle in its shape id
  116357. */
  116358. idxInShape: number;
  116359. /**
  116360. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116361. */
  116362. _modelBoundingInfo: BoundingInfo;
  116363. /**
  116364. * @hidden Particle BoundingInfo object (Internal use)
  116365. */
  116366. _boundingInfo: BoundingInfo;
  116367. /**
  116368. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116369. */
  116370. _sps: SolidParticleSystem;
  116371. /**
  116372. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116373. */
  116374. _stillInvisible: boolean;
  116375. /**
  116376. * @hidden Last computed particle rotation matrix
  116377. */
  116378. _rotationMatrix: number[];
  116379. /**
  116380. * Parent particle Id, if any.
  116381. * Default null.
  116382. */
  116383. parentId: Nullable<number>;
  116384. /**
  116385. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116386. */
  116387. materialIndex: Nullable<number>;
  116388. /**
  116389. * Custom object or properties.
  116390. */
  116391. props: Nullable<any>;
  116392. /**
  116393. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116394. * The possible values are :
  116395. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116396. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116397. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116398. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116399. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116400. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116401. * */
  116402. cullingStrategy: number;
  116403. /**
  116404. * @hidden Internal global position in the SPS.
  116405. */
  116406. _globalPosition: Vector3;
  116407. /**
  116408. * Creates a Solid Particle object.
  116409. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116410. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116411. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116412. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116413. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116414. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116415. * @param shapeId (integer) is the model shape identifier in the SPS.
  116416. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116417. * @param sps defines the sps it is associated to
  116418. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116419. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116420. */
  116421. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116422. /**
  116423. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116424. * @param target the particle target
  116425. * @returns the current particle
  116426. */
  116427. copyToRef(target: SolidParticle): SolidParticle;
  116428. /**
  116429. * Legacy support, changed scale to scaling
  116430. */
  116431. get scale(): Vector3;
  116432. /**
  116433. * Legacy support, changed scale to scaling
  116434. */
  116435. set scale(scale: Vector3);
  116436. /**
  116437. * Legacy support, changed quaternion to rotationQuaternion
  116438. */
  116439. get quaternion(): Nullable<Quaternion>;
  116440. /**
  116441. * Legacy support, changed quaternion to rotationQuaternion
  116442. */
  116443. set quaternion(q: Nullable<Quaternion>);
  116444. /**
  116445. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116446. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116447. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116448. * @returns true if it intersects
  116449. */
  116450. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116451. /**
  116452. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116453. * A particle is in the frustum if its bounding box intersects the frustum
  116454. * @param frustumPlanes defines the frustum to test
  116455. * @returns true if the particle is in the frustum planes
  116456. */
  116457. isInFrustum(frustumPlanes: Plane[]): boolean;
  116458. /**
  116459. * get the rotation matrix of the particle
  116460. * @hidden
  116461. */
  116462. getRotationMatrix(m: Matrix): void;
  116463. }
  116464. /**
  116465. * Represents the shape of the model used by one particle of a solid particle system.
  116466. * SPS internal tool, don't use it manually.
  116467. */
  116468. export class ModelShape {
  116469. /**
  116470. * The shape id
  116471. * @hidden
  116472. */
  116473. shapeID: number;
  116474. /**
  116475. * flat array of model positions (internal use)
  116476. * @hidden
  116477. */
  116478. _shape: Vector3[];
  116479. /**
  116480. * flat array of model UVs (internal use)
  116481. * @hidden
  116482. */
  116483. _shapeUV: number[];
  116484. /**
  116485. * color array of the model
  116486. * @hidden
  116487. */
  116488. _shapeColors: number[];
  116489. /**
  116490. * indices array of the model
  116491. * @hidden
  116492. */
  116493. _indices: number[];
  116494. /**
  116495. * normals array of the model
  116496. * @hidden
  116497. */
  116498. _normals: number[];
  116499. /**
  116500. * length of the shape in the model indices array (internal use)
  116501. * @hidden
  116502. */
  116503. _indicesLength: number;
  116504. /**
  116505. * Custom position function (internal use)
  116506. * @hidden
  116507. */
  116508. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116509. /**
  116510. * Custom vertex function (internal use)
  116511. * @hidden
  116512. */
  116513. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116514. /**
  116515. * Model material (internal use)
  116516. * @hidden
  116517. */
  116518. _material: Nullable<Material>;
  116519. /**
  116520. * 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.
  116521. * SPS internal tool, don't use it manually.
  116522. * @hidden
  116523. */
  116524. 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>);
  116525. }
  116526. /**
  116527. * Represents a Depth Sorted Particle in the solid particle system.
  116528. * @hidden
  116529. */
  116530. export class DepthSortedParticle {
  116531. /**
  116532. * Particle index
  116533. */
  116534. idx: number;
  116535. /**
  116536. * Index of the particle in the "indices" array
  116537. */
  116538. ind: number;
  116539. /**
  116540. * Length of the particle shape in the "indices" array
  116541. */
  116542. indicesLength: number;
  116543. /**
  116544. * Squared distance from the particle to the camera
  116545. */
  116546. sqDistance: number;
  116547. /**
  116548. * Material index when used with MultiMaterials
  116549. */
  116550. materialIndex: number;
  116551. /**
  116552. * Creates a new sorted particle
  116553. * @param materialIndex
  116554. */
  116555. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116556. }
  116557. /**
  116558. * Represents a solid particle vertex
  116559. */
  116560. export class SolidParticleVertex {
  116561. /**
  116562. * Vertex position
  116563. */
  116564. position: Vector3;
  116565. /**
  116566. * Vertex color
  116567. */
  116568. color: Color4;
  116569. /**
  116570. * Vertex UV
  116571. */
  116572. uv: Vector2;
  116573. /**
  116574. * Creates a new solid particle vertex
  116575. */
  116576. constructor();
  116577. /** Vertex x coordinate */
  116578. get x(): number;
  116579. set x(val: number);
  116580. /** Vertex y coordinate */
  116581. get y(): number;
  116582. set y(val: number);
  116583. /** Vertex z coordinate */
  116584. get z(): number;
  116585. set z(val: number);
  116586. }
  116587. }
  116588. declare module BABYLON {
  116589. /**
  116590. * @hidden
  116591. */
  116592. export class _MeshCollisionData {
  116593. _checkCollisions: boolean;
  116594. _collisionMask: number;
  116595. _collisionGroup: number;
  116596. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116597. _collider: Nullable<Collider>;
  116598. _oldPositionForCollisions: Vector3;
  116599. _diffPositionForCollisions: Vector3;
  116600. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116601. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116602. _collisionResponse: boolean;
  116603. }
  116604. }
  116605. declare module BABYLON {
  116606. /** @hidden */
  116607. class _FacetDataStorage {
  116608. facetPositions: Vector3[];
  116609. facetNormals: Vector3[];
  116610. facetPartitioning: number[][];
  116611. facetNb: number;
  116612. partitioningSubdivisions: number;
  116613. partitioningBBoxRatio: number;
  116614. facetDataEnabled: boolean;
  116615. facetParameters: any;
  116616. bbSize: Vector3;
  116617. subDiv: {
  116618. max: number;
  116619. X: number;
  116620. Y: number;
  116621. Z: number;
  116622. };
  116623. facetDepthSort: boolean;
  116624. facetDepthSortEnabled: boolean;
  116625. depthSortedIndices: IndicesArray;
  116626. depthSortedFacets: {
  116627. ind: number;
  116628. sqDistance: number;
  116629. }[];
  116630. facetDepthSortFunction: (f1: {
  116631. ind: number;
  116632. sqDistance: number;
  116633. }, f2: {
  116634. ind: number;
  116635. sqDistance: number;
  116636. }) => number;
  116637. facetDepthSortFrom: Vector3;
  116638. facetDepthSortOrigin: Vector3;
  116639. invertedMatrix: Matrix;
  116640. }
  116641. /**
  116642. * @hidden
  116643. **/
  116644. class _InternalAbstractMeshDataInfo {
  116645. _hasVertexAlpha: boolean;
  116646. _useVertexColors: boolean;
  116647. _numBoneInfluencers: number;
  116648. _applyFog: boolean;
  116649. _receiveShadows: boolean;
  116650. _facetData: _FacetDataStorage;
  116651. _visibility: number;
  116652. _skeleton: Nullable<Skeleton>;
  116653. _layerMask: number;
  116654. _computeBonesUsingShaders: boolean;
  116655. _isActive: boolean;
  116656. _onlyForInstances: boolean;
  116657. _isActiveIntermediate: boolean;
  116658. _onlyForInstancesIntermediate: boolean;
  116659. _actAsRegularMesh: boolean;
  116660. _currentLOD: Nullable<AbstractMesh>;
  116661. }
  116662. /**
  116663. * Class used to store all common mesh properties
  116664. */
  116665. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116666. /** No occlusion */
  116667. static OCCLUSION_TYPE_NONE: number;
  116668. /** Occlusion set to optimisitic */
  116669. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116670. /** Occlusion set to strict */
  116671. static OCCLUSION_TYPE_STRICT: number;
  116672. /** Use an accurante occlusion algorithm */
  116673. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116674. /** Use a conservative occlusion algorithm */
  116675. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116676. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116677. * Test order :
  116678. * Is the bounding sphere outside the frustum ?
  116679. * If not, are the bounding box vertices outside the frustum ?
  116680. * It not, then the cullable object is in the frustum.
  116681. */
  116682. static readonly CULLINGSTRATEGY_STANDARD: number;
  116683. /** Culling strategy : Bounding Sphere Only.
  116684. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116685. * It's also less accurate than the standard because some not visible objects can still be selected.
  116686. * Test : is the bounding sphere outside the frustum ?
  116687. * If not, then the cullable object is in the frustum.
  116688. */
  116689. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116690. /** Culling strategy : Optimistic Inclusion.
  116691. * This in an inclusion test first, then the standard exclusion test.
  116692. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116693. * 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.
  116694. * Anyway, it's as accurate as the standard strategy.
  116695. * Test :
  116696. * Is the cullable object bounding sphere center in the frustum ?
  116697. * If not, apply the default culling strategy.
  116698. */
  116699. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116700. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116701. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116702. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116703. * 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.
  116704. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116705. * Test :
  116706. * Is the cullable object bounding sphere center in the frustum ?
  116707. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116708. */
  116709. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116710. /**
  116711. * No billboard
  116712. */
  116713. static get BILLBOARDMODE_NONE(): number;
  116714. /** Billboard on X axis */
  116715. static get BILLBOARDMODE_X(): number;
  116716. /** Billboard on Y axis */
  116717. static get BILLBOARDMODE_Y(): number;
  116718. /** Billboard on Z axis */
  116719. static get BILLBOARDMODE_Z(): number;
  116720. /** Billboard on all axes */
  116721. static get BILLBOARDMODE_ALL(): number;
  116722. /** Billboard on using position instead of orientation */
  116723. static get BILLBOARDMODE_USE_POSITION(): number;
  116724. /** @hidden */
  116725. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116726. /**
  116727. * The culling strategy to use to check whether the mesh must be rendered or not.
  116728. * This value can be changed at any time and will be used on the next render mesh selection.
  116729. * The possible values are :
  116730. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116731. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116732. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116733. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116734. * Please read each static variable documentation to get details about the culling process.
  116735. * */
  116736. cullingStrategy: number;
  116737. /**
  116738. * Gets the number of facets in the mesh
  116739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116740. */
  116741. get facetNb(): number;
  116742. /**
  116743. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116744. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116745. */
  116746. get partitioningSubdivisions(): number;
  116747. set partitioningSubdivisions(nb: number);
  116748. /**
  116749. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116750. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116751. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116752. */
  116753. get partitioningBBoxRatio(): number;
  116754. set partitioningBBoxRatio(ratio: number);
  116755. /**
  116756. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116757. * Works only for updatable meshes.
  116758. * Doesn't work with multi-materials
  116759. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116760. */
  116761. get mustDepthSortFacets(): boolean;
  116762. set mustDepthSortFacets(sort: boolean);
  116763. /**
  116764. * The location (Vector3) where the facet depth sort must be computed from.
  116765. * By default, the active camera position.
  116766. * Used only when facet depth sort is enabled
  116767. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116768. */
  116769. get facetDepthSortFrom(): Vector3;
  116770. set facetDepthSortFrom(location: Vector3);
  116771. /**
  116772. * gets a boolean indicating if facetData is enabled
  116773. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116774. */
  116775. get isFacetDataEnabled(): boolean;
  116776. /** @hidden */
  116777. _updateNonUniformScalingState(value: boolean): boolean;
  116778. /**
  116779. * An event triggered when this mesh collides with another one
  116780. */
  116781. onCollideObservable: Observable<AbstractMesh>;
  116782. /** Set a function to call when this mesh collides with another one */
  116783. set onCollide(callback: () => void);
  116784. /**
  116785. * An event triggered when the collision's position changes
  116786. */
  116787. onCollisionPositionChangeObservable: Observable<Vector3>;
  116788. /** Set a function to call when the collision's position changes */
  116789. set onCollisionPositionChange(callback: () => void);
  116790. /**
  116791. * An event triggered when material is changed
  116792. */
  116793. onMaterialChangedObservable: Observable<AbstractMesh>;
  116794. /**
  116795. * Gets or sets the orientation for POV movement & rotation
  116796. */
  116797. definedFacingForward: boolean;
  116798. /** @hidden */
  116799. _occlusionQuery: Nullable<WebGLQuery>;
  116800. /** @hidden */
  116801. _renderingGroup: Nullable<RenderingGroup>;
  116802. /**
  116803. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116804. */
  116805. get visibility(): number;
  116806. /**
  116807. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116808. */
  116809. set visibility(value: number);
  116810. /** Gets or sets the alpha index used to sort transparent meshes
  116811. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116812. */
  116813. alphaIndex: number;
  116814. /**
  116815. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116816. */
  116817. isVisible: boolean;
  116818. /**
  116819. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116820. */
  116821. isPickable: boolean;
  116822. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116823. showSubMeshesBoundingBox: boolean;
  116824. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116825. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116826. */
  116827. isBlocker: boolean;
  116828. /**
  116829. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116830. */
  116831. enablePointerMoveEvents: boolean;
  116832. private _renderingGroupId;
  116833. /**
  116834. * Specifies the rendering group id for this mesh (0 by default)
  116835. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116836. */
  116837. get renderingGroupId(): number;
  116838. set renderingGroupId(value: number);
  116839. private _material;
  116840. /** Gets or sets current material */
  116841. get material(): Nullable<Material>;
  116842. set material(value: Nullable<Material>);
  116843. /**
  116844. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116845. * @see https://doc.babylonjs.com/babylon101/shadows
  116846. */
  116847. get receiveShadows(): boolean;
  116848. set receiveShadows(value: boolean);
  116849. /** Defines color to use when rendering outline */
  116850. outlineColor: Color3;
  116851. /** Define width to use when rendering outline */
  116852. outlineWidth: number;
  116853. /** Defines color to use when rendering overlay */
  116854. overlayColor: Color3;
  116855. /** Defines alpha to use when rendering overlay */
  116856. overlayAlpha: number;
  116857. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116858. get hasVertexAlpha(): boolean;
  116859. set hasVertexAlpha(value: boolean);
  116860. /** 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) */
  116861. get useVertexColors(): boolean;
  116862. set useVertexColors(value: boolean);
  116863. /**
  116864. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116865. */
  116866. get computeBonesUsingShaders(): boolean;
  116867. set computeBonesUsingShaders(value: boolean);
  116868. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116869. get numBoneInfluencers(): number;
  116870. set numBoneInfluencers(value: number);
  116871. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116872. get applyFog(): boolean;
  116873. set applyFog(value: boolean);
  116874. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116875. useOctreeForRenderingSelection: boolean;
  116876. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116877. useOctreeForPicking: boolean;
  116878. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116879. useOctreeForCollisions: boolean;
  116880. /**
  116881. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116882. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116883. */
  116884. get layerMask(): number;
  116885. set layerMask(value: number);
  116886. /**
  116887. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116888. */
  116889. alwaysSelectAsActiveMesh: boolean;
  116890. /**
  116891. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116892. */
  116893. doNotSyncBoundingInfo: boolean;
  116894. /**
  116895. * Gets or sets the current action manager
  116896. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116897. */
  116898. actionManager: Nullable<AbstractActionManager>;
  116899. private _meshCollisionData;
  116900. /**
  116901. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116902. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116903. */
  116904. ellipsoid: Vector3;
  116905. /**
  116906. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116907. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116908. */
  116909. ellipsoidOffset: Vector3;
  116910. /**
  116911. * Gets or sets a collision mask used to mask collisions (default is -1).
  116912. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116913. */
  116914. get collisionMask(): number;
  116915. set collisionMask(mask: number);
  116916. /**
  116917. * Gets or sets a collision response flag (default is true).
  116918. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116919. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116920. * to respond to the collision.
  116921. */
  116922. get collisionResponse(): boolean;
  116923. set collisionResponse(response: boolean);
  116924. /**
  116925. * Gets or sets the current collision group mask (-1 by default).
  116926. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116927. */
  116928. get collisionGroup(): number;
  116929. set collisionGroup(mask: number);
  116930. /**
  116931. * Gets or sets current surrounding meshes (null by default).
  116932. *
  116933. * By default collision detection is tested against every mesh in the scene.
  116934. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116935. * meshes will be tested for the collision.
  116936. *
  116937. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116938. */
  116939. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116940. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116941. /**
  116942. * Defines edge width used when edgesRenderer is enabled
  116943. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116944. */
  116945. edgesWidth: number;
  116946. /**
  116947. * Defines edge color used when edgesRenderer is enabled
  116948. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116949. */
  116950. edgesColor: Color4;
  116951. /** @hidden */
  116952. _edgesRenderer: Nullable<IEdgesRenderer>;
  116953. /** @hidden */
  116954. _masterMesh: Nullable<AbstractMesh>;
  116955. /** @hidden */
  116956. _boundingInfo: Nullable<BoundingInfo>;
  116957. /** @hidden */
  116958. _renderId: number;
  116959. /**
  116960. * Gets or sets the list of subMeshes
  116961. * @see https://doc.babylonjs.com/how_to/multi_materials
  116962. */
  116963. subMeshes: SubMesh[];
  116964. /** @hidden */
  116965. _intersectionsInProgress: AbstractMesh[];
  116966. /** @hidden */
  116967. _unIndexed: boolean;
  116968. /** @hidden */
  116969. _lightSources: Light[];
  116970. /** Gets the list of lights affecting that mesh */
  116971. get lightSources(): Light[];
  116972. /** @hidden */
  116973. get _positions(): Nullable<Vector3[]>;
  116974. /** @hidden */
  116975. _waitingData: {
  116976. lods: Nullable<any>;
  116977. actions: Nullable<any>;
  116978. freezeWorldMatrix: Nullable<boolean>;
  116979. };
  116980. /** @hidden */
  116981. _bonesTransformMatrices: Nullable<Float32Array>;
  116982. /** @hidden */
  116983. _transformMatrixTexture: Nullable<RawTexture>;
  116984. /**
  116985. * Gets or sets a skeleton to apply skining transformations
  116986. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116987. */
  116988. set skeleton(value: Nullable<Skeleton>);
  116989. get skeleton(): Nullable<Skeleton>;
  116990. /**
  116991. * An event triggered when the mesh is rebuilt.
  116992. */
  116993. onRebuildObservable: Observable<AbstractMesh>;
  116994. /**
  116995. * Creates a new AbstractMesh
  116996. * @param name defines the name of the mesh
  116997. * @param scene defines the hosting scene
  116998. */
  116999. constructor(name: string, scene?: Nullable<Scene>);
  117000. /**
  117001. * Returns the string "AbstractMesh"
  117002. * @returns "AbstractMesh"
  117003. */
  117004. getClassName(): string;
  117005. /**
  117006. * Gets a string representation of the current mesh
  117007. * @param fullDetails defines a boolean indicating if full details must be included
  117008. * @returns a string representation of the current mesh
  117009. */
  117010. toString(fullDetails?: boolean): string;
  117011. /**
  117012. * @hidden
  117013. */
  117014. protected _getEffectiveParent(): Nullable<Node>;
  117015. /** @hidden */
  117016. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117017. /** @hidden */
  117018. _rebuild(): void;
  117019. /** @hidden */
  117020. _resyncLightSources(): void;
  117021. /** @hidden */
  117022. _resyncLightSource(light: Light): void;
  117023. /** @hidden */
  117024. _unBindEffect(): void;
  117025. /** @hidden */
  117026. _removeLightSource(light: Light, dispose: boolean): void;
  117027. private _markSubMeshesAsDirty;
  117028. /** @hidden */
  117029. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  117030. /** @hidden */
  117031. _markSubMeshesAsAttributesDirty(): void;
  117032. /** @hidden */
  117033. _markSubMeshesAsMiscDirty(): void;
  117034. /**
  117035. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  117036. */
  117037. get scaling(): Vector3;
  117038. set scaling(newScaling: Vector3);
  117039. /**
  117040. * Returns true if the mesh is blocked. Implemented by child classes
  117041. */
  117042. get isBlocked(): boolean;
  117043. /**
  117044. * Returns the mesh itself by default. Implemented by child classes
  117045. * @param camera defines the camera to use to pick the right LOD level
  117046. * @returns the currentAbstractMesh
  117047. */
  117048. getLOD(camera: Camera): Nullable<AbstractMesh>;
  117049. /**
  117050. * Returns 0 by default. Implemented by child classes
  117051. * @returns an integer
  117052. */
  117053. getTotalVertices(): number;
  117054. /**
  117055. * Returns a positive integer : the total number of indices in this mesh geometry.
  117056. * @returns the numner of indices or zero if the mesh has no geometry.
  117057. */
  117058. getTotalIndices(): number;
  117059. /**
  117060. * Returns null by default. Implemented by child classes
  117061. * @returns null
  117062. */
  117063. getIndices(): Nullable<IndicesArray>;
  117064. /**
  117065. * Returns the array of the requested vertex data kind. Implemented by child classes
  117066. * @param kind defines the vertex data kind to use
  117067. * @returns null
  117068. */
  117069. getVerticesData(kind: string): Nullable<FloatArray>;
  117070. /**
  117071. * Sets the vertex data of the mesh geometry for the requested `kind`.
  117072. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  117073. * Note that a new underlying VertexBuffer object is created each call.
  117074. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  117075. * @param kind defines vertex data kind:
  117076. * * VertexBuffer.PositionKind
  117077. * * VertexBuffer.UVKind
  117078. * * VertexBuffer.UV2Kind
  117079. * * VertexBuffer.UV3Kind
  117080. * * VertexBuffer.UV4Kind
  117081. * * VertexBuffer.UV5Kind
  117082. * * VertexBuffer.UV6Kind
  117083. * * VertexBuffer.ColorKind
  117084. * * VertexBuffer.MatricesIndicesKind
  117085. * * VertexBuffer.MatricesIndicesExtraKind
  117086. * * VertexBuffer.MatricesWeightsKind
  117087. * * VertexBuffer.MatricesWeightsExtraKind
  117088. * @param data defines the data source
  117089. * @param updatable defines if the data must be flagged as updatable (or static)
  117090. * @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
  117091. * @returns the current mesh
  117092. */
  117093. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117094. /**
  117095. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117096. * If the mesh has no geometry, it is simply returned as it is.
  117097. * @param kind defines vertex data kind:
  117098. * * VertexBuffer.PositionKind
  117099. * * VertexBuffer.UVKind
  117100. * * VertexBuffer.UV2Kind
  117101. * * VertexBuffer.UV3Kind
  117102. * * VertexBuffer.UV4Kind
  117103. * * VertexBuffer.UV5Kind
  117104. * * VertexBuffer.UV6Kind
  117105. * * VertexBuffer.ColorKind
  117106. * * VertexBuffer.MatricesIndicesKind
  117107. * * VertexBuffer.MatricesIndicesExtraKind
  117108. * * VertexBuffer.MatricesWeightsKind
  117109. * * VertexBuffer.MatricesWeightsExtraKind
  117110. * @param data defines the data source
  117111. * @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
  117112. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117113. * @returns the current mesh
  117114. */
  117115. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117116. /**
  117117. * Sets the mesh indices,
  117118. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117119. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117120. * @param totalVertices Defines the total number of vertices
  117121. * @returns the current mesh
  117122. */
  117123. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117124. /**
  117125. * Gets a boolean indicating if specific vertex data is present
  117126. * @param kind defines the vertex data kind to use
  117127. * @returns true is data kind is present
  117128. */
  117129. isVerticesDataPresent(kind: string): boolean;
  117130. /**
  117131. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117132. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117133. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117134. * @returns a BoundingInfo
  117135. */
  117136. getBoundingInfo(): BoundingInfo;
  117137. /**
  117138. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117139. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117140. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117141. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117142. * @returns the current mesh
  117143. */
  117144. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117145. /**
  117146. * Overwrite the current bounding info
  117147. * @param boundingInfo defines the new bounding info
  117148. * @returns the current mesh
  117149. */
  117150. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117151. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117152. get useBones(): boolean;
  117153. /** @hidden */
  117154. _preActivate(): void;
  117155. /** @hidden */
  117156. _preActivateForIntermediateRendering(renderId: number): void;
  117157. /** @hidden */
  117158. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117159. /** @hidden */
  117160. _postActivate(): void;
  117161. /** @hidden */
  117162. _freeze(): void;
  117163. /** @hidden */
  117164. _unFreeze(): void;
  117165. /**
  117166. * Gets the current world matrix
  117167. * @returns a Matrix
  117168. */
  117169. getWorldMatrix(): Matrix;
  117170. /** @hidden */
  117171. _getWorldMatrixDeterminant(): number;
  117172. /**
  117173. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117174. */
  117175. get isAnInstance(): boolean;
  117176. /**
  117177. * Gets a boolean indicating if this mesh has instances
  117178. */
  117179. get hasInstances(): boolean;
  117180. /**
  117181. * Gets a boolean indicating if this mesh has thin instances
  117182. */
  117183. get hasThinInstances(): boolean;
  117184. /**
  117185. * Perform relative position change from the point of view of behind the front of the mesh.
  117186. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117187. * Supports definition of mesh facing forward or backward
  117188. * @param amountRight defines the distance on the right axis
  117189. * @param amountUp defines the distance on the up axis
  117190. * @param amountForward defines the distance on the forward axis
  117191. * @returns the current mesh
  117192. */
  117193. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117194. /**
  117195. * Calculate relative position change from the point of view of behind the front of the mesh.
  117196. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117197. * Supports definition of mesh facing forward or backward
  117198. * @param amountRight defines the distance on the right axis
  117199. * @param amountUp defines the distance on the up axis
  117200. * @param amountForward defines the distance on the forward axis
  117201. * @returns the new displacement vector
  117202. */
  117203. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117204. /**
  117205. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117206. * Supports definition of mesh facing forward or backward
  117207. * @param flipBack defines the flip
  117208. * @param twirlClockwise defines the twirl
  117209. * @param tiltRight defines the tilt
  117210. * @returns the current mesh
  117211. */
  117212. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117213. /**
  117214. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117215. * Supports definition of mesh facing forward or backward.
  117216. * @param flipBack defines the flip
  117217. * @param twirlClockwise defines the twirl
  117218. * @param tiltRight defines the tilt
  117219. * @returns the new rotation vector
  117220. */
  117221. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117222. /**
  117223. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117224. * This means the mesh underlying bounding box and sphere are recomputed.
  117225. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117226. * @returns the current mesh
  117227. */
  117228. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117229. /** @hidden */
  117230. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117231. /** @hidden */
  117232. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117233. /** @hidden */
  117234. _updateBoundingInfo(): AbstractMesh;
  117235. /** @hidden */
  117236. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117237. /** @hidden */
  117238. protected _afterComputeWorldMatrix(): void;
  117239. /** @hidden */
  117240. get _effectiveMesh(): AbstractMesh;
  117241. /**
  117242. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117243. * A mesh is in the frustum if its bounding box intersects the frustum
  117244. * @param frustumPlanes defines the frustum to test
  117245. * @returns true if the mesh is in the frustum planes
  117246. */
  117247. isInFrustum(frustumPlanes: Plane[]): boolean;
  117248. /**
  117249. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117250. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117251. * @param frustumPlanes defines the frustum to test
  117252. * @returns true if the mesh is completely in the frustum planes
  117253. */
  117254. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117255. /**
  117256. * True if the mesh intersects another mesh or a SolidParticle object
  117257. * @param mesh defines a target mesh or SolidParticle to test
  117258. * @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)
  117259. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117260. * @returns true if there is an intersection
  117261. */
  117262. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117263. /**
  117264. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117265. * @param point defines the point to test
  117266. * @returns true if there is an intersection
  117267. */
  117268. intersectsPoint(point: Vector3): boolean;
  117269. /**
  117270. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117271. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117272. */
  117273. get checkCollisions(): boolean;
  117274. set checkCollisions(collisionEnabled: boolean);
  117275. /**
  117276. * Gets Collider object used to compute collisions (not physics)
  117277. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117278. */
  117279. get collider(): Nullable<Collider>;
  117280. /**
  117281. * Move the mesh using collision engine
  117282. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117283. * @param displacement defines the requested displacement vector
  117284. * @returns the current mesh
  117285. */
  117286. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117287. private _onCollisionPositionChange;
  117288. /** @hidden */
  117289. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117290. /** @hidden */
  117291. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117292. /** @hidden */
  117293. _checkCollision(collider: Collider): AbstractMesh;
  117294. /** @hidden */
  117295. _generatePointsArray(): boolean;
  117296. /**
  117297. * Checks if the passed Ray intersects with the mesh
  117298. * @param ray defines the ray to use
  117299. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117300. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117301. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117302. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117303. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117304. * @returns the picking info
  117305. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117306. */
  117307. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117308. /**
  117309. * Clones the current mesh
  117310. * @param name defines the mesh name
  117311. * @param newParent defines the new mesh parent
  117312. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117313. * @returns the new mesh
  117314. */
  117315. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117316. /**
  117317. * Disposes all the submeshes of the current meshnp
  117318. * @returns the current mesh
  117319. */
  117320. releaseSubMeshes(): AbstractMesh;
  117321. /**
  117322. * Releases resources associated with this abstract mesh.
  117323. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117324. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117325. */
  117326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117327. /**
  117328. * Adds the passed mesh as a child to the current mesh
  117329. * @param mesh defines the child mesh
  117330. * @returns the current mesh
  117331. */
  117332. addChild(mesh: AbstractMesh): AbstractMesh;
  117333. /**
  117334. * Removes the passed mesh from the current mesh children list
  117335. * @param mesh defines the child mesh
  117336. * @returns the current mesh
  117337. */
  117338. removeChild(mesh: AbstractMesh): AbstractMesh;
  117339. /** @hidden */
  117340. private _initFacetData;
  117341. /**
  117342. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117343. * This method can be called within the render loop.
  117344. * 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
  117345. * @returns the current mesh
  117346. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117347. */
  117348. updateFacetData(): AbstractMesh;
  117349. /**
  117350. * Returns the facetLocalNormals array.
  117351. * The normals are expressed in the mesh local spac
  117352. * @returns an array of Vector3
  117353. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117354. */
  117355. getFacetLocalNormals(): Vector3[];
  117356. /**
  117357. * Returns the facetLocalPositions array.
  117358. * The facet positions are expressed in the mesh local space
  117359. * @returns an array of Vector3
  117360. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117361. */
  117362. getFacetLocalPositions(): Vector3[];
  117363. /**
  117364. * Returns the facetLocalPartioning array
  117365. * @returns an array of array of numbers
  117366. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117367. */
  117368. getFacetLocalPartitioning(): number[][];
  117369. /**
  117370. * Returns the i-th facet position in the world system.
  117371. * This method allocates a new Vector3 per call
  117372. * @param i defines the facet index
  117373. * @returns a new Vector3
  117374. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117375. */
  117376. getFacetPosition(i: number): Vector3;
  117377. /**
  117378. * Sets the reference Vector3 with the i-th facet position in the world system
  117379. * @param i defines the facet index
  117380. * @param ref defines the target vector
  117381. * @returns the current mesh
  117382. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117383. */
  117384. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117385. /**
  117386. * Returns the i-th facet normal in the world system.
  117387. * This method allocates a new Vector3 per call
  117388. * @param i defines the facet index
  117389. * @returns a new Vector3
  117390. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117391. */
  117392. getFacetNormal(i: number): Vector3;
  117393. /**
  117394. * Sets the reference Vector3 with the i-th facet normal in the world system
  117395. * @param i defines the facet index
  117396. * @param ref defines the target vector
  117397. * @returns the current mesh
  117398. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117399. */
  117400. getFacetNormalToRef(i: number, ref: Vector3): this;
  117401. /**
  117402. * 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)
  117403. * @param x defines x coordinate
  117404. * @param y defines y coordinate
  117405. * @param z defines z coordinate
  117406. * @returns the array of facet indexes
  117407. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117408. */
  117409. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117410. /**
  117411. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117412. * @param projected sets as the (x,y,z) world projection on the facet
  117413. * @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
  117414. * @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
  117415. * @param x defines x coordinate
  117416. * @param y defines y coordinate
  117417. * @param z defines z coordinate
  117418. * @returns the face index if found (or null instead)
  117419. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117420. */
  117421. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117422. /**
  117423. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117424. * @param projected sets as the (x,y,z) local projection on the facet
  117425. * @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
  117426. * @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
  117427. * @param x defines x coordinate
  117428. * @param y defines y coordinate
  117429. * @param z defines z coordinate
  117430. * @returns the face index if found (or null instead)
  117431. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117432. */
  117433. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117434. /**
  117435. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117436. * @returns the parameters
  117437. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117438. */
  117439. getFacetDataParameters(): any;
  117440. /**
  117441. * Disables the feature FacetData and frees the related memory
  117442. * @returns the current mesh
  117443. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117444. */
  117445. disableFacetData(): AbstractMesh;
  117446. /**
  117447. * Updates the AbstractMesh indices array
  117448. * @param indices defines the data source
  117449. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117450. * @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)
  117451. * @returns the current mesh
  117452. */
  117453. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117454. /**
  117455. * Creates new normals data for the mesh
  117456. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117457. * @returns the current mesh
  117458. */
  117459. createNormals(updatable: boolean): AbstractMesh;
  117460. /**
  117461. * Align the mesh with a normal
  117462. * @param normal defines the normal to use
  117463. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117464. * @returns the current mesh
  117465. */
  117466. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117467. /** @hidden */
  117468. _checkOcclusionQuery(): boolean;
  117469. /**
  117470. * Disables the mesh edge rendering mode
  117471. * @returns the currentAbstractMesh
  117472. */
  117473. disableEdgesRendering(): AbstractMesh;
  117474. /**
  117475. * Enables the edge rendering mode on the mesh.
  117476. * This mode makes the mesh edges visible
  117477. * @param epsilon defines the maximal distance between two angles to detect a face
  117478. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117479. * @returns the currentAbstractMesh
  117480. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117481. */
  117482. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  117483. /**
  117484. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117485. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117486. */
  117487. getConnectedParticleSystems(): IParticleSystem[];
  117488. }
  117489. }
  117490. declare module BABYLON {
  117491. /**
  117492. * Interface used to define ActionEvent
  117493. */
  117494. export interface IActionEvent {
  117495. /** The mesh or sprite that triggered the action */
  117496. source: any;
  117497. /** The X mouse cursor position at the time of the event */
  117498. pointerX: number;
  117499. /** The Y mouse cursor position at the time of the event */
  117500. pointerY: number;
  117501. /** The mesh that is currently pointed at (can be null) */
  117502. meshUnderPointer: Nullable<AbstractMesh>;
  117503. /** the original (browser) event that triggered the ActionEvent */
  117504. sourceEvent?: any;
  117505. /** additional data for the event */
  117506. additionalData?: any;
  117507. }
  117508. /**
  117509. * ActionEvent is the event being sent when an action is triggered.
  117510. */
  117511. export class ActionEvent implements IActionEvent {
  117512. /** The mesh or sprite that triggered the action */
  117513. source: any;
  117514. /** The X mouse cursor position at the time of the event */
  117515. pointerX: number;
  117516. /** The Y mouse cursor position at the time of the event */
  117517. pointerY: number;
  117518. /** The mesh that is currently pointed at (can be null) */
  117519. meshUnderPointer: Nullable<AbstractMesh>;
  117520. /** the original (browser) event that triggered the ActionEvent */
  117521. sourceEvent?: any;
  117522. /** additional data for the event */
  117523. additionalData?: any;
  117524. /**
  117525. * Creates a new ActionEvent
  117526. * @param source The mesh or sprite that triggered the action
  117527. * @param pointerX The X mouse cursor position at the time of the event
  117528. * @param pointerY The Y mouse cursor position at the time of the event
  117529. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117530. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117531. * @param additionalData additional data for the event
  117532. */
  117533. constructor(
  117534. /** The mesh or sprite that triggered the action */
  117535. source: any,
  117536. /** The X mouse cursor position at the time of the event */
  117537. pointerX: number,
  117538. /** The Y mouse cursor position at the time of the event */
  117539. pointerY: number,
  117540. /** The mesh that is currently pointed at (can be null) */
  117541. meshUnderPointer: Nullable<AbstractMesh>,
  117542. /** the original (browser) event that triggered the ActionEvent */
  117543. sourceEvent?: any,
  117544. /** additional data for the event */
  117545. additionalData?: any);
  117546. /**
  117547. * Helper function to auto-create an ActionEvent from a source mesh.
  117548. * @param source The source mesh that triggered the event
  117549. * @param evt The original (browser) event
  117550. * @param additionalData additional data for the event
  117551. * @returns the new ActionEvent
  117552. */
  117553. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117554. /**
  117555. * Helper function to auto-create an ActionEvent from a source sprite
  117556. * @param source The source sprite that triggered the event
  117557. * @param scene Scene associated with the sprite
  117558. * @param evt The original (browser) event
  117559. * @param additionalData additional data for the event
  117560. * @returns the new ActionEvent
  117561. */
  117562. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117563. /**
  117564. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117565. * @param scene the scene where the event occurred
  117566. * @param evt The original (browser) event
  117567. * @returns the new ActionEvent
  117568. */
  117569. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117570. /**
  117571. * Helper function to auto-create an ActionEvent from a primitive
  117572. * @param prim defines the target primitive
  117573. * @param pointerPos defines the pointer position
  117574. * @param evt The original (browser) event
  117575. * @param additionalData additional data for the event
  117576. * @returns the new ActionEvent
  117577. */
  117578. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117579. }
  117580. }
  117581. declare module BABYLON {
  117582. /**
  117583. * Abstract class used to decouple action Manager from scene and meshes.
  117584. * Do not instantiate.
  117585. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117586. */
  117587. export abstract class AbstractActionManager implements IDisposable {
  117588. /** Gets the list of active triggers */
  117589. static Triggers: {
  117590. [key: string]: number;
  117591. };
  117592. /** Gets the cursor to use when hovering items */
  117593. hoverCursor: string;
  117594. /** Gets the list of actions */
  117595. actions: IAction[];
  117596. /**
  117597. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117598. */
  117599. isRecursive: boolean;
  117600. /**
  117601. * Releases all associated resources
  117602. */
  117603. abstract dispose(): void;
  117604. /**
  117605. * Does this action manager has pointer triggers
  117606. */
  117607. abstract get hasPointerTriggers(): boolean;
  117608. /**
  117609. * Does this action manager has pick triggers
  117610. */
  117611. abstract get hasPickTriggers(): boolean;
  117612. /**
  117613. * Process a specific trigger
  117614. * @param trigger defines the trigger to process
  117615. * @param evt defines the event details to be processed
  117616. */
  117617. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117618. /**
  117619. * Does this action manager handles actions of any of the given triggers
  117620. * @param triggers defines the triggers to be tested
  117621. * @return a boolean indicating whether one (or more) of the triggers is handled
  117622. */
  117623. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117624. /**
  117625. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117626. * speed.
  117627. * @param triggerA defines the trigger to be tested
  117628. * @param triggerB defines the trigger to be tested
  117629. * @return a boolean indicating whether one (or more) of the triggers is handled
  117630. */
  117631. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117632. /**
  117633. * Does this action manager handles actions of a given trigger
  117634. * @param trigger defines the trigger to be tested
  117635. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117636. * @return whether the trigger is handled
  117637. */
  117638. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117639. /**
  117640. * Serialize this manager to a JSON object
  117641. * @param name defines the property name to store this manager
  117642. * @returns a JSON representation of this manager
  117643. */
  117644. abstract serialize(name: string): any;
  117645. /**
  117646. * Registers an action to this action manager
  117647. * @param action defines the action to be registered
  117648. * @return the action amended (prepared) after registration
  117649. */
  117650. abstract registerAction(action: IAction): Nullable<IAction>;
  117651. /**
  117652. * Unregisters an action to this action manager
  117653. * @param action defines the action to be unregistered
  117654. * @return a boolean indicating whether the action has been unregistered
  117655. */
  117656. abstract unregisterAction(action: IAction): Boolean;
  117657. /**
  117658. * Does exist one action manager with at least one trigger
  117659. **/
  117660. static get HasTriggers(): boolean;
  117661. /**
  117662. * Does exist one action manager with at least one pick trigger
  117663. **/
  117664. static get HasPickTriggers(): boolean;
  117665. /**
  117666. * Does exist one action manager that handles actions of a given trigger
  117667. * @param trigger defines the trigger to be tested
  117668. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117669. **/
  117670. static HasSpecificTrigger(trigger: number): boolean;
  117671. }
  117672. }
  117673. declare module BABYLON {
  117674. /**
  117675. * Defines how a node can be built from a string name.
  117676. */
  117677. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117678. /**
  117679. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117680. */
  117681. export class Node implements IBehaviorAware<Node> {
  117682. /** @hidden */
  117683. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117684. private static _NodeConstructors;
  117685. /**
  117686. * Add a new node constructor
  117687. * @param type defines the type name of the node to construct
  117688. * @param constructorFunc defines the constructor function
  117689. */
  117690. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117691. /**
  117692. * Returns a node constructor based on type name
  117693. * @param type defines the type name
  117694. * @param name defines the new node name
  117695. * @param scene defines the hosting scene
  117696. * @param options defines optional options to transmit to constructors
  117697. * @returns the new constructor or null
  117698. */
  117699. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117700. /**
  117701. * Gets or sets the name of the node
  117702. */
  117703. name: string;
  117704. /**
  117705. * Gets or sets the id of the node
  117706. */
  117707. id: string;
  117708. /**
  117709. * Gets or sets the unique id of the node
  117710. */
  117711. uniqueId: number;
  117712. /**
  117713. * Gets or sets a string used to store user defined state for the node
  117714. */
  117715. state: string;
  117716. /**
  117717. * Gets or sets an object used to store user defined information for the node
  117718. */
  117719. metadata: any;
  117720. /**
  117721. * For internal use only. Please do not use.
  117722. */
  117723. reservedDataStore: any;
  117724. /**
  117725. * List of inspectable custom properties (used by the Inspector)
  117726. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117727. */
  117728. inspectableCustomProperties: IInspectable[];
  117729. private _doNotSerialize;
  117730. /**
  117731. * Gets or sets a boolean used to define if the node must be serialized
  117732. */
  117733. get doNotSerialize(): boolean;
  117734. set doNotSerialize(value: boolean);
  117735. /** @hidden */
  117736. _isDisposed: boolean;
  117737. /**
  117738. * Gets a list of Animations associated with the node
  117739. */
  117740. animations: Animation[];
  117741. protected _ranges: {
  117742. [name: string]: Nullable<AnimationRange>;
  117743. };
  117744. /**
  117745. * Callback raised when the node is ready to be used
  117746. */
  117747. onReady: Nullable<(node: Node) => void>;
  117748. private _isEnabled;
  117749. private _isParentEnabled;
  117750. private _isReady;
  117751. /** @hidden */
  117752. _currentRenderId: number;
  117753. private _parentUpdateId;
  117754. /** @hidden */
  117755. _childUpdateId: number;
  117756. /** @hidden */
  117757. _waitingParentId: Nullable<string>;
  117758. /** @hidden */
  117759. _scene: Scene;
  117760. /** @hidden */
  117761. _cache: any;
  117762. private _parentNode;
  117763. private _children;
  117764. /** @hidden */
  117765. _worldMatrix: Matrix;
  117766. /** @hidden */
  117767. _worldMatrixDeterminant: number;
  117768. /** @hidden */
  117769. _worldMatrixDeterminantIsDirty: boolean;
  117770. /** @hidden */
  117771. private _sceneRootNodesIndex;
  117772. /**
  117773. * Gets a boolean indicating if the node has been disposed
  117774. * @returns true if the node was disposed
  117775. */
  117776. isDisposed(): boolean;
  117777. /**
  117778. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117779. * @see https://doc.babylonjs.com/how_to/parenting
  117780. */
  117781. set parent(parent: Nullable<Node>);
  117782. get parent(): Nullable<Node>;
  117783. /** @hidden */
  117784. _addToSceneRootNodes(): void;
  117785. /** @hidden */
  117786. _removeFromSceneRootNodes(): void;
  117787. private _animationPropertiesOverride;
  117788. /**
  117789. * Gets or sets the animation properties override
  117790. */
  117791. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117792. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117793. /**
  117794. * Gets a string identifying the name of the class
  117795. * @returns "Node" string
  117796. */
  117797. getClassName(): string;
  117798. /** @hidden */
  117799. readonly _isNode: boolean;
  117800. /**
  117801. * An event triggered when the mesh is disposed
  117802. */
  117803. onDisposeObservable: Observable<Node>;
  117804. private _onDisposeObserver;
  117805. /**
  117806. * Sets a callback that will be raised when the node will be disposed
  117807. */
  117808. set onDispose(callback: () => void);
  117809. /**
  117810. * Creates a new Node
  117811. * @param name the name and id to be given to this node
  117812. * @param scene the scene this node will be added to
  117813. */
  117814. constructor(name: string, scene?: Nullable<Scene>);
  117815. /**
  117816. * Gets the scene of the node
  117817. * @returns a scene
  117818. */
  117819. getScene(): Scene;
  117820. /**
  117821. * Gets the engine of the node
  117822. * @returns a Engine
  117823. */
  117824. getEngine(): Engine;
  117825. private _behaviors;
  117826. /**
  117827. * Attach a behavior to the node
  117828. * @see https://doc.babylonjs.com/features/behaviour
  117829. * @param behavior defines the behavior to attach
  117830. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117831. * @returns the current Node
  117832. */
  117833. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117834. /**
  117835. * Remove an attached behavior
  117836. * @see https://doc.babylonjs.com/features/behaviour
  117837. * @param behavior defines the behavior to attach
  117838. * @returns the current Node
  117839. */
  117840. removeBehavior(behavior: Behavior<Node>): Node;
  117841. /**
  117842. * Gets the list of attached behaviors
  117843. * @see https://doc.babylonjs.com/features/behaviour
  117844. */
  117845. get behaviors(): Behavior<Node>[];
  117846. /**
  117847. * Gets an attached behavior by name
  117848. * @param name defines the name of the behavior to look for
  117849. * @see https://doc.babylonjs.com/features/behaviour
  117850. * @returns null if behavior was not found else the requested behavior
  117851. */
  117852. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117853. /**
  117854. * Returns the latest update of the World matrix
  117855. * @returns a Matrix
  117856. */
  117857. getWorldMatrix(): Matrix;
  117858. /** @hidden */
  117859. _getWorldMatrixDeterminant(): number;
  117860. /**
  117861. * Returns directly the latest state of the mesh World matrix.
  117862. * A Matrix is returned.
  117863. */
  117864. get worldMatrixFromCache(): Matrix;
  117865. /** @hidden */
  117866. _initCache(): void;
  117867. /** @hidden */
  117868. updateCache(force?: boolean): void;
  117869. /** @hidden */
  117870. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117871. /** @hidden */
  117872. _updateCache(ignoreParentClass?: boolean): void;
  117873. /** @hidden */
  117874. _isSynchronized(): boolean;
  117875. /** @hidden */
  117876. _markSyncedWithParent(): void;
  117877. /** @hidden */
  117878. isSynchronizedWithParent(): boolean;
  117879. /** @hidden */
  117880. isSynchronized(): boolean;
  117881. /**
  117882. * Is this node ready to be used/rendered
  117883. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117884. * @return true if the node is ready
  117885. */
  117886. isReady(completeCheck?: boolean): boolean;
  117887. /**
  117888. * Is this node enabled?
  117889. * 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
  117890. * @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
  117891. * @return whether this node (and its parent) is enabled
  117892. */
  117893. isEnabled(checkAncestors?: boolean): boolean;
  117894. /** @hidden */
  117895. protected _syncParentEnabledState(): void;
  117896. /**
  117897. * Set the enabled state of this node
  117898. * @param value defines the new enabled state
  117899. */
  117900. setEnabled(value: boolean): void;
  117901. /**
  117902. * Is this node a descendant of the given node?
  117903. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117904. * @param ancestor defines the parent node to inspect
  117905. * @returns a boolean indicating if this node is a descendant of the given node
  117906. */
  117907. isDescendantOf(ancestor: Node): boolean;
  117908. /** @hidden */
  117909. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117910. /**
  117911. * Will return all nodes that have this node as ascendant
  117912. * @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
  117913. * @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
  117914. * @return all children nodes of all types
  117915. */
  117916. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117917. /**
  117918. * Get all child-meshes of this node
  117919. * @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)
  117920. * @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
  117921. * @returns an array of AbstractMesh
  117922. */
  117923. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117924. /**
  117925. * Get all direct children of this node
  117926. * @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
  117927. * @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)
  117928. * @returns an array of Node
  117929. */
  117930. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117931. /** @hidden */
  117932. _setReady(state: boolean): void;
  117933. /**
  117934. * Get an animation by name
  117935. * @param name defines the name of the animation to look for
  117936. * @returns null if not found else the requested animation
  117937. */
  117938. getAnimationByName(name: string): Nullable<Animation>;
  117939. /**
  117940. * Creates an animation range for this node
  117941. * @param name defines the name of the range
  117942. * @param from defines the starting key
  117943. * @param to defines the end key
  117944. */
  117945. createAnimationRange(name: string, from: number, to: number): void;
  117946. /**
  117947. * Delete a specific animation range
  117948. * @param name defines the name of the range to delete
  117949. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117950. */
  117951. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117952. /**
  117953. * Get an animation range by name
  117954. * @param name defines the name of the animation range to look for
  117955. * @returns null if not found else the requested animation range
  117956. */
  117957. getAnimationRange(name: string): Nullable<AnimationRange>;
  117958. /**
  117959. * Gets the list of all animation ranges defined on this node
  117960. * @returns an array
  117961. */
  117962. getAnimationRanges(): Nullable<AnimationRange>[];
  117963. /**
  117964. * Will start the animation sequence
  117965. * @param name defines the range frames for animation sequence
  117966. * @param loop defines if the animation should loop (false by default)
  117967. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117968. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117969. * @returns the object created for this animation. If range does not exist, it will return null
  117970. */
  117971. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117972. /**
  117973. * Serialize animation ranges into a JSON compatible object
  117974. * @returns serialization object
  117975. */
  117976. serializeAnimationRanges(): any;
  117977. /**
  117978. * Computes the world matrix of the node
  117979. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117980. * @returns the world matrix
  117981. */
  117982. computeWorldMatrix(force?: boolean): Matrix;
  117983. /**
  117984. * Releases resources associated with this node.
  117985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117987. */
  117988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117989. /**
  117990. * Parse animation range data from a serialization object and store them into a given node
  117991. * @param node defines where to store the animation ranges
  117992. * @param parsedNode defines the serialization object to read data from
  117993. * @param scene defines the hosting scene
  117994. */
  117995. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117996. /**
  117997. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117998. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117999. * @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
  118000. * @returns the new bounding vectors
  118001. */
  118002. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  118003. min: Vector3;
  118004. max: Vector3;
  118005. };
  118006. }
  118007. }
  118008. declare module BABYLON {
  118009. /**
  118010. * @hidden
  118011. */
  118012. export class _IAnimationState {
  118013. key: number;
  118014. repeatCount: number;
  118015. workValue?: any;
  118016. loopMode?: number;
  118017. offsetValue?: any;
  118018. highLimitValue?: any;
  118019. }
  118020. /**
  118021. * Class used to store any kind of animation
  118022. */
  118023. export class Animation {
  118024. /**Name of the animation */
  118025. name: string;
  118026. /**Property to animate */
  118027. targetProperty: string;
  118028. /**The frames per second of the animation */
  118029. framePerSecond: number;
  118030. /**The data type of the animation */
  118031. dataType: number;
  118032. /**The loop mode of the animation */
  118033. loopMode?: number | undefined;
  118034. /**Specifies if blending should be enabled */
  118035. enableBlending?: boolean | undefined;
  118036. /**
  118037. * Use matrix interpolation instead of using direct key value when animating matrices
  118038. */
  118039. static AllowMatricesInterpolation: boolean;
  118040. /**
  118041. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  118042. */
  118043. static AllowMatrixDecomposeForInterpolation: boolean;
  118044. /** Define the Url to load snippets */
  118045. static SnippetUrl: string;
  118046. /** Snippet ID if the animation was created from the snippet server */
  118047. snippetId: string;
  118048. /**
  118049. * Stores the key frames of the animation
  118050. */
  118051. private _keys;
  118052. /**
  118053. * Stores the easing function of the animation
  118054. */
  118055. private _easingFunction;
  118056. /**
  118057. * @hidden Internal use only
  118058. */
  118059. _runtimeAnimations: RuntimeAnimation[];
  118060. /**
  118061. * The set of event that will be linked to this animation
  118062. */
  118063. private _events;
  118064. /**
  118065. * Stores an array of target property paths
  118066. */
  118067. targetPropertyPath: string[];
  118068. /**
  118069. * Stores the blending speed of the animation
  118070. */
  118071. blendingSpeed: number;
  118072. /**
  118073. * Stores the animation ranges for the animation
  118074. */
  118075. private _ranges;
  118076. /**
  118077. * @hidden Internal use
  118078. */
  118079. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  118080. /**
  118081. * Sets up an animation
  118082. * @param property The property to animate
  118083. * @param animationType The animation type to apply
  118084. * @param framePerSecond The frames per second of the animation
  118085. * @param easingFunction The easing function used in the animation
  118086. * @returns The created animation
  118087. */
  118088. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  118089. /**
  118090. * Create and start an animation on a node
  118091. * @param name defines the name of the global animation that will be run on all nodes
  118092. * @param node defines the root node where the animation will take place
  118093. * @param targetProperty defines property to animate
  118094. * @param framePerSecond defines the number of frame per second yo use
  118095. * @param totalFrame defines the number of frames in total
  118096. * @param from defines the initial value
  118097. * @param to defines the final value
  118098. * @param loopMode defines which loop mode you want to use (off by default)
  118099. * @param easingFunction defines the easing function to use (linear by default)
  118100. * @param onAnimationEnd defines the callback to call when animation end
  118101. * @returns the animatable created for this animation
  118102. */
  118103. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118104. /**
  118105. * Create and start an animation on a node and its descendants
  118106. * @param name defines the name of the global animation that will be run on all nodes
  118107. * @param node defines the root node where the animation will take place
  118108. * @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
  118109. * @param targetProperty defines property to animate
  118110. * @param framePerSecond defines the number of frame per second to use
  118111. * @param totalFrame defines the number of frames in total
  118112. * @param from defines the initial value
  118113. * @param to defines the final value
  118114. * @param loopMode defines which loop mode you want to use (off by default)
  118115. * @param easingFunction defines the easing function to use (linear by default)
  118116. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118117. * @returns the list of animatables created for all nodes
  118118. * @example https://www.babylonjs-playground.com/#MH0VLI
  118119. */
  118120. 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[]>;
  118121. /**
  118122. * Creates a new animation, merges it with the existing animations and starts it
  118123. * @param name Name of the animation
  118124. * @param node Node which contains the scene that begins the animations
  118125. * @param targetProperty Specifies which property to animate
  118126. * @param framePerSecond The frames per second of the animation
  118127. * @param totalFrame The total number of frames
  118128. * @param from The frame at the beginning of the animation
  118129. * @param to The frame at the end of the animation
  118130. * @param loopMode Specifies the loop mode of the animation
  118131. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118132. * @param onAnimationEnd Callback to run once the animation is complete
  118133. * @returns Nullable animation
  118134. */
  118135. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118136. /**
  118137. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118138. * @param sourceAnimation defines the Animation containing keyframes to convert
  118139. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118140. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118141. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118142. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118143. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118144. */
  118145. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118146. /**
  118147. * Transition property of an host to the target Value
  118148. * @param property The property to transition
  118149. * @param targetValue The target Value of the property
  118150. * @param host The object where the property to animate belongs
  118151. * @param scene Scene used to run the animation
  118152. * @param frameRate Framerate (in frame/s) to use
  118153. * @param transition The transition type we want to use
  118154. * @param duration The duration of the animation, in milliseconds
  118155. * @param onAnimationEnd Callback trigger at the end of the animation
  118156. * @returns Nullable animation
  118157. */
  118158. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118159. /**
  118160. * Return the array of runtime animations currently using this animation
  118161. */
  118162. get runtimeAnimations(): RuntimeAnimation[];
  118163. /**
  118164. * Specifies if any of the runtime animations are currently running
  118165. */
  118166. get hasRunningRuntimeAnimations(): boolean;
  118167. /**
  118168. * Initializes the animation
  118169. * @param name Name of the animation
  118170. * @param targetProperty Property to animate
  118171. * @param framePerSecond The frames per second of the animation
  118172. * @param dataType The data type of the animation
  118173. * @param loopMode The loop mode of the animation
  118174. * @param enableBlending Specifies if blending should be enabled
  118175. */
  118176. constructor(
  118177. /**Name of the animation */
  118178. name: string,
  118179. /**Property to animate */
  118180. targetProperty: string,
  118181. /**The frames per second of the animation */
  118182. framePerSecond: number,
  118183. /**The data type of the animation */
  118184. dataType: number,
  118185. /**The loop mode of the animation */
  118186. loopMode?: number | undefined,
  118187. /**Specifies if blending should be enabled */
  118188. enableBlending?: boolean | undefined);
  118189. /**
  118190. * Converts the animation to a string
  118191. * @param fullDetails support for multiple levels of logging within scene loading
  118192. * @returns String form of the animation
  118193. */
  118194. toString(fullDetails?: boolean): string;
  118195. /**
  118196. * Add an event to this animation
  118197. * @param event Event to add
  118198. */
  118199. addEvent(event: AnimationEvent): void;
  118200. /**
  118201. * Remove all events found at the given frame
  118202. * @param frame The frame to remove events from
  118203. */
  118204. removeEvents(frame: number): void;
  118205. /**
  118206. * Retrieves all the events from the animation
  118207. * @returns Events from the animation
  118208. */
  118209. getEvents(): AnimationEvent[];
  118210. /**
  118211. * Creates an animation range
  118212. * @param name Name of the animation range
  118213. * @param from Starting frame of the animation range
  118214. * @param to Ending frame of the animation
  118215. */
  118216. createRange(name: string, from: number, to: number): void;
  118217. /**
  118218. * Deletes an animation range by name
  118219. * @param name Name of the animation range to delete
  118220. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118221. */
  118222. deleteRange(name: string, deleteFrames?: boolean): void;
  118223. /**
  118224. * Gets the animation range by name, or null if not defined
  118225. * @param name Name of the animation range
  118226. * @returns Nullable animation range
  118227. */
  118228. getRange(name: string): Nullable<AnimationRange>;
  118229. /**
  118230. * Gets the key frames from the animation
  118231. * @returns The key frames of the animation
  118232. */
  118233. getKeys(): Array<IAnimationKey>;
  118234. /**
  118235. * Gets the highest frame rate of the animation
  118236. * @returns Highest frame rate of the animation
  118237. */
  118238. getHighestFrame(): number;
  118239. /**
  118240. * Gets the easing function of the animation
  118241. * @returns Easing function of the animation
  118242. */
  118243. getEasingFunction(): IEasingFunction;
  118244. /**
  118245. * Sets the easing function of the animation
  118246. * @param easingFunction A custom mathematical formula for animation
  118247. */
  118248. setEasingFunction(easingFunction: EasingFunction): void;
  118249. /**
  118250. * Interpolates a scalar linearly
  118251. * @param startValue Start value of the animation curve
  118252. * @param endValue End value of the animation curve
  118253. * @param gradient Scalar amount to interpolate
  118254. * @returns Interpolated scalar value
  118255. */
  118256. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118257. /**
  118258. * Interpolates a scalar cubically
  118259. * @param startValue Start value of the animation curve
  118260. * @param outTangent End tangent of the animation
  118261. * @param endValue End value of the animation curve
  118262. * @param inTangent Start tangent of the animation curve
  118263. * @param gradient Scalar amount to interpolate
  118264. * @returns Interpolated scalar value
  118265. */
  118266. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118267. /**
  118268. * Interpolates a quaternion using a spherical linear interpolation
  118269. * @param startValue Start value of the animation curve
  118270. * @param endValue End value of the animation curve
  118271. * @param gradient Scalar amount to interpolate
  118272. * @returns Interpolated quaternion value
  118273. */
  118274. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118275. /**
  118276. * Interpolates a quaternion cubically
  118277. * @param startValue Start value of the animation curve
  118278. * @param outTangent End tangent of the animation curve
  118279. * @param endValue End value of the animation curve
  118280. * @param inTangent Start tangent of the animation curve
  118281. * @param gradient Scalar amount to interpolate
  118282. * @returns Interpolated quaternion value
  118283. */
  118284. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118285. /**
  118286. * Interpolates a Vector3 linearl
  118287. * @param startValue Start value of the animation curve
  118288. * @param endValue End value of the animation curve
  118289. * @param gradient Scalar amount to interpolate
  118290. * @returns Interpolated scalar value
  118291. */
  118292. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118293. /**
  118294. * Interpolates a Vector3 cubically
  118295. * @param startValue Start value of the animation curve
  118296. * @param outTangent End tangent of the animation
  118297. * @param endValue End value of the animation curve
  118298. * @param inTangent Start tangent of the animation curve
  118299. * @param gradient Scalar amount to interpolate
  118300. * @returns InterpolatedVector3 value
  118301. */
  118302. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118303. /**
  118304. * Interpolates a Vector2 linearly
  118305. * @param startValue Start value of the animation curve
  118306. * @param endValue End value of the animation curve
  118307. * @param gradient Scalar amount to interpolate
  118308. * @returns Interpolated Vector2 value
  118309. */
  118310. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118311. /**
  118312. * Interpolates a Vector2 cubically
  118313. * @param startValue Start value of the animation curve
  118314. * @param outTangent End tangent of the animation
  118315. * @param endValue End value of the animation curve
  118316. * @param inTangent Start tangent of the animation curve
  118317. * @param gradient Scalar amount to interpolate
  118318. * @returns Interpolated Vector2 value
  118319. */
  118320. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118321. /**
  118322. * Interpolates a size linearly
  118323. * @param startValue Start value of the animation curve
  118324. * @param endValue End value of the animation curve
  118325. * @param gradient Scalar amount to interpolate
  118326. * @returns Interpolated Size value
  118327. */
  118328. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118329. /**
  118330. * Interpolates a Color3 linearly
  118331. * @param startValue Start value of the animation curve
  118332. * @param endValue End value of the animation curve
  118333. * @param gradient Scalar amount to interpolate
  118334. * @returns Interpolated Color3 value
  118335. */
  118336. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118337. /**
  118338. * Interpolates a Color4 linearly
  118339. * @param startValue Start value of the animation curve
  118340. * @param endValue End value of the animation curve
  118341. * @param gradient Scalar amount to interpolate
  118342. * @returns Interpolated Color3 value
  118343. */
  118344. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118345. /**
  118346. * @hidden Internal use only
  118347. */
  118348. _getKeyValue(value: any): any;
  118349. /**
  118350. * @hidden Internal use only
  118351. */
  118352. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118353. /**
  118354. * Defines the function to use to interpolate matrices
  118355. * @param startValue defines the start matrix
  118356. * @param endValue defines the end matrix
  118357. * @param gradient defines the gradient between both matrices
  118358. * @param result defines an optional target matrix where to store the interpolation
  118359. * @returns the interpolated matrix
  118360. */
  118361. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118362. /**
  118363. * Makes a copy of the animation
  118364. * @returns Cloned animation
  118365. */
  118366. clone(): Animation;
  118367. /**
  118368. * Sets the key frames of the animation
  118369. * @param values The animation key frames to set
  118370. */
  118371. setKeys(values: Array<IAnimationKey>): void;
  118372. /**
  118373. * Serializes the animation to an object
  118374. * @returns Serialized object
  118375. */
  118376. serialize(): any;
  118377. /**
  118378. * Float animation type
  118379. */
  118380. static readonly ANIMATIONTYPE_FLOAT: number;
  118381. /**
  118382. * Vector3 animation type
  118383. */
  118384. static readonly ANIMATIONTYPE_VECTOR3: number;
  118385. /**
  118386. * Quaternion animation type
  118387. */
  118388. static readonly ANIMATIONTYPE_QUATERNION: number;
  118389. /**
  118390. * Matrix animation type
  118391. */
  118392. static readonly ANIMATIONTYPE_MATRIX: number;
  118393. /**
  118394. * Color3 animation type
  118395. */
  118396. static readonly ANIMATIONTYPE_COLOR3: number;
  118397. /**
  118398. * Color3 animation type
  118399. */
  118400. static readonly ANIMATIONTYPE_COLOR4: number;
  118401. /**
  118402. * Vector2 animation type
  118403. */
  118404. static readonly ANIMATIONTYPE_VECTOR2: number;
  118405. /**
  118406. * Size animation type
  118407. */
  118408. static readonly ANIMATIONTYPE_SIZE: number;
  118409. /**
  118410. * Relative Loop Mode
  118411. */
  118412. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118413. /**
  118414. * Cycle Loop Mode
  118415. */
  118416. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118417. /**
  118418. * Constant Loop Mode
  118419. */
  118420. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118421. /** @hidden */
  118422. static _UniversalLerp(left: any, right: any, amount: number): any;
  118423. /**
  118424. * Parses an animation object and creates an animation
  118425. * @param parsedAnimation Parsed animation object
  118426. * @returns Animation object
  118427. */
  118428. static Parse(parsedAnimation: any): Animation;
  118429. /**
  118430. * Appends the serialized animations from the source animations
  118431. * @param source Source containing the animations
  118432. * @param destination Target to store the animations
  118433. */
  118434. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118435. /**
  118436. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118437. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118438. * @param url defines the url to load from
  118439. * @returns a promise that will resolve to the new animation or an array of animations
  118440. */
  118441. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118442. /**
  118443. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118444. * @param snippetId defines the snippet to load
  118445. * @returns a promise that will resolve to the new animation or a new array of animations
  118446. */
  118447. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118448. }
  118449. }
  118450. declare module BABYLON {
  118451. /**
  118452. * Interface containing an array of animations
  118453. */
  118454. export interface IAnimatable {
  118455. /**
  118456. * Array of animations
  118457. */
  118458. animations: Nullable<Array<Animation>>;
  118459. }
  118460. }
  118461. declare module BABYLON {
  118462. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118463. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118464. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118465. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118466. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118467. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118468. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118469. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118470. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118471. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118472. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118473. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118474. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118475. /**
  118476. * Decorator used to define property that can be serialized as reference to a camera
  118477. * @param sourceName defines the name of the property to decorate
  118478. */
  118479. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118480. /**
  118481. * Class used to help serialization objects
  118482. */
  118483. export class SerializationHelper {
  118484. /** @hidden */
  118485. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118486. /** @hidden */
  118487. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118488. /** @hidden */
  118489. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118490. /** @hidden */
  118491. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118492. /**
  118493. * Appends the serialized animations from the source animations
  118494. * @param source Source containing the animations
  118495. * @param destination Target to store the animations
  118496. */
  118497. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118498. /**
  118499. * Static function used to serialized a specific entity
  118500. * @param entity defines the entity to serialize
  118501. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118502. * @returns a JSON compatible object representing the serialization of the entity
  118503. */
  118504. static Serialize<T>(entity: T, serializationObject?: any): any;
  118505. /**
  118506. * Creates a new entity from a serialization data object
  118507. * @param creationFunction defines a function used to instanciated the new entity
  118508. * @param source defines the source serialization data
  118509. * @param scene defines the hosting scene
  118510. * @param rootUrl defines the root url for resources
  118511. * @returns a new entity
  118512. */
  118513. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118514. /**
  118515. * Clones an object
  118516. * @param creationFunction defines the function used to instanciate the new object
  118517. * @param source defines the source object
  118518. * @returns the cloned object
  118519. */
  118520. static Clone<T>(creationFunction: () => T, source: T): T;
  118521. /**
  118522. * Instanciates a new object based on a source one (some data will be shared between both object)
  118523. * @param creationFunction defines the function used to instanciate the new object
  118524. * @param source defines the source object
  118525. * @returns the new object
  118526. */
  118527. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118528. }
  118529. }
  118530. declare module BABYLON {
  118531. /**
  118532. * Base class of all the textures in babylon.
  118533. * It groups all the common properties the materials, post process, lights... might need
  118534. * in order to make a correct use of the texture.
  118535. */
  118536. export class BaseTexture implements IAnimatable {
  118537. /**
  118538. * Default anisotropic filtering level for the application.
  118539. * It is set to 4 as a good tradeoff between perf and quality.
  118540. */
  118541. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  118542. /**
  118543. * Gets or sets the unique id of the texture
  118544. */
  118545. uniqueId: number;
  118546. /**
  118547. * Define the name of the texture.
  118548. */
  118549. name: string;
  118550. /**
  118551. * Gets or sets an object used to store user defined information.
  118552. */
  118553. metadata: any;
  118554. /**
  118555. * For internal use only. Please do not use.
  118556. */
  118557. reservedDataStore: any;
  118558. private _hasAlpha;
  118559. /**
  118560. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  118561. */
  118562. set hasAlpha(value: boolean);
  118563. get hasAlpha(): boolean;
  118564. /**
  118565. * Defines if the alpha value should be determined via the rgb values.
  118566. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  118567. */
  118568. getAlphaFromRGB: boolean;
  118569. /**
  118570. * Intensity or strength of the texture.
  118571. * It is commonly used by materials to fine tune the intensity of the texture
  118572. */
  118573. level: number;
  118574. /**
  118575. * Define the UV chanel to use starting from 0 and defaulting to 0.
  118576. * This is part of the texture as textures usually maps to one uv set.
  118577. */
  118578. coordinatesIndex: number;
  118579. protected _coordinatesMode: number;
  118580. /**
  118581. * How a texture is mapped.
  118582. *
  118583. * | Value | Type | Description |
  118584. * | ----- | ----------------------------------- | ----------- |
  118585. * | 0 | EXPLICIT_MODE | |
  118586. * | 1 | SPHERICAL_MODE | |
  118587. * | 2 | PLANAR_MODE | |
  118588. * | 3 | CUBIC_MODE | |
  118589. * | 4 | PROJECTION_MODE | |
  118590. * | 5 | SKYBOX_MODE | |
  118591. * | 6 | INVCUBIC_MODE | |
  118592. * | 7 | EQUIRECTANGULAR_MODE | |
  118593. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  118594. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  118595. */
  118596. set coordinatesMode(value: number);
  118597. get coordinatesMode(): number;
  118598. private _wrapU;
  118599. /**
  118600. * | Value | Type | Description |
  118601. * | ----- | ------------------ | ----------- |
  118602. * | 0 | CLAMP_ADDRESSMODE | |
  118603. * | 1 | WRAP_ADDRESSMODE | |
  118604. * | 2 | MIRROR_ADDRESSMODE | |
  118605. */
  118606. get wrapU(): number;
  118607. set wrapU(value: number);
  118608. private _wrapV;
  118609. /**
  118610. * | Value | Type | Description |
  118611. * | ----- | ------------------ | ----------- |
  118612. * | 0 | CLAMP_ADDRESSMODE | |
  118613. * | 1 | WRAP_ADDRESSMODE | |
  118614. * | 2 | MIRROR_ADDRESSMODE | |
  118615. */
  118616. get wrapV(): number;
  118617. set wrapV(value: number);
  118618. /**
  118619. * | Value | Type | Description |
  118620. * | ----- | ------------------ | ----------- |
  118621. * | 0 | CLAMP_ADDRESSMODE | |
  118622. * | 1 | WRAP_ADDRESSMODE | |
  118623. * | 2 | MIRROR_ADDRESSMODE | |
  118624. */
  118625. wrapR: number;
  118626. /**
  118627. * With compliant hardware and browser (supporting anisotropic filtering)
  118628. * this defines the level of anisotropic filtering in the texture.
  118629. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  118630. */
  118631. anisotropicFilteringLevel: number;
  118632. /**
  118633. * Define if the texture is a cube texture or if false a 2d texture.
  118634. */
  118635. get isCube(): boolean;
  118636. set isCube(value: boolean);
  118637. /**
  118638. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  118639. */
  118640. get is3D(): boolean;
  118641. set is3D(value: boolean);
  118642. /**
  118643. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  118644. */
  118645. get is2DArray(): boolean;
  118646. set is2DArray(value: boolean);
  118647. private _gammaSpace;
  118648. /**
  118649. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  118650. * HDR texture are usually stored in linear space.
  118651. * This only impacts the PBR and Background materials
  118652. */
  118653. get gammaSpace(): boolean;
  118654. set gammaSpace(gamma: boolean);
  118655. /**
  118656. * Gets or sets whether or not the texture contains RGBD data.
  118657. */
  118658. get isRGBD(): boolean;
  118659. set isRGBD(value: boolean);
  118660. /**
  118661. * Is Z inverted in the texture (useful in a cube texture).
  118662. */
  118663. invertZ: boolean;
  118664. /**
  118665. * Are mip maps generated for this texture or not.
  118666. */
  118667. get noMipmap(): boolean;
  118668. /**
  118669. * @hidden
  118670. */
  118671. lodLevelInAlpha: boolean;
  118672. /**
  118673. * With prefiltered texture, defined the offset used during the prefiltering steps.
  118674. */
  118675. get lodGenerationOffset(): number;
  118676. set lodGenerationOffset(value: number);
  118677. /**
  118678. * With prefiltered texture, defined the scale used during the prefiltering steps.
  118679. */
  118680. get lodGenerationScale(): number;
  118681. set lodGenerationScale(value: number);
  118682. /**
  118683. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  118684. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  118685. * average roughness values.
  118686. */
  118687. get linearSpecularLOD(): boolean;
  118688. set linearSpecularLOD(value: boolean);
  118689. /**
  118690. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  118691. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  118692. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  118693. */
  118694. get irradianceTexture(): Nullable<BaseTexture>;
  118695. set irradianceTexture(value: Nullable<BaseTexture>);
  118696. /**
  118697. * Define if the texture is a render target.
  118698. */
  118699. isRenderTarget: boolean;
  118700. /**
  118701. * Define the unique id of the texture in the scene.
  118702. */
  118703. get uid(): string;
  118704. /** @hidden */
  118705. _prefiltered: boolean;
  118706. /**
  118707. * Return a string representation of the texture.
  118708. * @returns the texture as a string
  118709. */
  118710. toString(): string;
  118711. /**
  118712. * Get the class name of the texture.
  118713. * @returns "BaseTexture"
  118714. */
  118715. getClassName(): string;
  118716. /**
  118717. * Define the list of animation attached to the texture.
  118718. */
  118719. animations: Animation[];
  118720. /**
  118721. * An event triggered when the texture is disposed.
  118722. */
  118723. onDisposeObservable: Observable<BaseTexture>;
  118724. private _onDisposeObserver;
  118725. /**
  118726. * Callback triggered when the texture has been disposed.
  118727. * Kept for back compatibility, you can use the onDisposeObservable instead.
  118728. */
  118729. set onDispose(callback: () => void);
  118730. /**
  118731. * Define the current state of the loading sequence when in delayed load mode.
  118732. */
  118733. delayLoadState: number;
  118734. protected _scene: Nullable<Scene>;
  118735. protected _engine: Nullable<ThinEngine>;
  118736. /** @hidden */
  118737. _texture: Nullable<InternalTexture>;
  118738. private _uid;
  118739. /**
  118740. * Define if the texture is preventinga material to render or not.
  118741. * If not and the texture is not ready, the engine will use a default black texture instead.
  118742. */
  118743. get isBlocking(): boolean;
  118744. /**
  118745. * Instantiates a new BaseTexture.
  118746. * Base class of all the textures in babylon.
  118747. * It groups all the common properties the materials, post process, lights... might need
  118748. * in order to make a correct use of the texture.
  118749. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118750. */
  118751. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118752. /**
  118753. * Get the scene the texture belongs to.
  118754. * @returns the scene or null if undefined
  118755. */
  118756. getScene(): Nullable<Scene>;
  118757. /** @hidden */
  118758. protected _getEngine(): Nullable<ThinEngine>;
  118759. /**
  118760. * Checks if the texture has the same transform matrix than another texture
  118761. * @param texture texture to check against
  118762. * @returns true if the transforms are the same, else false
  118763. */
  118764. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118765. /**
  118766. * Get the texture transform matrix used to offset tile the texture for istance.
  118767. * @returns the transformation matrix
  118768. */
  118769. getTextureMatrix(): Matrix;
  118770. /**
  118771. * Get the texture reflection matrix used to rotate/transform the reflection.
  118772. * @returns the reflection matrix
  118773. */
  118774. getReflectionTextureMatrix(): Matrix;
  118775. /**
  118776. * Get the underlying lower level texture from Babylon.
  118777. * @returns the insternal texture
  118778. */
  118779. getInternalTexture(): Nullable<InternalTexture>;
  118780. /**
  118781. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118782. * @returns true if ready or not blocking
  118783. */
  118784. isReadyOrNotBlocking(): boolean;
  118785. /**
  118786. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118787. * @returns true if fully ready
  118788. */
  118789. isReady(): boolean;
  118790. private _cachedSize;
  118791. /**
  118792. * Get the size of the texture.
  118793. * @returns the texture size.
  118794. */
  118795. getSize(): ISize;
  118796. /**
  118797. * Get the base size of the texture.
  118798. * It can be different from the size if the texture has been resized for POT for instance
  118799. * @returns the base size
  118800. */
  118801. getBaseSize(): ISize;
  118802. /**
  118803. * Update the sampling mode of the texture.
  118804. * Default is Trilinear mode.
  118805. *
  118806. * | Value | Type | Description |
  118807. * | ----- | ------------------ | ----------- |
  118808. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118809. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118810. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118811. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118812. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118813. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118814. * | 7 | NEAREST_LINEAR | |
  118815. * | 8 | NEAREST_NEAREST | |
  118816. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118817. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118818. * | 11 | LINEAR_LINEAR | |
  118819. * | 12 | LINEAR_NEAREST | |
  118820. *
  118821. * > _mag_: magnification filter (close to the viewer)
  118822. * > _min_: minification filter (far from the viewer)
  118823. * > _mip_: filter used between mip map levels
  118824. *@param samplingMode Define the new sampling mode of the texture
  118825. */
  118826. updateSamplingMode(samplingMode: number): void;
  118827. /**
  118828. * Scales the texture if is `canRescale()`
  118829. * @param ratio the resize factor we want to use to rescale
  118830. */
  118831. scale(ratio: number): void;
  118832. /**
  118833. * Get if the texture can rescale.
  118834. */
  118835. get canRescale(): boolean;
  118836. /** @hidden */
  118837. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118838. /** @hidden */
  118839. _rebuild(): void;
  118840. /**
  118841. * Triggers the load sequence in delayed load mode.
  118842. */
  118843. delayLoad(): void;
  118844. /**
  118845. * Clones the texture.
  118846. * @returns the cloned texture
  118847. */
  118848. clone(): Nullable<BaseTexture>;
  118849. /**
  118850. * Get the texture underlying type (INT, FLOAT...)
  118851. */
  118852. get textureType(): number;
  118853. /**
  118854. * Get the texture underlying format (RGB, RGBA...)
  118855. */
  118856. get textureFormat(): number;
  118857. /**
  118858. * Indicates that textures need to be re-calculated for all materials
  118859. */
  118860. protected _markAllSubMeshesAsTexturesDirty(): void;
  118861. /**
  118862. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118863. * This will returns an RGBA array buffer containing either in values (0-255) or
  118864. * float values (0-1) depending of the underlying buffer type.
  118865. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118866. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118867. * @param buffer defines a user defined buffer to fill with data (can be null)
  118868. * @returns The Array buffer containing the pixels data.
  118869. */
  118870. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118871. /**
  118872. * Release and destroy the underlying lower level texture aka internalTexture.
  118873. */
  118874. releaseInternalTexture(): void;
  118875. /** @hidden */
  118876. get _lodTextureHigh(): Nullable<BaseTexture>;
  118877. /** @hidden */
  118878. get _lodTextureMid(): Nullable<BaseTexture>;
  118879. /** @hidden */
  118880. get _lodTextureLow(): Nullable<BaseTexture>;
  118881. /**
  118882. * Dispose the texture and release its associated resources.
  118883. */
  118884. dispose(): void;
  118885. /**
  118886. * Serialize the texture into a JSON representation that can be parsed later on.
  118887. * @returns the JSON representation of the texture
  118888. */
  118889. serialize(): any;
  118890. /**
  118891. * Helper function to be called back once a list of texture contains only ready textures.
  118892. * @param textures Define the list of textures to wait for
  118893. * @param callback Define the callback triggered once the entire list will be ready
  118894. */
  118895. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118896. private static _isScene;
  118897. }
  118898. }
  118899. declare module BABYLON {
  118900. /**
  118901. * Options to be used when creating an effect.
  118902. */
  118903. export interface IEffectCreationOptions {
  118904. /**
  118905. * Atrributes that will be used in the shader.
  118906. */
  118907. attributes: string[];
  118908. /**
  118909. * Uniform varible names that will be set in the shader.
  118910. */
  118911. uniformsNames: string[];
  118912. /**
  118913. * Uniform buffer variable names that will be set in the shader.
  118914. */
  118915. uniformBuffersNames: string[];
  118916. /**
  118917. * Sampler texture variable names that will be set in the shader.
  118918. */
  118919. samplers: string[];
  118920. /**
  118921. * Define statements that will be set in the shader.
  118922. */
  118923. defines: any;
  118924. /**
  118925. * Possible fallbacks for this effect to improve performance when needed.
  118926. */
  118927. fallbacks: Nullable<IEffectFallbacks>;
  118928. /**
  118929. * Callback that will be called when the shader is compiled.
  118930. */
  118931. onCompiled: Nullable<(effect: Effect) => void>;
  118932. /**
  118933. * Callback that will be called if an error occurs during shader compilation.
  118934. */
  118935. onError: Nullable<(effect: Effect, errors: string) => void>;
  118936. /**
  118937. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118938. */
  118939. indexParameters?: any;
  118940. /**
  118941. * Max number of lights that can be used in the shader.
  118942. */
  118943. maxSimultaneousLights?: number;
  118944. /**
  118945. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118946. */
  118947. transformFeedbackVaryings?: Nullable<string[]>;
  118948. /**
  118949. * 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
  118950. */
  118951. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118952. /**
  118953. * Is this effect rendering to several color attachments ?
  118954. */
  118955. multiTarget?: boolean;
  118956. }
  118957. /**
  118958. * Effect containing vertex and fragment shader that can be executed on an object.
  118959. */
  118960. export class Effect implements IDisposable {
  118961. /**
  118962. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118963. */
  118964. static ShadersRepository: string;
  118965. /**
  118966. * Enable logging of the shader code when a compilation error occurs
  118967. */
  118968. static LogShaderCodeOnCompilationError: boolean;
  118969. /**
  118970. * Name of the effect.
  118971. */
  118972. name: any;
  118973. /**
  118974. * String container all the define statements that should be set on the shader.
  118975. */
  118976. defines: string;
  118977. /**
  118978. * Callback that will be called when the shader is compiled.
  118979. */
  118980. onCompiled: Nullable<(effect: Effect) => void>;
  118981. /**
  118982. * Callback that will be called if an error occurs during shader compilation.
  118983. */
  118984. onError: Nullable<(effect: Effect, errors: string) => void>;
  118985. /**
  118986. * Callback that will be called when effect is bound.
  118987. */
  118988. onBind: Nullable<(effect: Effect) => void>;
  118989. /**
  118990. * Unique ID of the effect.
  118991. */
  118992. uniqueId: number;
  118993. /**
  118994. * Observable that will be called when the shader is compiled.
  118995. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118996. */
  118997. onCompileObservable: Observable<Effect>;
  118998. /**
  118999. * Observable that will be called if an error occurs during shader compilation.
  119000. */
  119001. onErrorObservable: Observable<Effect>;
  119002. /** @hidden */
  119003. _onBindObservable: Nullable<Observable<Effect>>;
  119004. /**
  119005. * @hidden
  119006. * Specifies if the effect was previously ready
  119007. */
  119008. _wasPreviouslyReady: boolean;
  119009. /**
  119010. * Observable that will be called when effect is bound.
  119011. */
  119012. get onBindObservable(): Observable<Effect>;
  119013. /** @hidden */
  119014. _bonesComputationForcedToCPU: boolean;
  119015. /** @hidden */
  119016. _multiTarget: boolean;
  119017. private static _uniqueIdSeed;
  119018. private _engine;
  119019. private _uniformBuffersNames;
  119020. private _uniformBuffersNamesList;
  119021. private _uniformsNames;
  119022. private _samplerList;
  119023. private _samplers;
  119024. private _isReady;
  119025. private _compilationError;
  119026. private _allFallbacksProcessed;
  119027. private _attributesNames;
  119028. private _attributes;
  119029. private _attributeLocationByName;
  119030. private _uniforms;
  119031. /**
  119032. * Key for the effect.
  119033. * @hidden
  119034. */
  119035. _key: string;
  119036. private _indexParameters;
  119037. private _fallbacks;
  119038. private _vertexSourceCode;
  119039. private _fragmentSourceCode;
  119040. private _vertexSourceCodeOverride;
  119041. private _fragmentSourceCodeOverride;
  119042. private _transformFeedbackVaryings;
  119043. private _rawVertexSourceCode;
  119044. private _rawFragmentSourceCode;
  119045. /**
  119046. * Compiled shader to webGL program.
  119047. * @hidden
  119048. */
  119049. _pipelineContext: Nullable<IPipelineContext>;
  119050. private _valueCache;
  119051. private static _baseCache;
  119052. /**
  119053. * Instantiates an effect.
  119054. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119055. * @param baseName Name of the effect.
  119056. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119057. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119058. * @param samplers List of sampler variables that will be passed to the shader.
  119059. * @param engine Engine to be used to render the effect
  119060. * @param defines Define statements to be added to the shader.
  119061. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119062. * @param onCompiled Callback that will be called when the shader is compiled.
  119063. * @param onError Callback that will be called if an error occurs during shader compilation.
  119064. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119065. */
  119066. 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);
  119067. private _useFinalCode;
  119068. /**
  119069. * Unique key for this effect
  119070. */
  119071. get key(): string;
  119072. /**
  119073. * If the effect has been compiled and prepared.
  119074. * @returns if the effect is compiled and prepared.
  119075. */
  119076. isReady(): boolean;
  119077. private _isReadyInternal;
  119078. /**
  119079. * The engine the effect was initialized with.
  119080. * @returns the engine.
  119081. */
  119082. getEngine(): Engine;
  119083. /**
  119084. * The pipeline context for this effect
  119085. * @returns the associated pipeline context
  119086. */
  119087. getPipelineContext(): Nullable<IPipelineContext>;
  119088. /**
  119089. * The set of names of attribute variables for the shader.
  119090. * @returns An array of attribute names.
  119091. */
  119092. getAttributesNames(): string[];
  119093. /**
  119094. * Returns the attribute at the given index.
  119095. * @param index The index of the attribute.
  119096. * @returns The location of the attribute.
  119097. */
  119098. getAttributeLocation(index: number): number;
  119099. /**
  119100. * Returns the attribute based on the name of the variable.
  119101. * @param name of the attribute to look up.
  119102. * @returns the attribute location.
  119103. */
  119104. getAttributeLocationByName(name: string): number;
  119105. /**
  119106. * The number of attributes.
  119107. * @returns the numnber of attributes.
  119108. */
  119109. getAttributesCount(): number;
  119110. /**
  119111. * Gets the index of a uniform variable.
  119112. * @param uniformName of the uniform to look up.
  119113. * @returns the index.
  119114. */
  119115. getUniformIndex(uniformName: string): number;
  119116. /**
  119117. * Returns the attribute based on the name of the variable.
  119118. * @param uniformName of the uniform to look up.
  119119. * @returns the location of the uniform.
  119120. */
  119121. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119122. /**
  119123. * Returns an array of sampler variable names
  119124. * @returns The array of sampler variable names.
  119125. */
  119126. getSamplers(): string[];
  119127. /**
  119128. * Returns an array of uniform variable names
  119129. * @returns The array of uniform variable names.
  119130. */
  119131. getUniformNames(): string[];
  119132. /**
  119133. * Returns an array of uniform buffer variable names
  119134. * @returns The array of uniform buffer variable names.
  119135. */
  119136. getUniformBuffersNames(): string[];
  119137. /**
  119138. * Returns the index parameters used to create the effect
  119139. * @returns The index parameters object
  119140. */
  119141. getIndexParameters(): any;
  119142. /**
  119143. * The error from the last compilation.
  119144. * @returns the error string.
  119145. */
  119146. getCompilationError(): string;
  119147. /**
  119148. * Gets a boolean indicating that all fallbacks were used during compilation
  119149. * @returns true if all fallbacks were used
  119150. */
  119151. allFallbacksProcessed(): boolean;
  119152. /**
  119153. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119154. * @param func The callback to be used.
  119155. */
  119156. executeWhenCompiled(func: (effect: Effect) => void): void;
  119157. private _checkIsReady;
  119158. private _loadShader;
  119159. /**
  119160. * Gets the vertex shader source code of this effect
  119161. */
  119162. get vertexSourceCode(): string;
  119163. /**
  119164. * Gets the fragment shader source code of this effect
  119165. */
  119166. get fragmentSourceCode(): string;
  119167. /**
  119168. * Gets the vertex shader source code before it has been processed by the preprocessor
  119169. */
  119170. get rawVertexSourceCode(): string;
  119171. /**
  119172. * Gets the fragment shader source code before it has been processed by the preprocessor
  119173. */
  119174. get rawFragmentSourceCode(): string;
  119175. /**
  119176. * Recompiles the webGL program
  119177. * @param vertexSourceCode The source code for the vertex shader.
  119178. * @param fragmentSourceCode The source code for the fragment shader.
  119179. * @param onCompiled Callback called when completed.
  119180. * @param onError Callback called on error.
  119181. * @hidden
  119182. */
  119183. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119184. /**
  119185. * Prepares the effect
  119186. * @hidden
  119187. */
  119188. _prepareEffect(): void;
  119189. private _getShaderCodeAndErrorLine;
  119190. private _processCompilationErrors;
  119191. /**
  119192. * Checks if the effect is supported. (Must be called after compilation)
  119193. */
  119194. get isSupported(): boolean;
  119195. /**
  119196. * Binds a texture to the engine to be used as output of the shader.
  119197. * @param channel Name of the output variable.
  119198. * @param texture Texture to bind.
  119199. * @hidden
  119200. */
  119201. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119202. /**
  119203. * Sets a texture on the engine to be used in the shader.
  119204. * @param channel Name of the sampler variable.
  119205. * @param texture Texture to set.
  119206. */
  119207. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  119208. /**
  119209. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119210. * @param channel Name of the sampler variable.
  119211. * @param texture Texture to set.
  119212. */
  119213. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119214. /**
  119215. * Sets an array of textures on the engine to be used in the shader.
  119216. * @param channel Name of the variable.
  119217. * @param textures Textures to set.
  119218. */
  119219. setTextureArray(channel: string, textures: BaseTexture[]): void;
  119220. /**
  119221. * 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)
  119222. * @param channel Name of the sampler variable.
  119223. * @param postProcess Post process to get the input texture from.
  119224. */
  119225. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119226. /**
  119227. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119228. * 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)
  119229. * @param channel Name of the sampler variable.
  119230. * @param postProcess Post process to get the output texture from.
  119231. */
  119232. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119233. /** @hidden */
  119234. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119235. /** @hidden */
  119236. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119237. /** @hidden */
  119238. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119239. /** @hidden */
  119240. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119241. /**
  119242. * Binds a buffer to a uniform.
  119243. * @param buffer Buffer to bind.
  119244. * @param name Name of the uniform variable to bind to.
  119245. */
  119246. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119247. /**
  119248. * Binds block to a uniform.
  119249. * @param blockName Name of the block to bind.
  119250. * @param index Index to bind.
  119251. */
  119252. bindUniformBlock(blockName: string, index: number): void;
  119253. /**
  119254. * Sets an interger value on a uniform variable.
  119255. * @param uniformName Name of the variable.
  119256. * @param value Value to be set.
  119257. * @returns this effect.
  119258. */
  119259. setInt(uniformName: string, value: number): Effect;
  119260. /**
  119261. * Sets an int array on a uniform variable.
  119262. * @param uniformName Name of the variable.
  119263. * @param array array to be set.
  119264. * @returns this effect.
  119265. */
  119266. setIntArray(uniformName: string, array: Int32Array): Effect;
  119267. /**
  119268. * 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)
  119269. * @param uniformName Name of the variable.
  119270. * @param array array to be set.
  119271. * @returns this effect.
  119272. */
  119273. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119274. /**
  119275. * 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)
  119276. * @param uniformName Name of the variable.
  119277. * @param array array to be set.
  119278. * @returns this effect.
  119279. */
  119280. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119281. /**
  119282. * 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)
  119283. * @param uniformName Name of the variable.
  119284. * @param array array to be set.
  119285. * @returns this effect.
  119286. */
  119287. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119288. /**
  119289. * Sets an float array on a uniform variable.
  119290. * @param uniformName Name of the variable.
  119291. * @param array array to be set.
  119292. * @returns this effect.
  119293. */
  119294. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119295. /**
  119296. * 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)
  119297. * @param uniformName Name of the variable.
  119298. * @param array array to be set.
  119299. * @returns this effect.
  119300. */
  119301. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119302. /**
  119303. * 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)
  119304. * @param uniformName Name of the variable.
  119305. * @param array array to be set.
  119306. * @returns this effect.
  119307. */
  119308. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119309. /**
  119310. * 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)
  119311. * @param uniformName Name of the variable.
  119312. * @param array array to be set.
  119313. * @returns this effect.
  119314. */
  119315. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119316. /**
  119317. * Sets an array on a uniform variable.
  119318. * @param uniformName Name of the variable.
  119319. * @param array array to be set.
  119320. * @returns this effect.
  119321. */
  119322. setArray(uniformName: string, array: number[]): Effect;
  119323. /**
  119324. * 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)
  119325. * @param uniformName Name of the variable.
  119326. * @param array array to be set.
  119327. * @returns this effect.
  119328. */
  119329. setArray2(uniformName: string, array: number[]): Effect;
  119330. /**
  119331. * 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)
  119332. * @param uniformName Name of the variable.
  119333. * @param array array to be set.
  119334. * @returns this effect.
  119335. */
  119336. setArray3(uniformName: string, array: number[]): Effect;
  119337. /**
  119338. * 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)
  119339. * @param uniformName Name of the variable.
  119340. * @param array array to be set.
  119341. * @returns this effect.
  119342. */
  119343. setArray4(uniformName: string, array: number[]): Effect;
  119344. /**
  119345. * Sets matrices on a uniform variable.
  119346. * @param uniformName Name of the variable.
  119347. * @param matrices matrices to be set.
  119348. * @returns this effect.
  119349. */
  119350. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  119351. /**
  119352. * Sets matrix on a uniform variable.
  119353. * @param uniformName Name of the variable.
  119354. * @param matrix matrix to be set.
  119355. * @returns this effect.
  119356. */
  119357. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  119358. /**
  119359. * 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)
  119360. * @param uniformName Name of the variable.
  119361. * @param matrix matrix to be set.
  119362. * @returns this effect.
  119363. */
  119364. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119365. /**
  119366. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  119367. * @param uniformName Name of the variable.
  119368. * @param matrix matrix to be set.
  119369. * @returns this effect.
  119370. */
  119371. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119372. /**
  119373. * Sets a float on a uniform variable.
  119374. * @param uniformName Name of the variable.
  119375. * @param value value to be set.
  119376. * @returns this effect.
  119377. */
  119378. setFloat(uniformName: string, value: number): Effect;
  119379. /**
  119380. * Sets a boolean on a uniform variable.
  119381. * @param uniformName Name of the variable.
  119382. * @param bool value to be set.
  119383. * @returns this effect.
  119384. */
  119385. setBool(uniformName: string, bool: boolean): Effect;
  119386. /**
  119387. * Sets a Vector2 on a uniform variable.
  119388. * @param uniformName Name of the variable.
  119389. * @param vector2 vector2 to be set.
  119390. * @returns this effect.
  119391. */
  119392. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  119393. /**
  119394. * Sets a float2 on a uniform variable.
  119395. * @param uniformName Name of the variable.
  119396. * @param x First float in float2.
  119397. * @param y Second float in float2.
  119398. * @returns this effect.
  119399. */
  119400. setFloat2(uniformName: string, x: number, y: number): Effect;
  119401. /**
  119402. * Sets a Vector3 on a uniform variable.
  119403. * @param uniformName Name of the variable.
  119404. * @param vector3 Value to be set.
  119405. * @returns this effect.
  119406. */
  119407. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  119408. /**
  119409. * Sets a float3 on a uniform variable.
  119410. * @param uniformName Name of the variable.
  119411. * @param x First float in float3.
  119412. * @param y Second float in float3.
  119413. * @param z Third float in float3.
  119414. * @returns this effect.
  119415. */
  119416. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  119417. /**
  119418. * Sets a Vector4 on a uniform variable.
  119419. * @param uniformName Name of the variable.
  119420. * @param vector4 Value to be set.
  119421. * @returns this effect.
  119422. */
  119423. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  119424. /**
  119425. * Sets a float4 on a uniform variable.
  119426. * @param uniformName Name of the variable.
  119427. * @param x First float in float4.
  119428. * @param y Second float in float4.
  119429. * @param z Third float in float4.
  119430. * @param w Fourth float in float4.
  119431. * @returns this effect.
  119432. */
  119433. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  119434. /**
  119435. * Sets a Color3 on a uniform variable.
  119436. * @param uniformName Name of the variable.
  119437. * @param color3 Value to be set.
  119438. * @returns this effect.
  119439. */
  119440. setColor3(uniformName: string, color3: IColor3Like): Effect;
  119441. /**
  119442. * Sets a Color4 on a uniform variable.
  119443. * @param uniformName Name of the variable.
  119444. * @param color3 Value to be set.
  119445. * @param alpha Alpha value to be set.
  119446. * @returns this effect.
  119447. */
  119448. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  119449. /**
  119450. * Sets a Color4 on a uniform variable
  119451. * @param uniformName defines the name of the variable
  119452. * @param color4 defines the value to be set
  119453. * @returns this effect.
  119454. */
  119455. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  119456. /** Release all associated resources */
  119457. dispose(): void;
  119458. /**
  119459. * This function will add a new shader to the shader store
  119460. * @param name the name of the shader
  119461. * @param pixelShader optional pixel shader content
  119462. * @param vertexShader optional vertex shader content
  119463. */
  119464. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  119465. /**
  119466. * Store of each shader (The can be looked up using effect.key)
  119467. */
  119468. static ShadersStore: {
  119469. [key: string]: string;
  119470. };
  119471. /**
  119472. * Store of each included file for a shader (The can be looked up using effect.key)
  119473. */
  119474. static IncludesShadersStore: {
  119475. [key: string]: string;
  119476. };
  119477. /**
  119478. * Resets the cache of effects.
  119479. */
  119480. static ResetCache(): void;
  119481. }
  119482. }
  119483. declare module BABYLON {
  119484. /**
  119485. * Interface used to describe the capabilities of the engine relatively to the current browser
  119486. */
  119487. export interface EngineCapabilities {
  119488. /** Maximum textures units per fragment shader */
  119489. maxTexturesImageUnits: number;
  119490. /** Maximum texture units per vertex shader */
  119491. maxVertexTextureImageUnits: number;
  119492. /** Maximum textures units in the entire pipeline */
  119493. maxCombinedTexturesImageUnits: number;
  119494. /** Maximum texture size */
  119495. maxTextureSize: number;
  119496. /** Maximum texture samples */
  119497. maxSamples?: number;
  119498. /** Maximum cube texture size */
  119499. maxCubemapTextureSize: number;
  119500. /** Maximum render texture size */
  119501. maxRenderTextureSize: number;
  119502. /** Maximum number of vertex attributes */
  119503. maxVertexAttribs: number;
  119504. /** Maximum number of varyings */
  119505. maxVaryingVectors: number;
  119506. /** Maximum number of uniforms per vertex shader */
  119507. maxVertexUniformVectors: number;
  119508. /** Maximum number of uniforms per fragment shader */
  119509. maxFragmentUniformVectors: number;
  119510. /** Defines if standard derivates (dx/dy) are supported */
  119511. standardDerivatives: boolean;
  119512. /** Defines if s3tc texture compression is supported */
  119513. s3tc?: WEBGL_compressed_texture_s3tc;
  119514. /** Defines if pvrtc texture compression is supported */
  119515. pvrtc: any;
  119516. /** Defines if etc1 texture compression is supported */
  119517. etc1: any;
  119518. /** Defines if etc2 texture compression is supported */
  119519. etc2: any;
  119520. /** Defines if astc texture compression is supported */
  119521. astc: any;
  119522. /** Defines if bptc texture compression is supported */
  119523. bptc: any;
  119524. /** Defines if float textures are supported */
  119525. textureFloat: boolean;
  119526. /** Defines if vertex array objects are supported */
  119527. vertexArrayObject: boolean;
  119528. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  119529. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  119530. /** Gets the maximum level of anisotropy supported */
  119531. maxAnisotropy: number;
  119532. /** Defines if instancing is supported */
  119533. instancedArrays: boolean;
  119534. /** Defines if 32 bits indices are supported */
  119535. uintIndices: boolean;
  119536. /** Defines if high precision shaders are supported */
  119537. highPrecisionShaderSupported: boolean;
  119538. /** Defines if depth reading in the fragment shader is supported */
  119539. fragmentDepthSupported: boolean;
  119540. /** Defines if float texture linear filtering is supported*/
  119541. textureFloatLinearFiltering: boolean;
  119542. /** Defines if rendering to float textures is supported */
  119543. textureFloatRender: boolean;
  119544. /** Defines if half float textures are supported*/
  119545. textureHalfFloat: boolean;
  119546. /** Defines if half float texture linear filtering is supported*/
  119547. textureHalfFloatLinearFiltering: boolean;
  119548. /** Defines if rendering to half float textures is supported */
  119549. textureHalfFloatRender: boolean;
  119550. /** Defines if textureLOD shader command is supported */
  119551. textureLOD: boolean;
  119552. /** Defines if draw buffers extension is supported */
  119553. drawBuffersExtension: boolean;
  119554. /** Defines if depth textures are supported */
  119555. depthTextureExtension: boolean;
  119556. /** Defines if float color buffer are supported */
  119557. colorBufferFloat: boolean;
  119558. /** Gets disjoint timer query extension (null if not supported) */
  119559. timerQuery?: EXT_disjoint_timer_query;
  119560. /** Defines if timestamp can be used with timer query */
  119561. canUseTimestampForTimerQuery: boolean;
  119562. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  119563. multiview?: any;
  119564. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  119565. oculusMultiview?: any;
  119566. /** Function used to let the system compiles shaders in background */
  119567. parallelShaderCompile?: {
  119568. COMPLETION_STATUS_KHR: number;
  119569. };
  119570. /** Max number of texture samples for MSAA */
  119571. maxMSAASamples: number;
  119572. /** Defines if the blend min max extension is supported */
  119573. blendMinMax: boolean;
  119574. }
  119575. }
  119576. declare module BABYLON {
  119577. /**
  119578. * @hidden
  119579. **/
  119580. export class DepthCullingState {
  119581. private _isDepthTestDirty;
  119582. private _isDepthMaskDirty;
  119583. private _isDepthFuncDirty;
  119584. private _isCullFaceDirty;
  119585. private _isCullDirty;
  119586. private _isZOffsetDirty;
  119587. private _isFrontFaceDirty;
  119588. private _depthTest;
  119589. private _depthMask;
  119590. private _depthFunc;
  119591. private _cull;
  119592. private _cullFace;
  119593. private _zOffset;
  119594. private _frontFace;
  119595. /**
  119596. * Initializes the state.
  119597. */
  119598. constructor();
  119599. get isDirty(): boolean;
  119600. get zOffset(): number;
  119601. set zOffset(value: number);
  119602. get cullFace(): Nullable<number>;
  119603. set cullFace(value: Nullable<number>);
  119604. get cull(): Nullable<boolean>;
  119605. set cull(value: Nullable<boolean>);
  119606. get depthFunc(): Nullable<number>;
  119607. set depthFunc(value: Nullable<number>);
  119608. get depthMask(): boolean;
  119609. set depthMask(value: boolean);
  119610. get depthTest(): boolean;
  119611. set depthTest(value: boolean);
  119612. get frontFace(): Nullable<number>;
  119613. set frontFace(value: Nullable<number>);
  119614. reset(): void;
  119615. apply(gl: WebGLRenderingContext): void;
  119616. }
  119617. }
  119618. declare module BABYLON {
  119619. /**
  119620. * @hidden
  119621. **/
  119622. export class StencilState {
  119623. /** 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 */
  119624. static readonly ALWAYS: number;
  119625. /** Passed to stencilOperation to specify that stencil value must be kept */
  119626. static readonly KEEP: number;
  119627. /** Passed to stencilOperation to specify that stencil value must be replaced */
  119628. static readonly REPLACE: number;
  119629. private _isStencilTestDirty;
  119630. private _isStencilMaskDirty;
  119631. private _isStencilFuncDirty;
  119632. private _isStencilOpDirty;
  119633. private _stencilTest;
  119634. private _stencilMask;
  119635. private _stencilFunc;
  119636. private _stencilFuncRef;
  119637. private _stencilFuncMask;
  119638. private _stencilOpStencilFail;
  119639. private _stencilOpDepthFail;
  119640. private _stencilOpStencilDepthPass;
  119641. get isDirty(): boolean;
  119642. get stencilFunc(): number;
  119643. set stencilFunc(value: number);
  119644. get stencilFuncRef(): number;
  119645. set stencilFuncRef(value: number);
  119646. get stencilFuncMask(): number;
  119647. set stencilFuncMask(value: number);
  119648. get stencilOpStencilFail(): number;
  119649. set stencilOpStencilFail(value: number);
  119650. get stencilOpDepthFail(): number;
  119651. set stencilOpDepthFail(value: number);
  119652. get stencilOpStencilDepthPass(): number;
  119653. set stencilOpStencilDepthPass(value: number);
  119654. get stencilMask(): number;
  119655. set stencilMask(value: number);
  119656. get stencilTest(): boolean;
  119657. set stencilTest(value: boolean);
  119658. constructor();
  119659. reset(): void;
  119660. apply(gl: WebGLRenderingContext): void;
  119661. }
  119662. }
  119663. declare module BABYLON {
  119664. /**
  119665. * @hidden
  119666. **/
  119667. export class AlphaState {
  119668. private _isAlphaBlendDirty;
  119669. private _isBlendFunctionParametersDirty;
  119670. private _isBlendEquationParametersDirty;
  119671. private _isBlendConstantsDirty;
  119672. private _alphaBlend;
  119673. private _blendFunctionParameters;
  119674. private _blendEquationParameters;
  119675. private _blendConstants;
  119676. /**
  119677. * Initializes the state.
  119678. */
  119679. constructor();
  119680. get isDirty(): boolean;
  119681. get alphaBlend(): boolean;
  119682. set alphaBlend(value: boolean);
  119683. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  119684. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  119685. setAlphaEquationParameters(rgb: number, alpha: number): void;
  119686. reset(): void;
  119687. apply(gl: WebGLRenderingContext): void;
  119688. }
  119689. }
  119690. declare module BABYLON {
  119691. /** @hidden */
  119692. export class WebGLShaderProcessor implements IShaderProcessor {
  119693. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  119694. }
  119695. }
  119696. declare module BABYLON {
  119697. /** @hidden */
  119698. export class WebGL2ShaderProcessor implements IShaderProcessor {
  119699. attributeProcessor(attribute: string): string;
  119700. varyingProcessor(varying: string, isFragment: boolean): string;
  119701. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  119702. }
  119703. }
  119704. declare module BABYLON {
  119705. /**
  119706. * Interface for attribute information associated with buffer instanciation
  119707. */
  119708. export interface InstancingAttributeInfo {
  119709. /**
  119710. * Name of the GLSL attribute
  119711. * if attribute index is not specified, this is used to retrieve the index from the effect
  119712. */
  119713. attributeName: string;
  119714. /**
  119715. * Index/offset of the attribute in the vertex shader
  119716. * if not specified, this will be computes from the name.
  119717. */
  119718. index?: number;
  119719. /**
  119720. * size of the attribute, 1, 2, 3 or 4
  119721. */
  119722. attributeSize: number;
  119723. /**
  119724. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  119725. */
  119726. offset: number;
  119727. /**
  119728. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  119729. * default to 1
  119730. */
  119731. divisor?: number;
  119732. /**
  119733. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  119734. * default is FLOAT
  119735. */
  119736. attributeType?: number;
  119737. /**
  119738. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  119739. */
  119740. normalized?: boolean;
  119741. }
  119742. }
  119743. declare module BABYLON {
  119744. interface ThinEngine {
  119745. /**
  119746. * Update a video texture
  119747. * @param texture defines the texture to update
  119748. * @param video defines the video element to use
  119749. * @param invertY defines if data must be stored with Y axis inverted
  119750. */
  119751. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  119752. }
  119753. }
  119754. declare module BABYLON {
  119755. interface ThinEngine {
  119756. /**
  119757. * Creates a dynamic texture
  119758. * @param width defines the width of the texture
  119759. * @param height defines the height of the texture
  119760. * @param generateMipMaps defines if the engine should generate the mip levels
  119761. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119762. * @returns the dynamic texture inside an InternalTexture
  119763. */
  119764. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119765. /**
  119766. * Update the content of a dynamic texture
  119767. * @param texture defines the texture to update
  119768. * @param canvas defines the canvas containing the source
  119769. * @param invertY defines if data must be stored with Y axis inverted
  119770. * @param premulAlpha defines if alpha is stored as premultiplied
  119771. * @param format defines the format of the data
  119772. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119773. */
  119774. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119775. }
  119776. }
  119777. declare module BABYLON {
  119778. /**
  119779. * Settings for finer control over video usage
  119780. */
  119781. export interface VideoTextureSettings {
  119782. /**
  119783. * Applies `autoplay` to video, if specified
  119784. */
  119785. autoPlay?: boolean;
  119786. /**
  119787. * Applies `muted` to video, if specified
  119788. */
  119789. muted?: boolean;
  119790. /**
  119791. * Applies `loop` to video, if specified
  119792. */
  119793. loop?: boolean;
  119794. /**
  119795. * Automatically updates internal texture from video at every frame in the render loop
  119796. */
  119797. autoUpdateTexture: boolean;
  119798. /**
  119799. * Image src displayed during the video loading or until the user interacts with the video.
  119800. */
  119801. poster?: string;
  119802. }
  119803. /**
  119804. * If you want to display a video in your scene, this is the special texture for that.
  119805. * This special texture works similar to other textures, with the exception of a few parameters.
  119806. * @see https://doc.babylonjs.com/how_to/video_texture
  119807. */
  119808. export class VideoTexture extends Texture {
  119809. /**
  119810. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119811. */
  119812. readonly autoUpdateTexture: boolean;
  119813. /**
  119814. * The video instance used by the texture internally
  119815. */
  119816. readonly video: HTMLVideoElement;
  119817. private _onUserActionRequestedObservable;
  119818. /**
  119819. * Event triggerd when a dom action is required by the user to play the video.
  119820. * This happens due to recent changes in browser policies preventing video to auto start.
  119821. */
  119822. get onUserActionRequestedObservable(): Observable<Texture>;
  119823. private _generateMipMaps;
  119824. private _stillImageCaptured;
  119825. private _displayingPosterTexture;
  119826. private _settings;
  119827. private _createInternalTextureOnEvent;
  119828. private _frameId;
  119829. private _currentSrc;
  119830. /**
  119831. * Creates a video texture.
  119832. * If you want to display a video in your scene, this is the special texture for that.
  119833. * This special texture works similar to other textures, with the exception of a few parameters.
  119834. * @see https://doc.babylonjs.com/how_to/video_texture
  119835. * @param name optional name, will detect from video source, if not defined
  119836. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119837. * @param scene is obviously the current scene.
  119838. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119839. * @param invertY is false by default but can be used to invert video on Y axis
  119840. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119841. * @param settings allows finer control over video usage
  119842. */
  119843. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119844. private _getName;
  119845. private _getVideo;
  119846. private _createInternalTexture;
  119847. private reset;
  119848. /**
  119849. * @hidden Internal method to initiate `update`.
  119850. */
  119851. _rebuild(): void;
  119852. /**
  119853. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119854. */
  119855. update(): void;
  119856. /**
  119857. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119858. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119859. */
  119860. updateTexture(isVisible: boolean): void;
  119861. protected _updateInternalTexture: () => void;
  119862. /**
  119863. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119864. * @param url New url.
  119865. */
  119866. updateURL(url: string): void;
  119867. /**
  119868. * Clones the texture.
  119869. * @returns the cloned texture
  119870. */
  119871. clone(): VideoTexture;
  119872. /**
  119873. * Dispose the texture and release its associated resources.
  119874. */
  119875. dispose(): void;
  119876. /**
  119877. * Creates a video texture straight from a stream.
  119878. * @param scene Define the scene the texture should be created in
  119879. * @param stream Define the stream the texture should be created from
  119880. * @returns The created video texture as a promise
  119881. */
  119882. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119883. /**
  119884. * Creates a video texture straight from your WebCam video feed.
  119885. * @param scene Define the scene the texture should be created in
  119886. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119887. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119888. * @returns The created video texture as a promise
  119889. */
  119890. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119891. minWidth: number;
  119892. maxWidth: number;
  119893. minHeight: number;
  119894. maxHeight: number;
  119895. deviceId: string;
  119896. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119897. /**
  119898. * Creates a video texture straight from your WebCam video feed.
  119899. * @param scene Define the scene the texture should be created in
  119900. * @param onReady Define a callback to triggered once the texture will be ready
  119901. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119902. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119903. */
  119904. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119905. minWidth: number;
  119906. maxWidth: number;
  119907. minHeight: number;
  119908. maxHeight: number;
  119909. deviceId: string;
  119910. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119911. }
  119912. }
  119913. declare module BABYLON {
  119914. /**
  119915. * Defines the interface used by objects working like Scene
  119916. * @hidden
  119917. */
  119918. export interface ISceneLike {
  119919. _addPendingData(data: any): void;
  119920. _removePendingData(data: any): void;
  119921. offlineProvider: IOfflineProvider;
  119922. }
  119923. /**
  119924. * Information about the current host
  119925. */
  119926. export interface HostInformation {
  119927. /**
  119928. * Defines if the current host is a mobile
  119929. */
  119930. isMobile: boolean;
  119931. }
  119932. /** Interface defining initialization parameters for Engine class */
  119933. export interface EngineOptions extends WebGLContextAttributes {
  119934. /**
  119935. * Defines if the engine should no exceed a specified device ratio
  119936. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119937. */
  119938. limitDeviceRatio?: number;
  119939. /**
  119940. * Defines if webvr should be enabled automatically
  119941. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119942. */
  119943. autoEnableWebVR?: boolean;
  119944. /**
  119945. * Defines if webgl2 should be turned off even if supported
  119946. * @see https://doc.babylonjs.com/features/webgl2
  119947. */
  119948. disableWebGL2Support?: boolean;
  119949. /**
  119950. * Defines if webaudio should be initialized as well
  119951. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119952. */
  119953. audioEngine?: boolean;
  119954. /**
  119955. * Defines if animations should run using a deterministic lock step
  119956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119957. */
  119958. deterministicLockstep?: boolean;
  119959. /** Defines the maximum steps to use with deterministic lock step mode */
  119960. lockstepMaxSteps?: number;
  119961. /** Defines the seconds between each deterministic lock step */
  119962. timeStep?: number;
  119963. /**
  119964. * Defines that engine should ignore context lost events
  119965. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119966. */
  119967. doNotHandleContextLost?: boolean;
  119968. /**
  119969. * Defines that engine should ignore modifying touch action attribute and style
  119970. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119971. */
  119972. doNotHandleTouchAction?: boolean;
  119973. /**
  119974. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119975. */
  119976. useHighPrecisionFloats?: boolean;
  119977. /**
  119978. * Make the canvas XR Compatible for XR sessions
  119979. */
  119980. xrCompatible?: boolean;
  119981. /**
  119982. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119983. */
  119984. useHighPrecisionMatrix?: boolean;
  119985. /**
  119986. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119987. */
  119988. failIfMajorPerformanceCaveat?: boolean;
  119989. }
  119990. /**
  119991. * The base engine class (root of all engines)
  119992. */
  119993. export class ThinEngine {
  119994. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119995. static ExceptionList: ({
  119996. key: string;
  119997. capture: string;
  119998. captureConstraint: number;
  119999. targets: string[];
  120000. } | {
  120001. key: string;
  120002. capture: null;
  120003. captureConstraint: null;
  120004. targets: string[];
  120005. })[];
  120006. /** @hidden */
  120007. static _TextureLoaders: IInternalTextureLoader[];
  120008. /**
  120009. * Returns the current npm package of the sdk
  120010. */
  120011. static get NpmPackage(): string;
  120012. /**
  120013. * Returns the current version of the framework
  120014. */
  120015. static get Version(): string;
  120016. /**
  120017. * Returns a string describing the current engine
  120018. */
  120019. get description(): string;
  120020. /**
  120021. * Gets or sets the epsilon value used by collision engine
  120022. */
  120023. static CollisionsEpsilon: number;
  120024. /**
  120025. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120026. */
  120027. static get ShadersRepository(): string;
  120028. static set ShadersRepository(value: string);
  120029. /** @hidden */
  120030. _shaderProcessor: IShaderProcessor;
  120031. /**
  120032. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120033. */
  120034. forcePOTTextures: boolean;
  120035. /**
  120036. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120037. */
  120038. isFullscreen: boolean;
  120039. /**
  120040. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120041. */
  120042. cullBackFaces: boolean;
  120043. /**
  120044. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120045. */
  120046. renderEvenInBackground: boolean;
  120047. /**
  120048. * Gets or sets a boolean indicating that cache can be kept between frames
  120049. */
  120050. preventCacheWipeBetweenFrames: boolean;
  120051. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120052. validateShaderPrograms: boolean;
  120053. /**
  120054. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120055. * This can provide greater z depth for distant objects.
  120056. */
  120057. useReverseDepthBuffer: boolean;
  120058. /**
  120059. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120060. */
  120061. disableUniformBuffers: boolean;
  120062. /** @hidden */
  120063. _uniformBuffers: UniformBuffer[];
  120064. /**
  120065. * Gets a boolean indicating that the engine supports uniform buffers
  120066. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120067. */
  120068. get supportsUniformBuffers(): boolean;
  120069. /** @hidden */
  120070. _gl: WebGLRenderingContext;
  120071. /** @hidden */
  120072. _webGLVersion: number;
  120073. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120074. protected _windowIsBackground: boolean;
  120075. protected _creationOptions: EngineOptions;
  120076. protected _highPrecisionShadersAllowed: boolean;
  120077. /** @hidden */
  120078. get _shouldUseHighPrecisionShader(): boolean;
  120079. /**
  120080. * Gets a boolean indicating that only power of 2 textures are supported
  120081. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120082. */
  120083. get needPOTTextures(): boolean;
  120084. /** @hidden */
  120085. _badOS: boolean;
  120086. /** @hidden */
  120087. _badDesktopOS: boolean;
  120088. private _hardwareScalingLevel;
  120089. /** @hidden */
  120090. _caps: EngineCapabilities;
  120091. private _isStencilEnable;
  120092. private _glVersion;
  120093. private _glRenderer;
  120094. private _glVendor;
  120095. /** @hidden */
  120096. _videoTextureSupported: boolean;
  120097. protected _renderingQueueLaunched: boolean;
  120098. protected _activeRenderLoops: (() => void)[];
  120099. /**
  120100. * Observable signaled when a context lost event is raised
  120101. */
  120102. onContextLostObservable: Observable<ThinEngine>;
  120103. /**
  120104. * Observable signaled when a context restored event is raised
  120105. */
  120106. onContextRestoredObservable: Observable<ThinEngine>;
  120107. private _onContextLost;
  120108. private _onContextRestored;
  120109. protected _contextWasLost: boolean;
  120110. /** @hidden */
  120111. _doNotHandleContextLost: boolean;
  120112. /**
  120113. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120114. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120115. */
  120116. get doNotHandleContextLost(): boolean;
  120117. set doNotHandleContextLost(value: boolean);
  120118. /**
  120119. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120120. */
  120121. disableVertexArrayObjects: boolean;
  120122. /** @hidden */
  120123. protected _colorWrite: boolean;
  120124. /** @hidden */
  120125. protected _colorWriteChanged: boolean;
  120126. /** @hidden */
  120127. protected _depthCullingState: DepthCullingState;
  120128. /** @hidden */
  120129. protected _stencilState: StencilState;
  120130. /** @hidden */
  120131. _alphaState: AlphaState;
  120132. /** @hidden */
  120133. _alphaMode: number;
  120134. /** @hidden */
  120135. _alphaEquation: number;
  120136. /** @hidden */
  120137. _internalTexturesCache: InternalTexture[];
  120138. /** @hidden */
  120139. protected _activeChannel: number;
  120140. private _currentTextureChannel;
  120141. /** @hidden */
  120142. protected _boundTexturesCache: {
  120143. [key: string]: Nullable<InternalTexture>;
  120144. };
  120145. /** @hidden */
  120146. protected _currentEffect: Nullable<Effect>;
  120147. /** @hidden */
  120148. protected _currentProgram: Nullable<WebGLProgram>;
  120149. private _compiledEffects;
  120150. private _vertexAttribArraysEnabled;
  120151. /** @hidden */
  120152. protected _cachedViewport: Nullable<IViewportLike>;
  120153. private _cachedVertexArrayObject;
  120154. /** @hidden */
  120155. protected _cachedVertexBuffers: any;
  120156. /** @hidden */
  120157. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120158. /** @hidden */
  120159. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120160. /** @hidden */
  120161. _currentRenderTarget: Nullable<InternalTexture>;
  120162. private _uintIndicesCurrentlySet;
  120163. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120164. /** @hidden */
  120165. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120166. /** @hidden */
  120167. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120168. private _currentBufferPointers;
  120169. private _currentInstanceLocations;
  120170. private _currentInstanceBuffers;
  120171. private _textureUnits;
  120172. /** @hidden */
  120173. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120174. /** @hidden */
  120175. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120176. /** @hidden */
  120177. _boundRenderFunction: any;
  120178. private _vaoRecordInProgress;
  120179. private _mustWipeVertexAttributes;
  120180. private _emptyTexture;
  120181. private _emptyCubeTexture;
  120182. private _emptyTexture3D;
  120183. private _emptyTexture2DArray;
  120184. /** @hidden */
  120185. _frameHandler: number;
  120186. private _nextFreeTextureSlots;
  120187. private _maxSimultaneousTextures;
  120188. private _activeRequests;
  120189. /** @hidden */
  120190. _transformTextureUrl: Nullable<(url: string) => string>;
  120191. /**
  120192. * Gets information about the current host
  120193. */
  120194. hostInformation: HostInformation;
  120195. protected get _supportsHardwareTextureRescaling(): boolean;
  120196. private _framebufferDimensionsObject;
  120197. /**
  120198. * sets the object from which width and height will be taken from when getting render width and height
  120199. * Will fallback to the gl object
  120200. * @param dimensions the framebuffer width and height that will be used.
  120201. */
  120202. set framebufferDimensionsObject(dimensions: Nullable<{
  120203. framebufferWidth: number;
  120204. framebufferHeight: number;
  120205. }>);
  120206. /**
  120207. * Gets the current viewport
  120208. */
  120209. get currentViewport(): Nullable<IViewportLike>;
  120210. /**
  120211. * Gets the default empty texture
  120212. */
  120213. get emptyTexture(): InternalTexture;
  120214. /**
  120215. * Gets the default empty 3D texture
  120216. */
  120217. get emptyTexture3D(): InternalTexture;
  120218. /**
  120219. * Gets the default empty 2D array texture
  120220. */
  120221. get emptyTexture2DArray(): InternalTexture;
  120222. /**
  120223. * Gets the default empty cube texture
  120224. */
  120225. get emptyCubeTexture(): InternalTexture;
  120226. /**
  120227. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120228. */
  120229. readonly premultipliedAlpha: boolean;
  120230. /**
  120231. * Observable event triggered before each texture is initialized
  120232. */
  120233. onBeforeTextureInitObservable: Observable<Texture>;
  120234. /**
  120235. * Creates a new engine
  120236. * @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
  120237. * @param antialias defines enable antialiasing (default: false)
  120238. * @param options defines further options to be sent to the getContext() function
  120239. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120240. */
  120241. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120242. private _rebuildInternalTextures;
  120243. private _rebuildEffects;
  120244. /**
  120245. * Gets a boolean indicating if all created effects are ready
  120246. * @returns true if all effects are ready
  120247. */
  120248. areAllEffectsReady(): boolean;
  120249. protected _rebuildBuffers(): void;
  120250. protected _initGLContext(): void;
  120251. /**
  120252. * Gets version of the current webGL context
  120253. */
  120254. get webGLVersion(): number;
  120255. /**
  120256. * Gets a string identifying the name of the class
  120257. * @returns "Engine" string
  120258. */
  120259. getClassName(): string;
  120260. /**
  120261. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120262. */
  120263. get isStencilEnable(): boolean;
  120264. /** @hidden */
  120265. _prepareWorkingCanvas(): void;
  120266. /**
  120267. * Reset the texture cache to empty state
  120268. */
  120269. resetTextureCache(): void;
  120270. /**
  120271. * Gets an object containing information about the current webGL context
  120272. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120273. */
  120274. getGlInfo(): {
  120275. vendor: string;
  120276. renderer: string;
  120277. version: string;
  120278. };
  120279. /**
  120280. * Defines the hardware scaling level.
  120281. * By default the hardware scaling level is computed from the window device ratio.
  120282. * 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.
  120283. * @param level defines the level to use
  120284. */
  120285. setHardwareScalingLevel(level: number): void;
  120286. /**
  120287. * Gets the current hardware scaling level.
  120288. * By default the hardware scaling level is computed from the window device ratio.
  120289. * 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.
  120290. * @returns a number indicating the current hardware scaling level
  120291. */
  120292. getHardwareScalingLevel(): number;
  120293. /**
  120294. * Gets the list of loaded textures
  120295. * @returns an array containing all loaded textures
  120296. */
  120297. getLoadedTexturesCache(): InternalTexture[];
  120298. /**
  120299. * Gets the object containing all engine capabilities
  120300. * @returns the EngineCapabilities object
  120301. */
  120302. getCaps(): EngineCapabilities;
  120303. /**
  120304. * stop executing a render loop function and remove it from the execution array
  120305. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120306. */
  120307. stopRenderLoop(renderFunction?: () => void): void;
  120308. /** @hidden */
  120309. _renderLoop(): void;
  120310. /**
  120311. * Gets the HTML canvas attached with the current webGL context
  120312. * @returns a HTML canvas
  120313. */
  120314. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120315. /**
  120316. * Gets host window
  120317. * @returns the host window object
  120318. */
  120319. getHostWindow(): Nullable<Window>;
  120320. /**
  120321. * Gets the current render width
  120322. * @param useScreen defines if screen size must be used (or the current render target if any)
  120323. * @returns a number defining the current render width
  120324. */
  120325. getRenderWidth(useScreen?: boolean): number;
  120326. /**
  120327. * Gets the current render height
  120328. * @param useScreen defines if screen size must be used (or the current render target if any)
  120329. * @returns a number defining the current render height
  120330. */
  120331. getRenderHeight(useScreen?: boolean): number;
  120332. /**
  120333. * Can be used to override the current requestAnimationFrame requester.
  120334. * @hidden
  120335. */
  120336. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120337. /**
  120338. * Register and execute a render loop. The engine can have more than one render function
  120339. * @param renderFunction defines the function to continuously execute
  120340. */
  120341. runRenderLoop(renderFunction: () => void): void;
  120342. /**
  120343. * Clear the current render buffer or the current render target (if any is set up)
  120344. * @param color defines the color to use
  120345. * @param backBuffer defines if the back buffer must be cleared
  120346. * @param depth defines if the depth buffer must be cleared
  120347. * @param stencil defines if the stencil buffer must be cleared
  120348. */
  120349. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120350. private _viewportCached;
  120351. /** @hidden */
  120352. _viewport(x: number, y: number, width: number, height: number): void;
  120353. /**
  120354. * Set the WebGL's viewport
  120355. * @param viewport defines the viewport element to be used
  120356. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120357. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120358. */
  120359. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120360. /**
  120361. * Begin a new frame
  120362. */
  120363. beginFrame(): void;
  120364. /**
  120365. * Enf the current frame
  120366. */
  120367. endFrame(): void;
  120368. /**
  120369. * Resize the view according to the canvas' size
  120370. */
  120371. resize(): void;
  120372. /**
  120373. * Force a specific size of the canvas
  120374. * @param width defines the new canvas' width
  120375. * @param height defines the new canvas' height
  120376. * @returns true if the size was changed
  120377. */
  120378. setSize(width: number, height: number): boolean;
  120379. /**
  120380. * Binds the frame buffer to the specified texture.
  120381. * @param texture The texture to render to or null for the default canvas
  120382. * @param faceIndex The face of the texture to render to in case of cube texture
  120383. * @param requiredWidth The width of the target to render to
  120384. * @param requiredHeight The height of the target to render to
  120385. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120386. * @param lodLevel defines the lod level to bind to the frame buffer
  120387. * @param layer defines the 2d array index to bind to frame buffer to
  120388. */
  120389. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  120390. /** @hidden */
  120391. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120392. /**
  120393. * Unbind the current render target texture from the webGL context
  120394. * @param texture defines the render target texture to unbind
  120395. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120396. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120397. */
  120398. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120399. /**
  120400. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  120401. */
  120402. flushFramebuffer(): void;
  120403. /**
  120404. * Unbind the current render target and bind the default framebuffer
  120405. */
  120406. restoreDefaultFramebuffer(): void;
  120407. /** @hidden */
  120408. protected _resetVertexBufferBinding(): void;
  120409. /**
  120410. * Creates a vertex buffer
  120411. * @param data the data for the vertex buffer
  120412. * @returns the new WebGL static buffer
  120413. */
  120414. createVertexBuffer(data: DataArray): DataBuffer;
  120415. private _createVertexBuffer;
  120416. /**
  120417. * Creates a dynamic vertex buffer
  120418. * @param data the data for the dynamic vertex buffer
  120419. * @returns the new WebGL dynamic buffer
  120420. */
  120421. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120422. protected _resetIndexBufferBinding(): void;
  120423. /**
  120424. * Creates a new index buffer
  120425. * @param indices defines the content of the index buffer
  120426. * @param updatable defines if the index buffer must be updatable
  120427. * @returns a new webGL buffer
  120428. */
  120429. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  120430. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  120431. /**
  120432. * Bind a webGL buffer to the webGL context
  120433. * @param buffer defines the buffer to bind
  120434. */
  120435. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  120436. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  120437. private bindBuffer;
  120438. /**
  120439. * update the bound buffer with the given data
  120440. * @param data defines the data to update
  120441. */
  120442. updateArrayBuffer(data: Float32Array): void;
  120443. private _vertexAttribPointer;
  120444. /** @hidden */
  120445. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  120446. private _bindVertexBuffersAttributes;
  120447. /**
  120448. * Records a vertex array object
  120449. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120450. * @param vertexBuffers defines the list of vertex buffers to store
  120451. * @param indexBuffer defines the index buffer to store
  120452. * @param effect defines the effect to store
  120453. * @returns the new vertex array object
  120454. */
  120455. recordVertexArrayObject(vertexBuffers: {
  120456. [key: string]: VertexBuffer;
  120457. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120458. /**
  120459. * Bind a specific vertex array object
  120460. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120461. * @param vertexArrayObject defines the vertex array object to bind
  120462. * @param indexBuffer defines the index buffer to bind
  120463. */
  120464. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  120465. /**
  120466. * Bind webGl buffers directly to the webGL context
  120467. * @param vertexBuffer defines the vertex buffer to bind
  120468. * @param indexBuffer defines the index buffer to bind
  120469. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120470. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120471. * @param effect defines the effect associated with the vertex buffer
  120472. */
  120473. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  120474. private _unbindVertexArrayObject;
  120475. /**
  120476. * Bind a list of vertex buffers to the webGL context
  120477. * @param vertexBuffers defines the list of vertex buffers to bind
  120478. * @param indexBuffer defines the index buffer to bind
  120479. * @param effect defines the effect associated with the vertex buffers
  120480. */
  120481. bindBuffers(vertexBuffers: {
  120482. [key: string]: Nullable<VertexBuffer>;
  120483. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  120484. /**
  120485. * Unbind all instance attributes
  120486. */
  120487. unbindInstanceAttributes(): void;
  120488. /**
  120489. * Release and free the memory of a vertex array object
  120490. * @param vao defines the vertex array object to delete
  120491. */
  120492. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  120493. /** @hidden */
  120494. _releaseBuffer(buffer: DataBuffer): boolean;
  120495. protected _deleteBuffer(buffer: DataBuffer): void;
  120496. /**
  120497. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  120498. * @param instancesBuffer defines the webGL buffer to update and bind
  120499. * @param data defines the data to store in the buffer
  120500. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  120501. */
  120502. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  120503. /**
  120504. * Bind the content of a webGL buffer used with instantiation
  120505. * @param instancesBuffer defines the webGL buffer to bind
  120506. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  120507. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  120508. */
  120509. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  120510. /**
  120511. * Disable the instance attribute corresponding to the name in parameter
  120512. * @param name defines the name of the attribute to disable
  120513. */
  120514. disableInstanceAttributeByName(name: string): void;
  120515. /**
  120516. * Disable the instance attribute corresponding to the location in parameter
  120517. * @param attributeLocation defines the attribute location of the attribute to disable
  120518. */
  120519. disableInstanceAttribute(attributeLocation: number): void;
  120520. /**
  120521. * Disable the attribute corresponding to the location in parameter
  120522. * @param attributeLocation defines the attribute location of the attribute to disable
  120523. */
  120524. disableAttributeByIndex(attributeLocation: number): void;
  120525. /**
  120526. * Send a draw order
  120527. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120528. * @param indexStart defines the starting index
  120529. * @param indexCount defines the number of index to draw
  120530. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120531. */
  120532. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120533. /**
  120534. * Draw a list of points
  120535. * @param verticesStart defines the index of first vertex to draw
  120536. * @param verticesCount defines the count of vertices to draw
  120537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120538. */
  120539. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120540. /**
  120541. * Draw a list of unindexed primitives
  120542. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120543. * @param verticesStart defines the index of first vertex to draw
  120544. * @param verticesCount defines the count of vertices to draw
  120545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120546. */
  120547. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120548. /**
  120549. * Draw a list of indexed primitives
  120550. * @param fillMode defines the primitive to use
  120551. * @param indexStart defines the starting index
  120552. * @param indexCount defines the number of index to draw
  120553. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120554. */
  120555. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120556. /**
  120557. * Draw a list of unindexed primitives
  120558. * @param fillMode defines the primitive to use
  120559. * @param verticesStart defines the index of first vertex to draw
  120560. * @param verticesCount defines the count of vertices to draw
  120561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120562. */
  120563. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120564. private _drawMode;
  120565. /** @hidden */
  120566. protected _reportDrawCall(): void;
  120567. /** @hidden */
  120568. _releaseEffect(effect: Effect): void;
  120569. /** @hidden */
  120570. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120571. /**
  120572. * Create a new effect (used to store vertex/fragment shaders)
  120573. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  120574. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  120575. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  120576. * @param samplers defines an array of string used to represent textures
  120577. * @param defines defines the string containing the defines to use to compile the shaders
  120578. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120579. * @param onCompiled defines a function to call when the effect creation is successful
  120580. * @param onError defines a function to call when the effect creation has failed
  120581. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  120582. * @returns the new Effect
  120583. */
  120584. 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;
  120585. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  120586. private _compileShader;
  120587. private _compileRawShader;
  120588. /** @hidden */
  120589. _getShaderSource(shader: WebGLShader): Nullable<string>;
  120590. /**
  120591. * Directly creates a webGL program
  120592. * @param pipelineContext defines the pipeline context to attach to
  120593. * @param vertexCode defines the vertex shader code to use
  120594. * @param fragmentCode defines the fragment shader code to use
  120595. * @param context defines the webGL context to use (if not set, the current one will be used)
  120596. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120597. * @returns the new webGL program
  120598. */
  120599. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120600. /**
  120601. * Creates a webGL program
  120602. * @param pipelineContext defines the pipeline context to attach to
  120603. * @param vertexCode defines the vertex shader code to use
  120604. * @param fragmentCode defines the fragment shader code to use
  120605. * @param defines defines the string containing the defines to use to compile the shaders
  120606. * @param context defines the webGL context to use (if not set, the current one will be used)
  120607. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120608. * @returns the new webGL program
  120609. */
  120610. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120611. /**
  120612. * Creates a new pipeline context
  120613. * @returns the new pipeline
  120614. */
  120615. createPipelineContext(): IPipelineContext;
  120616. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120617. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  120618. /** @hidden */
  120619. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120620. /** @hidden */
  120621. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120622. /** @hidden */
  120623. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120624. /**
  120625. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120626. * @param pipelineContext defines the pipeline context to use
  120627. * @param uniformsNames defines the list of uniform names
  120628. * @returns an array of webGL uniform locations
  120629. */
  120630. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120631. /**
  120632. * Gets the lsit of active attributes for a given webGL program
  120633. * @param pipelineContext defines the pipeline context to use
  120634. * @param attributesNames defines the list of attribute names to get
  120635. * @returns an array of indices indicating the offset of each attribute
  120636. */
  120637. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120638. /**
  120639. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120640. * @param effect defines the effect to activate
  120641. */
  120642. enableEffect(effect: Nullable<Effect>): void;
  120643. /**
  120644. * Set the value of an uniform to a number (int)
  120645. * @param uniform defines the webGL uniform location where to store the value
  120646. * @param value defines the int number to store
  120647. * @returns true if the value was set
  120648. */
  120649. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120650. /**
  120651. * Set the value of an uniform to an array of int32
  120652. * @param uniform defines the webGL uniform location where to store the value
  120653. * @param array defines the array of int32 to store
  120654. * @returns true if the value was set
  120655. */
  120656. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120657. /**
  120658. * Set the value of an uniform to an array of int32 (stored as vec2)
  120659. * @param uniform defines the webGL uniform location where to store the value
  120660. * @param array defines the array of int32 to store
  120661. * @returns true if the value was set
  120662. */
  120663. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120664. /**
  120665. * Set the value of an uniform to an array of int32 (stored as vec3)
  120666. * @param uniform defines the webGL uniform location where to store the value
  120667. * @param array defines the array of int32 to store
  120668. * @returns true if the value was set
  120669. */
  120670. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120671. /**
  120672. * Set the value of an uniform to an array of int32 (stored as vec4)
  120673. * @param uniform defines the webGL uniform location where to store the value
  120674. * @param array defines the array of int32 to store
  120675. * @returns true if the value was set
  120676. */
  120677. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120678. /**
  120679. * Set the value of an uniform to an array of number
  120680. * @param uniform defines the webGL uniform location where to store the value
  120681. * @param array defines the array of number to store
  120682. * @returns true if the value was set
  120683. */
  120684. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120685. /**
  120686. * Set the value of an uniform to an array of number (stored as vec2)
  120687. * @param uniform defines the webGL uniform location where to store the value
  120688. * @param array defines the array of number to store
  120689. * @returns true if the value was set
  120690. */
  120691. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120692. /**
  120693. * Set the value of an uniform to an array of number (stored as vec3)
  120694. * @param uniform defines the webGL uniform location where to store the value
  120695. * @param array defines the array of number to store
  120696. * @returns true if the value was set
  120697. */
  120698. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120699. /**
  120700. * Set the value of an uniform to an array of number (stored as vec4)
  120701. * @param uniform defines the webGL uniform location where to store the value
  120702. * @param array defines the array of number to store
  120703. * @returns true if the value was set
  120704. */
  120705. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120706. /**
  120707. * Set the value of an uniform to an array of float32 (stored as matrices)
  120708. * @param uniform defines the webGL uniform location where to store the value
  120709. * @param matrices defines the array of float32 to store
  120710. * @returns true if the value was set
  120711. */
  120712. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  120713. /**
  120714. * Set the value of an uniform to a matrix (3x3)
  120715. * @param uniform defines the webGL uniform location where to store the value
  120716. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120717. * @returns true if the value was set
  120718. */
  120719. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120720. /**
  120721. * Set the value of an uniform to a matrix (2x2)
  120722. * @param uniform defines the webGL uniform location where to store the value
  120723. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120724. * @returns true if the value was set
  120725. */
  120726. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120727. /**
  120728. * Set the value of an uniform to a number (float)
  120729. * @param uniform defines the webGL uniform location where to store the value
  120730. * @param value defines the float number to store
  120731. * @returns true if the value was transfered
  120732. */
  120733. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120734. /**
  120735. * Set the value of an uniform to a vec2
  120736. * @param uniform defines the webGL uniform location where to store the value
  120737. * @param x defines the 1st component of the value
  120738. * @param y defines the 2nd component of the value
  120739. * @returns true if the value was set
  120740. */
  120741. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  120742. /**
  120743. * Set the value of an uniform to a vec3
  120744. * @param uniform defines the webGL uniform location where to store the value
  120745. * @param x defines the 1st component of the value
  120746. * @param y defines the 2nd component of the value
  120747. * @param z defines the 3rd component of the value
  120748. * @returns true if the value was set
  120749. */
  120750. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  120751. /**
  120752. * Set the value of an uniform to a vec4
  120753. * @param uniform defines the webGL uniform location where to store the value
  120754. * @param x defines the 1st component of the value
  120755. * @param y defines the 2nd component of the value
  120756. * @param z defines the 3rd component of the value
  120757. * @param w defines the 4th component of the value
  120758. * @returns true if the value was set
  120759. */
  120760. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120761. /**
  120762. * Apply all cached states (depth, culling, stencil and alpha)
  120763. */
  120764. applyStates(): void;
  120765. /**
  120766. * Enable or disable color writing
  120767. * @param enable defines the state to set
  120768. */
  120769. setColorWrite(enable: boolean): void;
  120770. /**
  120771. * Gets a boolean indicating if color writing is enabled
  120772. * @returns the current color writing state
  120773. */
  120774. getColorWrite(): boolean;
  120775. /**
  120776. * Gets the depth culling state manager
  120777. */
  120778. get depthCullingState(): DepthCullingState;
  120779. /**
  120780. * Gets the alpha state manager
  120781. */
  120782. get alphaState(): AlphaState;
  120783. /**
  120784. * Gets the stencil state manager
  120785. */
  120786. get stencilState(): StencilState;
  120787. /**
  120788. * Clears the list of texture accessible through engine.
  120789. * This can help preventing texture load conflict due to name collision.
  120790. */
  120791. clearInternalTexturesCache(): void;
  120792. /**
  120793. * Force the entire cache to be cleared
  120794. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120795. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120796. */
  120797. wipeCaches(bruteForce?: boolean): void;
  120798. /** @hidden */
  120799. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120800. min: number;
  120801. mag: number;
  120802. };
  120803. /** @hidden */
  120804. _createTexture(): WebGLTexture;
  120805. /**
  120806. * Usually called from Texture.ts.
  120807. * Passed information to create a WebGLTexture
  120808. * @param url defines a value which contains one of the following:
  120809. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120810. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120811. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120813. * @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)
  120814. * @param scene needed for loading to the correct scene
  120815. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120816. * @param onLoad optional callback to be called upon successful completion
  120817. * @param onError optional callback to be called upon failure
  120818. * @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
  120819. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120820. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120821. * @param forcedExtension defines the extension to use to pick the right loader
  120822. * @param mimeType defines an optional mime type
  120823. * @param loaderOptions options to be passed to the loader
  120824. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120825. */
  120826. 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;
  120827. /**
  120828. * Loads an image as an HTMLImageElement.
  120829. * @param input url string, ArrayBuffer, or Blob to load
  120830. * @param onLoad callback called when the image successfully loads
  120831. * @param onError callback called when the image fails to load
  120832. * @param offlineProvider offline provider for caching
  120833. * @param mimeType optional mime type
  120834. * @returns the HTMLImageElement of the loaded image
  120835. * @hidden
  120836. */
  120837. 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>;
  120838. /**
  120839. * @hidden
  120840. */
  120841. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120842. private _unpackFlipYCached;
  120843. /**
  120844. * In case you are sharing the context with other applications, it might
  120845. * be interested to not cache the unpack flip y state to ensure a consistent
  120846. * value would be set.
  120847. */
  120848. enableUnpackFlipYCached: boolean;
  120849. /** @hidden */
  120850. _unpackFlipY(value: boolean): void;
  120851. /** @hidden */
  120852. _getUnpackAlignement(): number;
  120853. private _getTextureTarget;
  120854. /**
  120855. * Update the sampling mode of a given texture
  120856. * @param samplingMode defines the required sampling mode
  120857. * @param texture defines the texture to update
  120858. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120859. */
  120860. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120861. /**
  120862. * Update the sampling mode of a given texture
  120863. * @param texture defines the texture to update
  120864. * @param wrapU defines the texture wrap mode of the u coordinates
  120865. * @param wrapV defines the texture wrap mode of the v coordinates
  120866. * @param wrapR defines the texture wrap mode of the r coordinates
  120867. */
  120868. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120869. /** @hidden */
  120870. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120871. width: number;
  120872. height: number;
  120873. layers?: number;
  120874. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120875. /** @hidden */
  120876. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120877. /** @hidden */
  120878. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120879. /**
  120880. * Update a portion of an internal texture
  120881. * @param texture defines the texture to update
  120882. * @param imageData defines the data to store into the texture
  120883. * @param xOffset defines the x coordinates of the update rectangle
  120884. * @param yOffset defines the y coordinates of the update rectangle
  120885. * @param width defines the width of the update rectangle
  120886. * @param height defines the height of the update rectangle
  120887. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120888. * @param lod defines the lod level to update (0 by default)
  120889. */
  120890. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120891. /** @hidden */
  120892. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120893. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120894. private _prepareWebGLTexture;
  120895. /** @hidden */
  120896. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120897. private _getDepthStencilBuffer;
  120898. /** @hidden */
  120899. _releaseFramebufferObjects(texture: InternalTexture): void;
  120900. /** @hidden */
  120901. _releaseTexture(texture: InternalTexture): void;
  120902. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120903. protected _setProgram(program: WebGLProgram): void;
  120904. protected _boundUniforms: {
  120905. [key: number]: WebGLUniformLocation;
  120906. };
  120907. /**
  120908. * Binds an effect to the webGL context
  120909. * @param effect defines the effect to bind
  120910. */
  120911. bindSamplers(effect: Effect): void;
  120912. private _activateCurrentTexture;
  120913. /** @hidden */
  120914. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120915. /** @hidden */
  120916. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120917. /**
  120918. * Unbind all textures from the webGL context
  120919. */
  120920. unbindAllTextures(): void;
  120921. /**
  120922. * Sets a texture to the according uniform.
  120923. * @param channel The texture channel
  120924. * @param uniform The uniform to set
  120925. * @param texture The texture to apply
  120926. */
  120927. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120928. private _bindSamplerUniformToChannel;
  120929. private _getTextureWrapMode;
  120930. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120931. /**
  120932. * Sets an array of texture to the webGL context
  120933. * @param channel defines the channel where the texture array must be set
  120934. * @param uniform defines the associated uniform location
  120935. * @param textures defines the array of textures to bind
  120936. */
  120937. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120938. /** @hidden */
  120939. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120940. private _setTextureParameterFloat;
  120941. private _setTextureParameterInteger;
  120942. /**
  120943. * Unbind all vertex attributes from the webGL context
  120944. */
  120945. unbindAllAttributes(): void;
  120946. /**
  120947. * 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
  120948. */
  120949. releaseEffects(): void;
  120950. /**
  120951. * Dispose and release all associated resources
  120952. */
  120953. dispose(): void;
  120954. /**
  120955. * Attach a new callback raised when context lost event is fired
  120956. * @param callback defines the callback to call
  120957. */
  120958. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120959. /**
  120960. * Attach a new callback raised when context restored event is fired
  120961. * @param callback defines the callback to call
  120962. */
  120963. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120964. /**
  120965. * Get the current error code of the webGL context
  120966. * @returns the error code
  120967. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120968. */
  120969. getError(): number;
  120970. private _canRenderToFloatFramebuffer;
  120971. private _canRenderToHalfFloatFramebuffer;
  120972. private _canRenderToFramebuffer;
  120973. /** @hidden */
  120974. _getWebGLTextureType(type: number): number;
  120975. /** @hidden */
  120976. _getInternalFormat(format: number): number;
  120977. /** @hidden */
  120978. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120979. /** @hidden */
  120980. _getRGBAMultiSampleBufferFormat(type: number): number;
  120981. /** @hidden */
  120982. _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;
  120983. /**
  120984. * Loads a file from a url
  120985. * @param url url to load
  120986. * @param onSuccess callback called when the file successfully loads
  120987. * @param onProgress callback called while file is loading (if the server supports this mode)
  120988. * @param offlineProvider defines the offline provider for caching
  120989. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120990. * @param onError callback called when the file fails to load
  120991. * @returns a file request object
  120992. * @hidden
  120993. */
  120994. 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;
  120995. /**
  120996. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120997. * @param x defines the x coordinate of the rectangle where pixels must be read
  120998. * @param y defines the y coordinate of the rectangle where pixels must be read
  120999. * @param width defines the width of the rectangle where pixels must be read
  121000. * @param height defines the height of the rectangle where pixels must be read
  121001. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  121002. * @returns a Uint8Array containing RGBA colors
  121003. */
  121004. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  121005. private static _IsSupported;
  121006. private static _HasMajorPerformanceCaveat;
  121007. /**
  121008. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121009. */
  121010. static get IsSupported(): boolean;
  121011. /**
  121012. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121013. * @returns true if the engine can be created
  121014. * @ignorenaming
  121015. */
  121016. static isSupported(): boolean;
  121017. /**
  121018. * 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)
  121019. */
  121020. static get HasMajorPerformanceCaveat(): boolean;
  121021. /**
  121022. * Find the next highest power of two.
  121023. * @param x Number to start search from.
  121024. * @return Next highest power of two.
  121025. */
  121026. static CeilingPOT(x: number): number;
  121027. /**
  121028. * Find the next lowest power of two.
  121029. * @param x Number to start search from.
  121030. * @return Next lowest power of two.
  121031. */
  121032. static FloorPOT(x: number): number;
  121033. /**
  121034. * Find the nearest power of two.
  121035. * @param x Number to start search from.
  121036. * @return Next nearest power of two.
  121037. */
  121038. static NearestPOT(x: number): number;
  121039. /**
  121040. * Get the closest exponent of two
  121041. * @param value defines the value to approximate
  121042. * @param max defines the maximum value to return
  121043. * @param mode defines how to define the closest value
  121044. * @returns closest exponent of two of the given value
  121045. */
  121046. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121047. /**
  121048. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121049. * @param func - the function to be called
  121050. * @param requester - the object that will request the next frame. Falls back to window.
  121051. * @returns frame number
  121052. */
  121053. static QueueNewFrame(func: () => void, requester?: any): number;
  121054. /**
  121055. * Gets host document
  121056. * @returns the host document object
  121057. */
  121058. getHostDocument(): Nullable<Document>;
  121059. }
  121060. }
  121061. declare module BABYLON {
  121062. /**
  121063. * Defines the source of the internal texture
  121064. */
  121065. export enum InternalTextureSource {
  121066. /**
  121067. * The source of the texture data is unknown
  121068. */
  121069. Unknown = 0,
  121070. /**
  121071. * Texture data comes from an URL
  121072. */
  121073. Url = 1,
  121074. /**
  121075. * Texture data is only used for temporary storage
  121076. */
  121077. Temp = 2,
  121078. /**
  121079. * Texture data comes from raw data (ArrayBuffer)
  121080. */
  121081. Raw = 3,
  121082. /**
  121083. * Texture content is dynamic (video or dynamic texture)
  121084. */
  121085. Dynamic = 4,
  121086. /**
  121087. * Texture content is generated by rendering to it
  121088. */
  121089. RenderTarget = 5,
  121090. /**
  121091. * Texture content is part of a multi render target process
  121092. */
  121093. MultiRenderTarget = 6,
  121094. /**
  121095. * Texture data comes from a cube data file
  121096. */
  121097. Cube = 7,
  121098. /**
  121099. * Texture data comes from a raw cube data
  121100. */
  121101. CubeRaw = 8,
  121102. /**
  121103. * Texture data come from a prefiltered cube data file
  121104. */
  121105. CubePrefiltered = 9,
  121106. /**
  121107. * Texture content is raw 3D data
  121108. */
  121109. Raw3D = 10,
  121110. /**
  121111. * Texture content is raw 2D array data
  121112. */
  121113. Raw2DArray = 11,
  121114. /**
  121115. * Texture content is a depth texture
  121116. */
  121117. Depth = 12,
  121118. /**
  121119. * Texture data comes from a raw cube data encoded with RGBD
  121120. */
  121121. CubeRawRGBD = 13
  121122. }
  121123. /**
  121124. * Class used to store data associated with WebGL texture data for the engine
  121125. * This class should not be used directly
  121126. */
  121127. export class InternalTexture {
  121128. /** @hidden */
  121129. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121130. /**
  121131. * Defines if the texture is ready
  121132. */
  121133. isReady: boolean;
  121134. /**
  121135. * Defines if the texture is a cube texture
  121136. */
  121137. isCube: boolean;
  121138. /**
  121139. * Defines if the texture contains 3D data
  121140. */
  121141. is3D: boolean;
  121142. /**
  121143. * Defines if the texture contains 2D array data
  121144. */
  121145. is2DArray: boolean;
  121146. /**
  121147. * Defines if the texture contains multiview data
  121148. */
  121149. isMultiview: boolean;
  121150. /**
  121151. * Gets the URL used to load this texture
  121152. */
  121153. url: string;
  121154. /**
  121155. * Gets the sampling mode of the texture
  121156. */
  121157. samplingMode: number;
  121158. /**
  121159. * Gets a boolean indicating if the texture needs mipmaps generation
  121160. */
  121161. generateMipMaps: boolean;
  121162. /**
  121163. * Gets the number of samples used by the texture (WebGL2+ only)
  121164. */
  121165. samples: number;
  121166. /**
  121167. * Gets the type of the texture (int, float...)
  121168. */
  121169. type: number;
  121170. /**
  121171. * Gets the format of the texture (RGB, RGBA...)
  121172. */
  121173. format: number;
  121174. /**
  121175. * Observable called when the texture is loaded
  121176. */
  121177. onLoadedObservable: Observable<InternalTexture>;
  121178. /**
  121179. * Gets the width of the texture
  121180. */
  121181. width: number;
  121182. /**
  121183. * Gets the height of the texture
  121184. */
  121185. height: number;
  121186. /**
  121187. * Gets the depth of the texture
  121188. */
  121189. depth: number;
  121190. /**
  121191. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121192. */
  121193. baseWidth: number;
  121194. /**
  121195. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121196. */
  121197. baseHeight: number;
  121198. /**
  121199. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121200. */
  121201. baseDepth: number;
  121202. /**
  121203. * Gets a boolean indicating if the texture is inverted on Y axis
  121204. */
  121205. invertY: boolean;
  121206. /** @hidden */
  121207. _invertVScale: boolean;
  121208. /** @hidden */
  121209. _associatedChannel: number;
  121210. /** @hidden */
  121211. _source: InternalTextureSource;
  121212. /** @hidden */
  121213. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121214. /** @hidden */
  121215. _bufferView: Nullable<ArrayBufferView>;
  121216. /** @hidden */
  121217. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121218. /** @hidden */
  121219. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121220. /** @hidden */
  121221. _size: number;
  121222. /** @hidden */
  121223. _extension: string;
  121224. /** @hidden */
  121225. _files: Nullable<string[]>;
  121226. /** @hidden */
  121227. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121228. /** @hidden */
  121229. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121230. /** @hidden */
  121231. _framebuffer: Nullable<WebGLFramebuffer>;
  121232. /** @hidden */
  121233. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121234. /** @hidden */
  121235. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121236. /** @hidden */
  121237. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121238. /** @hidden */
  121239. _attachments: Nullable<number[]>;
  121240. /** @hidden */
  121241. _textureArray: Nullable<InternalTexture[]>;
  121242. /** @hidden */
  121243. _cachedCoordinatesMode: Nullable<number>;
  121244. /** @hidden */
  121245. _cachedWrapU: Nullable<number>;
  121246. /** @hidden */
  121247. _cachedWrapV: Nullable<number>;
  121248. /** @hidden */
  121249. _cachedWrapR: Nullable<number>;
  121250. /** @hidden */
  121251. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121252. /** @hidden */
  121253. _isDisabled: boolean;
  121254. /** @hidden */
  121255. _compression: Nullable<string>;
  121256. /** @hidden */
  121257. _generateStencilBuffer: boolean;
  121258. /** @hidden */
  121259. _generateDepthBuffer: boolean;
  121260. /** @hidden */
  121261. _comparisonFunction: number;
  121262. /** @hidden */
  121263. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121264. /** @hidden */
  121265. _lodGenerationScale: number;
  121266. /** @hidden */
  121267. _lodGenerationOffset: number;
  121268. /** @hidden */
  121269. _depthStencilTexture: Nullable<InternalTexture>;
  121270. /** @hidden */
  121271. _colorTextureArray: Nullable<WebGLTexture>;
  121272. /** @hidden */
  121273. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121274. /** @hidden */
  121275. _lodTextureHigh: Nullable<BaseTexture>;
  121276. /** @hidden */
  121277. _lodTextureMid: Nullable<BaseTexture>;
  121278. /** @hidden */
  121279. _lodTextureLow: Nullable<BaseTexture>;
  121280. /** @hidden */
  121281. _isRGBD: boolean;
  121282. /** @hidden */
  121283. _linearSpecularLOD: boolean;
  121284. /** @hidden */
  121285. _irradianceTexture: Nullable<BaseTexture>;
  121286. /** @hidden */
  121287. _webGLTexture: Nullable<WebGLTexture>;
  121288. /** @hidden */
  121289. _references: number;
  121290. /** @hidden */
  121291. _gammaSpace: Nullable<boolean>;
  121292. private _engine;
  121293. /**
  121294. * Gets the Engine the texture belongs to.
  121295. * @returns The babylon engine
  121296. */
  121297. getEngine(): ThinEngine;
  121298. /**
  121299. * Gets the data source type of the texture
  121300. */
  121301. get source(): InternalTextureSource;
  121302. /**
  121303. * Creates a new InternalTexture
  121304. * @param engine defines the engine to use
  121305. * @param source defines the type of data that will be used
  121306. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121307. */
  121308. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121309. /**
  121310. * Increments the number of references (ie. the number of Texture that point to it)
  121311. */
  121312. incrementReferences(): void;
  121313. /**
  121314. * Change the size of the texture (not the size of the content)
  121315. * @param width defines the new width
  121316. * @param height defines the new height
  121317. * @param depth defines the new depth (1 by default)
  121318. */
  121319. updateSize(width: int, height: int, depth?: int): void;
  121320. /** @hidden */
  121321. _rebuild(): void;
  121322. /** @hidden */
  121323. _swapAndDie(target: InternalTexture): void;
  121324. /**
  121325. * Dispose the current allocated resources
  121326. */
  121327. dispose(): void;
  121328. }
  121329. }
  121330. declare module BABYLON {
  121331. /**
  121332. * Interface used to present a loading screen while loading a scene
  121333. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121334. */
  121335. export interface ILoadingScreen {
  121336. /**
  121337. * Function called to display the loading screen
  121338. */
  121339. displayLoadingUI: () => void;
  121340. /**
  121341. * Function called to hide the loading screen
  121342. */
  121343. hideLoadingUI: () => void;
  121344. /**
  121345. * Gets or sets the color to use for the background
  121346. */
  121347. loadingUIBackgroundColor: string;
  121348. /**
  121349. * Gets or sets the text to display while loading
  121350. */
  121351. loadingUIText: string;
  121352. }
  121353. /**
  121354. * Class used for the default loading screen
  121355. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121356. */
  121357. export class DefaultLoadingScreen implements ILoadingScreen {
  121358. private _renderingCanvas;
  121359. private _loadingText;
  121360. private _loadingDivBackgroundColor;
  121361. private _loadingDiv;
  121362. private _loadingTextDiv;
  121363. /** Gets or sets the logo url to use for the default loading screen */
  121364. static DefaultLogoUrl: string;
  121365. /** Gets or sets the spinner url to use for the default loading screen */
  121366. static DefaultSpinnerUrl: string;
  121367. /**
  121368. * Creates a new default loading screen
  121369. * @param _renderingCanvas defines the canvas used to render the scene
  121370. * @param _loadingText defines the default text to display
  121371. * @param _loadingDivBackgroundColor defines the default background color
  121372. */
  121373. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  121374. /**
  121375. * Function called to display the loading screen
  121376. */
  121377. displayLoadingUI(): void;
  121378. /**
  121379. * Function called to hide the loading screen
  121380. */
  121381. hideLoadingUI(): void;
  121382. /**
  121383. * Gets or sets the text to display while loading
  121384. */
  121385. set loadingUIText(text: string);
  121386. get loadingUIText(): string;
  121387. /**
  121388. * Gets or sets the color to use for the background
  121389. */
  121390. get loadingUIBackgroundColor(): string;
  121391. set loadingUIBackgroundColor(color: string);
  121392. private _resizeLoadingUI;
  121393. }
  121394. }
  121395. declare module BABYLON {
  121396. /**
  121397. * Interface for any object that can request an animation frame
  121398. */
  121399. export interface ICustomAnimationFrameRequester {
  121400. /**
  121401. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121402. */
  121403. renderFunction?: Function;
  121404. /**
  121405. * Called to request the next frame to render to
  121406. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121407. */
  121408. requestAnimationFrame: Function;
  121409. /**
  121410. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121411. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121412. */
  121413. requestID?: number;
  121414. }
  121415. }
  121416. declare module BABYLON {
  121417. /**
  121418. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121419. */
  121420. export class PerformanceMonitor {
  121421. private _enabled;
  121422. private _rollingFrameTime;
  121423. private _lastFrameTimeMs;
  121424. /**
  121425. * constructor
  121426. * @param frameSampleSize The number of samples required to saturate the sliding window
  121427. */
  121428. constructor(frameSampleSize?: number);
  121429. /**
  121430. * Samples current frame
  121431. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121432. */
  121433. sampleFrame(timeMs?: number): void;
  121434. /**
  121435. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121436. */
  121437. get averageFrameTime(): number;
  121438. /**
  121439. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121440. */
  121441. get averageFrameTimeVariance(): number;
  121442. /**
  121443. * Returns the frame time of the most recent frame
  121444. */
  121445. get instantaneousFrameTime(): number;
  121446. /**
  121447. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121448. */
  121449. get averageFPS(): number;
  121450. /**
  121451. * Returns the average framerate in frames per second using the most recent frame time
  121452. */
  121453. get instantaneousFPS(): number;
  121454. /**
  121455. * Returns true if enough samples have been taken to completely fill the sliding window
  121456. */
  121457. get isSaturated(): boolean;
  121458. /**
  121459. * Enables contributions to the sliding window sample set
  121460. */
  121461. enable(): void;
  121462. /**
  121463. * Disables contributions to the sliding window sample set
  121464. * Samples will not be interpolated over the disabled period
  121465. */
  121466. disable(): void;
  121467. /**
  121468. * Returns true if sampling is enabled
  121469. */
  121470. get isEnabled(): boolean;
  121471. /**
  121472. * Resets performance monitor
  121473. */
  121474. reset(): void;
  121475. }
  121476. /**
  121477. * RollingAverage
  121478. *
  121479. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121480. */
  121481. export class RollingAverage {
  121482. /**
  121483. * Current average
  121484. */
  121485. average: number;
  121486. /**
  121487. * Current variance
  121488. */
  121489. variance: number;
  121490. protected _samples: Array<number>;
  121491. protected _sampleCount: number;
  121492. protected _pos: number;
  121493. protected _m2: number;
  121494. /**
  121495. * constructor
  121496. * @param length The number of samples required to saturate the sliding window
  121497. */
  121498. constructor(length: number);
  121499. /**
  121500. * Adds a sample to the sample set
  121501. * @param v The sample value
  121502. */
  121503. add(v: number): void;
  121504. /**
  121505. * Returns previously added values or null if outside of history or outside the sliding window domain
  121506. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121507. * @return Value previously recorded with add() or null if outside of range
  121508. */
  121509. history(i: number): number;
  121510. /**
  121511. * Returns true if enough samples have been taken to completely fill the sliding window
  121512. * @return true if sample-set saturated
  121513. */
  121514. isSaturated(): boolean;
  121515. /**
  121516. * Resets the rolling average (equivalent to 0 samples taken so far)
  121517. */
  121518. reset(): void;
  121519. /**
  121520. * Wraps a value around the sample range boundaries
  121521. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121522. * @return Wrapped position in sample range
  121523. */
  121524. protected _wrapPosition(i: number): number;
  121525. }
  121526. }
  121527. declare module BABYLON {
  121528. /**
  121529. * This class is used to track a performance counter which is number based.
  121530. * The user has access to many properties which give statistics of different nature.
  121531. *
  121532. * The implementer can track two kinds of Performance Counter: time and count.
  121533. * 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.
  121534. * 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.
  121535. */
  121536. export class PerfCounter {
  121537. /**
  121538. * Gets or sets a global boolean to turn on and off all the counters
  121539. */
  121540. static Enabled: boolean;
  121541. /**
  121542. * Returns the smallest value ever
  121543. */
  121544. get min(): number;
  121545. /**
  121546. * Returns the biggest value ever
  121547. */
  121548. get max(): number;
  121549. /**
  121550. * Returns the average value since the performance counter is running
  121551. */
  121552. get average(): number;
  121553. /**
  121554. * Returns the average value of the last second the counter was monitored
  121555. */
  121556. get lastSecAverage(): number;
  121557. /**
  121558. * Returns the current value
  121559. */
  121560. get current(): number;
  121561. /**
  121562. * Gets the accumulated total
  121563. */
  121564. get total(): number;
  121565. /**
  121566. * Gets the total value count
  121567. */
  121568. get count(): number;
  121569. /**
  121570. * Creates a new counter
  121571. */
  121572. constructor();
  121573. /**
  121574. * Call this method to start monitoring a new frame.
  121575. * 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.
  121576. */
  121577. fetchNewFrame(): void;
  121578. /**
  121579. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121580. * @param newCount the count value to add to the monitored count
  121581. * @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.
  121582. */
  121583. addCount(newCount: number, fetchResult: boolean): void;
  121584. /**
  121585. * Start monitoring this performance counter
  121586. */
  121587. beginMonitoring(): void;
  121588. /**
  121589. * Compute the time lapsed since the previous beginMonitoring() call.
  121590. * @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
  121591. */
  121592. endMonitoring(newFrame?: boolean): void;
  121593. private _fetchResult;
  121594. private _startMonitoringTime;
  121595. private _min;
  121596. private _max;
  121597. private _average;
  121598. private _current;
  121599. private _totalValueCount;
  121600. private _totalAccumulated;
  121601. private _lastSecAverage;
  121602. private _lastSecAccumulated;
  121603. private _lastSecTime;
  121604. private _lastSecValueCount;
  121605. }
  121606. }
  121607. declare module BABYLON {
  121608. interface ThinEngine {
  121609. /** @hidden */
  121610. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121611. }
  121612. }
  121613. declare module BABYLON {
  121614. /**
  121615. * Class used to work with sound analyzer using fast fourier transform (FFT)
  121616. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121617. */
  121618. export class Analyser {
  121619. /**
  121620. * Gets or sets the smoothing
  121621. * @ignorenaming
  121622. */
  121623. SMOOTHING: number;
  121624. /**
  121625. * Gets or sets the FFT table size
  121626. * @ignorenaming
  121627. */
  121628. FFT_SIZE: number;
  121629. /**
  121630. * Gets or sets the bar graph amplitude
  121631. * @ignorenaming
  121632. */
  121633. BARGRAPHAMPLITUDE: number;
  121634. /**
  121635. * Gets or sets the position of the debug canvas
  121636. * @ignorenaming
  121637. */
  121638. DEBUGCANVASPOS: {
  121639. x: number;
  121640. y: number;
  121641. };
  121642. /**
  121643. * Gets or sets the debug canvas size
  121644. * @ignorenaming
  121645. */
  121646. DEBUGCANVASSIZE: {
  121647. width: number;
  121648. height: number;
  121649. };
  121650. private _byteFreqs;
  121651. private _byteTime;
  121652. private _floatFreqs;
  121653. private _webAudioAnalyser;
  121654. private _debugCanvas;
  121655. private _debugCanvasContext;
  121656. private _scene;
  121657. private _registerFunc;
  121658. private _audioEngine;
  121659. /**
  121660. * Creates a new analyser
  121661. * @param scene defines hosting scene
  121662. */
  121663. constructor(scene: Scene);
  121664. /**
  121665. * Get the number of data values you will have to play with for the visualization
  121666. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  121667. * @returns a number
  121668. */
  121669. getFrequencyBinCount(): number;
  121670. /**
  121671. * Gets the current frequency data as a byte array
  121672. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121673. * @returns a Uint8Array
  121674. */
  121675. getByteFrequencyData(): Uint8Array;
  121676. /**
  121677. * Gets the current waveform as a byte array
  121678. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  121679. * @returns a Uint8Array
  121680. */
  121681. getByteTimeDomainData(): Uint8Array;
  121682. /**
  121683. * Gets the current frequency data as a float array
  121684. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121685. * @returns a Float32Array
  121686. */
  121687. getFloatFrequencyData(): Float32Array;
  121688. /**
  121689. * Renders the debug canvas
  121690. */
  121691. drawDebugCanvas(): void;
  121692. /**
  121693. * Stops rendering the debug canvas and removes it
  121694. */
  121695. stopDebugCanvas(): void;
  121696. /**
  121697. * Connects two audio nodes
  121698. * @param inputAudioNode defines first node to connect
  121699. * @param outputAudioNode defines second node to connect
  121700. */
  121701. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  121702. /**
  121703. * Releases all associated resources
  121704. */
  121705. dispose(): void;
  121706. }
  121707. }
  121708. declare module BABYLON {
  121709. /**
  121710. * This represents an audio engine and it is responsible
  121711. * to play, synchronize and analyse sounds throughout the application.
  121712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121713. */
  121714. export interface IAudioEngine extends IDisposable {
  121715. /**
  121716. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  121717. */
  121718. readonly canUseWebAudio: boolean;
  121719. /**
  121720. * Gets the current AudioContext if available.
  121721. */
  121722. readonly audioContext: Nullable<AudioContext>;
  121723. /**
  121724. * The master gain node defines the global audio volume of your audio engine.
  121725. */
  121726. readonly masterGain: GainNode;
  121727. /**
  121728. * Gets whether or not mp3 are supported by your browser.
  121729. */
  121730. readonly isMP3supported: boolean;
  121731. /**
  121732. * Gets whether or not ogg are supported by your browser.
  121733. */
  121734. readonly isOGGsupported: boolean;
  121735. /**
  121736. * Defines if Babylon should emit a warning if WebAudio is not supported.
  121737. * @ignoreNaming
  121738. */
  121739. WarnedWebAudioUnsupported: boolean;
  121740. /**
  121741. * Defines if the audio engine relies on a custom unlocked button.
  121742. * In this case, the embedded button will not be displayed.
  121743. */
  121744. useCustomUnlockedButton: boolean;
  121745. /**
  121746. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  121747. */
  121748. readonly unlocked: boolean;
  121749. /**
  121750. * Event raised when audio has been unlocked on the browser.
  121751. */
  121752. onAudioUnlockedObservable: Observable<IAudioEngine>;
  121753. /**
  121754. * Event raised when audio has been locked on the browser.
  121755. */
  121756. onAudioLockedObservable: Observable<IAudioEngine>;
  121757. /**
  121758. * Flags the audio engine in Locked state.
  121759. * This happens due to new browser policies preventing audio to autoplay.
  121760. */
  121761. lock(): void;
  121762. /**
  121763. * Unlocks the audio engine once a user action has been done on the dom.
  121764. * This is helpful to resume play once browser policies have been satisfied.
  121765. */
  121766. unlock(): void;
  121767. /**
  121768. * Gets the global volume sets on the master gain.
  121769. * @returns the global volume if set or -1 otherwise
  121770. */
  121771. getGlobalVolume(): number;
  121772. /**
  121773. * Sets the global volume of your experience (sets on the master gain).
  121774. * @param newVolume Defines the new global volume of the application
  121775. */
  121776. setGlobalVolume(newVolume: number): void;
  121777. /**
  121778. * Connect the audio engine to an audio analyser allowing some amazing
  121779. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121780. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121781. * @param analyser The analyser to connect to the engine
  121782. */
  121783. connectToAnalyser(analyser: Analyser): void;
  121784. }
  121785. }
  121786. declare module BABYLON {
  121787. /**
  121788. * Defines the interface used by display changed events
  121789. */
  121790. export interface IDisplayChangedEventArgs {
  121791. /** Gets the vrDisplay object (if any) */
  121792. vrDisplay: Nullable<any>;
  121793. /** Gets a boolean indicating if webVR is supported */
  121794. vrSupported: boolean;
  121795. }
  121796. /**
  121797. * Defines the interface used by objects containing a viewport (like a camera)
  121798. */
  121799. interface IViewportOwnerLike {
  121800. /**
  121801. * Gets or sets the viewport
  121802. */
  121803. viewport: IViewportLike;
  121804. }
  121805. /**
  121806. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121807. */
  121808. export class Engine extends ThinEngine {
  121809. /** Defines that alpha blending is disabled */
  121810. static readonly ALPHA_DISABLE: number;
  121811. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121812. static readonly ALPHA_ADD: number;
  121813. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121814. static readonly ALPHA_COMBINE: number;
  121815. /** Defines that alpha blending to DEST - SRC * DEST */
  121816. static readonly ALPHA_SUBTRACT: number;
  121817. /** Defines that alpha blending to SRC * DEST */
  121818. static readonly ALPHA_MULTIPLY: number;
  121819. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121820. static readonly ALPHA_MAXIMIZED: number;
  121821. /** Defines that alpha blending to SRC + DEST */
  121822. static readonly ALPHA_ONEONE: number;
  121823. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121824. static readonly ALPHA_PREMULTIPLIED: number;
  121825. /**
  121826. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121827. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121828. */
  121829. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121830. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121831. static readonly ALPHA_INTERPOLATE: number;
  121832. /**
  121833. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121834. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121835. */
  121836. static readonly ALPHA_SCREENMODE: number;
  121837. /** Defines that the ressource is not delayed*/
  121838. static readonly DELAYLOADSTATE_NONE: number;
  121839. /** Defines that the ressource was successfully delay loaded */
  121840. static readonly DELAYLOADSTATE_LOADED: number;
  121841. /** Defines that the ressource is currently delay loading */
  121842. static readonly DELAYLOADSTATE_LOADING: number;
  121843. /** Defines that the ressource is delayed and has not started loading */
  121844. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121845. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121846. static readonly NEVER: number;
  121847. /** 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 */
  121848. static readonly ALWAYS: number;
  121849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121850. static readonly LESS: number;
  121851. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121852. static readonly EQUAL: number;
  121853. /** 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 */
  121854. static readonly LEQUAL: number;
  121855. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121856. static readonly GREATER: number;
  121857. /** 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 */
  121858. static readonly GEQUAL: number;
  121859. /** 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 */
  121860. static readonly NOTEQUAL: number;
  121861. /** Passed to stencilOperation to specify that stencil value must be kept */
  121862. static readonly KEEP: number;
  121863. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121864. static readonly REPLACE: number;
  121865. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121866. static readonly INCR: number;
  121867. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121868. static readonly DECR: number;
  121869. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121870. static readonly INVERT: number;
  121871. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121872. static readonly INCR_WRAP: number;
  121873. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121874. static readonly DECR_WRAP: number;
  121875. /** Texture is not repeating outside of 0..1 UVs */
  121876. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121877. /** Texture is repeating outside of 0..1 UVs */
  121878. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121879. /** Texture is repeating and mirrored */
  121880. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121881. /** ALPHA */
  121882. static readonly TEXTUREFORMAT_ALPHA: number;
  121883. /** LUMINANCE */
  121884. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121885. /** LUMINANCE_ALPHA */
  121886. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121887. /** RGB */
  121888. static readonly TEXTUREFORMAT_RGB: number;
  121889. /** RGBA */
  121890. static readonly TEXTUREFORMAT_RGBA: number;
  121891. /** RED */
  121892. static readonly TEXTUREFORMAT_RED: number;
  121893. /** RED (2nd reference) */
  121894. static readonly TEXTUREFORMAT_R: number;
  121895. /** RG */
  121896. static readonly TEXTUREFORMAT_RG: number;
  121897. /** RED_INTEGER */
  121898. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121899. /** RED_INTEGER (2nd reference) */
  121900. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121901. /** RG_INTEGER */
  121902. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121903. /** RGB_INTEGER */
  121904. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121905. /** RGBA_INTEGER */
  121906. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121907. /** UNSIGNED_BYTE */
  121908. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121909. /** UNSIGNED_BYTE (2nd reference) */
  121910. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121911. /** FLOAT */
  121912. static readonly TEXTURETYPE_FLOAT: number;
  121913. /** HALF_FLOAT */
  121914. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121915. /** BYTE */
  121916. static readonly TEXTURETYPE_BYTE: number;
  121917. /** SHORT */
  121918. static readonly TEXTURETYPE_SHORT: number;
  121919. /** UNSIGNED_SHORT */
  121920. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121921. /** INT */
  121922. static readonly TEXTURETYPE_INT: number;
  121923. /** UNSIGNED_INT */
  121924. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121925. /** UNSIGNED_SHORT_4_4_4_4 */
  121926. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121927. /** UNSIGNED_SHORT_5_5_5_1 */
  121928. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121929. /** UNSIGNED_SHORT_5_6_5 */
  121930. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121931. /** UNSIGNED_INT_2_10_10_10_REV */
  121932. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121933. /** UNSIGNED_INT_24_8 */
  121934. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121935. /** UNSIGNED_INT_10F_11F_11F_REV */
  121936. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121937. /** UNSIGNED_INT_5_9_9_9_REV */
  121938. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121939. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121940. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121941. /** nearest is mag = nearest and min = nearest and mip = linear */
  121942. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121943. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121944. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121945. /** Trilinear is mag = linear and min = linear and mip = linear */
  121946. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121947. /** nearest is mag = nearest and min = nearest and mip = linear */
  121948. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121949. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121950. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121951. /** Trilinear is mag = linear and min = linear and mip = linear */
  121952. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121953. /** mag = nearest and min = nearest and mip = nearest */
  121954. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121955. /** mag = nearest and min = linear and mip = nearest */
  121956. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121957. /** mag = nearest and min = linear and mip = linear */
  121958. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121959. /** mag = nearest and min = linear and mip = none */
  121960. static readonly TEXTURE_NEAREST_LINEAR: number;
  121961. /** mag = nearest and min = nearest and mip = none */
  121962. static readonly TEXTURE_NEAREST_NEAREST: number;
  121963. /** mag = linear and min = nearest and mip = nearest */
  121964. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121965. /** mag = linear and min = nearest and mip = linear */
  121966. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121967. /** mag = linear and min = linear and mip = none */
  121968. static readonly TEXTURE_LINEAR_LINEAR: number;
  121969. /** mag = linear and min = nearest and mip = none */
  121970. static readonly TEXTURE_LINEAR_NEAREST: number;
  121971. /** Explicit coordinates mode */
  121972. static readonly TEXTURE_EXPLICIT_MODE: number;
  121973. /** Spherical coordinates mode */
  121974. static readonly TEXTURE_SPHERICAL_MODE: number;
  121975. /** Planar coordinates mode */
  121976. static readonly TEXTURE_PLANAR_MODE: number;
  121977. /** Cubic coordinates mode */
  121978. static readonly TEXTURE_CUBIC_MODE: number;
  121979. /** Projection coordinates mode */
  121980. static readonly TEXTURE_PROJECTION_MODE: number;
  121981. /** Skybox coordinates mode */
  121982. static readonly TEXTURE_SKYBOX_MODE: number;
  121983. /** Inverse Cubic coordinates mode */
  121984. static readonly TEXTURE_INVCUBIC_MODE: number;
  121985. /** Equirectangular coordinates mode */
  121986. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121987. /** Equirectangular Fixed coordinates mode */
  121988. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121989. /** Equirectangular Fixed Mirrored coordinates mode */
  121990. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121991. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121992. static readonly SCALEMODE_FLOOR: number;
  121993. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121994. static readonly SCALEMODE_NEAREST: number;
  121995. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121996. static readonly SCALEMODE_CEILING: number;
  121997. /**
  121998. * Returns the current npm package of the sdk
  121999. */
  122000. static get NpmPackage(): string;
  122001. /**
  122002. * Returns the current version of the framework
  122003. */
  122004. static get Version(): string;
  122005. /** Gets the list of created engines */
  122006. static get Instances(): Engine[];
  122007. /**
  122008. * Gets the latest created engine
  122009. */
  122010. static get LastCreatedEngine(): Nullable<Engine>;
  122011. /**
  122012. * Gets the latest created scene
  122013. */
  122014. static get LastCreatedScene(): Nullable<Scene>;
  122015. /**
  122016. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122017. * @param flag defines which part of the materials must be marked as dirty
  122018. * @param predicate defines a predicate used to filter which materials should be affected
  122019. */
  122020. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122021. /**
  122022. * Method called to create the default loading screen.
  122023. * This can be overriden in your own app.
  122024. * @param canvas The rendering canvas element
  122025. * @returns The loading screen
  122026. */
  122027. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122028. /**
  122029. * Method called to create the default rescale post process on each engine.
  122030. */
  122031. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122032. /**
  122033. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122034. **/
  122035. enableOfflineSupport: boolean;
  122036. /**
  122037. * 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)
  122038. **/
  122039. disableManifestCheck: boolean;
  122040. /**
  122041. * Gets the list of created scenes
  122042. */
  122043. scenes: Scene[];
  122044. /**
  122045. * Event raised when a new scene is created
  122046. */
  122047. onNewSceneAddedObservable: Observable<Scene>;
  122048. /**
  122049. * Gets the list of created postprocesses
  122050. */
  122051. postProcesses: PostProcess[];
  122052. /**
  122053. * Gets a boolean indicating if the pointer is currently locked
  122054. */
  122055. isPointerLock: boolean;
  122056. /**
  122057. * Observable event triggered each time the rendering canvas is resized
  122058. */
  122059. onResizeObservable: Observable<Engine>;
  122060. /**
  122061. * Observable event triggered each time the canvas loses focus
  122062. */
  122063. onCanvasBlurObservable: Observable<Engine>;
  122064. /**
  122065. * Observable event triggered each time the canvas gains focus
  122066. */
  122067. onCanvasFocusObservable: Observable<Engine>;
  122068. /**
  122069. * Observable event triggered each time the canvas receives pointerout event
  122070. */
  122071. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122072. /**
  122073. * Observable raised when the engine begins a new frame
  122074. */
  122075. onBeginFrameObservable: Observable<Engine>;
  122076. /**
  122077. * If set, will be used to request the next animation frame for the render loop
  122078. */
  122079. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122080. /**
  122081. * Observable raised when the engine ends the current frame
  122082. */
  122083. onEndFrameObservable: Observable<Engine>;
  122084. /**
  122085. * Observable raised when the engine is about to compile a shader
  122086. */
  122087. onBeforeShaderCompilationObservable: Observable<Engine>;
  122088. /**
  122089. * Observable raised when the engine has jsut compiled a shader
  122090. */
  122091. onAfterShaderCompilationObservable: Observable<Engine>;
  122092. /**
  122093. * Gets the audio engine
  122094. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122095. * @ignorenaming
  122096. */
  122097. static audioEngine: IAudioEngine;
  122098. /**
  122099. * Default AudioEngine factory responsible of creating the Audio Engine.
  122100. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122101. */
  122102. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122103. /**
  122104. * Default offline support factory responsible of creating a tool used to store data locally.
  122105. * By default, this will create a Database object if the workload has been embedded.
  122106. */
  122107. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122108. private _loadingScreen;
  122109. private _pointerLockRequested;
  122110. private _rescalePostProcess;
  122111. private _deterministicLockstep;
  122112. private _lockstepMaxSteps;
  122113. private _timeStep;
  122114. protected get _supportsHardwareTextureRescaling(): boolean;
  122115. private _fps;
  122116. private _deltaTime;
  122117. /** @hidden */
  122118. _drawCalls: PerfCounter;
  122119. /** 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 */
  122120. canvasTabIndex: number;
  122121. /**
  122122. * Turn this value on if you want to pause FPS computation when in background
  122123. */
  122124. disablePerformanceMonitorInBackground: boolean;
  122125. private _performanceMonitor;
  122126. /**
  122127. * Gets the performance monitor attached to this engine
  122128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122129. */
  122130. get performanceMonitor(): PerformanceMonitor;
  122131. private _onFocus;
  122132. private _onBlur;
  122133. private _onCanvasPointerOut;
  122134. private _onCanvasBlur;
  122135. private _onCanvasFocus;
  122136. private _onFullscreenChange;
  122137. private _onPointerLockChange;
  122138. /**
  122139. * Gets the HTML element used to attach event listeners
  122140. * @returns a HTML element
  122141. */
  122142. getInputElement(): Nullable<HTMLElement>;
  122143. /**
  122144. * Creates a new engine
  122145. * @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
  122146. * @param antialias defines enable antialiasing (default: false)
  122147. * @param options defines further options to be sent to the getContext() function
  122148. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122149. */
  122150. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122151. /**
  122152. * Gets current aspect ratio
  122153. * @param viewportOwner defines the camera to use to get the aspect ratio
  122154. * @param useScreen defines if screen size must be used (or the current render target if any)
  122155. * @returns a number defining the aspect ratio
  122156. */
  122157. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122158. /**
  122159. * Gets current screen aspect ratio
  122160. * @returns a number defining the aspect ratio
  122161. */
  122162. getScreenAspectRatio(): number;
  122163. /**
  122164. * Gets the client rect of the HTML canvas attached with the current webGL context
  122165. * @returns a client rectanglee
  122166. */
  122167. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122168. /**
  122169. * Gets the client rect of the HTML element used for events
  122170. * @returns a client rectanglee
  122171. */
  122172. getInputElementClientRect(): Nullable<ClientRect>;
  122173. /**
  122174. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122175. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122176. * @returns true if engine is in deterministic lock step mode
  122177. */
  122178. isDeterministicLockStep(): boolean;
  122179. /**
  122180. * Gets the max steps when engine is running in deterministic lock step
  122181. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122182. * @returns the max steps
  122183. */
  122184. getLockstepMaxSteps(): number;
  122185. /**
  122186. * Returns the time in ms between steps when using deterministic lock step.
  122187. * @returns time step in (ms)
  122188. */
  122189. getTimeStep(): number;
  122190. /**
  122191. * Force the mipmap generation for the given render target texture
  122192. * @param texture defines the render target texture to use
  122193. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122194. */
  122195. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122196. /** States */
  122197. /**
  122198. * Set various states to the webGL context
  122199. * @param culling defines backface culling state
  122200. * @param zOffset defines the value to apply to zOffset (0 by default)
  122201. * @param force defines if states must be applied even if cache is up to date
  122202. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122203. */
  122204. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122205. /**
  122206. * Set the z offset to apply to current rendering
  122207. * @param value defines the offset to apply
  122208. */
  122209. setZOffset(value: number): void;
  122210. /**
  122211. * Gets the current value of the zOffset
  122212. * @returns the current zOffset state
  122213. */
  122214. getZOffset(): number;
  122215. /**
  122216. * Enable or disable depth buffering
  122217. * @param enable defines the state to set
  122218. */
  122219. setDepthBuffer(enable: boolean): void;
  122220. /**
  122221. * Gets a boolean indicating if depth writing is enabled
  122222. * @returns the current depth writing state
  122223. */
  122224. getDepthWrite(): boolean;
  122225. /**
  122226. * Enable or disable depth writing
  122227. * @param enable defines the state to set
  122228. */
  122229. setDepthWrite(enable: boolean): void;
  122230. /**
  122231. * Gets a boolean indicating if stencil buffer is enabled
  122232. * @returns the current stencil buffer state
  122233. */
  122234. getStencilBuffer(): boolean;
  122235. /**
  122236. * Enable or disable the stencil buffer
  122237. * @param enable defines if the stencil buffer must be enabled or disabled
  122238. */
  122239. setStencilBuffer(enable: boolean): void;
  122240. /**
  122241. * Gets the current stencil mask
  122242. * @returns a number defining the new stencil mask to use
  122243. */
  122244. getStencilMask(): number;
  122245. /**
  122246. * Sets the current stencil mask
  122247. * @param mask defines the new stencil mask to use
  122248. */
  122249. setStencilMask(mask: number): void;
  122250. /**
  122251. * Gets the current stencil function
  122252. * @returns a number defining the stencil function to use
  122253. */
  122254. getStencilFunction(): number;
  122255. /**
  122256. * Gets the current stencil reference value
  122257. * @returns a number defining the stencil reference value to use
  122258. */
  122259. getStencilFunctionReference(): number;
  122260. /**
  122261. * Gets the current stencil mask
  122262. * @returns a number defining the stencil mask to use
  122263. */
  122264. getStencilFunctionMask(): number;
  122265. /**
  122266. * Sets the current stencil function
  122267. * @param stencilFunc defines the new stencil function to use
  122268. */
  122269. setStencilFunction(stencilFunc: number): void;
  122270. /**
  122271. * Sets the current stencil reference
  122272. * @param reference defines the new stencil reference to use
  122273. */
  122274. setStencilFunctionReference(reference: number): void;
  122275. /**
  122276. * Sets the current stencil mask
  122277. * @param mask defines the new stencil mask to use
  122278. */
  122279. setStencilFunctionMask(mask: number): void;
  122280. /**
  122281. * Gets the current stencil operation when stencil fails
  122282. * @returns a number defining stencil operation to use when stencil fails
  122283. */
  122284. getStencilOperationFail(): number;
  122285. /**
  122286. * Gets the current stencil operation when depth fails
  122287. * @returns a number defining stencil operation to use when depth fails
  122288. */
  122289. getStencilOperationDepthFail(): number;
  122290. /**
  122291. * Gets the current stencil operation when stencil passes
  122292. * @returns a number defining stencil operation to use when stencil passes
  122293. */
  122294. getStencilOperationPass(): number;
  122295. /**
  122296. * Sets the stencil operation to use when stencil fails
  122297. * @param operation defines the stencil operation to use when stencil fails
  122298. */
  122299. setStencilOperationFail(operation: number): void;
  122300. /**
  122301. * Sets the stencil operation to use when depth fails
  122302. * @param operation defines the stencil operation to use when depth fails
  122303. */
  122304. setStencilOperationDepthFail(operation: number): void;
  122305. /**
  122306. * Sets the stencil operation to use when stencil passes
  122307. * @param operation defines the stencil operation to use when stencil passes
  122308. */
  122309. setStencilOperationPass(operation: number): void;
  122310. /**
  122311. * Sets a boolean indicating if the dithering state is enabled or disabled
  122312. * @param value defines the dithering state
  122313. */
  122314. setDitheringState(value: boolean): void;
  122315. /**
  122316. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122317. * @param value defines the rasterizer state
  122318. */
  122319. setRasterizerState(value: boolean): void;
  122320. /**
  122321. * Gets the current depth function
  122322. * @returns a number defining the depth function
  122323. */
  122324. getDepthFunction(): Nullable<number>;
  122325. /**
  122326. * Sets the current depth function
  122327. * @param depthFunc defines the function to use
  122328. */
  122329. setDepthFunction(depthFunc: number): void;
  122330. /**
  122331. * Sets the current depth function to GREATER
  122332. */
  122333. setDepthFunctionToGreater(): void;
  122334. /**
  122335. * Sets the current depth function to GEQUAL
  122336. */
  122337. setDepthFunctionToGreaterOrEqual(): void;
  122338. /**
  122339. * Sets the current depth function to LESS
  122340. */
  122341. setDepthFunctionToLess(): void;
  122342. /**
  122343. * Sets the current depth function to LEQUAL
  122344. */
  122345. setDepthFunctionToLessOrEqual(): void;
  122346. private _cachedStencilBuffer;
  122347. private _cachedStencilFunction;
  122348. private _cachedStencilMask;
  122349. private _cachedStencilOperationPass;
  122350. private _cachedStencilOperationFail;
  122351. private _cachedStencilOperationDepthFail;
  122352. private _cachedStencilReference;
  122353. /**
  122354. * Caches the the state of the stencil buffer
  122355. */
  122356. cacheStencilState(): void;
  122357. /**
  122358. * Restores the state of the stencil buffer
  122359. */
  122360. restoreStencilState(): void;
  122361. /**
  122362. * Directly set the WebGL Viewport
  122363. * @param x defines the x coordinate of the viewport (in screen space)
  122364. * @param y defines the y coordinate of the viewport (in screen space)
  122365. * @param width defines the width of the viewport (in screen space)
  122366. * @param height defines the height of the viewport (in screen space)
  122367. * @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
  122368. */
  122369. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  122370. /**
  122371. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  122372. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122373. * @param y defines the y-coordinate of the corner of the clear rectangle
  122374. * @param width defines the width of the clear rectangle
  122375. * @param height defines the height of the clear rectangle
  122376. * @param clearColor defines the clear color
  122377. */
  122378. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  122379. /**
  122380. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  122381. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122382. * @param y defines the y-coordinate of the corner of the clear rectangle
  122383. * @param width defines the width of the clear rectangle
  122384. * @param height defines the height of the clear rectangle
  122385. */
  122386. enableScissor(x: number, y: number, width: number, height: number): void;
  122387. /**
  122388. * Disable previously set scissor test rectangle
  122389. */
  122390. disableScissor(): void;
  122391. protected _reportDrawCall(): void;
  122392. /**
  122393. * Initializes a webVR display and starts listening to display change events
  122394. * The onVRDisplayChangedObservable will be notified upon these changes
  122395. * @returns The onVRDisplayChangedObservable
  122396. */
  122397. initWebVR(): Observable<IDisplayChangedEventArgs>;
  122398. /** @hidden */
  122399. _prepareVRComponent(): void;
  122400. /** @hidden */
  122401. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  122402. /** @hidden */
  122403. _submitVRFrame(): void;
  122404. /**
  122405. * Call this function to leave webVR mode
  122406. * Will do nothing if webVR is not supported or if there is no webVR device
  122407. * @see https://doc.babylonjs.com/how_to/webvr_camera
  122408. */
  122409. disableVR(): void;
  122410. /**
  122411. * Gets a boolean indicating that the system is in VR mode and is presenting
  122412. * @returns true if VR mode is engaged
  122413. */
  122414. isVRPresenting(): boolean;
  122415. /** @hidden */
  122416. _requestVRFrame(): void;
  122417. /** @hidden */
  122418. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  122419. /**
  122420. * Gets the source code of the vertex shader associated with a specific webGL program
  122421. * @param program defines the program to use
  122422. * @returns a string containing the source code of the vertex shader associated with the program
  122423. */
  122424. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  122425. /**
  122426. * Gets the source code of the fragment shader associated with a specific webGL program
  122427. * @param program defines the program to use
  122428. * @returns a string containing the source code of the fragment shader associated with the program
  122429. */
  122430. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  122431. /**
  122432. * Sets a depth stencil texture from a render target to the according uniform.
  122433. * @param channel The texture channel
  122434. * @param uniform The uniform to set
  122435. * @param texture The render target texture containing the depth stencil texture to apply
  122436. */
  122437. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  122438. /**
  122439. * Sets a texture to the webGL context from a postprocess
  122440. * @param channel defines the channel to use
  122441. * @param postProcess defines the source postprocess
  122442. */
  122443. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  122444. /**
  122445. * Binds the output of the passed in post process to the texture channel specified
  122446. * @param channel The channel the texture should be bound to
  122447. * @param postProcess The post process which's output should be bound
  122448. */
  122449. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  122450. protected _rebuildBuffers(): void;
  122451. /** @hidden */
  122452. _renderFrame(): void;
  122453. _renderLoop(): void;
  122454. /** @hidden */
  122455. _renderViews(): boolean;
  122456. /**
  122457. * Toggle full screen mode
  122458. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122459. */
  122460. switchFullscreen(requestPointerLock: boolean): void;
  122461. /**
  122462. * Enters full screen mode
  122463. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122464. */
  122465. enterFullscreen(requestPointerLock: boolean): void;
  122466. /**
  122467. * Exits full screen mode
  122468. */
  122469. exitFullscreen(): void;
  122470. /**
  122471. * Enters Pointerlock mode
  122472. */
  122473. enterPointerlock(): void;
  122474. /**
  122475. * Exits Pointerlock mode
  122476. */
  122477. exitPointerlock(): void;
  122478. /**
  122479. * Begin a new frame
  122480. */
  122481. beginFrame(): void;
  122482. /**
  122483. * Enf the current frame
  122484. */
  122485. endFrame(): void;
  122486. resize(): void;
  122487. /**
  122488. * Force a specific size of the canvas
  122489. * @param width defines the new canvas' width
  122490. * @param height defines the new canvas' height
  122491. * @returns true if the size was changed
  122492. */
  122493. setSize(width: number, height: number): boolean;
  122494. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122495. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122496. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122497. _releaseTexture(texture: InternalTexture): void;
  122498. /**
  122499. * @hidden
  122500. * Rescales a texture
  122501. * @param source input texutre
  122502. * @param destination destination texture
  122503. * @param scene scene to use to render the resize
  122504. * @param internalFormat format to use when resizing
  122505. * @param onComplete callback to be called when resize has completed
  122506. */
  122507. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  122508. /**
  122509. * Gets the current framerate
  122510. * @returns a number representing the framerate
  122511. */
  122512. getFps(): number;
  122513. /**
  122514. * Gets the time spent between current and previous frame
  122515. * @returns a number representing the delta time in ms
  122516. */
  122517. getDeltaTime(): number;
  122518. private _measureFps;
  122519. /** @hidden */
  122520. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  122521. /**
  122522. * Updates the sample count of a render target texture
  122523. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  122524. * @param texture defines the texture to update
  122525. * @param samples defines the sample count to set
  122526. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  122527. */
  122528. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  122529. /**
  122530. * Updates a depth texture Comparison Mode and Function.
  122531. * If the comparison Function is equal to 0, the mode will be set to none.
  122532. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  122533. * @param texture The texture to set the comparison function for
  122534. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  122535. */
  122536. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  122537. /**
  122538. * Creates a webGL buffer to use with instanciation
  122539. * @param capacity defines the size of the buffer
  122540. * @returns the webGL buffer
  122541. */
  122542. createInstancesBuffer(capacity: number): DataBuffer;
  122543. /**
  122544. * Delete a webGL buffer used with instanciation
  122545. * @param buffer defines the webGL buffer to delete
  122546. */
  122547. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  122548. private _clientWaitAsync;
  122549. /** @hidden */
  122550. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  122551. dispose(): void;
  122552. private _disableTouchAction;
  122553. /**
  122554. * Display the loading screen
  122555. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122556. */
  122557. displayLoadingUI(): void;
  122558. /**
  122559. * Hide the loading screen
  122560. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122561. */
  122562. hideLoadingUI(): void;
  122563. /**
  122564. * Gets the current loading screen object
  122565. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122566. */
  122567. get loadingScreen(): ILoadingScreen;
  122568. /**
  122569. * Sets the current loading screen object
  122570. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122571. */
  122572. set loadingScreen(loadingScreen: ILoadingScreen);
  122573. /**
  122574. * Sets the current loading screen text
  122575. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122576. */
  122577. set loadingUIText(text: string);
  122578. /**
  122579. * Sets the current loading screen background color
  122580. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122581. */
  122582. set loadingUIBackgroundColor(color: string);
  122583. /** Pointerlock and fullscreen */
  122584. /**
  122585. * Ask the browser to promote the current element to pointerlock mode
  122586. * @param element defines the DOM element to promote
  122587. */
  122588. static _RequestPointerlock(element: HTMLElement): void;
  122589. /**
  122590. * Asks the browser to exit pointerlock mode
  122591. */
  122592. static _ExitPointerlock(): void;
  122593. /**
  122594. * Ask the browser to promote the current element to fullscreen rendering mode
  122595. * @param element defines the DOM element to promote
  122596. */
  122597. static _RequestFullscreen(element: HTMLElement): void;
  122598. /**
  122599. * Asks the browser to exit fullscreen mode
  122600. */
  122601. static _ExitFullscreen(): void;
  122602. }
  122603. }
  122604. declare module BABYLON {
  122605. /**
  122606. * The engine store class is responsible to hold all the instances of Engine and Scene created
  122607. * during the life time of the application.
  122608. */
  122609. export class EngineStore {
  122610. /** Gets the list of created engines */
  122611. static Instances: Engine[];
  122612. /** @hidden */
  122613. static _LastCreatedScene: Nullable<Scene>;
  122614. /**
  122615. * Gets the latest created engine
  122616. */
  122617. static get LastCreatedEngine(): Nullable<Engine>;
  122618. /**
  122619. * Gets the latest created scene
  122620. */
  122621. static get LastCreatedScene(): Nullable<Scene>;
  122622. /**
  122623. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122624. * @ignorenaming
  122625. */
  122626. static UseFallbackTexture: boolean;
  122627. /**
  122628. * Texture content used if a texture cannot loaded
  122629. * @ignorenaming
  122630. */
  122631. static FallbackTexture: string;
  122632. }
  122633. }
  122634. declare module BABYLON {
  122635. /**
  122636. * Helper class that provides a small promise polyfill
  122637. */
  122638. export class PromisePolyfill {
  122639. /**
  122640. * Static function used to check if the polyfill is required
  122641. * If this is the case then the function will inject the polyfill to window.Promise
  122642. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  122643. */
  122644. static Apply(force?: boolean): void;
  122645. }
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * Interface for screenshot methods with describe argument called `size` as object with options
  122650. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  122651. */
  122652. export interface IScreenshotSize {
  122653. /**
  122654. * number in pixels for canvas height
  122655. */
  122656. height?: number;
  122657. /**
  122658. * multiplier allowing render at a higher or lower resolution
  122659. * If value is defined then height and width will be ignored and taken from camera
  122660. */
  122661. precision?: number;
  122662. /**
  122663. * number in pixels for canvas width
  122664. */
  122665. width?: number;
  122666. }
  122667. }
  122668. declare module BABYLON {
  122669. interface IColor4Like {
  122670. r: float;
  122671. g: float;
  122672. b: float;
  122673. a: float;
  122674. }
  122675. /**
  122676. * Class containing a set of static utilities functions
  122677. */
  122678. export class Tools {
  122679. /**
  122680. * Gets or sets the base URL to use to load assets
  122681. */
  122682. static get BaseUrl(): string;
  122683. static set BaseUrl(value: string);
  122684. /**
  122685. * Enable/Disable Custom HTTP Request Headers globally.
  122686. * default = false
  122687. * @see CustomRequestHeaders
  122688. */
  122689. static UseCustomRequestHeaders: boolean;
  122690. /**
  122691. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122692. * i.e. when loading files, where the server/service expects an Authorization header
  122693. */
  122694. static CustomRequestHeaders: {
  122695. [key: string]: string;
  122696. };
  122697. /**
  122698. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122699. */
  122700. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122701. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122702. /**
  122703. * Default behaviour for cors in the application.
  122704. * It can be a string if the expected behavior is identical in the entire app.
  122705. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122706. */
  122707. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122708. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122709. /**
  122710. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122711. * @ignorenaming
  122712. */
  122713. static get UseFallbackTexture(): boolean;
  122714. static set UseFallbackTexture(value: boolean);
  122715. /**
  122716. * Use this object to register external classes like custom textures or material
  122717. * to allow the laoders to instantiate them
  122718. */
  122719. static get RegisteredExternalClasses(): {
  122720. [key: string]: Object;
  122721. };
  122722. static set RegisteredExternalClasses(classes: {
  122723. [key: string]: Object;
  122724. });
  122725. /**
  122726. * Texture content used if a texture cannot loaded
  122727. * @ignorenaming
  122728. */
  122729. static get fallbackTexture(): string;
  122730. static set fallbackTexture(value: string);
  122731. /**
  122732. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122733. * @param u defines the coordinate on X axis
  122734. * @param v defines the coordinate on Y axis
  122735. * @param width defines the width of the source data
  122736. * @param height defines the height of the source data
  122737. * @param pixels defines the source byte array
  122738. * @param color defines the output color
  122739. */
  122740. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122741. /**
  122742. * Interpolates between a and b via alpha
  122743. * @param a The lower value (returned when alpha = 0)
  122744. * @param b The upper value (returned when alpha = 1)
  122745. * @param alpha The interpolation-factor
  122746. * @return The mixed value
  122747. */
  122748. static Mix(a: number, b: number, alpha: number): number;
  122749. /**
  122750. * Tries to instantiate a new object from a given class name
  122751. * @param className defines the class name to instantiate
  122752. * @returns the new object or null if the system was not able to do the instantiation
  122753. */
  122754. static Instantiate(className: string): any;
  122755. /**
  122756. * Provides a slice function that will work even on IE
  122757. * @param data defines the array to slice
  122758. * @param start defines the start of the data (optional)
  122759. * @param end defines the end of the data (optional)
  122760. * @returns the new sliced array
  122761. */
  122762. static Slice<T>(data: T, start?: number, end?: number): T;
  122763. /**
  122764. * Provides a slice function that will work even on IE
  122765. * The difference between this and Slice is that this will force-convert to array
  122766. * @param data defines the array to slice
  122767. * @param start defines the start of the data (optional)
  122768. * @param end defines the end of the data (optional)
  122769. * @returns the new sliced array
  122770. */
  122771. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  122772. /**
  122773. * Polyfill for setImmediate
  122774. * @param action defines the action to execute after the current execution block
  122775. */
  122776. static SetImmediate(action: () => void): void;
  122777. /**
  122778. * Function indicating if a number is an exponent of 2
  122779. * @param value defines the value to test
  122780. * @returns true if the value is an exponent of 2
  122781. */
  122782. static IsExponentOfTwo(value: number): boolean;
  122783. private static _tmpFloatArray;
  122784. /**
  122785. * Returns the nearest 32-bit single precision float representation of a Number
  122786. * @param value A Number. If the parameter is of a different type, it will get converted
  122787. * to a number or to NaN if it cannot be converted
  122788. * @returns number
  122789. */
  122790. static FloatRound(value: number): number;
  122791. /**
  122792. * Extracts the filename from a path
  122793. * @param path defines the path to use
  122794. * @returns the filename
  122795. */
  122796. static GetFilename(path: string): string;
  122797. /**
  122798. * Extracts the "folder" part of a path (everything before the filename).
  122799. * @param uri The URI to extract the info from
  122800. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122801. * @returns The "folder" part of the path
  122802. */
  122803. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122804. /**
  122805. * Extracts text content from a DOM element hierarchy
  122806. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122807. */
  122808. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122809. /**
  122810. * Convert an angle in radians to degrees
  122811. * @param angle defines the angle to convert
  122812. * @returns the angle in degrees
  122813. */
  122814. static ToDegrees(angle: number): number;
  122815. /**
  122816. * Convert an angle in degrees to radians
  122817. * @param angle defines the angle to convert
  122818. * @returns the angle in radians
  122819. */
  122820. static ToRadians(angle: number): number;
  122821. /**
  122822. * Returns an array if obj is not an array
  122823. * @param obj defines the object to evaluate as an array
  122824. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122825. * @returns either obj directly if obj is an array or a new array containing obj
  122826. */
  122827. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122828. /**
  122829. * Gets the pointer prefix to use
  122830. * @param engine defines the engine we are finding the prefix for
  122831. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122832. */
  122833. static GetPointerPrefix(engine: Engine): string;
  122834. /**
  122835. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122836. * @param url define the url we are trying
  122837. * @param element define the dom element where to configure the cors policy
  122838. */
  122839. static SetCorsBehavior(url: string | string[], element: {
  122840. crossOrigin: string | null;
  122841. }): void;
  122842. /**
  122843. * Removes unwanted characters from an url
  122844. * @param url defines the url to clean
  122845. * @returns the cleaned url
  122846. */
  122847. static CleanUrl(url: string): string;
  122848. /**
  122849. * Gets or sets a function used to pre-process url before using them to load assets
  122850. */
  122851. static get PreprocessUrl(): (url: string) => string;
  122852. static set PreprocessUrl(processor: (url: string) => string);
  122853. /**
  122854. * Loads an image as an HTMLImageElement.
  122855. * @param input url string, ArrayBuffer, or Blob to load
  122856. * @param onLoad callback called when the image successfully loads
  122857. * @param onError callback called when the image fails to load
  122858. * @param offlineProvider offline provider for caching
  122859. * @param mimeType optional mime type
  122860. * @returns the HTMLImageElement of the loaded image
  122861. */
  122862. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122863. /**
  122864. * Loads a file from a url
  122865. * @param url url string, ArrayBuffer, or Blob to load
  122866. * @param onSuccess callback called when the file successfully loads
  122867. * @param onProgress callback called while file is loading (if the server supports this mode)
  122868. * @param offlineProvider defines the offline provider for caching
  122869. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122870. * @param onError callback called when the file fails to load
  122871. * @returns a file request object
  122872. */
  122873. 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;
  122874. /**
  122875. * Loads a file from a url
  122876. * @param url the file url to load
  122877. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122878. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122879. */
  122880. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122881. /**
  122882. * Load a script (identified by an url). When the url returns, the
  122883. * content of this file is added into a new script element, attached to the DOM (body element)
  122884. * @param scriptUrl defines the url of the script to laod
  122885. * @param onSuccess defines the callback called when the script is loaded
  122886. * @param onError defines the callback to call if an error occurs
  122887. * @param scriptId defines the id of the script element
  122888. */
  122889. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122890. /**
  122891. * Load an asynchronous script (identified by an url). When the url returns, the
  122892. * content of this file is added into a new script element, attached to the DOM (body element)
  122893. * @param scriptUrl defines the url of the script to laod
  122894. * @param scriptId defines the id of the script element
  122895. * @returns a promise request object
  122896. */
  122897. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122898. /**
  122899. * Loads a file from a blob
  122900. * @param fileToLoad defines the blob to use
  122901. * @param callback defines the callback to call when data is loaded
  122902. * @param progressCallback defines the callback to call during loading process
  122903. * @returns a file request object
  122904. */
  122905. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122906. /**
  122907. * Reads a file from a File object
  122908. * @param file defines the file to load
  122909. * @param onSuccess defines the callback to call when data is loaded
  122910. * @param onProgress defines the callback to call during loading process
  122911. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122912. * @param onError defines the callback to call when an error occurs
  122913. * @returns a file request object
  122914. */
  122915. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122916. /**
  122917. * Creates a data url from a given string content
  122918. * @param content defines the content to convert
  122919. * @returns the new data url link
  122920. */
  122921. static FileAsURL(content: string): string;
  122922. /**
  122923. * Format the given number to a specific decimal format
  122924. * @param value defines the number to format
  122925. * @param decimals defines the number of decimals to use
  122926. * @returns the formatted string
  122927. */
  122928. static Format(value: number, decimals?: number): string;
  122929. /**
  122930. * Tries to copy an object by duplicating every property
  122931. * @param source defines the source object
  122932. * @param destination defines the target object
  122933. * @param doNotCopyList defines a list of properties to avoid
  122934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122935. */
  122936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122937. /**
  122938. * Gets a boolean indicating if the given object has no own property
  122939. * @param obj defines the object to test
  122940. * @returns true if object has no own property
  122941. */
  122942. static IsEmpty(obj: any): boolean;
  122943. /**
  122944. * Function used to register events at window level
  122945. * @param windowElement defines the Window object to use
  122946. * @param events defines the events to register
  122947. */
  122948. static RegisterTopRootEvents(windowElement: Window, events: {
  122949. name: string;
  122950. handler: Nullable<(e: FocusEvent) => any>;
  122951. }[]): void;
  122952. /**
  122953. * Function used to unregister events from window level
  122954. * @param windowElement defines the Window object to use
  122955. * @param events defines the events to unregister
  122956. */
  122957. static UnregisterTopRootEvents(windowElement: Window, events: {
  122958. name: string;
  122959. handler: Nullable<(e: FocusEvent) => any>;
  122960. }[]): void;
  122961. /**
  122962. * @ignore
  122963. */
  122964. static _ScreenshotCanvas: HTMLCanvasElement;
  122965. /**
  122966. * Dumps the current bound framebuffer
  122967. * @param width defines the rendering width
  122968. * @param height defines the rendering height
  122969. * @param engine defines the hosting engine
  122970. * @param successCallback defines the callback triggered once the data are available
  122971. * @param mimeType defines the mime type of the result
  122972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122973. */
  122974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122975. /**
  122976. * Converts the canvas data to blob.
  122977. * This acts as a polyfill for browsers not supporting the to blob function.
  122978. * @param canvas Defines the canvas to extract the data from
  122979. * @param successCallback Defines the callback triggered once the data are available
  122980. * @param mimeType Defines the mime type of the result
  122981. */
  122982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122983. /**
  122984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122985. * @param successCallback defines the callback triggered once the data are available
  122986. * @param mimeType defines the mime type of the result
  122987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122988. */
  122989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122990. /**
  122991. * Downloads a blob in the browser
  122992. * @param blob defines the blob to download
  122993. * @param fileName defines the name of the downloaded file
  122994. */
  122995. static Download(blob: Blob, fileName: string): void;
  122996. /**
  122997. * Will return the right value of the noPreventDefault variable
  122998. * Needed to keep backwards compatibility to the old API.
  122999. *
  123000. * @param args arguments passed to the attachControl function
  123001. * @returns the correct value for noPreventDefault
  123002. */
  123003. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  123004. /**
  123005. * Captures a screenshot of the current rendering
  123006. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123007. * @param engine defines the rendering engine
  123008. * @param camera defines the source camera
  123009. * @param size This parameter can be set to a single number or to an object with the
  123010. * following (optional) properties: precision, width, height. If a single number is passed,
  123011. * it will be used for both width and height. If an object is passed, the screenshot size
  123012. * will be derived from the parameters. The precision property is a multiplier allowing
  123013. * rendering at a higher or lower resolution
  123014. * @param successCallback defines the callback receives a single parameter which contains the
  123015. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123016. * src parameter of an <img> to display it
  123017. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123018. * Check your browser for supported MIME types
  123019. */
  123020. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123021. /**
  123022. * Captures a screenshot of the current rendering
  123023. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123024. * @param engine defines the rendering engine
  123025. * @param camera defines the source camera
  123026. * @param size This parameter can be set to a single number or to an object with the
  123027. * following (optional) properties: precision, width, height. If a single number is passed,
  123028. * it will be used for both width and height. If an object is passed, the screenshot size
  123029. * will be derived from the parameters. The precision property is a multiplier allowing
  123030. * rendering at a higher or lower resolution
  123031. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123032. * Check your browser for supported MIME types
  123033. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123034. * to the src parameter of an <img> to display it
  123035. */
  123036. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123037. /**
  123038. * Generates an image screenshot from the specified camera.
  123039. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123040. * @param engine The engine to use for rendering
  123041. * @param camera The camera to use for rendering
  123042. * @param size This parameter can be set to a single number or to an object with the
  123043. * following (optional) properties: precision, width, height. If a single number is passed,
  123044. * it will be used for both width and height. If an object is passed, the screenshot size
  123045. * will be derived from the parameters. The precision property is a multiplier allowing
  123046. * rendering at a higher or lower resolution
  123047. * @param successCallback The callback receives a single parameter which contains the
  123048. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123049. * src parameter of an <img> to display it
  123050. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123051. * Check your browser for supported MIME types
  123052. * @param samples Texture samples (default: 1)
  123053. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123054. * @param fileName A name for for the downloaded file.
  123055. */
  123056. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123057. /**
  123058. * Generates an image screenshot from the specified camera.
  123059. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123060. * @param engine The engine to use for rendering
  123061. * @param camera The camera to use for rendering
  123062. * @param size This parameter can be set to a single number or to an object with the
  123063. * following (optional) properties: precision, width, height. If a single number is passed,
  123064. * it will be used for both width and height. If an object is passed, the screenshot size
  123065. * will be derived from the parameters. The precision property is a multiplier allowing
  123066. * rendering at a higher or lower resolution
  123067. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123068. * Check your browser for supported MIME types
  123069. * @param samples Texture samples (default: 1)
  123070. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123071. * @param fileName A name for for the downloaded file.
  123072. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123073. * to the src parameter of an <img> to display it
  123074. */
  123075. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123076. /**
  123077. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123078. * Be aware Math.random() could cause collisions, but:
  123079. * "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"
  123080. * @returns a pseudo random id
  123081. */
  123082. static RandomId(): string;
  123083. /**
  123084. * Test if the given uri is a base64 string
  123085. * @param uri The uri to test
  123086. * @return True if the uri is a base64 string or false otherwise
  123087. */
  123088. static IsBase64(uri: string): boolean;
  123089. /**
  123090. * Decode the given base64 uri.
  123091. * @param uri The uri to decode
  123092. * @return The decoded base64 data.
  123093. */
  123094. static DecodeBase64(uri: string): ArrayBuffer;
  123095. /**
  123096. * Gets the absolute url.
  123097. * @param url the input url
  123098. * @return the absolute url
  123099. */
  123100. static GetAbsoluteUrl(url: string): string;
  123101. /**
  123102. * No log
  123103. */
  123104. static readonly NoneLogLevel: number;
  123105. /**
  123106. * Only message logs
  123107. */
  123108. static readonly MessageLogLevel: number;
  123109. /**
  123110. * Only warning logs
  123111. */
  123112. static readonly WarningLogLevel: number;
  123113. /**
  123114. * Only error logs
  123115. */
  123116. static readonly ErrorLogLevel: number;
  123117. /**
  123118. * All logs
  123119. */
  123120. static readonly AllLogLevel: number;
  123121. /**
  123122. * Gets a value indicating the number of loading errors
  123123. * @ignorenaming
  123124. */
  123125. static get errorsCount(): number;
  123126. /**
  123127. * Callback called when a new log is added
  123128. */
  123129. static OnNewCacheEntry: (entry: string) => void;
  123130. /**
  123131. * Log a message to the console
  123132. * @param message defines the message to log
  123133. */
  123134. static Log(message: string): void;
  123135. /**
  123136. * Write a warning message to the console
  123137. * @param message defines the message to log
  123138. */
  123139. static Warn(message: string): void;
  123140. /**
  123141. * Write an error message to the console
  123142. * @param message defines the message to log
  123143. */
  123144. static Error(message: string): void;
  123145. /**
  123146. * Gets current log cache (list of logs)
  123147. */
  123148. static get LogCache(): string;
  123149. /**
  123150. * Clears the log cache
  123151. */
  123152. static ClearLogCache(): void;
  123153. /**
  123154. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123155. */
  123156. static set LogLevels(level: number);
  123157. /**
  123158. * Checks if the window object exists
  123159. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123160. */
  123161. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123162. /**
  123163. * No performance log
  123164. */
  123165. static readonly PerformanceNoneLogLevel: number;
  123166. /**
  123167. * Use user marks to log performance
  123168. */
  123169. static readonly PerformanceUserMarkLogLevel: number;
  123170. /**
  123171. * Log performance to the console
  123172. */
  123173. static readonly PerformanceConsoleLogLevel: number;
  123174. private static _performance;
  123175. /**
  123176. * Sets the current performance log level
  123177. */
  123178. static set PerformanceLogLevel(level: number);
  123179. private static _StartPerformanceCounterDisabled;
  123180. private static _EndPerformanceCounterDisabled;
  123181. private static _StartUserMark;
  123182. private static _EndUserMark;
  123183. private static _StartPerformanceConsole;
  123184. private static _EndPerformanceConsole;
  123185. /**
  123186. * Starts a performance counter
  123187. */
  123188. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123189. /**
  123190. * Ends a specific performance coutner
  123191. */
  123192. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123193. /**
  123194. * Gets either window.performance.now() if supported or Date.now() else
  123195. */
  123196. static get Now(): number;
  123197. /**
  123198. * This method will return the name of the class used to create the instance of the given object.
  123199. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123200. * @param object the object to get the class name from
  123201. * @param isType defines if the object is actually a type
  123202. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123203. */
  123204. static GetClassName(object: any, isType?: boolean): string;
  123205. /**
  123206. * Gets the first element of an array satisfying a given predicate
  123207. * @param array defines the array to browse
  123208. * @param predicate defines the predicate to use
  123209. * @returns null if not found or the element
  123210. */
  123211. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123212. /**
  123213. * This method will return the name of the full name of the class, including its owning module (if any).
  123214. * 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).
  123215. * @param object the object to get the class name from
  123216. * @param isType defines if the object is actually a type
  123217. * @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.
  123218. * @ignorenaming
  123219. */
  123220. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123221. /**
  123222. * Returns a promise that resolves after the given amount of time.
  123223. * @param delay Number of milliseconds to delay
  123224. * @returns Promise that resolves after the given amount of time
  123225. */
  123226. static DelayAsync(delay: number): Promise<void>;
  123227. /**
  123228. * Utility function to detect if the current user agent is Safari
  123229. * @returns whether or not the current user agent is safari
  123230. */
  123231. static IsSafari(): boolean;
  123232. }
  123233. /**
  123234. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123235. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123236. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123237. * @param name The name of the class, case should be preserved
  123238. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123239. */
  123240. export function className(name: string, module?: string): (target: Object) => void;
  123241. /**
  123242. * An implementation of a loop for asynchronous functions.
  123243. */
  123244. export class AsyncLoop {
  123245. /**
  123246. * Defines the number of iterations for the loop
  123247. */
  123248. iterations: number;
  123249. /**
  123250. * Defines the current index of the loop.
  123251. */
  123252. index: number;
  123253. private _done;
  123254. private _fn;
  123255. private _successCallback;
  123256. /**
  123257. * Constructor.
  123258. * @param iterations the number of iterations.
  123259. * @param func the function to run each iteration
  123260. * @param successCallback the callback that will be called upon succesful execution
  123261. * @param offset starting offset.
  123262. */
  123263. constructor(
  123264. /**
  123265. * Defines the number of iterations for the loop
  123266. */
  123267. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123268. /**
  123269. * Execute the next iteration. Must be called after the last iteration was finished.
  123270. */
  123271. executeNext(): void;
  123272. /**
  123273. * Break the loop and run the success callback.
  123274. */
  123275. breakLoop(): void;
  123276. /**
  123277. * Create and run an async loop.
  123278. * @param iterations the number of iterations.
  123279. * @param fn the function to run each iteration
  123280. * @param successCallback the callback that will be called upon succesful execution
  123281. * @param offset starting offset.
  123282. * @returns the created async loop object
  123283. */
  123284. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123285. /**
  123286. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123287. * @param iterations total number of iterations
  123288. * @param syncedIterations number of synchronous iterations in each async iteration.
  123289. * @param fn the function to call each iteration.
  123290. * @param callback a success call back that will be called when iterating stops.
  123291. * @param breakFunction a break condition (optional)
  123292. * @param timeout timeout settings for the setTimeout function. default - 0.
  123293. * @returns the created async loop object
  123294. */
  123295. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123296. }
  123297. }
  123298. declare module BABYLON {
  123299. /**
  123300. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123301. * The underlying implementation relies on an associative array to ensure the best performances.
  123302. * The value can be anything including 'null' but except 'undefined'
  123303. */
  123304. export class StringDictionary<T> {
  123305. /**
  123306. * This will clear this dictionary and copy the content from the 'source' one.
  123307. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123308. * @param source the dictionary to take the content from and copy to this dictionary
  123309. */
  123310. copyFrom(source: StringDictionary<T>): void;
  123311. /**
  123312. * Get a value based from its key
  123313. * @param key the given key to get the matching value from
  123314. * @return the value if found, otherwise undefined is returned
  123315. */
  123316. get(key: string): T | undefined;
  123317. /**
  123318. * Get a value from its key or add it if it doesn't exist.
  123319. * This method will ensure you that a given key/data will be present in the dictionary.
  123320. * @param key the given key to get the matching value from
  123321. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123322. * The factory will only be invoked if there's no data for the given key.
  123323. * @return the value corresponding to the key.
  123324. */
  123325. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123326. /**
  123327. * Get a value from its key if present in the dictionary otherwise add it
  123328. * @param key the key to get the value from
  123329. * @param val if there's no such key/value pair in the dictionary add it with this value
  123330. * @return the value corresponding to the key
  123331. */
  123332. getOrAdd(key: string, val: T): T;
  123333. /**
  123334. * Check if there's a given key in the dictionary
  123335. * @param key the key to check for
  123336. * @return true if the key is present, false otherwise
  123337. */
  123338. contains(key: string): boolean;
  123339. /**
  123340. * Add a new key and its corresponding value
  123341. * @param key the key to add
  123342. * @param value the value corresponding to the key
  123343. * @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
  123344. */
  123345. add(key: string, value: T): boolean;
  123346. /**
  123347. * Update a specific value associated to a key
  123348. * @param key defines the key to use
  123349. * @param value defines the value to store
  123350. * @returns true if the value was updated (or false if the key was not found)
  123351. */
  123352. set(key: string, value: T): boolean;
  123353. /**
  123354. * Get the element of the given key and remove it from the dictionary
  123355. * @param key defines the key to search
  123356. * @returns the value associated with the key or null if not found
  123357. */
  123358. getAndRemove(key: string): Nullable<T>;
  123359. /**
  123360. * Remove a key/value from the dictionary.
  123361. * @param key the key to remove
  123362. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  123363. */
  123364. remove(key: string): boolean;
  123365. /**
  123366. * Clear the whole content of the dictionary
  123367. */
  123368. clear(): void;
  123369. /**
  123370. * Gets the current count
  123371. */
  123372. get count(): number;
  123373. /**
  123374. * Execute a callback on each key/val of the dictionary.
  123375. * Note that you can remove any element in this dictionary in the callback implementation
  123376. * @param callback the callback to execute on a given key/value pair
  123377. */
  123378. forEach(callback: (key: string, val: T) => void): void;
  123379. /**
  123380. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  123381. * If the callback returns null or undefined the method will iterate to the next key/value pair
  123382. * Note that you can remove any element in this dictionary in the callback implementation
  123383. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  123384. * @returns the first item
  123385. */
  123386. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  123387. private _count;
  123388. private _data;
  123389. }
  123390. }
  123391. declare module BABYLON {
  123392. /** @hidden */
  123393. export interface ICollisionCoordinator {
  123394. createCollider(): Collider;
  123395. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123396. init(scene: Scene): void;
  123397. }
  123398. /** @hidden */
  123399. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  123400. private _scene;
  123401. private _scaledPosition;
  123402. private _scaledVelocity;
  123403. private _finalPosition;
  123404. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123405. createCollider(): Collider;
  123406. init(scene: Scene): void;
  123407. private _collideWithWorld;
  123408. }
  123409. }
  123410. declare module BABYLON {
  123411. /**
  123412. * Class used to manage all inputs for the scene.
  123413. */
  123414. export class InputManager {
  123415. /** The distance in pixel that you have to move to prevent some events */
  123416. static DragMovementThreshold: number;
  123417. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  123418. static LongPressDelay: number;
  123419. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  123420. static DoubleClickDelay: number;
  123421. /** If you need to check double click without raising a single click at first click, enable this flag */
  123422. static ExclusiveDoubleClickMode: boolean;
  123423. /** 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. */
  123424. private _alreadyAttached;
  123425. private _alreadyAttachedTo;
  123426. private _wheelEventName;
  123427. private _onPointerMove;
  123428. private _onPointerDown;
  123429. private _onPointerUp;
  123430. private _initClickEvent;
  123431. private _initActionManager;
  123432. private _delayedSimpleClick;
  123433. private _delayedSimpleClickTimeout;
  123434. private _previousDelayedSimpleClickTimeout;
  123435. private _meshPickProceed;
  123436. private _previousButtonPressed;
  123437. private _currentPickResult;
  123438. private _previousPickResult;
  123439. private _totalPointersPressed;
  123440. private _doubleClickOccured;
  123441. private _pointerOverMesh;
  123442. private _pickedDownMesh;
  123443. private _pickedUpMesh;
  123444. private _pointerX;
  123445. private _pointerY;
  123446. private _unTranslatedPointerX;
  123447. private _unTranslatedPointerY;
  123448. private _startingPointerPosition;
  123449. private _previousStartingPointerPosition;
  123450. private _startingPointerTime;
  123451. private _previousStartingPointerTime;
  123452. private _pointerCaptures;
  123453. private _meshUnderPointerId;
  123454. private _onKeyDown;
  123455. private _onKeyUp;
  123456. private _keyboardIsAttached;
  123457. private _onCanvasFocusObserver;
  123458. private _onCanvasBlurObserver;
  123459. private _scene;
  123460. /**
  123461. * Creates a new InputManager
  123462. * @param scene defines the hosting scene
  123463. */
  123464. constructor(scene: Scene);
  123465. /**
  123466. * Gets the mesh that is currently under the pointer
  123467. */
  123468. get meshUnderPointer(): Nullable<AbstractMesh>;
  123469. /**
  123470. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  123471. * @param pointerId the pointer id to use
  123472. * @returns The mesh under this pointer id or null if not found
  123473. */
  123474. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  123475. /**
  123476. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  123477. */
  123478. get unTranslatedPointer(): Vector2;
  123479. /**
  123480. * Gets or sets the current on-screen X position of the pointer
  123481. */
  123482. get pointerX(): number;
  123483. set pointerX(value: number);
  123484. /**
  123485. * Gets or sets the current on-screen Y position of the pointer
  123486. */
  123487. get pointerY(): number;
  123488. set pointerY(value: number);
  123489. private _updatePointerPosition;
  123490. private _processPointerMove;
  123491. private _setRayOnPointerInfo;
  123492. private _checkPrePointerObservable;
  123493. /**
  123494. * Use this method to simulate a pointer move on a mesh
  123495. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123496. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123497. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123498. */
  123499. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123500. /**
  123501. * Use this method to simulate a pointer down on a mesh
  123502. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123503. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123504. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123505. */
  123506. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123507. private _processPointerDown;
  123508. /** @hidden */
  123509. _isPointerSwiping(): boolean;
  123510. /**
  123511. * Use this method to simulate a pointer up on a mesh
  123512. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123513. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123514. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123515. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123516. */
  123517. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  123518. private _processPointerUp;
  123519. /**
  123520. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123521. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123522. * @returns true if the pointer was captured
  123523. */
  123524. isPointerCaptured(pointerId?: number): boolean;
  123525. /**
  123526. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123527. * @param attachUp defines if you want to attach events to pointerup
  123528. * @param attachDown defines if you want to attach events to pointerdown
  123529. * @param attachMove defines if you want to attach events to pointermove
  123530. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  123531. */
  123532. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  123533. /**
  123534. * Detaches all event handlers
  123535. */
  123536. detachControl(): void;
  123537. /**
  123538. * Force the value of meshUnderPointer
  123539. * @param mesh defines the mesh to use
  123540. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  123541. */
  123542. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  123543. /**
  123544. * Gets the mesh under the pointer
  123545. * @returns a Mesh or null if no mesh is under the pointer
  123546. */
  123547. getPointerOverMesh(): Nullable<AbstractMesh>;
  123548. }
  123549. }
  123550. declare module BABYLON {
  123551. /**
  123552. * This class defines the direct association between an animation and a target
  123553. */
  123554. export class TargetedAnimation {
  123555. /**
  123556. * Animation to perform
  123557. */
  123558. animation: Animation;
  123559. /**
  123560. * Target to animate
  123561. */
  123562. target: any;
  123563. /**
  123564. * Returns the string "TargetedAnimation"
  123565. * @returns "TargetedAnimation"
  123566. */
  123567. getClassName(): string;
  123568. /**
  123569. * Serialize the object
  123570. * @returns the JSON object representing the current entity
  123571. */
  123572. serialize(): any;
  123573. }
  123574. /**
  123575. * Use this class to create coordinated animations on multiple targets
  123576. */
  123577. export class AnimationGroup implements IDisposable {
  123578. /** The name of the animation group */
  123579. name: string;
  123580. private _scene;
  123581. private _targetedAnimations;
  123582. private _animatables;
  123583. private _from;
  123584. private _to;
  123585. private _isStarted;
  123586. private _isPaused;
  123587. private _speedRatio;
  123588. private _loopAnimation;
  123589. private _isAdditive;
  123590. /**
  123591. * Gets or sets the unique id of the node
  123592. */
  123593. uniqueId: number;
  123594. /**
  123595. * This observable will notify when one animation have ended
  123596. */
  123597. onAnimationEndObservable: Observable<TargetedAnimation>;
  123598. /**
  123599. * Observer raised when one animation loops
  123600. */
  123601. onAnimationLoopObservable: Observable<TargetedAnimation>;
  123602. /**
  123603. * Observer raised when all animations have looped
  123604. */
  123605. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  123606. /**
  123607. * This observable will notify when all animations have ended.
  123608. */
  123609. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  123610. /**
  123611. * This observable will notify when all animations have paused.
  123612. */
  123613. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  123614. /**
  123615. * This observable will notify when all animations are playing.
  123616. */
  123617. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  123618. /**
  123619. * Gets the first frame
  123620. */
  123621. get from(): number;
  123622. /**
  123623. * Gets the last frame
  123624. */
  123625. get to(): number;
  123626. /**
  123627. * Define if the animations are started
  123628. */
  123629. get isStarted(): boolean;
  123630. /**
  123631. * Gets a value indicating that the current group is playing
  123632. */
  123633. get isPlaying(): boolean;
  123634. /**
  123635. * Gets or sets the speed ratio to use for all animations
  123636. */
  123637. get speedRatio(): number;
  123638. /**
  123639. * Gets or sets the speed ratio to use for all animations
  123640. */
  123641. set speedRatio(value: number);
  123642. /**
  123643. * Gets or sets if all animations should loop or not
  123644. */
  123645. get loopAnimation(): boolean;
  123646. set loopAnimation(value: boolean);
  123647. /**
  123648. * Gets or sets if all animations should be evaluated additively
  123649. */
  123650. get isAdditive(): boolean;
  123651. set isAdditive(value: boolean);
  123652. /**
  123653. * Gets the targeted animations for this animation group
  123654. */
  123655. get targetedAnimations(): Array<TargetedAnimation>;
  123656. /**
  123657. * returning the list of animatables controlled by this animation group.
  123658. */
  123659. get animatables(): Array<Animatable>;
  123660. /**
  123661. * Gets the list of target animations
  123662. */
  123663. get children(): TargetedAnimation[];
  123664. /**
  123665. * Instantiates a new Animation Group.
  123666. * This helps managing several animations at once.
  123667. * @see https://doc.babylonjs.com/how_to/group
  123668. * @param name Defines the name of the group
  123669. * @param scene Defines the scene the group belongs to
  123670. */
  123671. constructor(
  123672. /** The name of the animation group */
  123673. name: string, scene?: Nullable<Scene>);
  123674. /**
  123675. * Add an animation (with its target) in the group
  123676. * @param animation defines the animation we want to add
  123677. * @param target defines the target of the animation
  123678. * @returns the TargetedAnimation object
  123679. */
  123680. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123681. /**
  123682. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123683. * It can add constant keys at begin or end
  123684. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123685. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123686. * @returns the animation group
  123687. */
  123688. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123689. private _animationLoopCount;
  123690. private _animationLoopFlags;
  123691. private _processLoop;
  123692. /**
  123693. * Start all animations on given targets
  123694. * @param loop defines if animations must loop
  123695. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123696. * @param from defines the from key (optional)
  123697. * @param to defines the to key (optional)
  123698. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123699. * @returns the current animation group
  123700. */
  123701. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123702. /**
  123703. * Pause all animations
  123704. * @returns the animation group
  123705. */
  123706. pause(): AnimationGroup;
  123707. /**
  123708. * Play all animations to initial state
  123709. * This function will start() the animations if they were not started or will restart() them if they were paused
  123710. * @param loop defines if animations must loop
  123711. * @returns the animation group
  123712. */
  123713. play(loop?: boolean): AnimationGroup;
  123714. /**
  123715. * Reset all animations to initial state
  123716. * @returns the animation group
  123717. */
  123718. reset(): AnimationGroup;
  123719. /**
  123720. * Restart animations from key 0
  123721. * @returns the animation group
  123722. */
  123723. restart(): AnimationGroup;
  123724. /**
  123725. * Stop all animations
  123726. * @returns the animation group
  123727. */
  123728. stop(): AnimationGroup;
  123729. /**
  123730. * Set animation weight for all animatables
  123731. * @param weight defines the weight to use
  123732. * @return the animationGroup
  123733. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123734. */
  123735. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123736. /**
  123737. * Synchronize and normalize all animatables with a source animatable
  123738. * @param root defines the root animatable to synchronize with
  123739. * @return the animationGroup
  123740. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123741. */
  123742. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123743. /**
  123744. * Goes to a specific frame in this animation group
  123745. * @param frame the frame number to go to
  123746. * @return the animationGroup
  123747. */
  123748. goToFrame(frame: number): AnimationGroup;
  123749. /**
  123750. * Dispose all associated resources
  123751. */
  123752. dispose(): void;
  123753. private _checkAnimationGroupEnded;
  123754. /**
  123755. * Clone the current animation group and returns a copy
  123756. * @param newName defines the name of the new group
  123757. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123758. * @returns the new aniamtion group
  123759. */
  123760. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123761. /**
  123762. * Serializes the animationGroup to an object
  123763. * @returns Serialized object
  123764. */
  123765. serialize(): any;
  123766. /**
  123767. * Returns a new AnimationGroup object parsed from the source provided.
  123768. * @param parsedAnimationGroup defines the source
  123769. * @param scene defines the scene that will receive the animationGroup
  123770. * @returns a new AnimationGroup
  123771. */
  123772. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123773. /**
  123774. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123775. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123776. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123777. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123778. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123779. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123780. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123781. */
  123782. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123783. /**
  123784. * Returns the string "AnimationGroup"
  123785. * @returns "AnimationGroup"
  123786. */
  123787. getClassName(): string;
  123788. /**
  123789. * Creates a detailled string about the object
  123790. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123791. * @returns a string representing the object
  123792. */
  123793. toString(fullDetails?: boolean): string;
  123794. }
  123795. }
  123796. declare module BABYLON {
  123797. /**
  123798. * Define an interface for all classes that will hold resources
  123799. */
  123800. export interface IDisposable {
  123801. /**
  123802. * Releases all held resources
  123803. */
  123804. dispose(): void;
  123805. }
  123806. /** Interface defining initialization parameters for Scene class */
  123807. export interface SceneOptions {
  123808. /**
  123809. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123810. * It will improve performance when the number of geometries becomes important.
  123811. */
  123812. useGeometryUniqueIdsMap?: boolean;
  123813. /**
  123814. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123815. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123816. */
  123817. useMaterialMeshMap?: boolean;
  123818. /**
  123819. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123820. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123821. */
  123822. useClonedMeshMap?: boolean;
  123823. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123824. virtual?: boolean;
  123825. }
  123826. /**
  123827. * Represents a scene to be rendered by the engine.
  123828. * @see https://doc.babylonjs.com/features/scene
  123829. */
  123830. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123831. /** The fog is deactivated */
  123832. static readonly FOGMODE_NONE: number;
  123833. /** The fog density is following an exponential function */
  123834. static readonly FOGMODE_EXP: number;
  123835. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123836. static readonly FOGMODE_EXP2: number;
  123837. /** The fog density is following a linear function. */
  123838. static readonly FOGMODE_LINEAR: number;
  123839. /**
  123840. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123841. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123842. */
  123843. static MinDeltaTime: number;
  123844. /**
  123845. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123846. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123847. */
  123848. static MaxDeltaTime: number;
  123849. /**
  123850. * Factory used to create the default material.
  123851. * @param name The name of the material to create
  123852. * @param scene The scene to create the material for
  123853. * @returns The default material
  123854. */
  123855. static DefaultMaterialFactory(scene: Scene): Material;
  123856. /**
  123857. * Factory used to create the a collision coordinator.
  123858. * @returns The collision coordinator
  123859. */
  123860. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123861. /** @hidden */
  123862. _inputManager: InputManager;
  123863. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123864. cameraToUseForPointers: Nullable<Camera>;
  123865. /** @hidden */
  123866. readonly _isScene: boolean;
  123867. /** @hidden */
  123868. _blockEntityCollection: boolean;
  123869. /**
  123870. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123871. */
  123872. autoClear: boolean;
  123873. /**
  123874. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123875. */
  123876. autoClearDepthAndStencil: boolean;
  123877. /**
  123878. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123879. */
  123880. clearColor: Color4;
  123881. /**
  123882. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123883. */
  123884. ambientColor: Color3;
  123885. /**
  123886. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123887. * It should only be one of the following (if not the default embedded one):
  123888. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123889. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123890. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123891. * The material properties need to be setup according to the type of texture in use.
  123892. */
  123893. environmentBRDFTexture: BaseTexture;
  123894. /**
  123895. * Texture used in all pbr material as the reflection texture.
  123896. * As in the majority of the scene they are the same (exception for multi room and so on),
  123897. * this is easier to reference from here than from all the materials.
  123898. */
  123899. get environmentTexture(): Nullable<BaseTexture>;
  123900. /**
  123901. * Texture used in all pbr material as the reflection texture.
  123902. * As in the majority of the scene they are the same (exception for multi room and so on),
  123903. * this is easier to set here than in all the materials.
  123904. */
  123905. set environmentTexture(value: Nullable<BaseTexture>);
  123906. /** @hidden */
  123907. protected _environmentIntensity: number;
  123908. /**
  123909. * Intensity of the environment in all pbr material.
  123910. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123911. * As in the majority of the scene they are the same (exception for multi room and so on),
  123912. * this is easier to reference from here than from all the materials.
  123913. */
  123914. get environmentIntensity(): number;
  123915. /**
  123916. * Intensity of the environment in all pbr material.
  123917. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123918. * As in the majority of the scene they are the same (exception for multi room and so on),
  123919. * this is easier to set here than in all the materials.
  123920. */
  123921. set environmentIntensity(value: number);
  123922. /** @hidden */
  123923. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123924. /**
  123925. * Default image processing configuration used either in the rendering
  123926. * Forward main pass or through the imageProcessingPostProcess if present.
  123927. * As in the majority of the scene they are the same (exception for multi camera),
  123928. * this is easier to reference from here than from all the materials and post process.
  123929. *
  123930. * No setter as we it is a shared configuration, you can set the values instead.
  123931. */
  123932. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123933. private _forceWireframe;
  123934. /**
  123935. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123936. */
  123937. set forceWireframe(value: boolean);
  123938. get forceWireframe(): boolean;
  123939. private _skipFrustumClipping;
  123940. /**
  123941. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123942. */
  123943. set skipFrustumClipping(value: boolean);
  123944. get skipFrustumClipping(): boolean;
  123945. private _forcePointsCloud;
  123946. /**
  123947. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123948. */
  123949. set forcePointsCloud(value: boolean);
  123950. get forcePointsCloud(): boolean;
  123951. /**
  123952. * Gets or sets the active clipplane 1
  123953. */
  123954. clipPlane: Nullable<Plane>;
  123955. /**
  123956. * Gets or sets the active clipplane 2
  123957. */
  123958. clipPlane2: Nullable<Plane>;
  123959. /**
  123960. * Gets or sets the active clipplane 3
  123961. */
  123962. clipPlane3: Nullable<Plane>;
  123963. /**
  123964. * Gets or sets the active clipplane 4
  123965. */
  123966. clipPlane4: Nullable<Plane>;
  123967. /**
  123968. * Gets or sets the active clipplane 5
  123969. */
  123970. clipPlane5: Nullable<Plane>;
  123971. /**
  123972. * Gets or sets the active clipplane 6
  123973. */
  123974. clipPlane6: Nullable<Plane>;
  123975. /**
  123976. * Gets or sets a boolean indicating if animations are enabled
  123977. */
  123978. animationsEnabled: boolean;
  123979. private _animationPropertiesOverride;
  123980. /**
  123981. * Gets or sets the animation properties override
  123982. */
  123983. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123984. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123985. /**
  123986. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123987. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123988. */
  123989. useConstantAnimationDeltaTime: boolean;
  123990. /**
  123991. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123992. * Please note that it requires to run a ray cast through the scene on every frame
  123993. */
  123994. constantlyUpdateMeshUnderPointer: boolean;
  123995. /**
  123996. * Defines the HTML cursor to use when hovering over interactive elements
  123997. */
  123998. hoverCursor: string;
  123999. /**
  124000. * Defines the HTML default cursor to use (empty by default)
  124001. */
  124002. defaultCursor: string;
  124003. /**
  124004. * Defines whether cursors are handled by the scene.
  124005. */
  124006. doNotHandleCursors: boolean;
  124007. /**
  124008. * This is used to call preventDefault() on pointer down
  124009. * in order to block unwanted artifacts like system double clicks
  124010. */
  124011. preventDefaultOnPointerDown: boolean;
  124012. /**
  124013. * This is used to call preventDefault() on pointer up
  124014. * in order to block unwanted artifacts like system double clicks
  124015. */
  124016. preventDefaultOnPointerUp: boolean;
  124017. /**
  124018. * Gets or sets user defined metadata
  124019. */
  124020. metadata: any;
  124021. /**
  124022. * For internal use only. Please do not use.
  124023. */
  124024. reservedDataStore: any;
  124025. /**
  124026. * Gets the name of the plugin used to load this scene (null by default)
  124027. */
  124028. loadingPluginName: string;
  124029. /**
  124030. * Use this array to add regular expressions used to disable offline support for specific urls
  124031. */
  124032. disableOfflineSupportExceptionRules: RegExp[];
  124033. /**
  124034. * An event triggered when the scene is disposed.
  124035. */
  124036. onDisposeObservable: Observable<Scene>;
  124037. private _onDisposeObserver;
  124038. /** Sets a function to be executed when this scene is disposed. */
  124039. set onDispose(callback: () => void);
  124040. /**
  124041. * An event triggered before rendering the scene (right after animations and physics)
  124042. */
  124043. onBeforeRenderObservable: Observable<Scene>;
  124044. private _onBeforeRenderObserver;
  124045. /** Sets a function to be executed before rendering this scene */
  124046. set beforeRender(callback: Nullable<() => void>);
  124047. /**
  124048. * An event triggered after rendering the scene
  124049. */
  124050. onAfterRenderObservable: Observable<Scene>;
  124051. /**
  124052. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124053. */
  124054. onAfterRenderCameraObservable: Observable<Camera>;
  124055. private _onAfterRenderObserver;
  124056. /** Sets a function to be executed after rendering this scene */
  124057. set afterRender(callback: Nullable<() => void>);
  124058. /**
  124059. * An event triggered before animating the scene
  124060. */
  124061. onBeforeAnimationsObservable: Observable<Scene>;
  124062. /**
  124063. * An event triggered after animations processing
  124064. */
  124065. onAfterAnimationsObservable: Observable<Scene>;
  124066. /**
  124067. * An event triggered before draw calls are ready to be sent
  124068. */
  124069. onBeforeDrawPhaseObservable: Observable<Scene>;
  124070. /**
  124071. * An event triggered after draw calls have been sent
  124072. */
  124073. onAfterDrawPhaseObservable: Observable<Scene>;
  124074. /**
  124075. * An event triggered when the scene is ready
  124076. */
  124077. onReadyObservable: Observable<Scene>;
  124078. /**
  124079. * An event triggered before rendering a camera
  124080. */
  124081. onBeforeCameraRenderObservable: Observable<Camera>;
  124082. private _onBeforeCameraRenderObserver;
  124083. /** Sets a function to be executed before rendering a camera*/
  124084. set beforeCameraRender(callback: () => void);
  124085. /**
  124086. * An event triggered after rendering a camera
  124087. */
  124088. onAfterCameraRenderObservable: Observable<Camera>;
  124089. private _onAfterCameraRenderObserver;
  124090. /** Sets a function to be executed after rendering a camera*/
  124091. set afterCameraRender(callback: () => void);
  124092. /**
  124093. * An event triggered when active meshes evaluation is about to start
  124094. */
  124095. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124096. /**
  124097. * An event triggered when active meshes evaluation is done
  124098. */
  124099. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124100. /**
  124101. * An event triggered when particles rendering is about to start
  124102. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124103. */
  124104. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124105. /**
  124106. * An event triggered when particles rendering is done
  124107. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124108. */
  124109. onAfterParticlesRenderingObservable: Observable<Scene>;
  124110. /**
  124111. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124112. */
  124113. onDataLoadedObservable: Observable<Scene>;
  124114. /**
  124115. * An event triggered when a camera is created
  124116. */
  124117. onNewCameraAddedObservable: Observable<Camera>;
  124118. /**
  124119. * An event triggered when a camera is removed
  124120. */
  124121. onCameraRemovedObservable: Observable<Camera>;
  124122. /**
  124123. * An event triggered when a light is created
  124124. */
  124125. onNewLightAddedObservable: Observable<Light>;
  124126. /**
  124127. * An event triggered when a light is removed
  124128. */
  124129. onLightRemovedObservable: Observable<Light>;
  124130. /**
  124131. * An event triggered when a geometry is created
  124132. */
  124133. onNewGeometryAddedObservable: Observable<Geometry>;
  124134. /**
  124135. * An event triggered when a geometry is removed
  124136. */
  124137. onGeometryRemovedObservable: Observable<Geometry>;
  124138. /**
  124139. * An event triggered when a transform node is created
  124140. */
  124141. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124142. /**
  124143. * An event triggered when a transform node is removed
  124144. */
  124145. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124146. /**
  124147. * An event triggered when a mesh is created
  124148. */
  124149. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124150. /**
  124151. * An event triggered when a mesh is removed
  124152. */
  124153. onMeshRemovedObservable: Observable<AbstractMesh>;
  124154. /**
  124155. * An event triggered when a skeleton is created
  124156. */
  124157. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124158. /**
  124159. * An event triggered when a skeleton is removed
  124160. */
  124161. onSkeletonRemovedObservable: Observable<Skeleton>;
  124162. /**
  124163. * An event triggered when a material is created
  124164. */
  124165. onNewMaterialAddedObservable: Observable<Material>;
  124166. /**
  124167. * An event triggered when a material is removed
  124168. */
  124169. onMaterialRemovedObservable: Observable<Material>;
  124170. /**
  124171. * An event triggered when a texture is created
  124172. */
  124173. onNewTextureAddedObservable: Observable<BaseTexture>;
  124174. /**
  124175. * An event triggered when a texture is removed
  124176. */
  124177. onTextureRemovedObservable: Observable<BaseTexture>;
  124178. /**
  124179. * An event triggered when render targets are about to be rendered
  124180. * Can happen multiple times per frame.
  124181. */
  124182. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124183. /**
  124184. * An event triggered when render targets were rendered.
  124185. * Can happen multiple times per frame.
  124186. */
  124187. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124188. /**
  124189. * An event triggered before calculating deterministic simulation step
  124190. */
  124191. onBeforeStepObservable: Observable<Scene>;
  124192. /**
  124193. * An event triggered after calculating deterministic simulation step
  124194. */
  124195. onAfterStepObservable: Observable<Scene>;
  124196. /**
  124197. * An event triggered when the activeCamera property is updated
  124198. */
  124199. onActiveCameraChanged: Observable<Scene>;
  124200. /**
  124201. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124202. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124203. * 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)
  124204. */
  124205. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124206. /**
  124207. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124208. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124209. * 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)
  124210. */
  124211. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124212. /**
  124213. * This Observable will when a mesh has been imported into the scene.
  124214. */
  124215. onMeshImportedObservable: Observable<AbstractMesh>;
  124216. /**
  124217. * This Observable will when an animation file has been imported into the scene.
  124218. */
  124219. onAnimationFileImportedObservable: Observable<Scene>;
  124220. /**
  124221. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124222. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124223. */
  124224. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124225. /** @hidden */
  124226. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124227. /**
  124228. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124229. */
  124230. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124231. /**
  124232. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124233. */
  124234. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124235. /**
  124236. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124237. */
  124238. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124239. /** Callback called when a pointer move is detected */
  124240. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124241. /** Callback called when a pointer down is detected */
  124242. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124243. /** Callback called when a pointer up is detected */
  124244. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124245. /** Callback called when a pointer pick is detected */
  124246. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124247. /**
  124248. * 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).
  124249. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124250. */
  124251. onPrePointerObservable: Observable<PointerInfoPre>;
  124252. /**
  124253. * Observable event triggered each time an input event is received from the rendering canvas
  124254. */
  124255. onPointerObservable: Observable<PointerInfo>;
  124256. /**
  124257. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124258. */
  124259. get unTranslatedPointer(): Vector2;
  124260. /**
  124261. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124262. */
  124263. static get DragMovementThreshold(): number;
  124264. static set DragMovementThreshold(value: number);
  124265. /**
  124266. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124267. */
  124268. static get LongPressDelay(): number;
  124269. static set LongPressDelay(value: number);
  124270. /**
  124271. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124272. */
  124273. static get DoubleClickDelay(): number;
  124274. static set DoubleClickDelay(value: number);
  124275. /** If you need to check double click without raising a single click at first click, enable this flag */
  124276. static get ExclusiveDoubleClickMode(): boolean;
  124277. static set ExclusiveDoubleClickMode(value: boolean);
  124278. /** @hidden */
  124279. _mirroredCameraPosition: Nullable<Vector3>;
  124280. /**
  124281. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124282. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124283. */
  124284. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124285. /**
  124286. * Observable event triggered each time an keyboard event is received from the hosting window
  124287. */
  124288. onKeyboardObservable: Observable<KeyboardInfo>;
  124289. private _useRightHandedSystem;
  124290. /**
  124291. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124292. */
  124293. set useRightHandedSystem(value: boolean);
  124294. get useRightHandedSystem(): boolean;
  124295. private _timeAccumulator;
  124296. private _currentStepId;
  124297. private _currentInternalStep;
  124298. /**
  124299. * Sets the step Id used by deterministic lock step
  124300. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124301. * @param newStepId defines the step Id
  124302. */
  124303. setStepId(newStepId: number): void;
  124304. /**
  124305. * Gets the step Id used by deterministic lock step
  124306. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124307. * @returns the step Id
  124308. */
  124309. getStepId(): number;
  124310. /**
  124311. * Gets the internal step used by deterministic lock step
  124312. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124313. * @returns the internal step
  124314. */
  124315. getInternalStep(): number;
  124316. private _fogEnabled;
  124317. /**
  124318. * Gets or sets a boolean indicating if fog is enabled on this scene
  124319. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124320. * (Default is true)
  124321. */
  124322. set fogEnabled(value: boolean);
  124323. get fogEnabled(): boolean;
  124324. private _fogMode;
  124325. /**
  124326. * Gets or sets the fog mode to use
  124327. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124328. * | mode | value |
  124329. * | --- | --- |
  124330. * | FOGMODE_NONE | 0 |
  124331. * | FOGMODE_EXP | 1 |
  124332. * | FOGMODE_EXP2 | 2 |
  124333. * | FOGMODE_LINEAR | 3 |
  124334. */
  124335. set fogMode(value: number);
  124336. get fogMode(): number;
  124337. /**
  124338. * Gets or sets the fog color to use
  124339. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124340. * (Default is Color3(0.2, 0.2, 0.3))
  124341. */
  124342. fogColor: Color3;
  124343. /**
  124344. * Gets or sets the fog density to use
  124345. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124346. * (Default is 0.1)
  124347. */
  124348. fogDensity: number;
  124349. /**
  124350. * Gets or sets the fog start distance to use
  124351. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124352. * (Default is 0)
  124353. */
  124354. fogStart: number;
  124355. /**
  124356. * Gets or sets the fog end distance to use
  124357. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124358. * (Default is 1000)
  124359. */
  124360. fogEnd: number;
  124361. /**
  124362. * Flag indicating that the frame buffer binding is handled by another component
  124363. */
  124364. prePass: boolean;
  124365. private _shadowsEnabled;
  124366. /**
  124367. * Gets or sets a boolean indicating if shadows are enabled on this scene
  124368. */
  124369. set shadowsEnabled(value: boolean);
  124370. get shadowsEnabled(): boolean;
  124371. private _lightsEnabled;
  124372. /**
  124373. * Gets or sets a boolean indicating if lights are enabled on this scene
  124374. */
  124375. set lightsEnabled(value: boolean);
  124376. get lightsEnabled(): boolean;
  124377. /** All of the active cameras added to this scene. */
  124378. activeCameras: Camera[];
  124379. /** @hidden */
  124380. _activeCamera: Nullable<Camera>;
  124381. /** Gets or sets the current active camera */
  124382. get activeCamera(): Nullable<Camera>;
  124383. set activeCamera(value: Nullable<Camera>);
  124384. private _defaultMaterial;
  124385. /** The default material used on meshes when no material is affected */
  124386. get defaultMaterial(): Material;
  124387. /** The default material used on meshes when no material is affected */
  124388. set defaultMaterial(value: Material);
  124389. private _texturesEnabled;
  124390. /**
  124391. * Gets or sets a boolean indicating if textures are enabled on this scene
  124392. */
  124393. set texturesEnabled(value: boolean);
  124394. get texturesEnabled(): boolean;
  124395. /**
  124396. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  124397. */
  124398. physicsEnabled: boolean;
  124399. /**
  124400. * Gets or sets a boolean indicating if particles are enabled on this scene
  124401. */
  124402. particlesEnabled: boolean;
  124403. /**
  124404. * Gets or sets a boolean indicating if sprites are enabled on this scene
  124405. */
  124406. spritesEnabled: boolean;
  124407. private _skeletonsEnabled;
  124408. /**
  124409. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  124410. */
  124411. set skeletonsEnabled(value: boolean);
  124412. get skeletonsEnabled(): boolean;
  124413. /**
  124414. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  124415. */
  124416. lensFlaresEnabled: boolean;
  124417. /**
  124418. * Gets or sets a boolean indicating if collisions are enabled on this scene
  124419. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124420. */
  124421. collisionsEnabled: boolean;
  124422. private _collisionCoordinator;
  124423. /** @hidden */
  124424. get collisionCoordinator(): ICollisionCoordinator;
  124425. /**
  124426. * Defines the gravity applied to this scene (used only for collisions)
  124427. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124428. */
  124429. gravity: Vector3;
  124430. /**
  124431. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  124432. */
  124433. postProcessesEnabled: boolean;
  124434. /**
  124435. * Gets the current postprocess manager
  124436. */
  124437. postProcessManager: PostProcessManager;
  124438. /**
  124439. * Gets or sets a boolean indicating if render targets are enabled on this scene
  124440. */
  124441. renderTargetsEnabled: boolean;
  124442. /**
  124443. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  124444. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  124445. */
  124446. dumpNextRenderTargets: boolean;
  124447. /**
  124448. * The list of user defined render targets added to the scene
  124449. */
  124450. customRenderTargets: RenderTargetTexture[];
  124451. /**
  124452. * Defines if texture loading must be delayed
  124453. * If true, textures will only be loaded when they need to be rendered
  124454. */
  124455. useDelayedTextureLoading: boolean;
  124456. /**
  124457. * Gets the list of meshes imported to the scene through SceneLoader
  124458. */
  124459. importedMeshesFiles: String[];
  124460. /**
  124461. * Gets or sets a boolean indicating if probes are enabled on this scene
  124462. */
  124463. probesEnabled: boolean;
  124464. /**
  124465. * Gets or sets the current offline provider to use to store scene data
  124466. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124467. */
  124468. offlineProvider: IOfflineProvider;
  124469. /**
  124470. * Gets or sets the action manager associated with the scene
  124471. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  124472. */
  124473. actionManager: AbstractActionManager;
  124474. private _meshesForIntersections;
  124475. /**
  124476. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  124477. */
  124478. proceduralTexturesEnabled: boolean;
  124479. private _engine;
  124480. private _totalVertices;
  124481. /** @hidden */
  124482. _activeIndices: PerfCounter;
  124483. /** @hidden */
  124484. _activeParticles: PerfCounter;
  124485. /** @hidden */
  124486. _activeBones: PerfCounter;
  124487. private _animationRatio;
  124488. /** @hidden */
  124489. _animationTimeLast: number;
  124490. /** @hidden */
  124491. _animationTime: number;
  124492. /**
  124493. * Gets or sets a general scale for animation speed
  124494. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  124495. */
  124496. animationTimeScale: number;
  124497. /** @hidden */
  124498. _cachedMaterial: Nullable<Material>;
  124499. /** @hidden */
  124500. _cachedEffect: Nullable<Effect>;
  124501. /** @hidden */
  124502. _cachedVisibility: Nullable<number>;
  124503. private _renderId;
  124504. private _frameId;
  124505. private _executeWhenReadyTimeoutId;
  124506. private _intermediateRendering;
  124507. private _viewUpdateFlag;
  124508. private _projectionUpdateFlag;
  124509. /** @hidden */
  124510. _toBeDisposed: Nullable<IDisposable>[];
  124511. private _activeRequests;
  124512. /** @hidden */
  124513. _pendingData: any[];
  124514. private _isDisposed;
  124515. /**
  124516. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  124517. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  124518. */
  124519. dispatchAllSubMeshesOfActiveMeshes: boolean;
  124520. private _activeMeshes;
  124521. private _processedMaterials;
  124522. private _renderTargets;
  124523. /** @hidden */
  124524. _activeParticleSystems: SmartArray<IParticleSystem>;
  124525. private _activeSkeletons;
  124526. private _softwareSkinnedMeshes;
  124527. private _renderingManager;
  124528. /** @hidden */
  124529. _activeAnimatables: Animatable[];
  124530. private _transformMatrix;
  124531. private _sceneUbo;
  124532. /** @hidden */
  124533. _viewMatrix: Matrix;
  124534. private _projectionMatrix;
  124535. /** @hidden */
  124536. _forcedViewPosition: Nullable<Vector3>;
  124537. /** @hidden */
  124538. _frustumPlanes: Plane[];
  124539. /**
  124540. * Gets the list of frustum planes (built from the active camera)
  124541. */
  124542. get frustumPlanes(): Plane[];
  124543. /**
  124544. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  124545. * This is useful if there are more lights that the maximum simulteanous authorized
  124546. */
  124547. requireLightSorting: boolean;
  124548. /** @hidden */
  124549. readonly useMaterialMeshMap: boolean;
  124550. /** @hidden */
  124551. readonly useClonedMeshMap: boolean;
  124552. private _externalData;
  124553. private _uid;
  124554. /**
  124555. * @hidden
  124556. * Backing store of defined scene components.
  124557. */
  124558. _components: ISceneComponent[];
  124559. /**
  124560. * @hidden
  124561. * Backing store of defined scene components.
  124562. */
  124563. _serializableComponents: ISceneSerializableComponent[];
  124564. /**
  124565. * List of components to register on the next registration step.
  124566. */
  124567. private _transientComponents;
  124568. /**
  124569. * Registers the transient components if needed.
  124570. */
  124571. private _registerTransientComponents;
  124572. /**
  124573. * @hidden
  124574. * Add a component to the scene.
  124575. * Note that the ccomponent could be registered on th next frame if this is called after
  124576. * the register component stage.
  124577. * @param component Defines the component to add to the scene
  124578. */
  124579. _addComponent(component: ISceneComponent): void;
  124580. /**
  124581. * @hidden
  124582. * Gets a component from the scene.
  124583. * @param name defines the name of the component to retrieve
  124584. * @returns the component or null if not present
  124585. */
  124586. _getComponent(name: string): Nullable<ISceneComponent>;
  124587. /**
  124588. * @hidden
  124589. * Defines the actions happening before camera updates.
  124590. */
  124591. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  124592. /**
  124593. * @hidden
  124594. * Defines the actions happening before clear the canvas.
  124595. */
  124596. _beforeClearStage: Stage<SimpleStageAction>;
  124597. /**
  124598. * @hidden
  124599. * Defines the actions when collecting render targets for the frame.
  124600. */
  124601. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124602. /**
  124603. * @hidden
  124604. * Defines the actions happening for one camera in the frame.
  124605. */
  124606. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124607. /**
  124608. * @hidden
  124609. * Defines the actions happening during the per mesh ready checks.
  124610. */
  124611. _isReadyForMeshStage: Stage<MeshStageAction>;
  124612. /**
  124613. * @hidden
  124614. * Defines the actions happening before evaluate active mesh checks.
  124615. */
  124616. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  124617. /**
  124618. * @hidden
  124619. * Defines the actions happening during the evaluate sub mesh checks.
  124620. */
  124621. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  124622. /**
  124623. * @hidden
  124624. * Defines the actions happening during the active mesh stage.
  124625. */
  124626. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  124627. /**
  124628. * @hidden
  124629. * Defines the actions happening during the per camera render target step.
  124630. */
  124631. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  124632. /**
  124633. * @hidden
  124634. * Defines the actions happening just before the active camera is drawing.
  124635. */
  124636. _beforeCameraDrawStage: Stage<CameraStageAction>;
  124637. /**
  124638. * @hidden
  124639. * Defines the actions happening just before a render target is drawing.
  124640. */
  124641. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124642. /**
  124643. * @hidden
  124644. * Defines the actions happening just before a rendering group is drawing.
  124645. */
  124646. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124647. /**
  124648. * @hidden
  124649. * Defines the actions happening just before a mesh is drawing.
  124650. */
  124651. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124652. /**
  124653. * @hidden
  124654. * Defines the actions happening just after a mesh has been drawn.
  124655. */
  124656. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124657. /**
  124658. * @hidden
  124659. * Defines the actions happening just after a rendering group has been drawn.
  124660. */
  124661. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124662. /**
  124663. * @hidden
  124664. * Defines the actions happening just after the active camera has been drawn.
  124665. */
  124666. _afterCameraDrawStage: Stage<CameraStageAction>;
  124667. /**
  124668. * @hidden
  124669. * Defines the actions happening just after a render target has been drawn.
  124670. */
  124671. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124672. /**
  124673. * @hidden
  124674. * Defines the actions happening just after rendering all cameras and computing intersections.
  124675. */
  124676. _afterRenderStage: Stage<SimpleStageAction>;
  124677. /**
  124678. * @hidden
  124679. * Defines the actions happening when a pointer move event happens.
  124680. */
  124681. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124682. /**
  124683. * @hidden
  124684. * Defines the actions happening when a pointer down event happens.
  124685. */
  124686. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124687. /**
  124688. * @hidden
  124689. * Defines the actions happening when a pointer up event happens.
  124690. */
  124691. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124692. /**
  124693. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124694. */
  124695. private geometriesByUniqueId;
  124696. /**
  124697. * Creates a new Scene
  124698. * @param engine defines the engine to use to render this scene
  124699. * @param options defines the scene options
  124700. */
  124701. constructor(engine: Engine, options?: SceneOptions);
  124702. /**
  124703. * Gets a string identifying the name of the class
  124704. * @returns "Scene" string
  124705. */
  124706. getClassName(): string;
  124707. private _defaultMeshCandidates;
  124708. /**
  124709. * @hidden
  124710. */
  124711. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124712. private _defaultSubMeshCandidates;
  124713. /**
  124714. * @hidden
  124715. */
  124716. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124717. /**
  124718. * Sets the default candidate providers for the scene.
  124719. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124720. * and getCollidingSubMeshCandidates to their default function
  124721. */
  124722. setDefaultCandidateProviders(): void;
  124723. /**
  124724. * Gets the mesh that is currently under the pointer
  124725. */
  124726. get meshUnderPointer(): Nullable<AbstractMesh>;
  124727. /**
  124728. * Gets or sets the current on-screen X position of the pointer
  124729. */
  124730. get pointerX(): number;
  124731. set pointerX(value: number);
  124732. /**
  124733. * Gets or sets the current on-screen Y position of the pointer
  124734. */
  124735. get pointerY(): number;
  124736. set pointerY(value: number);
  124737. /**
  124738. * Gets the cached material (ie. the latest rendered one)
  124739. * @returns the cached material
  124740. */
  124741. getCachedMaterial(): Nullable<Material>;
  124742. /**
  124743. * Gets the cached effect (ie. the latest rendered one)
  124744. * @returns the cached effect
  124745. */
  124746. getCachedEffect(): Nullable<Effect>;
  124747. /**
  124748. * Gets the cached visibility state (ie. the latest rendered one)
  124749. * @returns the cached visibility state
  124750. */
  124751. getCachedVisibility(): Nullable<number>;
  124752. /**
  124753. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124754. * @param material defines the current material
  124755. * @param effect defines the current effect
  124756. * @param visibility defines the current visibility state
  124757. * @returns true if one parameter is not cached
  124758. */
  124759. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124760. /**
  124761. * Gets the engine associated with the scene
  124762. * @returns an Engine
  124763. */
  124764. getEngine(): Engine;
  124765. /**
  124766. * Gets the total number of vertices rendered per frame
  124767. * @returns the total number of vertices rendered per frame
  124768. */
  124769. getTotalVertices(): number;
  124770. /**
  124771. * Gets the performance counter for total vertices
  124772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124773. */
  124774. get totalVerticesPerfCounter(): PerfCounter;
  124775. /**
  124776. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124777. * @returns the total number of active indices rendered per frame
  124778. */
  124779. getActiveIndices(): number;
  124780. /**
  124781. * Gets the performance counter for active indices
  124782. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124783. */
  124784. get totalActiveIndicesPerfCounter(): PerfCounter;
  124785. /**
  124786. * Gets the total number of active particles rendered per frame
  124787. * @returns the total number of active particles rendered per frame
  124788. */
  124789. getActiveParticles(): number;
  124790. /**
  124791. * Gets the performance counter for active particles
  124792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124793. */
  124794. get activeParticlesPerfCounter(): PerfCounter;
  124795. /**
  124796. * Gets the total number of active bones rendered per frame
  124797. * @returns the total number of active bones rendered per frame
  124798. */
  124799. getActiveBones(): number;
  124800. /**
  124801. * Gets the performance counter for active bones
  124802. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124803. */
  124804. get activeBonesPerfCounter(): PerfCounter;
  124805. /**
  124806. * Gets the array of active meshes
  124807. * @returns an array of AbstractMesh
  124808. */
  124809. getActiveMeshes(): SmartArray<AbstractMesh>;
  124810. /**
  124811. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124812. * @returns a number
  124813. */
  124814. getAnimationRatio(): number;
  124815. /**
  124816. * Gets an unique Id for the current render phase
  124817. * @returns a number
  124818. */
  124819. getRenderId(): number;
  124820. /**
  124821. * Gets an unique Id for the current frame
  124822. * @returns a number
  124823. */
  124824. getFrameId(): number;
  124825. /** Call this function if you want to manually increment the render Id*/
  124826. incrementRenderId(): void;
  124827. private _createUbo;
  124828. /**
  124829. * Use this method to simulate a pointer move on a mesh
  124830. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124831. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124832. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124833. * @returns the current scene
  124834. */
  124835. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124836. /**
  124837. * Use this method to simulate a pointer down on a mesh
  124838. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124839. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124840. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124841. * @returns the current scene
  124842. */
  124843. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124844. /**
  124845. * Use this method to simulate a pointer up on a mesh
  124846. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124847. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124848. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124849. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124850. * @returns the current scene
  124851. */
  124852. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124853. /**
  124854. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124855. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124856. * @returns true if the pointer was captured
  124857. */
  124858. isPointerCaptured(pointerId?: number): boolean;
  124859. /**
  124860. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124861. * @param attachUp defines if you want to attach events to pointerup
  124862. * @param attachDown defines if you want to attach events to pointerdown
  124863. * @param attachMove defines if you want to attach events to pointermove
  124864. */
  124865. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124866. /** Detaches all event handlers*/
  124867. detachControl(): void;
  124868. /**
  124869. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124870. * Delay loaded resources are not taking in account
  124871. * @return true if all required resources are ready
  124872. */
  124873. isReady(): boolean;
  124874. /** Resets all cached information relative to material (including effect and visibility) */
  124875. resetCachedMaterial(): void;
  124876. /**
  124877. * Registers a function to be called before every frame render
  124878. * @param func defines the function to register
  124879. */
  124880. registerBeforeRender(func: () => void): void;
  124881. /**
  124882. * Unregisters a function called before every frame render
  124883. * @param func defines the function to unregister
  124884. */
  124885. unregisterBeforeRender(func: () => void): void;
  124886. /**
  124887. * Registers a function to be called after every frame render
  124888. * @param func defines the function to register
  124889. */
  124890. registerAfterRender(func: () => void): void;
  124891. /**
  124892. * Unregisters a function called after every frame render
  124893. * @param func defines the function to unregister
  124894. */
  124895. unregisterAfterRender(func: () => void): void;
  124896. private _executeOnceBeforeRender;
  124897. /**
  124898. * The provided function will run before render once and will be disposed afterwards.
  124899. * A timeout delay can be provided so that the function will be executed in N ms.
  124900. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124901. * @param func The function to be executed.
  124902. * @param timeout optional delay in ms
  124903. */
  124904. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124905. /** @hidden */
  124906. _addPendingData(data: any): void;
  124907. /** @hidden */
  124908. _removePendingData(data: any): void;
  124909. /**
  124910. * Returns the number of items waiting to be loaded
  124911. * @returns the number of items waiting to be loaded
  124912. */
  124913. getWaitingItemsCount(): number;
  124914. /**
  124915. * Returns a boolean indicating if the scene is still loading data
  124916. */
  124917. get isLoading(): boolean;
  124918. /**
  124919. * Registers a function to be executed when the scene is ready
  124920. * @param {Function} func - the function to be executed
  124921. */
  124922. executeWhenReady(func: () => void): void;
  124923. /**
  124924. * Returns a promise that resolves when the scene is ready
  124925. * @returns A promise that resolves when the scene is ready
  124926. */
  124927. whenReadyAsync(): Promise<void>;
  124928. /** @hidden */
  124929. _checkIsReady(): void;
  124930. /**
  124931. * Gets all animatable attached to the scene
  124932. */
  124933. get animatables(): Animatable[];
  124934. /**
  124935. * Resets the last animation time frame.
  124936. * Useful to override when animations start running when loading a scene for the first time.
  124937. */
  124938. resetLastAnimationTimeFrame(): void;
  124939. /**
  124940. * Gets the current view matrix
  124941. * @returns a Matrix
  124942. */
  124943. getViewMatrix(): Matrix;
  124944. /**
  124945. * Gets the current projection matrix
  124946. * @returns a Matrix
  124947. */
  124948. getProjectionMatrix(): Matrix;
  124949. /**
  124950. * Gets the current transform matrix
  124951. * @returns a Matrix made of View * Projection
  124952. */
  124953. getTransformMatrix(): Matrix;
  124954. /**
  124955. * Sets the current transform matrix
  124956. * @param viewL defines the View matrix to use
  124957. * @param projectionL defines the Projection matrix to use
  124958. * @param viewR defines the right View matrix to use (if provided)
  124959. * @param projectionR defines the right Projection matrix to use (if provided)
  124960. */
  124961. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124962. /**
  124963. * Gets the uniform buffer used to store scene data
  124964. * @returns a UniformBuffer
  124965. */
  124966. getSceneUniformBuffer(): UniformBuffer;
  124967. /**
  124968. * Gets an unique (relatively to the current scene) Id
  124969. * @returns an unique number for the scene
  124970. */
  124971. getUniqueId(): number;
  124972. /**
  124973. * Add a mesh to the list of scene's meshes
  124974. * @param newMesh defines the mesh to add
  124975. * @param recursive if all child meshes should also be added to the scene
  124976. */
  124977. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124978. /**
  124979. * Remove a mesh for the list of scene's meshes
  124980. * @param toRemove defines the mesh to remove
  124981. * @param recursive if all child meshes should also be removed from the scene
  124982. * @returns the index where the mesh was in the mesh list
  124983. */
  124984. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124985. /**
  124986. * Add a transform node to the list of scene's transform nodes
  124987. * @param newTransformNode defines the transform node to add
  124988. */
  124989. addTransformNode(newTransformNode: TransformNode): void;
  124990. /**
  124991. * Remove a transform node for the list of scene's transform nodes
  124992. * @param toRemove defines the transform node to remove
  124993. * @returns the index where the transform node was in the transform node list
  124994. */
  124995. removeTransformNode(toRemove: TransformNode): number;
  124996. /**
  124997. * Remove a skeleton for the list of scene's skeletons
  124998. * @param toRemove defines the skeleton to remove
  124999. * @returns the index where the skeleton was in the skeleton list
  125000. */
  125001. removeSkeleton(toRemove: Skeleton): number;
  125002. /**
  125003. * Remove a morph target for the list of scene's morph targets
  125004. * @param toRemove defines the morph target to remove
  125005. * @returns the index where the morph target was in the morph target list
  125006. */
  125007. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125008. /**
  125009. * Remove a light for the list of scene's lights
  125010. * @param toRemove defines the light to remove
  125011. * @returns the index where the light was in the light list
  125012. */
  125013. removeLight(toRemove: Light): number;
  125014. /**
  125015. * Remove a camera for the list of scene's cameras
  125016. * @param toRemove defines the camera to remove
  125017. * @returns the index where the camera was in the camera list
  125018. */
  125019. removeCamera(toRemove: Camera): number;
  125020. /**
  125021. * Remove a particle system for the list of scene's particle systems
  125022. * @param toRemove defines the particle system to remove
  125023. * @returns the index where the particle system was in the particle system list
  125024. */
  125025. removeParticleSystem(toRemove: IParticleSystem): number;
  125026. /**
  125027. * Remove a animation for the list of scene's animations
  125028. * @param toRemove defines the animation to remove
  125029. * @returns the index where the animation was in the animation list
  125030. */
  125031. removeAnimation(toRemove: Animation): number;
  125032. /**
  125033. * Will stop the animation of the given target
  125034. * @param target - the target
  125035. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125036. * @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)
  125037. */
  125038. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125039. /**
  125040. * Removes the given animation group from this scene.
  125041. * @param toRemove The animation group to remove
  125042. * @returns The index of the removed animation group
  125043. */
  125044. removeAnimationGroup(toRemove: AnimationGroup): number;
  125045. /**
  125046. * Removes the given multi-material from this scene.
  125047. * @param toRemove The multi-material to remove
  125048. * @returns The index of the removed multi-material
  125049. */
  125050. removeMultiMaterial(toRemove: MultiMaterial): number;
  125051. /**
  125052. * Removes the given material from this scene.
  125053. * @param toRemove The material to remove
  125054. * @returns The index of the removed material
  125055. */
  125056. removeMaterial(toRemove: Material): number;
  125057. /**
  125058. * Removes the given action manager from this scene.
  125059. * @param toRemove The action manager to remove
  125060. * @returns The index of the removed action manager
  125061. */
  125062. removeActionManager(toRemove: AbstractActionManager): number;
  125063. /**
  125064. * Removes the given texture from this scene.
  125065. * @param toRemove The texture to remove
  125066. * @returns The index of the removed texture
  125067. */
  125068. removeTexture(toRemove: BaseTexture): number;
  125069. /**
  125070. * Adds the given light to this scene
  125071. * @param newLight The light to add
  125072. */
  125073. addLight(newLight: Light): void;
  125074. /**
  125075. * Sorts the list list based on light priorities
  125076. */
  125077. sortLightsByPriority(): void;
  125078. /**
  125079. * Adds the given camera to this scene
  125080. * @param newCamera The camera to add
  125081. */
  125082. addCamera(newCamera: Camera): void;
  125083. /**
  125084. * Adds the given skeleton to this scene
  125085. * @param newSkeleton The skeleton to add
  125086. */
  125087. addSkeleton(newSkeleton: Skeleton): void;
  125088. /**
  125089. * Adds the given particle system to this scene
  125090. * @param newParticleSystem The particle system to add
  125091. */
  125092. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125093. /**
  125094. * Adds the given animation to this scene
  125095. * @param newAnimation The animation to add
  125096. */
  125097. addAnimation(newAnimation: Animation): void;
  125098. /**
  125099. * Adds the given animation group to this scene.
  125100. * @param newAnimationGroup The animation group to add
  125101. */
  125102. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125103. /**
  125104. * Adds the given multi-material to this scene
  125105. * @param newMultiMaterial The multi-material to add
  125106. */
  125107. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125108. /**
  125109. * Adds the given material to this scene
  125110. * @param newMaterial The material to add
  125111. */
  125112. addMaterial(newMaterial: Material): void;
  125113. /**
  125114. * Adds the given morph target to this scene
  125115. * @param newMorphTargetManager The morph target to add
  125116. */
  125117. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125118. /**
  125119. * Adds the given geometry to this scene
  125120. * @param newGeometry The geometry to add
  125121. */
  125122. addGeometry(newGeometry: Geometry): void;
  125123. /**
  125124. * Adds the given action manager to this scene
  125125. * @param newActionManager The action manager to add
  125126. */
  125127. addActionManager(newActionManager: AbstractActionManager): void;
  125128. /**
  125129. * Adds the given texture to this scene.
  125130. * @param newTexture The texture to add
  125131. */
  125132. addTexture(newTexture: BaseTexture): void;
  125133. /**
  125134. * Switch active camera
  125135. * @param newCamera defines the new active camera
  125136. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125137. */
  125138. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125139. /**
  125140. * sets the active camera of the scene using its ID
  125141. * @param id defines the camera's ID
  125142. * @return the new active camera or null if none found.
  125143. */
  125144. setActiveCameraByID(id: string): Nullable<Camera>;
  125145. /**
  125146. * sets the active camera of the scene using its name
  125147. * @param name defines the camera's name
  125148. * @returns the new active camera or null if none found.
  125149. */
  125150. setActiveCameraByName(name: string): Nullable<Camera>;
  125151. /**
  125152. * get an animation group using its name
  125153. * @param name defines the material's name
  125154. * @return the animation group or null if none found.
  125155. */
  125156. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125157. /**
  125158. * Get a material using its unique id
  125159. * @param uniqueId defines the material's unique id
  125160. * @return the material or null if none found.
  125161. */
  125162. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125163. /**
  125164. * get a material using its id
  125165. * @param id defines the material's ID
  125166. * @return the material or null if none found.
  125167. */
  125168. getMaterialByID(id: string): Nullable<Material>;
  125169. /**
  125170. * Gets a the last added material using a given id
  125171. * @param id defines the material's ID
  125172. * @return the last material with the given id or null if none found.
  125173. */
  125174. getLastMaterialByID(id: string): Nullable<Material>;
  125175. /**
  125176. * Gets a material using its name
  125177. * @param name defines the material's name
  125178. * @return the material or null if none found.
  125179. */
  125180. getMaterialByName(name: string): Nullable<Material>;
  125181. /**
  125182. * Get a texture using its unique id
  125183. * @param uniqueId defines the texture's unique id
  125184. * @return the texture or null if none found.
  125185. */
  125186. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125187. /**
  125188. * Gets a camera using its id
  125189. * @param id defines the id to look for
  125190. * @returns the camera or null if not found
  125191. */
  125192. getCameraByID(id: string): Nullable<Camera>;
  125193. /**
  125194. * Gets a camera using its unique id
  125195. * @param uniqueId defines the unique id to look for
  125196. * @returns the camera or null if not found
  125197. */
  125198. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125199. /**
  125200. * Gets a camera using its name
  125201. * @param name defines the camera's name
  125202. * @return the camera or null if none found.
  125203. */
  125204. getCameraByName(name: string): Nullable<Camera>;
  125205. /**
  125206. * Gets a bone using its id
  125207. * @param id defines the bone's id
  125208. * @return the bone or null if not found
  125209. */
  125210. getBoneByID(id: string): Nullable<Bone>;
  125211. /**
  125212. * Gets a bone using its id
  125213. * @param name defines the bone's name
  125214. * @return the bone or null if not found
  125215. */
  125216. getBoneByName(name: string): Nullable<Bone>;
  125217. /**
  125218. * Gets a light node using its name
  125219. * @param name defines the the light's name
  125220. * @return the light or null if none found.
  125221. */
  125222. getLightByName(name: string): Nullable<Light>;
  125223. /**
  125224. * Gets a light node using its id
  125225. * @param id defines the light's id
  125226. * @return the light or null if none found.
  125227. */
  125228. getLightByID(id: string): Nullable<Light>;
  125229. /**
  125230. * Gets a light node using its scene-generated unique ID
  125231. * @param uniqueId defines the light's unique id
  125232. * @return the light or null if none found.
  125233. */
  125234. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125235. /**
  125236. * Gets a particle system by id
  125237. * @param id defines the particle system id
  125238. * @return the corresponding system or null if none found
  125239. */
  125240. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125241. /**
  125242. * Gets a geometry using its ID
  125243. * @param id defines the geometry's id
  125244. * @return the geometry or null if none found.
  125245. */
  125246. getGeometryByID(id: string): Nullable<Geometry>;
  125247. private _getGeometryByUniqueID;
  125248. /**
  125249. * Add a new geometry to this scene
  125250. * @param geometry defines the geometry to be added to the scene.
  125251. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125252. * @return a boolean defining if the geometry was added or not
  125253. */
  125254. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125255. /**
  125256. * Removes an existing geometry
  125257. * @param geometry defines the geometry to be removed from the scene
  125258. * @return a boolean defining if the geometry was removed or not
  125259. */
  125260. removeGeometry(geometry: Geometry): boolean;
  125261. /**
  125262. * Gets the list of geometries attached to the scene
  125263. * @returns an array of Geometry
  125264. */
  125265. getGeometries(): Geometry[];
  125266. /**
  125267. * Gets the first added mesh found of a given ID
  125268. * @param id defines the id to search for
  125269. * @return the mesh found or null if not found at all
  125270. */
  125271. getMeshByID(id: string): Nullable<AbstractMesh>;
  125272. /**
  125273. * Gets a list of meshes using their id
  125274. * @param id defines the id to search for
  125275. * @returns a list of meshes
  125276. */
  125277. getMeshesByID(id: string): Array<AbstractMesh>;
  125278. /**
  125279. * Gets the first added transform node found of a given ID
  125280. * @param id defines the id to search for
  125281. * @return the found transform node or null if not found at all.
  125282. */
  125283. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125284. /**
  125285. * Gets a transform node with its auto-generated unique id
  125286. * @param uniqueId efines the unique id to search for
  125287. * @return the found transform node or null if not found at all.
  125288. */
  125289. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125290. /**
  125291. * Gets a list of transform nodes using their id
  125292. * @param id defines the id to search for
  125293. * @returns a list of transform nodes
  125294. */
  125295. getTransformNodesByID(id: string): Array<TransformNode>;
  125296. /**
  125297. * Gets a mesh with its auto-generated unique id
  125298. * @param uniqueId defines the unique id to search for
  125299. * @return the found mesh or null if not found at all.
  125300. */
  125301. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125302. /**
  125303. * Gets a the last added mesh using a given id
  125304. * @param id defines the id to search for
  125305. * @return the found mesh or null if not found at all.
  125306. */
  125307. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125308. /**
  125309. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125310. * @param id defines the id to search for
  125311. * @return the found node or null if not found at all
  125312. */
  125313. getLastEntryByID(id: string): Nullable<Node>;
  125314. /**
  125315. * Gets a node (Mesh, Camera, Light) using a given id
  125316. * @param id defines the id to search for
  125317. * @return the found node or null if not found at all
  125318. */
  125319. getNodeByID(id: string): Nullable<Node>;
  125320. /**
  125321. * Gets a node (Mesh, Camera, Light) using a given name
  125322. * @param name defines the name to search for
  125323. * @return the found node or null if not found at all.
  125324. */
  125325. getNodeByName(name: string): Nullable<Node>;
  125326. /**
  125327. * Gets a mesh using a given name
  125328. * @param name defines the name to search for
  125329. * @return the found mesh or null if not found at all.
  125330. */
  125331. getMeshByName(name: string): Nullable<AbstractMesh>;
  125332. /**
  125333. * Gets a transform node using a given name
  125334. * @param name defines the name to search for
  125335. * @return the found transform node or null if not found at all.
  125336. */
  125337. getTransformNodeByName(name: string): Nullable<TransformNode>;
  125338. /**
  125339. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  125340. * @param id defines the id to search for
  125341. * @return the found skeleton or null if not found at all.
  125342. */
  125343. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  125344. /**
  125345. * Gets a skeleton using a given auto generated unique id
  125346. * @param uniqueId defines the unique id to search for
  125347. * @return the found skeleton or null if not found at all.
  125348. */
  125349. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  125350. /**
  125351. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  125352. * @param id defines the id to search for
  125353. * @return the found skeleton or null if not found at all.
  125354. */
  125355. getSkeletonById(id: string): Nullable<Skeleton>;
  125356. /**
  125357. * Gets a skeleton using a given name
  125358. * @param name defines the name to search for
  125359. * @return the found skeleton or null if not found at all.
  125360. */
  125361. getSkeletonByName(name: string): Nullable<Skeleton>;
  125362. /**
  125363. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  125364. * @param id defines the id to search for
  125365. * @return the found morph target manager or null if not found at all.
  125366. */
  125367. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  125368. /**
  125369. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  125370. * @param id defines the id to search for
  125371. * @return the found morph target or null if not found at all.
  125372. */
  125373. getMorphTargetById(id: string): Nullable<MorphTarget>;
  125374. /**
  125375. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  125376. * @param name defines the name to search for
  125377. * @return the found morph target or null if not found at all.
  125378. */
  125379. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  125380. /**
  125381. * Gets a post process using a given name (if many are found, this function will pick the first one)
  125382. * @param name defines the name to search for
  125383. * @return the found post process or null if not found at all.
  125384. */
  125385. getPostProcessByName(name: string): Nullable<PostProcess>;
  125386. /**
  125387. * Gets a boolean indicating if the given mesh is active
  125388. * @param mesh defines the mesh to look for
  125389. * @returns true if the mesh is in the active list
  125390. */
  125391. isActiveMesh(mesh: AbstractMesh): boolean;
  125392. /**
  125393. * Return a unique id as a string which can serve as an identifier for the scene
  125394. */
  125395. get uid(): string;
  125396. /**
  125397. * Add an externaly attached data from its key.
  125398. * This method call will fail and return false, if such key already exists.
  125399. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  125400. * @param key the unique key that identifies the data
  125401. * @param data the data object to associate to the key for this Engine instance
  125402. * @return true if no such key were already present and the data was added successfully, false otherwise
  125403. */
  125404. addExternalData<T>(key: string, data: T): boolean;
  125405. /**
  125406. * Get an externaly attached data from its key
  125407. * @param key the unique key that identifies the data
  125408. * @return the associated data, if present (can be null), or undefined if not present
  125409. */
  125410. getExternalData<T>(key: string): Nullable<T>;
  125411. /**
  125412. * Get an externaly attached data from its key, create it using a factory if it's not already present
  125413. * @param key the unique key that identifies the data
  125414. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  125415. * @return the associated data, can be null if the factory returned null.
  125416. */
  125417. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  125418. /**
  125419. * Remove an externaly attached data from the Engine instance
  125420. * @param key the unique key that identifies the data
  125421. * @return true if the data was successfully removed, false if it doesn't exist
  125422. */
  125423. removeExternalData(key: string): boolean;
  125424. private _evaluateSubMesh;
  125425. /**
  125426. * Clear the processed materials smart array preventing retention point in material dispose.
  125427. */
  125428. freeProcessedMaterials(): void;
  125429. private _preventFreeActiveMeshesAndRenderingGroups;
  125430. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  125431. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  125432. * when disposing several meshes in a row or a hierarchy of meshes.
  125433. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  125434. */
  125435. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  125436. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  125437. /**
  125438. * Clear the active meshes smart array preventing retention point in mesh dispose.
  125439. */
  125440. freeActiveMeshes(): void;
  125441. /**
  125442. * Clear the info related to rendering groups preventing retention points during dispose.
  125443. */
  125444. freeRenderingGroups(): void;
  125445. /** @hidden */
  125446. _isInIntermediateRendering(): boolean;
  125447. /**
  125448. * Lambda returning the list of potentially active meshes.
  125449. */
  125450. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  125451. /**
  125452. * Lambda returning the list of potentially active sub meshes.
  125453. */
  125454. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  125455. /**
  125456. * Lambda returning the list of potentially intersecting sub meshes.
  125457. */
  125458. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  125459. /**
  125460. * Lambda returning the list of potentially colliding sub meshes.
  125461. */
  125462. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  125463. private _activeMeshesFrozen;
  125464. private _skipEvaluateActiveMeshesCompletely;
  125465. /**
  125466. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  125467. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  125468. * @param onSuccess optional success callback
  125469. * @param onError optional error callback
  125470. * @returns the current scene
  125471. */
  125472. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  125473. /**
  125474. * Use this function to restart evaluating active meshes on every frame
  125475. * @returns the current scene
  125476. */
  125477. unfreezeActiveMeshes(): Scene;
  125478. private _evaluateActiveMeshes;
  125479. private _activeMesh;
  125480. /**
  125481. * Update the transform matrix to update from the current active camera
  125482. * @param force defines a boolean used to force the update even if cache is up to date
  125483. */
  125484. updateTransformMatrix(force?: boolean): void;
  125485. private _bindFrameBuffer;
  125486. /** @hidden */
  125487. _allowPostProcessClearColor: boolean;
  125488. /** @hidden */
  125489. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  125490. private _processSubCameras;
  125491. private _checkIntersections;
  125492. /** @hidden */
  125493. _advancePhysicsEngineStep(step: number): void;
  125494. /**
  125495. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  125496. */
  125497. getDeterministicFrameTime: () => number;
  125498. /** @hidden */
  125499. _animate(): void;
  125500. /** Execute all animations (for a frame) */
  125501. animate(): void;
  125502. /**
  125503. * Render the scene
  125504. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  125505. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  125506. */
  125507. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  125508. /**
  125509. * Freeze all materials
  125510. * A frozen material will not be updatable but should be faster to render
  125511. */
  125512. freezeMaterials(): void;
  125513. /**
  125514. * Unfreeze all materials
  125515. * A frozen material will not be updatable but should be faster to render
  125516. */
  125517. unfreezeMaterials(): void;
  125518. /**
  125519. * Releases all held ressources
  125520. */
  125521. dispose(): void;
  125522. /**
  125523. * Gets if the scene is already disposed
  125524. */
  125525. get isDisposed(): boolean;
  125526. /**
  125527. * Call this function to reduce memory footprint of the scene.
  125528. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  125529. */
  125530. clearCachedVertexData(): void;
  125531. /**
  125532. * This function will remove the local cached buffer data from texture.
  125533. * It will save memory but will prevent the texture from being rebuilt
  125534. */
  125535. cleanCachedTextureBuffer(): void;
  125536. /**
  125537. * Get the world extend vectors with an optional filter
  125538. *
  125539. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  125540. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  125541. */
  125542. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  125543. min: Vector3;
  125544. max: Vector3;
  125545. };
  125546. /**
  125547. * Creates a ray that can be used to pick in the scene
  125548. * @param x defines the x coordinate of the origin (on-screen)
  125549. * @param y defines the y coordinate of the origin (on-screen)
  125550. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125551. * @param camera defines the camera to use for the picking
  125552. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125553. * @returns a Ray
  125554. */
  125555. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  125556. /**
  125557. * Creates a ray that can be used to pick in the scene
  125558. * @param x defines the x coordinate of the origin (on-screen)
  125559. * @param y defines the y coordinate of the origin (on-screen)
  125560. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125561. * @param result defines the ray where to store the picking ray
  125562. * @param camera defines the camera to use for the picking
  125563. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125564. * @returns the current scene
  125565. */
  125566. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  125567. /**
  125568. * Creates a ray that can be used to pick in the scene
  125569. * @param x defines the x coordinate of the origin (on-screen)
  125570. * @param y defines the y coordinate of the origin (on-screen)
  125571. * @param camera defines the camera to use for the picking
  125572. * @returns a Ray
  125573. */
  125574. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  125575. /**
  125576. * Creates a ray that can be used to pick in the scene
  125577. * @param x defines the x coordinate of the origin (on-screen)
  125578. * @param y defines the y coordinate of the origin (on-screen)
  125579. * @param result defines the ray where to store the picking ray
  125580. * @param camera defines the camera to use for the picking
  125581. * @returns the current scene
  125582. */
  125583. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  125584. /** Launch a ray to try to pick a mesh in the scene
  125585. * @param x position on screen
  125586. * @param y position on screen
  125587. * @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
  125588. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125589. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125590. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125591. * @returns a PickingInfo
  125592. */
  125593. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125594. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  125595. * @param x position on screen
  125596. * @param y position on screen
  125597. * @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
  125598. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125599. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125600. * @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)
  125601. */
  125602. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  125603. /** Use the given ray to pick a mesh in the scene
  125604. * @param ray The ray to use to pick meshes
  125605. * @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
  125606. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125607. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125608. * @returns a PickingInfo
  125609. */
  125610. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125611. /**
  125612. * Launch a ray to try to pick a mesh in the scene
  125613. * @param x X position on screen
  125614. * @param y Y position on screen
  125615. * @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
  125616. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125617. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125618. * @returns an array of PickingInfo
  125619. */
  125620. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125621. /**
  125622. * Launch a ray to try to pick a mesh in the scene
  125623. * @param ray Ray to use
  125624. * @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
  125625. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125626. * @returns an array of PickingInfo
  125627. */
  125628. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125629. /**
  125630. * Force the value of meshUnderPointer
  125631. * @param mesh defines the mesh to use
  125632. * @param pointerId optional pointer id when using more than one pointer
  125633. */
  125634. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  125635. /**
  125636. * Gets the mesh under the pointer
  125637. * @returns a Mesh or null if no mesh is under the pointer
  125638. */
  125639. getPointerOverMesh(): Nullable<AbstractMesh>;
  125640. /** @hidden */
  125641. _rebuildGeometries(): void;
  125642. /** @hidden */
  125643. _rebuildTextures(): void;
  125644. private _getByTags;
  125645. /**
  125646. * Get a list of meshes by tags
  125647. * @param tagsQuery defines the tags query to use
  125648. * @param forEach defines a predicate used to filter results
  125649. * @returns an array of Mesh
  125650. */
  125651. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  125652. /**
  125653. * Get a list of cameras by tags
  125654. * @param tagsQuery defines the tags query to use
  125655. * @param forEach defines a predicate used to filter results
  125656. * @returns an array of Camera
  125657. */
  125658. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  125659. /**
  125660. * Get a list of lights by tags
  125661. * @param tagsQuery defines the tags query to use
  125662. * @param forEach defines a predicate used to filter results
  125663. * @returns an array of Light
  125664. */
  125665. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  125666. /**
  125667. * Get a list of materials by tags
  125668. * @param tagsQuery defines the tags query to use
  125669. * @param forEach defines a predicate used to filter results
  125670. * @returns an array of Material
  125671. */
  125672. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  125673. /**
  125674. * Get a list of transform nodes by tags
  125675. * @param tagsQuery defines the tags query to use
  125676. * @param forEach defines a predicate used to filter results
  125677. * @returns an array of TransformNode
  125678. */
  125679. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125680. /**
  125681. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125682. * This allowed control for front to back rendering or reversly depending of the special needs.
  125683. *
  125684. * @param renderingGroupId The rendering group id corresponding to its index
  125685. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125686. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125687. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125688. */
  125689. 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;
  125690. /**
  125691. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125692. *
  125693. * @param renderingGroupId The rendering group id corresponding to its index
  125694. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125695. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125696. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125697. */
  125698. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125699. /**
  125700. * Gets the current auto clear configuration for one rendering group of the rendering
  125701. * manager.
  125702. * @param index the rendering group index to get the information for
  125703. * @returns The auto clear setup for the requested rendering group
  125704. */
  125705. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125706. private _blockMaterialDirtyMechanism;
  125707. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125708. get blockMaterialDirtyMechanism(): boolean;
  125709. set blockMaterialDirtyMechanism(value: boolean);
  125710. /**
  125711. * Will flag all materials as dirty to trigger new shader compilation
  125712. * @param flag defines the flag used to specify which material part must be marked as dirty
  125713. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125714. */
  125715. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125716. /** @hidden */
  125717. _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;
  125718. /** @hidden */
  125719. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125720. /** @hidden */
  125721. _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;
  125722. /** @hidden */
  125723. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125724. /** @hidden */
  125725. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125726. /** @hidden */
  125727. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125728. }
  125729. }
  125730. declare module BABYLON {
  125731. /**
  125732. * Set of assets to keep when moving a scene into an asset container.
  125733. */
  125734. export class KeepAssets extends AbstractScene {
  125735. }
  125736. /**
  125737. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125738. */
  125739. export class InstantiatedEntries {
  125740. /**
  125741. * List of new root nodes (eg. nodes with no parent)
  125742. */
  125743. rootNodes: TransformNode[];
  125744. /**
  125745. * List of new skeletons
  125746. */
  125747. skeletons: Skeleton[];
  125748. /**
  125749. * List of new animation groups
  125750. */
  125751. animationGroups: AnimationGroup[];
  125752. }
  125753. /**
  125754. * Container with a set of assets that can be added or removed from a scene.
  125755. */
  125756. export class AssetContainer extends AbstractScene {
  125757. private _wasAddedToScene;
  125758. /**
  125759. * The scene the AssetContainer belongs to.
  125760. */
  125761. scene: Scene;
  125762. /**
  125763. * Instantiates an AssetContainer.
  125764. * @param scene The scene the AssetContainer belongs to.
  125765. */
  125766. constructor(scene: Scene);
  125767. /**
  125768. * Instantiate or clone all meshes and add the new ones to the scene.
  125769. * Skeletons and animation groups will all be cloned
  125770. * @param nameFunction defines an optional function used to get new names for clones
  125771. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125772. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125773. */
  125774. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125775. /**
  125776. * Adds all the assets from the container to the scene.
  125777. */
  125778. addAllToScene(): void;
  125779. /**
  125780. * Removes all the assets in the container from the scene
  125781. */
  125782. removeAllFromScene(): void;
  125783. /**
  125784. * Disposes all the assets in the container
  125785. */
  125786. dispose(): void;
  125787. private _moveAssets;
  125788. /**
  125789. * Removes all the assets contained in the scene and adds them to the container.
  125790. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125791. */
  125792. moveAllFromScene(keepAssets?: KeepAssets): void;
  125793. /**
  125794. * 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.
  125795. * @returns the root mesh
  125796. */
  125797. createRootMesh(): Mesh;
  125798. /**
  125799. * Merge animations (direct and animation groups) from this asset container into a scene
  125800. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125801. * @param animatables set of animatables to retarget to a node from the scene
  125802. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125803. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125804. */
  125805. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125806. }
  125807. }
  125808. declare module BABYLON {
  125809. /**
  125810. * Defines how the parser contract is defined.
  125811. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125812. */
  125813. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125814. /**
  125815. * Defines how the individual parser contract is defined.
  125816. * These parser can parse an individual asset
  125817. */
  125818. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125819. /**
  125820. * Base class of the scene acting as a container for the different elements composing a scene.
  125821. * This class is dynamically extended by the different components of the scene increasing
  125822. * flexibility and reducing coupling
  125823. */
  125824. export abstract class AbstractScene {
  125825. /**
  125826. * Stores the list of available parsers in the application.
  125827. */
  125828. private static _BabylonFileParsers;
  125829. /**
  125830. * Stores the list of available individual parsers in the application.
  125831. */
  125832. private static _IndividualBabylonFileParsers;
  125833. /**
  125834. * Adds a parser in the list of available ones
  125835. * @param name Defines the name of the parser
  125836. * @param parser Defines the parser to add
  125837. */
  125838. static AddParser(name: string, parser: BabylonFileParser): void;
  125839. /**
  125840. * Gets a general parser from the list of avaialble ones
  125841. * @param name Defines the name of the parser
  125842. * @returns the requested parser or null
  125843. */
  125844. static GetParser(name: string): Nullable<BabylonFileParser>;
  125845. /**
  125846. * Adds n individual parser in the list of available ones
  125847. * @param name Defines the name of the parser
  125848. * @param parser Defines the parser to add
  125849. */
  125850. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125851. /**
  125852. * Gets an individual parser from the list of avaialble ones
  125853. * @param name Defines the name of the parser
  125854. * @returns the requested parser or null
  125855. */
  125856. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125857. /**
  125858. * Parser json data and populate both a scene and its associated container object
  125859. * @param jsonData Defines the data to parse
  125860. * @param scene Defines the scene to parse the data for
  125861. * @param container Defines the container attached to the parsing sequence
  125862. * @param rootUrl Defines the root url of the data
  125863. */
  125864. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125865. /**
  125866. * Gets the list of root nodes (ie. nodes with no parent)
  125867. */
  125868. rootNodes: Node[];
  125869. /** All of the cameras added to this scene
  125870. * @see https://doc.babylonjs.com/babylon101/cameras
  125871. */
  125872. cameras: Camera[];
  125873. /**
  125874. * All of the lights added to this scene
  125875. * @see https://doc.babylonjs.com/babylon101/lights
  125876. */
  125877. lights: Light[];
  125878. /**
  125879. * All of the (abstract) meshes added to this scene
  125880. */
  125881. meshes: AbstractMesh[];
  125882. /**
  125883. * The list of skeletons added to the scene
  125884. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125885. */
  125886. skeletons: Skeleton[];
  125887. /**
  125888. * All of the particle systems added to this scene
  125889. * @see https://doc.babylonjs.com/babylon101/particles
  125890. */
  125891. particleSystems: IParticleSystem[];
  125892. /**
  125893. * Gets a list of Animations associated with the scene
  125894. */
  125895. animations: Animation[];
  125896. /**
  125897. * All of the animation groups added to this scene
  125898. * @see https://doc.babylonjs.com/how_to/group
  125899. */
  125900. animationGroups: AnimationGroup[];
  125901. /**
  125902. * All of the multi-materials added to this scene
  125903. * @see https://doc.babylonjs.com/how_to/multi_materials
  125904. */
  125905. multiMaterials: MultiMaterial[];
  125906. /**
  125907. * All of the materials added to this scene
  125908. * In the context of a Scene, it is not supposed to be modified manually.
  125909. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125910. * Note also that the order of the Material within the array is not significant and might change.
  125911. * @see https://doc.babylonjs.com/babylon101/materials
  125912. */
  125913. materials: Material[];
  125914. /**
  125915. * The list of morph target managers added to the scene
  125916. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125917. */
  125918. morphTargetManagers: MorphTargetManager[];
  125919. /**
  125920. * The list of geometries used in the scene.
  125921. */
  125922. geometries: Geometry[];
  125923. /**
  125924. * All of the tranform nodes added to this scene
  125925. * In the context of a Scene, it is not supposed to be modified manually.
  125926. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125927. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125928. * @see https://doc.babylonjs.com/how_to/transformnode
  125929. */
  125930. transformNodes: TransformNode[];
  125931. /**
  125932. * ActionManagers available on the scene.
  125933. */
  125934. actionManagers: AbstractActionManager[];
  125935. /**
  125936. * Textures to keep.
  125937. */
  125938. textures: BaseTexture[];
  125939. /** @hidden */
  125940. protected _environmentTexture: Nullable<BaseTexture>;
  125941. /**
  125942. * Texture used in all pbr material as the reflection texture.
  125943. * As in the majority of the scene they are the same (exception for multi room and so on),
  125944. * this is easier to reference from here than from all the materials.
  125945. */
  125946. get environmentTexture(): Nullable<BaseTexture>;
  125947. set environmentTexture(value: Nullable<BaseTexture>);
  125948. /**
  125949. * The list of postprocesses added to the scene
  125950. */
  125951. postProcesses: PostProcess[];
  125952. /**
  125953. * @returns all meshes, lights, cameras, transformNodes and bones
  125954. */
  125955. getNodes(): Array<Node>;
  125956. }
  125957. }
  125958. declare module BABYLON {
  125959. /**
  125960. * Interface used to define options for Sound class
  125961. */
  125962. export interface ISoundOptions {
  125963. /**
  125964. * Does the sound autoplay once loaded.
  125965. */
  125966. autoplay?: boolean;
  125967. /**
  125968. * Does the sound loop after it finishes playing once.
  125969. */
  125970. loop?: boolean;
  125971. /**
  125972. * Sound's volume
  125973. */
  125974. volume?: number;
  125975. /**
  125976. * Is it a spatial sound?
  125977. */
  125978. spatialSound?: boolean;
  125979. /**
  125980. * Maximum distance to hear that sound
  125981. */
  125982. maxDistance?: number;
  125983. /**
  125984. * Uses user defined attenuation function
  125985. */
  125986. useCustomAttenuation?: boolean;
  125987. /**
  125988. * Define the roll off factor of spatial sounds.
  125989. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125990. */
  125991. rolloffFactor?: number;
  125992. /**
  125993. * Define the reference distance the sound should be heard perfectly.
  125994. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125995. */
  125996. refDistance?: number;
  125997. /**
  125998. * Define the distance attenuation model the sound will follow.
  125999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126000. */
  126001. distanceModel?: string;
  126002. /**
  126003. * Defines the playback speed (1 by default)
  126004. */
  126005. playbackRate?: number;
  126006. /**
  126007. * Defines if the sound is from a streaming source
  126008. */
  126009. streaming?: boolean;
  126010. /**
  126011. * Defines an optional length (in seconds) inside the sound file
  126012. */
  126013. length?: number;
  126014. /**
  126015. * Defines an optional offset (in seconds) inside the sound file
  126016. */
  126017. offset?: number;
  126018. /**
  126019. * If true, URLs will not be required to state the audio file codec to use.
  126020. */
  126021. skipCodecCheck?: boolean;
  126022. }
  126023. }
  126024. declare module BABYLON {
  126025. /**
  126026. * Defines a sound that can be played in the application.
  126027. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126029. */
  126030. export class Sound {
  126031. /**
  126032. * The name of the sound in the scene.
  126033. */
  126034. name: string;
  126035. /**
  126036. * Does the sound autoplay once loaded.
  126037. */
  126038. autoplay: boolean;
  126039. /**
  126040. * Does the sound loop after it finishes playing once.
  126041. */
  126042. loop: boolean;
  126043. /**
  126044. * Does the sound use a custom attenuation curve to simulate the falloff
  126045. * happening when the source gets further away from the camera.
  126046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126047. */
  126048. useCustomAttenuation: boolean;
  126049. /**
  126050. * The sound track id this sound belongs to.
  126051. */
  126052. soundTrackId: number;
  126053. /**
  126054. * Is this sound currently played.
  126055. */
  126056. isPlaying: boolean;
  126057. /**
  126058. * Is this sound currently paused.
  126059. */
  126060. isPaused: boolean;
  126061. /**
  126062. * Does this sound enables spatial sound.
  126063. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126064. */
  126065. spatialSound: boolean;
  126066. /**
  126067. * Define the reference distance the sound should be heard perfectly.
  126068. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126069. */
  126070. refDistance: number;
  126071. /**
  126072. * Define the roll off factor of spatial sounds.
  126073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126074. */
  126075. rolloffFactor: number;
  126076. /**
  126077. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126078. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126079. */
  126080. maxDistance: number;
  126081. /**
  126082. * Define the distance attenuation model the sound will follow.
  126083. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126084. */
  126085. distanceModel: string;
  126086. /**
  126087. * @hidden
  126088. * Back Compat
  126089. **/
  126090. onended: () => any;
  126091. /**
  126092. * Gets or sets an object used to store user defined information for the sound.
  126093. */
  126094. metadata: any;
  126095. /**
  126096. * Observable event when the current playing sound finishes.
  126097. */
  126098. onEndedObservable: Observable<Sound>;
  126099. /**
  126100. * Gets the current time for the sound.
  126101. */
  126102. get currentTime(): number;
  126103. private _panningModel;
  126104. private _playbackRate;
  126105. private _streaming;
  126106. private _startTime;
  126107. private _startOffset;
  126108. private _position;
  126109. /** @hidden */
  126110. _positionInEmitterSpace: boolean;
  126111. private _localDirection;
  126112. private _volume;
  126113. private _isReadyToPlay;
  126114. private _isDirectional;
  126115. private _readyToPlayCallback;
  126116. private _audioBuffer;
  126117. private _soundSource;
  126118. private _streamingSource;
  126119. private _soundPanner;
  126120. private _soundGain;
  126121. private _inputAudioNode;
  126122. private _outputAudioNode;
  126123. private _coneInnerAngle;
  126124. private _coneOuterAngle;
  126125. private _coneOuterGain;
  126126. private _scene;
  126127. private _connectedTransformNode;
  126128. private _customAttenuationFunction;
  126129. private _registerFunc;
  126130. private _isOutputConnected;
  126131. private _htmlAudioElement;
  126132. private _urlType;
  126133. private _length?;
  126134. private _offset?;
  126135. /** @hidden */
  126136. static _SceneComponentInitialization: (scene: Scene) => void;
  126137. /**
  126138. * Create a sound and attach it to a scene
  126139. * @param name Name of your sound
  126140. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126141. * @param scene defines the scene the sound belongs to
  126142. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126143. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126144. */
  126145. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126146. /**
  126147. * Release the sound and its associated resources
  126148. */
  126149. dispose(): void;
  126150. /**
  126151. * Gets if the sounds is ready to be played or not.
  126152. * @returns true if ready, otherwise false
  126153. */
  126154. isReady(): boolean;
  126155. private _soundLoaded;
  126156. /**
  126157. * Sets the data of the sound from an audiobuffer
  126158. * @param audioBuffer The audioBuffer containing the data
  126159. */
  126160. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126161. /**
  126162. * Updates the current sounds options such as maxdistance, loop...
  126163. * @param options A JSON object containing values named as the object properties
  126164. */
  126165. updateOptions(options: ISoundOptions): void;
  126166. private _createSpatialParameters;
  126167. private _updateSpatialParameters;
  126168. /**
  126169. * Switch the panning model to HRTF:
  126170. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126171. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126172. */
  126173. switchPanningModelToHRTF(): void;
  126174. /**
  126175. * Switch the panning model to Equal Power:
  126176. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126178. */
  126179. switchPanningModelToEqualPower(): void;
  126180. private _switchPanningModel;
  126181. /**
  126182. * Connect this sound to a sound track audio node like gain...
  126183. * @param soundTrackAudioNode the sound track audio node to connect to
  126184. */
  126185. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126186. /**
  126187. * Transform this sound into a directional source
  126188. * @param coneInnerAngle Size of the inner cone in degree
  126189. * @param coneOuterAngle Size of the outer cone in degree
  126190. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126191. */
  126192. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126193. /**
  126194. * Gets or sets the inner angle for the directional cone.
  126195. */
  126196. get directionalConeInnerAngle(): number;
  126197. /**
  126198. * Gets or sets the inner angle for the directional cone.
  126199. */
  126200. set directionalConeInnerAngle(value: number);
  126201. /**
  126202. * Gets or sets the outer angle for the directional cone.
  126203. */
  126204. get directionalConeOuterAngle(): number;
  126205. /**
  126206. * Gets or sets the outer angle for the directional cone.
  126207. */
  126208. set directionalConeOuterAngle(value: number);
  126209. /**
  126210. * Sets the position of the emitter if spatial sound is enabled
  126211. * @param newPosition Defines the new posisiton
  126212. */
  126213. setPosition(newPosition: Vector3): void;
  126214. /**
  126215. * Sets the local direction of the emitter if spatial sound is enabled
  126216. * @param newLocalDirection Defines the new local direction
  126217. */
  126218. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126219. private _updateDirection;
  126220. /** @hidden */
  126221. updateDistanceFromListener(): void;
  126222. /**
  126223. * Sets a new custom attenuation function for the sound.
  126224. * @param callback Defines the function used for the attenuation
  126225. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126226. */
  126227. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126228. /**
  126229. * Play the sound
  126230. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126231. * @param offset (optional) Start the sound at a specific time in seconds
  126232. * @param length (optional) Sound duration (in seconds)
  126233. */
  126234. play(time?: number, offset?: number, length?: number): void;
  126235. private _onended;
  126236. /**
  126237. * Stop the sound
  126238. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126239. */
  126240. stop(time?: number): void;
  126241. /**
  126242. * Put the sound in pause
  126243. */
  126244. pause(): void;
  126245. /**
  126246. * Sets a dedicated volume for this sounds
  126247. * @param newVolume Define the new volume of the sound
  126248. * @param time Define time for gradual change to new volume
  126249. */
  126250. setVolume(newVolume: number, time?: number): void;
  126251. /**
  126252. * Set the sound play back rate
  126253. * @param newPlaybackRate Define the playback rate the sound should be played at
  126254. */
  126255. setPlaybackRate(newPlaybackRate: number): void;
  126256. /**
  126257. * Gets the volume of the sound.
  126258. * @returns the volume of the sound
  126259. */
  126260. getVolume(): number;
  126261. /**
  126262. * Attach the sound to a dedicated mesh
  126263. * @param transformNode The transform node to connect the sound with
  126264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126265. */
  126266. attachToMesh(transformNode: TransformNode): void;
  126267. /**
  126268. * Detach the sound from the previously attached mesh
  126269. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126270. */
  126271. detachFromMesh(): void;
  126272. private _onRegisterAfterWorldMatrixUpdate;
  126273. /**
  126274. * Clone the current sound in the scene.
  126275. * @returns the new sound clone
  126276. */
  126277. clone(): Nullable<Sound>;
  126278. /**
  126279. * Gets the current underlying audio buffer containing the data
  126280. * @returns the audio buffer
  126281. */
  126282. getAudioBuffer(): Nullable<AudioBuffer>;
  126283. /**
  126284. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126285. * @returns the source node
  126286. */
  126287. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126288. /**
  126289. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126290. * @returns the gain node
  126291. */
  126292. getSoundGain(): Nullable<GainNode>;
  126293. /**
  126294. * Serializes the Sound in a JSON representation
  126295. * @returns the JSON representation of the sound
  126296. */
  126297. serialize(): any;
  126298. /**
  126299. * Parse a JSON representation of a sound to innstantiate in a given scene
  126300. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126301. * @param scene Define the scene the new parsed sound should be created in
  126302. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126303. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126304. * @returns the newly parsed sound
  126305. */
  126306. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126307. }
  126308. }
  126309. declare module BABYLON {
  126310. /**
  126311. * This defines an action helpful to play a defined sound on a triggered action.
  126312. */
  126313. export class PlaySoundAction extends Action {
  126314. private _sound;
  126315. /**
  126316. * Instantiate the action
  126317. * @param triggerOptions defines the trigger options
  126318. * @param sound defines the sound to play
  126319. * @param condition defines the trigger related conditions
  126320. */
  126321. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126322. /** @hidden */
  126323. _prepare(): void;
  126324. /**
  126325. * Execute the action and play the sound.
  126326. */
  126327. execute(): void;
  126328. /**
  126329. * Serializes the actions and its related information.
  126330. * @param parent defines the object to serialize in
  126331. * @returns the serialized object
  126332. */
  126333. serialize(parent: any): any;
  126334. }
  126335. /**
  126336. * This defines an action helpful to stop a defined sound on a triggered action.
  126337. */
  126338. export class StopSoundAction extends Action {
  126339. private _sound;
  126340. /**
  126341. * Instantiate the action
  126342. * @param triggerOptions defines the trigger options
  126343. * @param sound defines the sound to stop
  126344. * @param condition defines the trigger related conditions
  126345. */
  126346. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126347. /** @hidden */
  126348. _prepare(): void;
  126349. /**
  126350. * Execute the action and stop the sound.
  126351. */
  126352. execute(): void;
  126353. /**
  126354. * Serializes the actions and its related information.
  126355. * @param parent defines the object to serialize in
  126356. * @returns the serialized object
  126357. */
  126358. serialize(parent: any): any;
  126359. }
  126360. }
  126361. declare module BABYLON {
  126362. /**
  126363. * This defines an action responsible to change the value of a property
  126364. * by interpolating between its current value and the newly set one once triggered.
  126365. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  126366. */
  126367. export class InterpolateValueAction extends Action {
  126368. /**
  126369. * Defines the path of the property where the value should be interpolated
  126370. */
  126371. propertyPath: string;
  126372. /**
  126373. * Defines the target value at the end of the interpolation.
  126374. */
  126375. value: any;
  126376. /**
  126377. * Defines the time it will take for the property to interpolate to the value.
  126378. */
  126379. duration: number;
  126380. /**
  126381. * Defines if the other scene animations should be stopped when the action has been triggered
  126382. */
  126383. stopOtherAnimations?: boolean;
  126384. /**
  126385. * Defines a callback raised once the interpolation animation has been done.
  126386. */
  126387. onInterpolationDone?: () => void;
  126388. /**
  126389. * Observable triggered once the interpolation animation has been done.
  126390. */
  126391. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  126392. private _target;
  126393. private _effectiveTarget;
  126394. private _property;
  126395. /**
  126396. * Instantiate the action
  126397. * @param triggerOptions defines the trigger options
  126398. * @param target defines the object containing the value to interpolate
  126399. * @param propertyPath defines the path to the property in the target object
  126400. * @param value defines the target value at the end of the interpolation
  126401. * @param duration deines the time it will take for the property to interpolate to the value.
  126402. * @param condition defines the trigger related conditions
  126403. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  126404. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  126405. */
  126406. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  126407. /** @hidden */
  126408. _prepare(): void;
  126409. /**
  126410. * Execute the action starts the value interpolation.
  126411. */
  126412. execute(): void;
  126413. /**
  126414. * Serializes the actions and its related information.
  126415. * @param parent defines the object to serialize in
  126416. * @returns the serialized object
  126417. */
  126418. serialize(parent: any): any;
  126419. }
  126420. }
  126421. declare module BABYLON {
  126422. /**
  126423. * This represents the default audio engine used in babylon.
  126424. * It is responsible to play, synchronize and analyse sounds throughout the application.
  126425. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126426. */
  126427. export class AudioEngine implements IAudioEngine {
  126428. private _audioContext;
  126429. private _audioContextInitialized;
  126430. private _muteButton;
  126431. private _hostElement;
  126432. /**
  126433. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126434. */
  126435. canUseWebAudio: boolean;
  126436. /**
  126437. * The master gain node defines the global audio volume of your audio engine.
  126438. */
  126439. masterGain: GainNode;
  126440. /**
  126441. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126442. * @ignoreNaming
  126443. */
  126444. WarnedWebAudioUnsupported: boolean;
  126445. /**
  126446. * Gets whether or not mp3 are supported by your browser.
  126447. */
  126448. isMP3supported: boolean;
  126449. /**
  126450. * Gets whether or not ogg are supported by your browser.
  126451. */
  126452. isOGGsupported: boolean;
  126453. /**
  126454. * Gets whether audio has been unlocked on the device.
  126455. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  126456. * a user interaction has happened.
  126457. */
  126458. unlocked: boolean;
  126459. /**
  126460. * Defines if the audio engine relies on a custom unlocked button.
  126461. * In this case, the embedded button will not be displayed.
  126462. */
  126463. useCustomUnlockedButton: boolean;
  126464. /**
  126465. * Event raised when audio has been unlocked on the browser.
  126466. */
  126467. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126468. /**
  126469. * Event raised when audio has been locked on the browser.
  126470. */
  126471. onAudioLockedObservable: Observable<IAudioEngine>;
  126472. /**
  126473. * Gets the current AudioContext if available.
  126474. */
  126475. get audioContext(): Nullable<AudioContext>;
  126476. private _connectedAnalyser;
  126477. /**
  126478. * Instantiates a new audio engine.
  126479. *
  126480. * There should be only one per page as some browsers restrict the number
  126481. * of audio contexts you can create.
  126482. * @param hostElement defines the host element where to display the mute icon if necessary
  126483. */
  126484. constructor(hostElement?: Nullable<HTMLElement>);
  126485. /**
  126486. * Flags the audio engine in Locked state.
  126487. * This happens due to new browser policies preventing audio to autoplay.
  126488. */
  126489. lock(): void;
  126490. /**
  126491. * Unlocks the audio engine once a user action has been done on the dom.
  126492. * This is helpful to resume play once browser policies have been satisfied.
  126493. */
  126494. unlock(): void;
  126495. private _resumeAudioContext;
  126496. private _initializeAudioContext;
  126497. private _tryToRun;
  126498. private _triggerRunningState;
  126499. private _triggerSuspendedState;
  126500. private _displayMuteButton;
  126501. private _moveButtonToTopLeft;
  126502. private _onResize;
  126503. private _hideMuteButton;
  126504. /**
  126505. * Destroy and release the resources associated with the audio ccontext.
  126506. */
  126507. dispose(): void;
  126508. /**
  126509. * Gets the global volume sets on the master gain.
  126510. * @returns the global volume if set or -1 otherwise
  126511. */
  126512. getGlobalVolume(): number;
  126513. /**
  126514. * Sets the global volume of your experience (sets on the master gain).
  126515. * @param newVolume Defines the new global volume of the application
  126516. */
  126517. setGlobalVolume(newVolume: number): void;
  126518. /**
  126519. * Connect the audio engine to an audio analyser allowing some amazing
  126520. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126521. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126522. * @param analyser The analyser to connect to the engine
  126523. */
  126524. connectToAnalyser(analyser: Analyser): void;
  126525. }
  126526. }
  126527. declare module BABYLON {
  126528. /**
  126529. * Options allowed during the creation of a sound track.
  126530. */
  126531. export interface ISoundTrackOptions {
  126532. /**
  126533. * The volume the sound track should take during creation
  126534. */
  126535. volume?: number;
  126536. /**
  126537. * Define if the sound track is the main sound track of the scene
  126538. */
  126539. mainTrack?: boolean;
  126540. }
  126541. /**
  126542. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  126543. * It will be also used in a future release to apply effects on a specific track.
  126544. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126545. */
  126546. export class SoundTrack {
  126547. /**
  126548. * The unique identifier of the sound track in the scene.
  126549. */
  126550. id: number;
  126551. /**
  126552. * The list of sounds included in the sound track.
  126553. */
  126554. soundCollection: Array<Sound>;
  126555. private _outputAudioNode;
  126556. private _scene;
  126557. private _connectedAnalyser;
  126558. private _options;
  126559. private _isInitialized;
  126560. /**
  126561. * Creates a new sound track.
  126562. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126563. * @param scene Define the scene the sound track belongs to
  126564. * @param options
  126565. */
  126566. constructor(scene: Scene, options?: ISoundTrackOptions);
  126567. private _initializeSoundTrackAudioGraph;
  126568. /**
  126569. * Release the sound track and its associated resources
  126570. */
  126571. dispose(): void;
  126572. /**
  126573. * Adds a sound to this sound track
  126574. * @param sound define the cound to add
  126575. * @ignoreNaming
  126576. */
  126577. addSound(sound: Sound): void;
  126578. /**
  126579. * Removes a sound to this sound track
  126580. * @param sound define the cound to remove
  126581. * @ignoreNaming
  126582. */
  126583. removeSound(sound: Sound): void;
  126584. /**
  126585. * Set a global volume for the full sound track.
  126586. * @param newVolume Define the new volume of the sound track
  126587. */
  126588. setVolume(newVolume: number): void;
  126589. /**
  126590. * Switch the panning model to HRTF:
  126591. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126592. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126593. */
  126594. switchPanningModelToHRTF(): void;
  126595. /**
  126596. * Switch the panning model to Equal Power:
  126597. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126598. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126599. */
  126600. switchPanningModelToEqualPower(): void;
  126601. /**
  126602. * Connect the sound track to an audio analyser allowing some amazing
  126603. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126605. * @param analyser The analyser to connect to the engine
  126606. */
  126607. connectToAnalyser(analyser: Analyser): void;
  126608. }
  126609. }
  126610. declare module BABYLON {
  126611. interface AbstractScene {
  126612. /**
  126613. * The list of sounds used in the scene.
  126614. */
  126615. sounds: Nullable<Array<Sound>>;
  126616. }
  126617. interface Scene {
  126618. /**
  126619. * @hidden
  126620. * Backing field
  126621. */
  126622. _mainSoundTrack: SoundTrack;
  126623. /**
  126624. * The main sound track played by the scene.
  126625. * It cotains your primary collection of sounds.
  126626. */
  126627. mainSoundTrack: SoundTrack;
  126628. /**
  126629. * The list of sound tracks added to the scene
  126630. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126631. */
  126632. soundTracks: Nullable<Array<SoundTrack>>;
  126633. /**
  126634. * Gets a sound using a given name
  126635. * @param name defines the name to search for
  126636. * @return the found sound or null if not found at all.
  126637. */
  126638. getSoundByName(name: string): Nullable<Sound>;
  126639. /**
  126640. * Gets or sets if audio support is enabled
  126641. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126642. */
  126643. audioEnabled: boolean;
  126644. /**
  126645. * Gets or sets if audio will be output to headphones
  126646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126647. */
  126648. headphone: boolean;
  126649. /**
  126650. * Gets or sets custom audio listener position provider
  126651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126652. */
  126653. audioListenerPositionProvider: Nullable<() => Vector3>;
  126654. /**
  126655. * Gets or sets a refresh rate when using 3D audio positioning
  126656. */
  126657. audioPositioningRefreshRate: number;
  126658. }
  126659. /**
  126660. * Defines the sound scene component responsible to manage any sounds
  126661. * in a given scene.
  126662. */
  126663. export class AudioSceneComponent implements ISceneSerializableComponent {
  126664. private static _CameraDirectionLH;
  126665. private static _CameraDirectionRH;
  126666. /**
  126667. * The component name helpfull to identify the component in the list of scene components.
  126668. */
  126669. readonly name: string;
  126670. /**
  126671. * The scene the component belongs to.
  126672. */
  126673. scene: Scene;
  126674. private _audioEnabled;
  126675. /**
  126676. * Gets whether audio is enabled or not.
  126677. * Please use related enable/disable method to switch state.
  126678. */
  126679. get audioEnabled(): boolean;
  126680. private _headphone;
  126681. /**
  126682. * Gets whether audio is outputing to headphone or not.
  126683. * Please use the according Switch methods to change output.
  126684. */
  126685. get headphone(): boolean;
  126686. /**
  126687. * Gets or sets a refresh rate when using 3D audio positioning
  126688. */
  126689. audioPositioningRefreshRate: number;
  126690. private _audioListenerPositionProvider;
  126691. /**
  126692. * Gets the current audio listener position provider
  126693. */
  126694. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  126695. /**
  126696. * Sets a custom listener position for all sounds in the scene
  126697. * By default, this is the position of the first active camera
  126698. */
  126699. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  126700. /**
  126701. * Creates a new instance of the component for the given scene
  126702. * @param scene Defines the scene to register the component in
  126703. */
  126704. constructor(scene: Scene);
  126705. /**
  126706. * Registers the component in a given scene
  126707. */
  126708. register(): void;
  126709. /**
  126710. * Rebuilds the elements related to this component in case of
  126711. * context lost for instance.
  126712. */
  126713. rebuild(): void;
  126714. /**
  126715. * Serializes the component data to the specified json object
  126716. * @param serializationObject The object to serialize to
  126717. */
  126718. serialize(serializationObject: any): void;
  126719. /**
  126720. * Adds all the elements from the container to the scene
  126721. * @param container the container holding the elements
  126722. */
  126723. addFromContainer(container: AbstractScene): void;
  126724. /**
  126725. * Removes all the elements in the container from the scene
  126726. * @param container contains the elements to remove
  126727. * @param dispose if the removed element should be disposed (default: false)
  126728. */
  126729. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126730. /**
  126731. * Disposes the component and the associated ressources.
  126732. */
  126733. dispose(): void;
  126734. /**
  126735. * Disables audio in the associated scene.
  126736. */
  126737. disableAudio(): void;
  126738. /**
  126739. * Enables audio in the associated scene.
  126740. */
  126741. enableAudio(): void;
  126742. /**
  126743. * Switch audio to headphone output.
  126744. */
  126745. switchAudioModeForHeadphones(): void;
  126746. /**
  126747. * Switch audio to normal speakers.
  126748. */
  126749. switchAudioModeForNormalSpeakers(): void;
  126750. private _cachedCameraDirection;
  126751. private _cachedCameraPosition;
  126752. private _lastCheck;
  126753. private _afterRender;
  126754. }
  126755. }
  126756. declare module BABYLON {
  126757. /**
  126758. * Wraps one or more Sound objects and selects one with random weight for playback.
  126759. */
  126760. export class WeightedSound {
  126761. /** When true a Sound will be selected and played when the current playing Sound completes. */
  126762. loop: boolean;
  126763. private _coneInnerAngle;
  126764. private _coneOuterAngle;
  126765. private _volume;
  126766. /** A Sound is currently playing. */
  126767. isPlaying: boolean;
  126768. /** A Sound is currently paused. */
  126769. isPaused: boolean;
  126770. private _sounds;
  126771. private _weights;
  126772. private _currentIndex?;
  126773. /**
  126774. * Creates a new WeightedSound from the list of sounds given.
  126775. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  126776. * @param sounds Array of Sounds that will be selected from.
  126777. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  126778. */
  126779. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  126780. /**
  126781. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  126782. */
  126783. get directionalConeInnerAngle(): number;
  126784. /**
  126785. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126786. */
  126787. set directionalConeInnerAngle(value: number);
  126788. /**
  126789. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126790. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126791. */
  126792. get directionalConeOuterAngle(): number;
  126793. /**
  126794. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126795. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126796. */
  126797. set directionalConeOuterAngle(value: number);
  126798. /**
  126799. * Playback volume.
  126800. */
  126801. get volume(): number;
  126802. /**
  126803. * Playback volume.
  126804. */
  126805. set volume(value: number);
  126806. private _onended;
  126807. /**
  126808. * Suspend playback
  126809. */
  126810. pause(): void;
  126811. /**
  126812. * Stop playback
  126813. */
  126814. stop(): void;
  126815. /**
  126816. * Start playback.
  126817. * @param startOffset Position the clip head at a specific time in seconds.
  126818. */
  126819. play(startOffset?: number): void;
  126820. }
  126821. }
  126822. declare module BABYLON {
  126823. /**
  126824. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126825. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126826. */
  126827. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126828. /**
  126829. * Gets the name of the behavior.
  126830. */
  126831. get name(): string;
  126832. /**
  126833. * The easing function used by animations
  126834. */
  126835. static EasingFunction: BackEase;
  126836. /**
  126837. * The easing mode used by animations
  126838. */
  126839. static EasingMode: number;
  126840. /**
  126841. * The duration of the animation, in milliseconds
  126842. */
  126843. transitionDuration: number;
  126844. /**
  126845. * Length of the distance animated by the transition when lower radius is reached
  126846. */
  126847. lowerRadiusTransitionRange: number;
  126848. /**
  126849. * Length of the distance animated by the transition when upper radius is reached
  126850. */
  126851. upperRadiusTransitionRange: number;
  126852. private _autoTransitionRange;
  126853. /**
  126854. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126855. */
  126856. get autoTransitionRange(): boolean;
  126857. /**
  126858. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126859. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126860. */
  126861. set autoTransitionRange(value: boolean);
  126862. private _attachedCamera;
  126863. private _onAfterCheckInputsObserver;
  126864. private _onMeshTargetChangedObserver;
  126865. /**
  126866. * Initializes the behavior.
  126867. */
  126868. init(): void;
  126869. /**
  126870. * Attaches the behavior to its arc rotate camera.
  126871. * @param camera Defines the camera to attach the behavior to
  126872. */
  126873. attach(camera: ArcRotateCamera): void;
  126874. /**
  126875. * Detaches the behavior from its current arc rotate camera.
  126876. */
  126877. detach(): void;
  126878. private _radiusIsAnimating;
  126879. private _radiusBounceTransition;
  126880. private _animatables;
  126881. private _cachedWheelPrecision;
  126882. /**
  126883. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126884. * @param radiusLimit The limit to check against.
  126885. * @return Bool to indicate if at limit.
  126886. */
  126887. private _isRadiusAtLimit;
  126888. /**
  126889. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126890. * @param radiusDelta The delta by which to animate to. Can be negative.
  126891. */
  126892. private _applyBoundRadiusAnimation;
  126893. /**
  126894. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126895. */
  126896. protected _clearAnimationLocks(): void;
  126897. /**
  126898. * Stops and removes all animations that have been applied to the camera
  126899. */
  126900. stopAllAnimations(): void;
  126901. }
  126902. }
  126903. declare module BABYLON {
  126904. /**
  126905. * 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.
  126906. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126907. */
  126908. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126909. /**
  126910. * Gets the name of the behavior.
  126911. */
  126912. get name(): string;
  126913. private _mode;
  126914. private _radiusScale;
  126915. private _positionScale;
  126916. private _defaultElevation;
  126917. private _elevationReturnTime;
  126918. private _elevationReturnWaitTime;
  126919. private _zoomStopsAnimation;
  126920. private _framingTime;
  126921. /**
  126922. * The easing function used by animations
  126923. */
  126924. static EasingFunction: ExponentialEase;
  126925. /**
  126926. * The easing mode used by animations
  126927. */
  126928. static EasingMode: number;
  126929. /**
  126930. * Sets the current mode used by the behavior
  126931. */
  126932. set mode(mode: number);
  126933. /**
  126934. * Gets current mode used by the behavior.
  126935. */
  126936. get mode(): number;
  126937. /**
  126938. * Sets the scale applied to the radius (1 by default)
  126939. */
  126940. set radiusScale(radius: number);
  126941. /**
  126942. * Gets the scale applied to the radius
  126943. */
  126944. get radiusScale(): number;
  126945. /**
  126946. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126947. */
  126948. set positionScale(scale: number);
  126949. /**
  126950. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126951. */
  126952. get positionScale(): number;
  126953. /**
  126954. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126955. * behaviour is triggered, in radians.
  126956. */
  126957. set defaultElevation(elevation: number);
  126958. /**
  126959. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126960. * behaviour is triggered, in radians.
  126961. */
  126962. get defaultElevation(): number;
  126963. /**
  126964. * Sets the time (in milliseconds) taken to return to the default beta position.
  126965. * Negative value indicates camera should not return to default.
  126966. */
  126967. set elevationReturnTime(speed: number);
  126968. /**
  126969. * Gets the time (in milliseconds) taken to return to the default beta position.
  126970. * Negative value indicates camera should not return to default.
  126971. */
  126972. get elevationReturnTime(): number;
  126973. /**
  126974. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126975. */
  126976. set elevationReturnWaitTime(time: number);
  126977. /**
  126978. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126979. */
  126980. get elevationReturnWaitTime(): number;
  126981. /**
  126982. * Sets the flag that indicates if user zooming should stop animation.
  126983. */
  126984. set zoomStopsAnimation(flag: boolean);
  126985. /**
  126986. * Gets the flag that indicates if user zooming should stop animation.
  126987. */
  126988. get zoomStopsAnimation(): boolean;
  126989. /**
  126990. * Sets the transition time when framing the mesh, in milliseconds
  126991. */
  126992. set framingTime(time: number);
  126993. /**
  126994. * Gets the transition time when framing the mesh, in milliseconds
  126995. */
  126996. get framingTime(): number;
  126997. /**
  126998. * Define if the behavior should automatically change the configured
  126999. * camera limits and sensibilities.
  127000. */
  127001. autoCorrectCameraLimitsAndSensibility: boolean;
  127002. private _onPrePointerObservableObserver;
  127003. private _onAfterCheckInputsObserver;
  127004. private _onMeshTargetChangedObserver;
  127005. private _attachedCamera;
  127006. private _isPointerDown;
  127007. private _lastInteractionTime;
  127008. /**
  127009. * Initializes the behavior.
  127010. */
  127011. init(): void;
  127012. /**
  127013. * Attaches the behavior to its arc rotate camera.
  127014. * @param camera Defines the camera to attach the behavior to
  127015. */
  127016. attach(camera: ArcRotateCamera): void;
  127017. /**
  127018. * Detaches the behavior from its current arc rotate camera.
  127019. */
  127020. detach(): void;
  127021. private _animatables;
  127022. private _betaIsAnimating;
  127023. private _betaTransition;
  127024. private _radiusTransition;
  127025. private _vectorTransition;
  127026. /**
  127027. * Targets the given mesh and updates zoom level accordingly.
  127028. * @param mesh The mesh to target.
  127029. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127030. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127031. */
  127032. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127033. /**
  127034. * Targets the given mesh with its children and updates zoom level accordingly.
  127035. * @param mesh The mesh to target.
  127036. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127037. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127038. */
  127039. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127040. /**
  127041. * Targets the given meshes with their children and updates zoom level accordingly.
  127042. * @param meshes The mesh to target.
  127043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127045. */
  127046. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127047. /**
  127048. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127049. * @param minimumWorld Determines the smaller position of the bounding box extend
  127050. * @param maximumWorld Determines the bigger position of the bounding box extend
  127051. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127052. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127053. */
  127054. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127055. /**
  127056. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127057. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127058. * frustum width.
  127059. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127060. * to fully enclose the mesh in the viewing frustum.
  127061. */
  127062. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127063. /**
  127064. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127065. * is automatically returned to its default position (expected to be above ground plane).
  127066. */
  127067. private _maintainCameraAboveGround;
  127068. /**
  127069. * Returns the frustum slope based on the canvas ratio and camera FOV
  127070. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127071. */
  127072. private _getFrustumSlope;
  127073. /**
  127074. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127075. */
  127076. private _clearAnimationLocks;
  127077. /**
  127078. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127079. */
  127080. private _applyUserInteraction;
  127081. /**
  127082. * Stops and removes all animations that have been applied to the camera
  127083. */
  127084. stopAllAnimations(): void;
  127085. /**
  127086. * Gets a value indicating if the user is moving the camera
  127087. */
  127088. get isUserIsMoving(): boolean;
  127089. /**
  127090. * The camera can move all the way towards the mesh.
  127091. */
  127092. static IgnoreBoundsSizeMode: number;
  127093. /**
  127094. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127095. */
  127096. static FitFrustumSidesMode: number;
  127097. }
  127098. }
  127099. declare module BABYLON {
  127100. /**
  127101. * Base class for Camera Pointer Inputs.
  127102. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127103. * for example usage.
  127104. */
  127105. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127106. /**
  127107. * Defines the camera the input is attached to.
  127108. */
  127109. abstract camera: Camera;
  127110. /**
  127111. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127112. */
  127113. protected _altKey: boolean;
  127114. protected _ctrlKey: boolean;
  127115. protected _metaKey: boolean;
  127116. protected _shiftKey: boolean;
  127117. /**
  127118. * Which mouse buttons were pressed at time of last mouse event.
  127119. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127120. */
  127121. protected _buttonsPressed: number;
  127122. /**
  127123. * Defines the buttons associated with the input to handle camera move.
  127124. */
  127125. buttons: number[];
  127126. /**
  127127. * Attach the input controls to a specific dom element to get the input from.
  127128. * @param element Defines the element the controls should be listened from
  127129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127130. */
  127131. attachControl(noPreventDefault?: boolean): void;
  127132. /**
  127133. * Detach the current controls from the specified dom element.
  127134. */
  127135. detachControl(): void;
  127136. /**
  127137. * Gets the class name of the current input.
  127138. * @returns the class name
  127139. */
  127140. getClassName(): string;
  127141. /**
  127142. * Get the friendly name associated with the input class.
  127143. * @returns the input friendly name
  127144. */
  127145. getSimpleName(): string;
  127146. /**
  127147. * Called on pointer POINTERDOUBLETAP event.
  127148. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127149. */
  127150. protected onDoubleTap(type: string): void;
  127151. /**
  127152. * Called on pointer POINTERMOVE event if only a single touch is active.
  127153. * Override this method to provide functionality.
  127154. */
  127155. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127156. /**
  127157. * Called on pointer POINTERMOVE event if multiple touches are active.
  127158. * Override this method to provide functionality.
  127159. */
  127160. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127161. /**
  127162. * Called on JS contextmenu event.
  127163. * Override this method to provide functionality.
  127164. */
  127165. protected onContextMenu(evt: PointerEvent): void;
  127166. /**
  127167. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127168. * press.
  127169. * Override this method to provide functionality.
  127170. */
  127171. protected onButtonDown(evt: PointerEvent): void;
  127172. /**
  127173. * Called each time a new POINTERUP event occurs. Ie, for each button
  127174. * release.
  127175. * Override this method to provide functionality.
  127176. */
  127177. protected onButtonUp(evt: PointerEvent): void;
  127178. /**
  127179. * Called when window becomes inactive.
  127180. * Override this method to provide functionality.
  127181. */
  127182. protected onLostFocus(): void;
  127183. private _pointerInput;
  127184. private _observer;
  127185. private _onLostFocus;
  127186. private pointA;
  127187. private pointB;
  127188. }
  127189. }
  127190. declare module BABYLON {
  127191. /**
  127192. * Manage the pointers inputs to control an arc rotate camera.
  127193. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127194. */
  127195. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127196. /**
  127197. * Defines the camera the input is attached to.
  127198. */
  127199. camera: ArcRotateCamera;
  127200. /**
  127201. * Gets the class name of the current input.
  127202. * @returns the class name
  127203. */
  127204. getClassName(): string;
  127205. /**
  127206. * Defines the buttons associated with the input to handle camera move.
  127207. */
  127208. buttons: number[];
  127209. /**
  127210. * Defines the pointer angular sensibility along the X axis or how fast is
  127211. * the camera rotating.
  127212. */
  127213. angularSensibilityX: number;
  127214. /**
  127215. * Defines the pointer angular sensibility along the Y axis or how fast is
  127216. * the camera rotating.
  127217. */
  127218. angularSensibilityY: number;
  127219. /**
  127220. * Defines the pointer pinch precision or how fast is the camera zooming.
  127221. */
  127222. pinchPrecision: number;
  127223. /**
  127224. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127225. * from 0.
  127226. * It defines the percentage of current camera.radius to use as delta when
  127227. * pinch zoom is used.
  127228. */
  127229. pinchDeltaPercentage: number;
  127230. /**
  127231. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127232. * that any object in the plane at the camera's target point will scale
  127233. * perfectly with finger motion.
  127234. * Overrides pinchDeltaPercentage and pinchPrecision.
  127235. */
  127236. useNaturalPinchZoom: boolean;
  127237. /**
  127238. * Defines the pointer panning sensibility or how fast is the camera moving.
  127239. */
  127240. panningSensibility: number;
  127241. /**
  127242. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127243. */
  127244. multiTouchPanning: boolean;
  127245. /**
  127246. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127247. * zoom (pinch) through multitouch.
  127248. */
  127249. multiTouchPanAndZoom: boolean;
  127250. /**
  127251. * Revers pinch action direction.
  127252. */
  127253. pinchInwards: boolean;
  127254. private _isPanClick;
  127255. private _twoFingerActivityCount;
  127256. private _isPinching;
  127257. /**
  127258. * Called on pointer POINTERMOVE event if only a single touch is active.
  127259. */
  127260. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127261. /**
  127262. * Called on pointer POINTERDOUBLETAP event.
  127263. */
  127264. protected onDoubleTap(type: string): void;
  127265. /**
  127266. * Called on pointer POINTERMOVE event if multiple touches are active.
  127267. */
  127268. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127269. /**
  127270. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127271. * press.
  127272. */
  127273. protected onButtonDown(evt: PointerEvent): void;
  127274. /**
  127275. * Called each time a new POINTERUP event occurs. Ie, for each button
  127276. * release.
  127277. */
  127278. protected onButtonUp(evt: PointerEvent): void;
  127279. /**
  127280. * Called when window becomes inactive.
  127281. */
  127282. protected onLostFocus(): void;
  127283. }
  127284. }
  127285. declare module BABYLON {
  127286. /**
  127287. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127288. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127289. */
  127290. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127291. /**
  127292. * Defines the camera the input is attached to.
  127293. */
  127294. camera: ArcRotateCamera;
  127295. /**
  127296. * Defines the list of key codes associated with the up action (increase alpha)
  127297. */
  127298. keysUp: number[];
  127299. /**
  127300. * Defines the list of key codes associated with the down action (decrease alpha)
  127301. */
  127302. keysDown: number[];
  127303. /**
  127304. * Defines the list of key codes associated with the left action (increase beta)
  127305. */
  127306. keysLeft: number[];
  127307. /**
  127308. * Defines the list of key codes associated with the right action (decrease beta)
  127309. */
  127310. keysRight: number[];
  127311. /**
  127312. * Defines the list of key codes associated with the reset action.
  127313. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127314. */
  127315. keysReset: number[];
  127316. /**
  127317. * Defines the panning sensibility of the inputs.
  127318. * (How fast is the camera panning)
  127319. */
  127320. panningSensibility: number;
  127321. /**
  127322. * Defines the zooming sensibility of the inputs.
  127323. * (How fast is the camera zooming)
  127324. */
  127325. zoomingSensibility: number;
  127326. /**
  127327. * Defines whether maintaining the alt key down switch the movement mode from
  127328. * orientation to zoom.
  127329. */
  127330. useAltToZoom: boolean;
  127331. /**
  127332. * Rotation speed of the camera
  127333. */
  127334. angularSpeed: number;
  127335. private _keys;
  127336. private _ctrlPressed;
  127337. private _altPressed;
  127338. private _onCanvasBlurObserver;
  127339. private _onKeyboardObserver;
  127340. private _engine;
  127341. private _scene;
  127342. /**
  127343. * Attach the input controls to a specific dom element to get the input from.
  127344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127345. */
  127346. attachControl(noPreventDefault?: boolean): void;
  127347. /**
  127348. * Detach the current controls from the specified dom element.
  127349. */
  127350. detachControl(): void;
  127351. /**
  127352. * Update the current camera state depending on the inputs that have been used this frame.
  127353. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127354. */
  127355. checkInputs(): void;
  127356. /**
  127357. * Gets the class name of the current intput.
  127358. * @returns the class name
  127359. */
  127360. getClassName(): string;
  127361. /**
  127362. * Get the friendly name associated with the input class.
  127363. * @returns the input friendly name
  127364. */
  127365. getSimpleName(): string;
  127366. }
  127367. }
  127368. declare module BABYLON {
  127369. /**
  127370. * Manage the mouse wheel inputs to control an arc rotate camera.
  127371. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127372. */
  127373. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  127374. /**
  127375. * Defines the camera the input is attached to.
  127376. */
  127377. camera: ArcRotateCamera;
  127378. /**
  127379. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127380. */
  127381. wheelPrecision: number;
  127382. /**
  127383. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  127384. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  127385. */
  127386. wheelDeltaPercentage: number;
  127387. private _wheel;
  127388. private _observer;
  127389. private computeDeltaFromMouseWheelLegacyEvent;
  127390. /**
  127391. * Attach the input controls to a specific dom element to get the input from.
  127392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127393. */
  127394. attachControl(noPreventDefault?: boolean): void;
  127395. /**
  127396. * Detach the current controls from the specified dom element.
  127397. */
  127398. detachControl(): void;
  127399. /**
  127400. * Gets the class name of the current intput.
  127401. * @returns the class name
  127402. */
  127403. getClassName(): string;
  127404. /**
  127405. * Get the friendly name associated with the input class.
  127406. * @returns the input friendly name
  127407. */
  127408. getSimpleName(): string;
  127409. }
  127410. }
  127411. declare module BABYLON {
  127412. /**
  127413. * Default Inputs manager for the ArcRotateCamera.
  127414. * It groups all the default supported inputs for ease of use.
  127415. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127416. */
  127417. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  127418. /**
  127419. * Instantiates a new ArcRotateCameraInputsManager.
  127420. * @param camera Defines the camera the inputs belong to
  127421. */
  127422. constructor(camera: ArcRotateCamera);
  127423. /**
  127424. * Add mouse wheel input support to the input manager.
  127425. * @returns the current input manager
  127426. */
  127427. addMouseWheel(): ArcRotateCameraInputsManager;
  127428. /**
  127429. * Add pointers input support to the input manager.
  127430. * @returns the current input manager
  127431. */
  127432. addPointers(): ArcRotateCameraInputsManager;
  127433. /**
  127434. * Add keyboard input support to the input manager.
  127435. * @returns the current input manager
  127436. */
  127437. addKeyboard(): ArcRotateCameraInputsManager;
  127438. }
  127439. }
  127440. declare module BABYLON {
  127441. /**
  127442. * This represents an orbital type of camera.
  127443. *
  127444. * 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.
  127445. * 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.
  127446. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  127447. */
  127448. export class ArcRotateCamera extends TargetCamera {
  127449. /**
  127450. * Defines the rotation angle of the camera along the longitudinal axis.
  127451. */
  127452. alpha: number;
  127453. /**
  127454. * Defines the rotation angle of the camera along the latitudinal axis.
  127455. */
  127456. beta: number;
  127457. /**
  127458. * Defines the radius of the camera from it s target point.
  127459. */
  127460. radius: number;
  127461. protected _target: Vector3;
  127462. protected _targetHost: Nullable<AbstractMesh>;
  127463. /**
  127464. * Defines the target point of the camera.
  127465. * The camera looks towards it form the radius distance.
  127466. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  127467. */
  127468. get target(): Vector3;
  127469. set target(value: Vector3);
  127470. /**
  127471. * Define the current local position of the camera in the scene
  127472. */
  127473. get position(): Vector3;
  127474. set position(newPosition: Vector3);
  127475. protected _upToYMatrix: Matrix;
  127476. protected _YToUpMatrix: Matrix;
  127477. /**
  127478. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  127479. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  127480. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  127481. */
  127482. set upVector(vec: Vector3);
  127483. get upVector(): Vector3;
  127484. /**
  127485. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  127486. */
  127487. setMatUp(): void;
  127488. /**
  127489. * Current inertia value on the longitudinal axis.
  127490. * The bigger this number the longer it will take for the camera to stop.
  127491. */
  127492. inertialAlphaOffset: number;
  127493. /**
  127494. * Current inertia value on the latitudinal axis.
  127495. * The bigger this number the longer it will take for the camera to stop.
  127496. */
  127497. inertialBetaOffset: number;
  127498. /**
  127499. * Current inertia value on the radius axis.
  127500. * The bigger this number the longer it will take for the camera to stop.
  127501. */
  127502. inertialRadiusOffset: number;
  127503. /**
  127504. * Minimum allowed angle on the longitudinal axis.
  127505. * This can help limiting how the Camera is able to move in the scene.
  127506. */
  127507. lowerAlphaLimit: Nullable<number>;
  127508. /**
  127509. * Maximum allowed angle on the longitudinal axis.
  127510. * This can help limiting how the Camera is able to move in the scene.
  127511. */
  127512. upperAlphaLimit: Nullable<number>;
  127513. /**
  127514. * Minimum allowed angle on the latitudinal axis.
  127515. * This can help limiting how the Camera is able to move in the scene.
  127516. */
  127517. lowerBetaLimit: number;
  127518. /**
  127519. * Maximum allowed angle on the latitudinal axis.
  127520. * This can help limiting how the Camera is able to move in the scene.
  127521. */
  127522. upperBetaLimit: number;
  127523. /**
  127524. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  127525. * This can help limiting how the Camera is able to move in the scene.
  127526. */
  127527. lowerRadiusLimit: Nullable<number>;
  127528. /**
  127529. * Maximum allowed distance of the camera to the target (The camera can not get further).
  127530. * This can help limiting how the Camera is able to move in the scene.
  127531. */
  127532. upperRadiusLimit: Nullable<number>;
  127533. /**
  127534. * Defines the current inertia value used during panning of the camera along the X axis.
  127535. */
  127536. inertialPanningX: number;
  127537. /**
  127538. * Defines the current inertia value used during panning of the camera along the Y axis.
  127539. */
  127540. inertialPanningY: number;
  127541. /**
  127542. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  127543. * Basically if your fingers moves away from more than this distance you will be considered
  127544. * in pinch mode.
  127545. */
  127546. pinchToPanMaxDistance: number;
  127547. /**
  127548. * Defines the maximum distance the camera can pan.
  127549. * This could help keeping the cammera always in your scene.
  127550. */
  127551. panningDistanceLimit: Nullable<number>;
  127552. /**
  127553. * Defines the target of the camera before paning.
  127554. */
  127555. panningOriginTarget: Vector3;
  127556. /**
  127557. * Defines the value of the inertia used during panning.
  127558. * 0 would mean stop inertia and one would mean no decelleration at all.
  127559. */
  127560. panningInertia: number;
  127561. /**
  127562. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  127563. */
  127564. get angularSensibilityX(): number;
  127565. set angularSensibilityX(value: number);
  127566. /**
  127567. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  127568. */
  127569. get angularSensibilityY(): number;
  127570. set angularSensibilityY(value: number);
  127571. /**
  127572. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  127573. */
  127574. get pinchPrecision(): number;
  127575. set pinchPrecision(value: number);
  127576. /**
  127577. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  127578. * It will be used instead of pinchDeltaPrecision if different from 0.
  127579. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127580. */
  127581. get pinchDeltaPercentage(): number;
  127582. set pinchDeltaPercentage(value: number);
  127583. /**
  127584. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  127585. * and pinch delta percentage.
  127586. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127587. * that any object in the plane at the camera's target point will scale
  127588. * perfectly with finger motion.
  127589. */
  127590. get useNaturalPinchZoom(): boolean;
  127591. set useNaturalPinchZoom(value: boolean);
  127592. /**
  127593. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  127594. */
  127595. get panningSensibility(): number;
  127596. set panningSensibility(value: number);
  127597. /**
  127598. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  127599. */
  127600. get keysUp(): number[];
  127601. set keysUp(value: number[]);
  127602. /**
  127603. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  127604. */
  127605. get keysDown(): number[];
  127606. set keysDown(value: number[]);
  127607. /**
  127608. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  127609. */
  127610. get keysLeft(): number[];
  127611. set keysLeft(value: number[]);
  127612. /**
  127613. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  127614. */
  127615. get keysRight(): number[];
  127616. set keysRight(value: number[]);
  127617. /**
  127618. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127619. */
  127620. get wheelPrecision(): number;
  127621. set wheelPrecision(value: number);
  127622. /**
  127623. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  127624. * It will be used instead of pinchDeltaPrecision if different from 0.
  127625. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127626. */
  127627. get wheelDeltaPercentage(): number;
  127628. set wheelDeltaPercentage(value: number);
  127629. /**
  127630. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  127631. */
  127632. zoomOnFactor: number;
  127633. /**
  127634. * Defines a screen offset for the camera position.
  127635. */
  127636. targetScreenOffset: Vector2;
  127637. /**
  127638. * Allows the camera to be completely reversed.
  127639. * If false the camera can not arrive upside down.
  127640. */
  127641. allowUpsideDown: boolean;
  127642. /**
  127643. * Define if double tap/click is used to restore the previously saved state of the camera.
  127644. */
  127645. useInputToRestoreState: boolean;
  127646. /** @hidden */
  127647. _viewMatrix: Matrix;
  127648. /** @hidden */
  127649. _useCtrlForPanning: boolean;
  127650. /** @hidden */
  127651. _panningMouseButton: number;
  127652. /**
  127653. * Defines the input associated to the camera.
  127654. */
  127655. inputs: ArcRotateCameraInputsManager;
  127656. /** @hidden */
  127657. _reset: () => void;
  127658. /**
  127659. * Defines the allowed panning axis.
  127660. */
  127661. panningAxis: Vector3;
  127662. protected _localDirection: Vector3;
  127663. protected _transformedDirection: Vector3;
  127664. private _bouncingBehavior;
  127665. /**
  127666. * Gets the bouncing behavior of the camera if it has been enabled.
  127667. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127668. */
  127669. get bouncingBehavior(): Nullable<BouncingBehavior>;
  127670. /**
  127671. * Defines if the bouncing behavior of the camera is enabled on the camera.
  127672. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127673. */
  127674. get useBouncingBehavior(): boolean;
  127675. set useBouncingBehavior(value: boolean);
  127676. private _framingBehavior;
  127677. /**
  127678. * Gets the framing behavior of the camera if it has been enabled.
  127679. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127680. */
  127681. get framingBehavior(): Nullable<FramingBehavior>;
  127682. /**
  127683. * Defines if the framing behavior of the camera is enabled on the camera.
  127684. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127685. */
  127686. get useFramingBehavior(): boolean;
  127687. set useFramingBehavior(value: boolean);
  127688. private _autoRotationBehavior;
  127689. /**
  127690. * Gets the auto rotation behavior of the camera if it has been enabled.
  127691. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127692. */
  127693. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  127694. /**
  127695. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  127696. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127697. */
  127698. get useAutoRotationBehavior(): boolean;
  127699. set useAutoRotationBehavior(value: boolean);
  127700. /**
  127701. * Observable triggered when the mesh target has been changed on the camera.
  127702. */
  127703. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  127704. /**
  127705. * Event raised when the camera is colliding with a mesh.
  127706. */
  127707. onCollide: (collidedMesh: AbstractMesh) => void;
  127708. /**
  127709. * Defines whether the camera should check collision with the objects oh the scene.
  127710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  127711. */
  127712. checkCollisions: boolean;
  127713. /**
  127714. * Defines the collision radius of the camera.
  127715. * This simulates a sphere around the camera.
  127716. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127717. */
  127718. collisionRadius: Vector3;
  127719. protected _collider: Collider;
  127720. protected _previousPosition: Vector3;
  127721. protected _collisionVelocity: Vector3;
  127722. protected _newPosition: Vector3;
  127723. protected _previousAlpha: number;
  127724. protected _previousBeta: number;
  127725. protected _previousRadius: number;
  127726. protected _collisionTriggered: boolean;
  127727. protected _targetBoundingCenter: Nullable<Vector3>;
  127728. private _computationVector;
  127729. /**
  127730. * Instantiates a new ArcRotateCamera in a given scene
  127731. * @param name Defines the name of the camera
  127732. * @param alpha Defines the camera rotation along the logitudinal axis
  127733. * @param beta Defines the camera rotation along the latitudinal axis
  127734. * @param radius Defines the camera distance from its target
  127735. * @param target Defines the camera target
  127736. * @param scene Defines the scene the camera belongs to
  127737. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  127738. */
  127739. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127740. /** @hidden */
  127741. _initCache(): void;
  127742. /** @hidden */
  127743. _updateCache(ignoreParentClass?: boolean): void;
  127744. protected _getTargetPosition(): Vector3;
  127745. private _storedAlpha;
  127746. private _storedBeta;
  127747. private _storedRadius;
  127748. private _storedTarget;
  127749. private _storedTargetScreenOffset;
  127750. /**
  127751. * Stores the current state of the camera (alpha, beta, radius and target)
  127752. * @returns the camera itself
  127753. */
  127754. storeState(): Camera;
  127755. /**
  127756. * @hidden
  127757. * Restored camera state. You must call storeState() first
  127758. */
  127759. _restoreStateValues(): boolean;
  127760. /** @hidden */
  127761. _isSynchronizedViewMatrix(): boolean;
  127762. /**
  127763. * Attach the input controls to a specific dom element to get the input from.
  127764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127765. */
  127766. attachControl(noPreventDefault?: boolean): void;
  127767. /**
  127768. * Attach the input controls to a specific dom element to get the input from.
  127769. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  127770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127771. */
  127772. attachControl(ignored: any, noPreventDefault?: boolean): void;
  127773. /**
  127774. * Attached controls to the current camera.
  127775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127776. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127777. */
  127778. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  127779. /**
  127780. * Attached controls to the current camera.
  127781. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  127782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127783. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127784. */
  127785. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  127786. /**
  127787. * Attached controls to the current camera.
  127788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127789. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127790. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  127791. */
  127792. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  127793. /**
  127794. * Detach the current controls from the specified dom element.
  127795. */
  127796. detachControl(): void;
  127797. /** @hidden */
  127798. _checkInputs(): void;
  127799. protected _checkLimits(): void;
  127800. /**
  127801. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127802. */
  127803. rebuildAnglesAndRadius(): void;
  127804. /**
  127805. * Use a position to define the current camera related information like alpha, beta and radius
  127806. * @param position Defines the position to set the camera at
  127807. */
  127808. setPosition(position: Vector3): void;
  127809. /**
  127810. * Defines the target the camera should look at.
  127811. * This will automatically adapt alpha beta and radius to fit within the new target.
  127812. * @param target Defines the new target as a Vector or a mesh
  127813. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127814. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127815. */
  127816. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127817. /** @hidden */
  127818. _getViewMatrix(): Matrix;
  127819. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127820. /**
  127821. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127822. * @param meshes Defines the mesh to zoom on
  127823. * @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)
  127824. */
  127825. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127826. /**
  127827. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127828. * The target will be changed but the radius
  127829. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127830. * @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)
  127831. */
  127832. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127833. min: Vector3;
  127834. max: Vector3;
  127835. distance: number;
  127836. }, doNotUpdateMaxZ?: boolean): void;
  127837. /**
  127838. * @override
  127839. * Override Camera.createRigCamera
  127840. */
  127841. createRigCamera(name: string, cameraIndex: number): Camera;
  127842. /**
  127843. * @hidden
  127844. * @override
  127845. * Override Camera._updateRigCameras
  127846. */
  127847. _updateRigCameras(): void;
  127848. /**
  127849. * Destroy the camera and release the current resources hold by it.
  127850. */
  127851. dispose(): void;
  127852. /**
  127853. * Gets the current object class name.
  127854. * @return the class name
  127855. */
  127856. getClassName(): string;
  127857. }
  127858. }
  127859. declare module BABYLON {
  127860. /**
  127861. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127862. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127863. */
  127864. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127865. /**
  127866. * Gets the name of the behavior.
  127867. */
  127868. get name(): string;
  127869. private _zoomStopsAnimation;
  127870. private _idleRotationSpeed;
  127871. private _idleRotationWaitTime;
  127872. private _idleRotationSpinupTime;
  127873. /**
  127874. * Sets the flag that indicates if user zooming should stop animation.
  127875. */
  127876. set zoomStopsAnimation(flag: boolean);
  127877. /**
  127878. * Gets the flag that indicates if user zooming should stop animation.
  127879. */
  127880. get zoomStopsAnimation(): boolean;
  127881. /**
  127882. * Sets the default speed at which the camera rotates around the model.
  127883. */
  127884. set idleRotationSpeed(speed: number);
  127885. /**
  127886. * Gets the default speed at which the camera rotates around the model.
  127887. */
  127888. get idleRotationSpeed(): number;
  127889. /**
  127890. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127891. */
  127892. set idleRotationWaitTime(time: number);
  127893. /**
  127894. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127895. */
  127896. get idleRotationWaitTime(): number;
  127897. /**
  127898. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127899. */
  127900. set idleRotationSpinupTime(time: number);
  127901. /**
  127902. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127903. */
  127904. get idleRotationSpinupTime(): number;
  127905. /**
  127906. * Gets a value indicating if the camera is currently rotating because of this behavior
  127907. */
  127908. get rotationInProgress(): boolean;
  127909. private _onPrePointerObservableObserver;
  127910. private _onAfterCheckInputsObserver;
  127911. private _attachedCamera;
  127912. private _isPointerDown;
  127913. private _lastFrameTime;
  127914. private _lastInteractionTime;
  127915. private _cameraRotationSpeed;
  127916. /**
  127917. * Initializes the behavior.
  127918. */
  127919. init(): void;
  127920. /**
  127921. * Attaches the behavior to its arc rotate camera.
  127922. * @param camera Defines the camera to attach the behavior to
  127923. */
  127924. attach(camera: ArcRotateCamera): void;
  127925. /**
  127926. * Detaches the behavior from its current arc rotate camera.
  127927. */
  127928. detach(): void;
  127929. /**
  127930. * Returns true if user is scrolling.
  127931. * @return true if user is scrolling.
  127932. */
  127933. private _userIsZooming;
  127934. private _lastFrameRadius;
  127935. private _shouldAnimationStopForInteraction;
  127936. /**
  127937. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127938. */
  127939. private _applyUserInteraction;
  127940. private _userIsMoving;
  127941. }
  127942. }
  127943. declare module BABYLON {
  127944. /**
  127945. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127946. */
  127947. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127948. private ui;
  127949. /**
  127950. * The name of the behavior
  127951. */
  127952. name: string;
  127953. /**
  127954. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127955. */
  127956. distanceAwayFromFace: number;
  127957. /**
  127958. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127959. */
  127960. distanceAwayFromBottomOfFace: number;
  127961. private _faceVectors;
  127962. private _target;
  127963. private _scene;
  127964. private _onRenderObserver;
  127965. private _tmpMatrix;
  127966. private _tmpVector;
  127967. /**
  127968. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127969. * @param ui The transform node that should be attched to the mesh
  127970. */
  127971. constructor(ui: TransformNode);
  127972. /**
  127973. * Initializes the behavior
  127974. */
  127975. init(): void;
  127976. private _closestFace;
  127977. private _zeroVector;
  127978. private _lookAtTmpMatrix;
  127979. private _lookAtToRef;
  127980. /**
  127981. * Attaches the AttachToBoxBehavior to the passed in mesh
  127982. * @param target The mesh that the specified node will be attached to
  127983. */
  127984. attach(target: Mesh): void;
  127985. /**
  127986. * Detaches the behavior from the mesh
  127987. */
  127988. detach(): void;
  127989. }
  127990. }
  127991. declare module BABYLON {
  127992. /**
  127993. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127994. */
  127995. export class FadeInOutBehavior implements Behavior<Mesh> {
  127996. /**
  127997. * Time in milliseconds to delay before fading in (Default: 0)
  127998. */
  127999. delay: number;
  128000. /**
  128001. * Time in milliseconds for the mesh to fade in (Default: 300)
  128002. */
  128003. fadeInTime: number;
  128004. private _millisecondsPerFrame;
  128005. private _hovered;
  128006. private _hoverValue;
  128007. private _ownerNode;
  128008. /**
  128009. * Instatiates the FadeInOutBehavior
  128010. */
  128011. constructor();
  128012. /**
  128013. * The name of the behavior
  128014. */
  128015. get name(): string;
  128016. /**
  128017. * Initializes the behavior
  128018. */
  128019. init(): void;
  128020. /**
  128021. * Attaches the fade behavior on the passed in mesh
  128022. * @param ownerNode The mesh that will be faded in/out once attached
  128023. */
  128024. attach(ownerNode: Mesh): void;
  128025. /**
  128026. * Detaches the behavior from the mesh
  128027. */
  128028. detach(): void;
  128029. /**
  128030. * Triggers the mesh to begin fading in or out
  128031. * @param value if the object should fade in or out (true to fade in)
  128032. */
  128033. fadeIn(value: boolean): void;
  128034. private _update;
  128035. private _setAllVisibility;
  128036. }
  128037. }
  128038. declare module BABYLON {
  128039. /**
  128040. * Class containing a set of static utilities functions for managing Pivots
  128041. * @hidden
  128042. */
  128043. export class PivotTools {
  128044. private static _PivotCached;
  128045. private static _OldPivotPoint;
  128046. private static _PivotTranslation;
  128047. private static _PivotTmpVector;
  128048. private static _PivotPostMultiplyPivotMatrix;
  128049. /** @hidden */
  128050. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128051. /** @hidden */
  128052. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128053. }
  128054. }
  128055. declare module BABYLON {
  128056. /**
  128057. * Class containing static functions to help procedurally build meshes
  128058. */
  128059. export class PlaneBuilder {
  128060. /**
  128061. * Creates a plane mesh
  128062. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128063. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128064. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128068. * @param name defines the name of the mesh
  128069. * @param options defines the options used to create the mesh
  128070. * @param scene defines the hosting scene
  128071. * @returns the plane mesh
  128072. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128073. */
  128074. static CreatePlane(name: string, options: {
  128075. size?: number;
  128076. width?: number;
  128077. height?: number;
  128078. sideOrientation?: number;
  128079. frontUVs?: Vector4;
  128080. backUVs?: Vector4;
  128081. updatable?: boolean;
  128082. sourcePlane?: Plane;
  128083. }, scene?: Nullable<Scene>): Mesh;
  128084. }
  128085. }
  128086. declare module BABYLON {
  128087. /**
  128088. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128089. */
  128090. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128091. private static _AnyMouseID;
  128092. /**
  128093. * Abstract mesh the behavior is set on
  128094. */
  128095. attachedNode: AbstractMesh;
  128096. private _dragPlane;
  128097. private _scene;
  128098. private _pointerObserver;
  128099. private _beforeRenderObserver;
  128100. private static _planeScene;
  128101. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128102. /**
  128103. * 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)
  128104. */
  128105. maxDragAngle: number;
  128106. /**
  128107. * @hidden
  128108. */
  128109. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128110. /**
  128111. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128112. */
  128113. currentDraggingPointerID: number;
  128114. /**
  128115. * The last position where the pointer hit the drag plane in world space
  128116. */
  128117. lastDragPosition: Vector3;
  128118. /**
  128119. * If the behavior is currently in a dragging state
  128120. */
  128121. dragging: boolean;
  128122. /**
  128123. * 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)
  128124. */
  128125. dragDeltaRatio: number;
  128126. /**
  128127. * If the drag plane orientation should be updated during the dragging (Default: true)
  128128. */
  128129. updateDragPlane: boolean;
  128130. private _debugMode;
  128131. private _moving;
  128132. /**
  128133. * Fires each time the attached mesh is dragged with the pointer
  128134. * * delta between last drag position and current drag position in world space
  128135. * * dragDistance along the drag axis
  128136. * * dragPlaneNormal normal of the current drag plane used during the drag
  128137. * * dragPlanePoint in world space where the drag intersects the drag plane
  128138. */
  128139. onDragObservable: Observable<{
  128140. delta: Vector3;
  128141. dragPlanePoint: Vector3;
  128142. dragPlaneNormal: Vector3;
  128143. dragDistance: number;
  128144. pointerId: number;
  128145. }>;
  128146. /**
  128147. * Fires each time a drag begins (eg. mouse down on mesh)
  128148. */
  128149. onDragStartObservable: Observable<{
  128150. dragPlanePoint: Vector3;
  128151. pointerId: number;
  128152. }>;
  128153. /**
  128154. * Fires each time a drag ends (eg. mouse release after drag)
  128155. */
  128156. onDragEndObservable: Observable<{
  128157. dragPlanePoint: Vector3;
  128158. pointerId: number;
  128159. }>;
  128160. /**
  128161. * If the attached mesh should be moved when dragged
  128162. */
  128163. moveAttached: boolean;
  128164. /**
  128165. * If the drag behavior will react to drag events (Default: true)
  128166. */
  128167. enabled: boolean;
  128168. /**
  128169. * If pointer events should start and release the drag (Default: true)
  128170. */
  128171. startAndReleaseDragOnPointerEvents: boolean;
  128172. /**
  128173. * If camera controls should be detached during the drag
  128174. */
  128175. detachCameraControls: boolean;
  128176. /**
  128177. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128178. */
  128179. useObjectOrientationForDragging: boolean;
  128180. private _options;
  128181. /**
  128182. * Gets the options used by the behavior
  128183. */
  128184. get options(): {
  128185. dragAxis?: Vector3;
  128186. dragPlaneNormal?: Vector3;
  128187. };
  128188. /**
  128189. * Sets the options used by the behavior
  128190. */
  128191. set options(options: {
  128192. dragAxis?: Vector3;
  128193. dragPlaneNormal?: Vector3;
  128194. });
  128195. /**
  128196. * Creates a pointer drag behavior that can be attached to a mesh
  128197. * @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)
  128198. */
  128199. constructor(options?: {
  128200. dragAxis?: Vector3;
  128201. dragPlaneNormal?: Vector3;
  128202. });
  128203. /**
  128204. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128205. */
  128206. validateDrag: (targetPosition: Vector3) => boolean;
  128207. /**
  128208. * The name of the behavior
  128209. */
  128210. get name(): string;
  128211. /**
  128212. * Initializes the behavior
  128213. */
  128214. init(): void;
  128215. private _tmpVector;
  128216. private _alternatePickedPoint;
  128217. private _worldDragAxis;
  128218. private _targetPosition;
  128219. private _attachedToElement;
  128220. /**
  128221. * Attaches the drag behavior the passed in mesh
  128222. * @param ownerNode The mesh that will be dragged around once attached
  128223. * @param predicate Predicate to use for pick filtering
  128224. */
  128225. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128226. /**
  128227. * Force relase the drag action by code.
  128228. */
  128229. releaseDrag(): void;
  128230. private _startDragRay;
  128231. private _lastPointerRay;
  128232. /**
  128233. * Simulates the start of a pointer drag event on the behavior
  128234. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128235. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128236. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128237. */
  128238. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128239. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128240. private _dragDelta;
  128241. protected _moveDrag(ray: Ray): void;
  128242. private _pickWithRayOnDragPlane;
  128243. private _pointA;
  128244. private _pointC;
  128245. private _localAxis;
  128246. private _lookAt;
  128247. private _updateDragPlanePosition;
  128248. /**
  128249. * Detaches the behavior from the mesh
  128250. */
  128251. detach(): void;
  128252. }
  128253. }
  128254. declare module BABYLON {
  128255. /**
  128256. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128257. */
  128258. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128259. private _dragBehaviorA;
  128260. private _dragBehaviorB;
  128261. private _startDistance;
  128262. private _initialScale;
  128263. private _targetScale;
  128264. private _ownerNode;
  128265. private _sceneRenderObserver;
  128266. /**
  128267. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128268. */
  128269. constructor();
  128270. /**
  128271. * The name of the behavior
  128272. */
  128273. get name(): string;
  128274. /**
  128275. * Initializes the behavior
  128276. */
  128277. init(): void;
  128278. private _getCurrentDistance;
  128279. /**
  128280. * Attaches the scale behavior the passed in mesh
  128281. * @param ownerNode The mesh that will be scaled around once attached
  128282. */
  128283. attach(ownerNode: Mesh): void;
  128284. /**
  128285. * Detaches the behavior from the mesh
  128286. */
  128287. detach(): void;
  128288. }
  128289. }
  128290. declare module BABYLON {
  128291. /**
  128292. * 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
  128293. */
  128294. export class SixDofDragBehavior implements Behavior<Mesh> {
  128295. private static _virtualScene;
  128296. private _ownerNode;
  128297. private _sceneRenderObserver;
  128298. private _scene;
  128299. private _targetPosition;
  128300. private _virtualOriginMesh;
  128301. private _virtualDragMesh;
  128302. private _pointerObserver;
  128303. private _moving;
  128304. private _startingOrientation;
  128305. private _attachedToElement;
  128306. /**
  128307. * 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)
  128308. */
  128309. private zDragFactor;
  128310. /**
  128311. * If the object should rotate to face the drag origin
  128312. */
  128313. rotateDraggedObject: boolean;
  128314. /**
  128315. * If the behavior is currently in a dragging state
  128316. */
  128317. dragging: boolean;
  128318. /**
  128319. * 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)
  128320. */
  128321. dragDeltaRatio: number;
  128322. /**
  128323. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128324. */
  128325. currentDraggingPointerID: number;
  128326. /**
  128327. * If camera controls should be detached during the drag
  128328. */
  128329. detachCameraControls: boolean;
  128330. /**
  128331. * Fires each time a drag starts
  128332. */
  128333. onDragStartObservable: Observable<{}>;
  128334. /**
  128335. * Fires each time a drag ends (eg. mouse release after drag)
  128336. */
  128337. onDragEndObservable: Observable<{}>;
  128338. /**
  128339. * 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
  128340. */
  128341. constructor();
  128342. /**
  128343. * The name of the behavior
  128344. */
  128345. get name(): string;
  128346. /**
  128347. * Initializes the behavior
  128348. */
  128349. init(): void;
  128350. /**
  128351. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  128352. */
  128353. private get _pointerCamera();
  128354. /**
  128355. * Attaches the scale behavior the passed in mesh
  128356. * @param ownerNode The mesh that will be scaled around once attached
  128357. */
  128358. attach(ownerNode: Mesh): void;
  128359. /**
  128360. * Detaches the behavior from the mesh
  128361. */
  128362. detach(): void;
  128363. }
  128364. }
  128365. declare module BABYLON {
  128366. /**
  128367. * Class used to apply inverse kinematics to bones
  128368. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  128369. */
  128370. export class BoneIKController {
  128371. private static _tmpVecs;
  128372. private static _tmpQuat;
  128373. private static _tmpMats;
  128374. /**
  128375. * Gets or sets the target mesh
  128376. */
  128377. targetMesh: AbstractMesh;
  128378. /** Gets or sets the mesh used as pole */
  128379. poleTargetMesh: AbstractMesh;
  128380. /**
  128381. * Gets or sets the bone used as pole
  128382. */
  128383. poleTargetBone: Nullable<Bone>;
  128384. /**
  128385. * Gets or sets the target position
  128386. */
  128387. targetPosition: Vector3;
  128388. /**
  128389. * Gets or sets the pole target position
  128390. */
  128391. poleTargetPosition: Vector3;
  128392. /**
  128393. * Gets or sets the pole target local offset
  128394. */
  128395. poleTargetLocalOffset: Vector3;
  128396. /**
  128397. * Gets or sets the pole angle
  128398. */
  128399. poleAngle: number;
  128400. /**
  128401. * Gets or sets the mesh associated with the controller
  128402. */
  128403. mesh: AbstractMesh;
  128404. /**
  128405. * 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)
  128406. */
  128407. slerpAmount: number;
  128408. private _bone1Quat;
  128409. private _bone1Mat;
  128410. private _bone2Ang;
  128411. private _bone1;
  128412. private _bone2;
  128413. private _bone1Length;
  128414. private _bone2Length;
  128415. private _maxAngle;
  128416. private _maxReach;
  128417. private _rightHandedSystem;
  128418. private _bendAxis;
  128419. private _slerping;
  128420. private _adjustRoll;
  128421. /**
  128422. * Gets or sets maximum allowed angle
  128423. */
  128424. get maxAngle(): number;
  128425. set maxAngle(value: number);
  128426. /**
  128427. * Creates a new BoneIKController
  128428. * @param mesh defines the mesh to control
  128429. * @param bone defines the bone to control
  128430. * @param options defines options to set up the controller
  128431. */
  128432. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  128433. targetMesh?: AbstractMesh;
  128434. poleTargetMesh?: AbstractMesh;
  128435. poleTargetBone?: Bone;
  128436. poleTargetLocalOffset?: Vector3;
  128437. poleAngle?: number;
  128438. bendAxis?: Vector3;
  128439. maxAngle?: number;
  128440. slerpAmount?: number;
  128441. });
  128442. private _setMaxAngle;
  128443. /**
  128444. * Force the controller to update the bones
  128445. */
  128446. update(): void;
  128447. }
  128448. }
  128449. declare module BABYLON {
  128450. /**
  128451. * Class used to make a bone look toward a point in space
  128452. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  128453. */
  128454. export class BoneLookController {
  128455. private static _tmpVecs;
  128456. private static _tmpQuat;
  128457. private static _tmpMats;
  128458. /**
  128459. * The target Vector3 that the bone will look at
  128460. */
  128461. target: Vector3;
  128462. /**
  128463. * The mesh that the bone is attached to
  128464. */
  128465. mesh: AbstractMesh;
  128466. /**
  128467. * The bone that will be looking to the target
  128468. */
  128469. bone: Bone;
  128470. /**
  128471. * The up axis of the coordinate system that is used when the bone is rotated
  128472. */
  128473. upAxis: Vector3;
  128474. /**
  128475. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  128476. */
  128477. upAxisSpace: Space;
  128478. /**
  128479. * Used to make an adjustment to the yaw of the bone
  128480. */
  128481. adjustYaw: number;
  128482. /**
  128483. * Used to make an adjustment to the pitch of the bone
  128484. */
  128485. adjustPitch: number;
  128486. /**
  128487. * Used to make an adjustment to the roll of the bone
  128488. */
  128489. adjustRoll: number;
  128490. /**
  128491. * 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)
  128492. */
  128493. slerpAmount: number;
  128494. private _minYaw;
  128495. private _maxYaw;
  128496. private _minPitch;
  128497. private _maxPitch;
  128498. private _minYawSin;
  128499. private _minYawCos;
  128500. private _maxYawSin;
  128501. private _maxYawCos;
  128502. private _midYawConstraint;
  128503. private _minPitchTan;
  128504. private _maxPitchTan;
  128505. private _boneQuat;
  128506. private _slerping;
  128507. private _transformYawPitch;
  128508. private _transformYawPitchInv;
  128509. private _firstFrameSkipped;
  128510. private _yawRange;
  128511. private _fowardAxis;
  128512. /**
  128513. * Gets or sets the minimum yaw angle that the bone can look to
  128514. */
  128515. get minYaw(): number;
  128516. set minYaw(value: number);
  128517. /**
  128518. * Gets or sets the maximum yaw angle that the bone can look to
  128519. */
  128520. get maxYaw(): number;
  128521. set maxYaw(value: number);
  128522. /**
  128523. * Gets or sets the minimum pitch angle that the bone can look to
  128524. */
  128525. get minPitch(): number;
  128526. set minPitch(value: number);
  128527. /**
  128528. * Gets or sets the maximum pitch angle that the bone can look to
  128529. */
  128530. get maxPitch(): number;
  128531. set maxPitch(value: number);
  128532. /**
  128533. * Create a BoneLookController
  128534. * @param mesh the mesh that the bone belongs to
  128535. * @param bone the bone that will be looking to the target
  128536. * @param target the target Vector3 to look at
  128537. * @param options optional settings:
  128538. * * maxYaw: the maximum angle the bone will yaw to
  128539. * * minYaw: the minimum angle the bone will yaw to
  128540. * * maxPitch: the maximum angle the bone will pitch to
  128541. * * minPitch: the minimum angle the bone will yaw to
  128542. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  128543. * * upAxis: the up axis of the coordinate system
  128544. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  128545. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  128546. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  128547. * * adjustYaw: used to make an adjustment to the yaw of the bone
  128548. * * adjustPitch: used to make an adjustment to the pitch of the bone
  128549. * * adjustRoll: used to make an adjustment to the roll of the bone
  128550. **/
  128551. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  128552. maxYaw?: number;
  128553. minYaw?: number;
  128554. maxPitch?: number;
  128555. minPitch?: number;
  128556. slerpAmount?: number;
  128557. upAxis?: Vector3;
  128558. upAxisSpace?: Space;
  128559. yawAxis?: Vector3;
  128560. pitchAxis?: Vector3;
  128561. adjustYaw?: number;
  128562. adjustPitch?: number;
  128563. adjustRoll?: number;
  128564. });
  128565. /**
  128566. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  128567. */
  128568. update(): void;
  128569. private _getAngleDiff;
  128570. private _getAngleBetween;
  128571. private _isAngleBetween;
  128572. }
  128573. }
  128574. declare module BABYLON {
  128575. /**
  128576. * Manage the gamepad inputs to control an arc rotate camera.
  128577. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128578. */
  128579. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  128580. /**
  128581. * Defines the camera the input is attached to.
  128582. */
  128583. camera: ArcRotateCamera;
  128584. /**
  128585. * Defines the gamepad the input is gathering event from.
  128586. */
  128587. gamepad: Nullable<Gamepad>;
  128588. /**
  128589. * Defines the gamepad rotation sensiblity.
  128590. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128591. */
  128592. gamepadRotationSensibility: number;
  128593. /**
  128594. * Defines the gamepad move sensiblity.
  128595. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128596. */
  128597. gamepadMoveSensibility: number;
  128598. private _yAxisScale;
  128599. /**
  128600. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128601. */
  128602. get invertYAxis(): boolean;
  128603. set invertYAxis(value: boolean);
  128604. private _onGamepadConnectedObserver;
  128605. private _onGamepadDisconnectedObserver;
  128606. /**
  128607. * Attach the input controls to a specific dom element to get the input from.
  128608. */
  128609. attachControl(): void;
  128610. /**
  128611. * Detach the current controls from the specified dom element.
  128612. */
  128613. detachControl(): void;
  128614. /**
  128615. * Update the current camera state depending on the inputs that have been used this frame.
  128616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128617. */
  128618. checkInputs(): void;
  128619. /**
  128620. * Gets the class name of the current intput.
  128621. * @returns the class name
  128622. */
  128623. getClassName(): string;
  128624. /**
  128625. * Get the friendly name associated with the input class.
  128626. * @returns the input friendly name
  128627. */
  128628. getSimpleName(): string;
  128629. }
  128630. }
  128631. declare module BABYLON {
  128632. interface ArcRotateCameraInputsManager {
  128633. /**
  128634. * Add orientation input support to the input manager.
  128635. * @returns the current input manager
  128636. */
  128637. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  128638. }
  128639. /**
  128640. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  128641. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128642. */
  128643. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  128644. /**
  128645. * Defines the camera the input is attached to.
  128646. */
  128647. camera: ArcRotateCamera;
  128648. /**
  128649. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  128650. */
  128651. alphaCorrection: number;
  128652. /**
  128653. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  128654. */
  128655. gammaCorrection: number;
  128656. private _alpha;
  128657. private _gamma;
  128658. private _dirty;
  128659. private _deviceOrientationHandler;
  128660. /**
  128661. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  128662. */
  128663. constructor();
  128664. /**
  128665. * Attach the input controls to a specific dom element to get the input from.
  128666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128667. */
  128668. attachControl(noPreventDefault?: boolean): void;
  128669. /** @hidden */
  128670. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  128671. /**
  128672. * Update the current camera state depending on the inputs that have been used this frame.
  128673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128674. */
  128675. checkInputs(): void;
  128676. /**
  128677. * Detach the current controls from the specified dom element.
  128678. */
  128679. detachControl(): void;
  128680. /**
  128681. * Gets the class name of the current intput.
  128682. * @returns the class name
  128683. */
  128684. getClassName(): string;
  128685. /**
  128686. * Get the friendly name associated with the input class.
  128687. * @returns the input friendly name
  128688. */
  128689. getSimpleName(): string;
  128690. }
  128691. }
  128692. declare module BABYLON {
  128693. /**
  128694. * Listen to mouse events to control the camera.
  128695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128696. */
  128697. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  128698. /**
  128699. * Defines the camera the input is attached to.
  128700. */
  128701. camera: FlyCamera;
  128702. /**
  128703. * Defines if touch is enabled. (Default is true.)
  128704. */
  128705. touchEnabled: boolean;
  128706. /**
  128707. * Defines the buttons associated with the input to handle camera rotation.
  128708. */
  128709. buttons: number[];
  128710. /**
  128711. * Assign buttons for Yaw control.
  128712. */
  128713. buttonsYaw: number[];
  128714. /**
  128715. * Assign buttons for Pitch control.
  128716. */
  128717. buttonsPitch: number[];
  128718. /**
  128719. * Assign buttons for Roll control.
  128720. */
  128721. buttonsRoll: number[];
  128722. /**
  128723. * Detect if any button is being pressed while mouse is moved.
  128724. * -1 = Mouse locked.
  128725. * 0 = Left button.
  128726. * 1 = Middle Button.
  128727. * 2 = Right Button.
  128728. */
  128729. activeButton: number;
  128730. /**
  128731. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  128732. * Higher values reduce its sensitivity.
  128733. */
  128734. angularSensibility: number;
  128735. private _observer;
  128736. private _rollObserver;
  128737. private previousPosition;
  128738. private noPreventDefault;
  128739. private element;
  128740. /**
  128741. * Listen to mouse events to control the camera.
  128742. * @param touchEnabled Define if touch is enabled. (Default is true.)
  128743. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128744. */
  128745. constructor(touchEnabled?: boolean);
  128746. /**
  128747. * Attach the mouse control to the HTML DOM element.
  128748. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  128749. */
  128750. attachControl(noPreventDefault?: boolean): void;
  128751. /**
  128752. * Detach the current controls from the specified dom element.
  128753. */
  128754. detachControl(): void;
  128755. /**
  128756. * Gets the class name of the current input.
  128757. * @returns the class name.
  128758. */
  128759. getClassName(): string;
  128760. /**
  128761. * Get the friendly name associated with the input class.
  128762. * @returns the input's friendly name.
  128763. */
  128764. getSimpleName(): string;
  128765. private _pointerInput;
  128766. private _onMouseMove;
  128767. /**
  128768. * Rotate camera by mouse offset.
  128769. */
  128770. private rotateCamera;
  128771. }
  128772. }
  128773. declare module BABYLON {
  128774. /**
  128775. * Default Inputs manager for the FlyCamera.
  128776. * It groups all the default supported inputs for ease of use.
  128777. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128778. */
  128779. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  128780. /**
  128781. * Instantiates a new FlyCameraInputsManager.
  128782. * @param camera Defines the camera the inputs belong to.
  128783. */
  128784. constructor(camera: FlyCamera);
  128785. /**
  128786. * Add keyboard input support to the input manager.
  128787. * @returns the new FlyCameraKeyboardMoveInput().
  128788. */
  128789. addKeyboard(): FlyCameraInputsManager;
  128790. /**
  128791. * Add mouse input support to the input manager.
  128792. * @param touchEnabled Enable touch screen support.
  128793. * @returns the new FlyCameraMouseInput().
  128794. */
  128795. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128796. }
  128797. }
  128798. declare module BABYLON {
  128799. /**
  128800. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128801. * such as in a 3D Space Shooter or a Flight Simulator.
  128802. */
  128803. export class FlyCamera extends TargetCamera {
  128804. /**
  128805. * Define the collision ellipsoid of the camera.
  128806. * This is helpful for simulating a camera body, like a player's body.
  128807. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128808. */
  128809. ellipsoid: Vector3;
  128810. /**
  128811. * Define an offset for the position of the ellipsoid around the camera.
  128812. * This can be helpful if the camera is attached away from the player's body center,
  128813. * such as at its head.
  128814. */
  128815. ellipsoidOffset: Vector3;
  128816. /**
  128817. * Enable or disable collisions of the camera with the rest of the scene objects.
  128818. */
  128819. checkCollisions: boolean;
  128820. /**
  128821. * Enable or disable gravity on the camera.
  128822. */
  128823. applyGravity: boolean;
  128824. /**
  128825. * Define the current direction the camera is moving to.
  128826. */
  128827. cameraDirection: Vector3;
  128828. /**
  128829. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128830. * This overrides and empties cameraRotation.
  128831. */
  128832. rotationQuaternion: Quaternion;
  128833. /**
  128834. * Track Roll to maintain the wanted Rolling when looking around.
  128835. */
  128836. _trackRoll: number;
  128837. /**
  128838. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128839. */
  128840. rollCorrect: number;
  128841. /**
  128842. * Mimic a banked turn, Rolling the camera when Yawing.
  128843. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128844. */
  128845. bankedTurn: boolean;
  128846. /**
  128847. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128848. */
  128849. bankedTurnLimit: number;
  128850. /**
  128851. * Value of 0 disables the banked Roll.
  128852. * Value of 1 is equal to the Yaw angle in radians.
  128853. */
  128854. bankedTurnMultiplier: number;
  128855. /**
  128856. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128857. */
  128858. inputs: FlyCameraInputsManager;
  128859. /**
  128860. * Gets the input sensibility for mouse input.
  128861. * Higher values reduce sensitivity.
  128862. */
  128863. get angularSensibility(): number;
  128864. /**
  128865. * Sets the input sensibility for a mouse input.
  128866. * Higher values reduce sensitivity.
  128867. */
  128868. set angularSensibility(value: number);
  128869. /**
  128870. * Get the keys for camera movement forward.
  128871. */
  128872. get keysForward(): number[];
  128873. /**
  128874. * Set the keys for camera movement forward.
  128875. */
  128876. set keysForward(value: number[]);
  128877. /**
  128878. * Get the keys for camera movement backward.
  128879. */
  128880. get keysBackward(): number[];
  128881. set keysBackward(value: number[]);
  128882. /**
  128883. * Get the keys for camera movement up.
  128884. */
  128885. get keysUp(): number[];
  128886. /**
  128887. * Set the keys for camera movement up.
  128888. */
  128889. set keysUp(value: number[]);
  128890. /**
  128891. * Get the keys for camera movement down.
  128892. */
  128893. get keysDown(): number[];
  128894. /**
  128895. * Set the keys for camera movement down.
  128896. */
  128897. set keysDown(value: number[]);
  128898. /**
  128899. * Get the keys for camera movement left.
  128900. */
  128901. get keysLeft(): number[];
  128902. /**
  128903. * Set the keys for camera movement left.
  128904. */
  128905. set keysLeft(value: number[]);
  128906. /**
  128907. * Set the keys for camera movement right.
  128908. */
  128909. get keysRight(): number[];
  128910. /**
  128911. * Set the keys for camera movement right.
  128912. */
  128913. set keysRight(value: number[]);
  128914. /**
  128915. * Event raised when the camera collides with a mesh in the scene.
  128916. */
  128917. onCollide: (collidedMesh: AbstractMesh) => void;
  128918. private _collider;
  128919. private _needMoveForGravity;
  128920. private _oldPosition;
  128921. private _diffPosition;
  128922. private _newPosition;
  128923. /** @hidden */
  128924. _localDirection: Vector3;
  128925. /** @hidden */
  128926. _transformedDirection: Vector3;
  128927. /**
  128928. * Instantiates a FlyCamera.
  128929. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128930. * such as in a 3D Space Shooter or a Flight Simulator.
  128931. * @param name Define the name of the camera in the scene.
  128932. * @param position Define the starting position of the camera in the scene.
  128933. * @param scene Define the scene the camera belongs to.
  128934. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128935. */
  128936. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128937. /**
  128938. * Attach the input controls to a specific dom element to get the input from.
  128939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128940. */
  128941. attachControl(noPreventDefault?: boolean): void;
  128942. /**
  128943. * Detach a control from the HTML DOM element.
  128944. * The camera will stop reacting to that input.
  128945. */
  128946. detachControl(): void;
  128947. private _collisionMask;
  128948. /**
  128949. * Get the mask that the camera ignores in collision events.
  128950. */
  128951. get collisionMask(): number;
  128952. /**
  128953. * Set the mask that the camera ignores in collision events.
  128954. */
  128955. set collisionMask(mask: number);
  128956. /** @hidden */
  128957. _collideWithWorld(displacement: Vector3): void;
  128958. /** @hidden */
  128959. private _onCollisionPositionChange;
  128960. /** @hidden */
  128961. _checkInputs(): void;
  128962. /** @hidden */
  128963. _decideIfNeedsToMove(): boolean;
  128964. /** @hidden */
  128965. _updatePosition(): void;
  128966. /**
  128967. * Restore the Roll to its target value at the rate specified.
  128968. * @param rate - Higher means slower restoring.
  128969. * @hidden
  128970. */
  128971. restoreRoll(rate: number): void;
  128972. /**
  128973. * Destroy the camera and release the current resources held by it.
  128974. */
  128975. dispose(): void;
  128976. /**
  128977. * Get the current object class name.
  128978. * @returns the class name.
  128979. */
  128980. getClassName(): string;
  128981. }
  128982. }
  128983. declare module BABYLON {
  128984. /**
  128985. * Listen to keyboard events to control the camera.
  128986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128987. */
  128988. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128989. /**
  128990. * Defines the camera the input is attached to.
  128991. */
  128992. camera: FlyCamera;
  128993. /**
  128994. * The list of keyboard keys used to control the forward move of the camera.
  128995. */
  128996. keysForward: number[];
  128997. /**
  128998. * The list of keyboard keys used to control the backward move of the camera.
  128999. */
  129000. keysBackward: number[];
  129001. /**
  129002. * The list of keyboard keys used to control the forward move of the camera.
  129003. */
  129004. keysUp: number[];
  129005. /**
  129006. * The list of keyboard keys used to control the backward move of the camera.
  129007. */
  129008. keysDown: number[];
  129009. /**
  129010. * The list of keyboard keys used to control the right strafe move of the camera.
  129011. */
  129012. keysRight: number[];
  129013. /**
  129014. * The list of keyboard keys used to control the left strafe move of the camera.
  129015. */
  129016. keysLeft: number[];
  129017. private _keys;
  129018. private _onCanvasBlurObserver;
  129019. private _onKeyboardObserver;
  129020. private _engine;
  129021. private _scene;
  129022. /**
  129023. * Attach the input controls to a specific dom element to get the input from.
  129024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129025. */
  129026. attachControl(noPreventDefault?: boolean): void;
  129027. /**
  129028. * Detach the current controls from the specified dom element.
  129029. */
  129030. detachControl(): void;
  129031. /**
  129032. * Gets the class name of the current intput.
  129033. * @returns the class name
  129034. */
  129035. getClassName(): string;
  129036. /** @hidden */
  129037. _onLostFocus(e: FocusEvent): void;
  129038. /**
  129039. * Get the friendly name associated with the input class.
  129040. * @returns the input friendly name
  129041. */
  129042. getSimpleName(): string;
  129043. /**
  129044. * Update the current camera state depending on the inputs that have been used this frame.
  129045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129046. */
  129047. checkInputs(): void;
  129048. }
  129049. }
  129050. declare module BABYLON {
  129051. /**
  129052. * Manage the mouse wheel inputs to control a follow camera.
  129053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129054. */
  129055. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129056. /**
  129057. * Defines the camera the input is attached to.
  129058. */
  129059. camera: FollowCamera;
  129060. /**
  129061. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129062. */
  129063. axisControlRadius: boolean;
  129064. /**
  129065. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129066. */
  129067. axisControlHeight: boolean;
  129068. /**
  129069. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129070. */
  129071. axisControlRotation: boolean;
  129072. /**
  129073. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129074. * relation to mouseWheel events.
  129075. */
  129076. wheelPrecision: number;
  129077. /**
  129078. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129079. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129080. */
  129081. wheelDeltaPercentage: number;
  129082. private _wheel;
  129083. private _observer;
  129084. /**
  129085. * Attach the input controls to a specific dom element to get the input from.
  129086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129087. */
  129088. attachControl(noPreventDefault?: boolean): void;
  129089. /**
  129090. * Detach the current controls from the specified dom element.
  129091. */
  129092. detachControl(): void;
  129093. /**
  129094. * Gets the class name of the current intput.
  129095. * @returns the class name
  129096. */
  129097. getClassName(): string;
  129098. /**
  129099. * Get the friendly name associated with the input class.
  129100. * @returns the input friendly name
  129101. */
  129102. getSimpleName(): string;
  129103. }
  129104. }
  129105. declare module BABYLON {
  129106. /**
  129107. * Manage the pointers inputs to control an follow camera.
  129108. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129109. */
  129110. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129111. /**
  129112. * Defines the camera the input is attached to.
  129113. */
  129114. camera: FollowCamera;
  129115. /**
  129116. * Gets the class name of the current input.
  129117. * @returns the class name
  129118. */
  129119. getClassName(): string;
  129120. /**
  129121. * Defines the pointer angular sensibility along the X axis or how fast is
  129122. * the camera rotating.
  129123. * A negative number will reverse the axis direction.
  129124. */
  129125. angularSensibilityX: number;
  129126. /**
  129127. * Defines the pointer angular sensibility along the Y axis or how fast is
  129128. * the camera rotating.
  129129. * A negative number will reverse the axis direction.
  129130. */
  129131. angularSensibilityY: number;
  129132. /**
  129133. * Defines the pointer pinch precision or how fast is the camera zooming.
  129134. * A negative number will reverse the axis direction.
  129135. */
  129136. pinchPrecision: number;
  129137. /**
  129138. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129139. * from 0.
  129140. * It defines the percentage of current camera.radius to use as delta when
  129141. * pinch zoom is used.
  129142. */
  129143. pinchDeltaPercentage: number;
  129144. /**
  129145. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129146. */
  129147. axisXControlRadius: boolean;
  129148. /**
  129149. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129150. */
  129151. axisXControlHeight: boolean;
  129152. /**
  129153. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129154. */
  129155. axisXControlRotation: boolean;
  129156. /**
  129157. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129158. */
  129159. axisYControlRadius: boolean;
  129160. /**
  129161. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129162. */
  129163. axisYControlHeight: boolean;
  129164. /**
  129165. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129166. */
  129167. axisYControlRotation: boolean;
  129168. /**
  129169. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129170. */
  129171. axisPinchControlRadius: boolean;
  129172. /**
  129173. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129174. */
  129175. axisPinchControlHeight: boolean;
  129176. /**
  129177. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129178. */
  129179. axisPinchControlRotation: boolean;
  129180. /**
  129181. * Log error messages if basic misconfiguration has occurred.
  129182. */
  129183. warningEnable: boolean;
  129184. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129186. private _warningCounter;
  129187. private _warning;
  129188. }
  129189. }
  129190. declare module BABYLON {
  129191. /**
  129192. * Default Inputs manager for the FollowCamera.
  129193. * It groups all the default supported inputs for ease of use.
  129194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129195. */
  129196. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129197. /**
  129198. * Instantiates a new FollowCameraInputsManager.
  129199. * @param camera Defines the camera the inputs belong to
  129200. */
  129201. constructor(camera: FollowCamera);
  129202. /**
  129203. * Add keyboard input support to the input manager.
  129204. * @returns the current input manager
  129205. */
  129206. addKeyboard(): FollowCameraInputsManager;
  129207. /**
  129208. * Add mouse wheel input support to the input manager.
  129209. * @returns the current input manager
  129210. */
  129211. addMouseWheel(): FollowCameraInputsManager;
  129212. /**
  129213. * Add pointers input support to the input manager.
  129214. * @returns the current input manager
  129215. */
  129216. addPointers(): FollowCameraInputsManager;
  129217. /**
  129218. * Add orientation input support to the input manager.
  129219. * @returns the current input manager
  129220. */
  129221. addVRDeviceOrientation(): FollowCameraInputsManager;
  129222. }
  129223. }
  129224. declare module BABYLON {
  129225. /**
  129226. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129227. * an arc rotate version arcFollowCamera are available.
  129228. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129229. */
  129230. export class FollowCamera extends TargetCamera {
  129231. /**
  129232. * Distance the follow camera should follow an object at
  129233. */
  129234. radius: number;
  129235. /**
  129236. * Minimum allowed distance of the camera to the axis of rotation
  129237. * (The camera can not get closer).
  129238. * This can help limiting how the Camera is able to move in the scene.
  129239. */
  129240. lowerRadiusLimit: Nullable<number>;
  129241. /**
  129242. * Maximum allowed distance of the camera to the axis of rotation
  129243. * (The camera can not get further).
  129244. * This can help limiting how the Camera is able to move in the scene.
  129245. */
  129246. upperRadiusLimit: Nullable<number>;
  129247. /**
  129248. * Define a rotation offset between the camera and the object it follows
  129249. */
  129250. rotationOffset: number;
  129251. /**
  129252. * Minimum allowed angle to camera position relative to target object.
  129253. * This can help limiting how the Camera is able to move in the scene.
  129254. */
  129255. lowerRotationOffsetLimit: Nullable<number>;
  129256. /**
  129257. * Maximum allowed angle to camera position relative to target object.
  129258. * This can help limiting how the Camera is able to move in the scene.
  129259. */
  129260. upperRotationOffsetLimit: Nullable<number>;
  129261. /**
  129262. * Define a height offset between the camera and the object it follows.
  129263. * It can help following an object from the top (like a car chaing a plane)
  129264. */
  129265. heightOffset: number;
  129266. /**
  129267. * Minimum allowed height of camera position relative to target object.
  129268. * This can help limiting how the Camera is able to move in the scene.
  129269. */
  129270. lowerHeightOffsetLimit: Nullable<number>;
  129271. /**
  129272. * Maximum allowed height of camera position relative to target object.
  129273. * This can help limiting how the Camera is able to move in the scene.
  129274. */
  129275. upperHeightOffsetLimit: Nullable<number>;
  129276. /**
  129277. * Define how fast the camera can accelerate to follow it s target.
  129278. */
  129279. cameraAcceleration: number;
  129280. /**
  129281. * Define the speed limit of the camera following an object.
  129282. */
  129283. maxCameraSpeed: number;
  129284. /**
  129285. * Define the target of the camera.
  129286. */
  129287. lockedTarget: Nullable<AbstractMesh>;
  129288. /**
  129289. * Defines the input associated with the camera.
  129290. */
  129291. inputs: FollowCameraInputsManager;
  129292. /**
  129293. * Instantiates the follow camera.
  129294. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129295. * @param name Define the name of the camera in the scene
  129296. * @param position Define the position of the camera
  129297. * @param scene Define the scene the camera belong to
  129298. * @param lockedTarget Define the target of the camera
  129299. */
  129300. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129301. private _follow;
  129302. /**
  129303. * Attach the input controls to a specific dom element to get the input from.
  129304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129305. */
  129306. attachControl(noPreventDefault?: boolean): void;
  129307. /**
  129308. * Detach the current controls from the specified dom element.
  129309. */
  129310. detachControl(): void;
  129311. /** @hidden */
  129312. _checkInputs(): void;
  129313. private _checkLimits;
  129314. /**
  129315. * Gets the camera class name.
  129316. * @returns the class name
  129317. */
  129318. getClassName(): string;
  129319. }
  129320. /**
  129321. * Arc Rotate version of the follow camera.
  129322. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  129323. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129324. */
  129325. export class ArcFollowCamera extends TargetCamera {
  129326. /** The longitudinal angle of the camera */
  129327. alpha: number;
  129328. /** The latitudinal angle of the camera */
  129329. beta: number;
  129330. /** The radius of the camera from its target */
  129331. radius: number;
  129332. private _cartesianCoordinates;
  129333. /** Define the camera target (the mesh it should follow) */
  129334. private _meshTarget;
  129335. /**
  129336. * Instantiates a new ArcFollowCamera
  129337. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129338. * @param name Define the name of the camera
  129339. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  129340. * @param beta Define the rotation angle of the camera around the elevation axis
  129341. * @param radius Define the radius of the camera from its target point
  129342. * @param target Define the target of the camera
  129343. * @param scene Define the scene the camera belongs to
  129344. */
  129345. constructor(name: string,
  129346. /** The longitudinal angle of the camera */
  129347. alpha: number,
  129348. /** The latitudinal angle of the camera */
  129349. beta: number,
  129350. /** The radius of the camera from its target */
  129351. radius: number,
  129352. /** Define the camera target (the mesh it should follow) */
  129353. target: Nullable<AbstractMesh>, scene: Scene);
  129354. private _follow;
  129355. /** @hidden */
  129356. _checkInputs(): void;
  129357. /**
  129358. * Returns the class name of the object.
  129359. * It is mostly used internally for serialization purposes.
  129360. */
  129361. getClassName(): string;
  129362. }
  129363. }
  129364. declare module BABYLON {
  129365. /**
  129366. * Manage the keyboard inputs to control the movement of a follow camera.
  129367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129368. */
  129369. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  129370. /**
  129371. * Defines the camera the input is attached to.
  129372. */
  129373. camera: FollowCamera;
  129374. /**
  129375. * Defines the list of key codes associated with the up action (increase heightOffset)
  129376. */
  129377. keysHeightOffsetIncr: number[];
  129378. /**
  129379. * Defines the list of key codes associated with the down action (decrease heightOffset)
  129380. */
  129381. keysHeightOffsetDecr: number[];
  129382. /**
  129383. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  129384. */
  129385. keysHeightOffsetModifierAlt: boolean;
  129386. /**
  129387. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  129388. */
  129389. keysHeightOffsetModifierCtrl: boolean;
  129390. /**
  129391. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  129392. */
  129393. keysHeightOffsetModifierShift: boolean;
  129394. /**
  129395. * Defines the list of key codes associated with the left action (increase rotationOffset)
  129396. */
  129397. keysRotationOffsetIncr: number[];
  129398. /**
  129399. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  129400. */
  129401. keysRotationOffsetDecr: number[];
  129402. /**
  129403. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  129404. */
  129405. keysRotationOffsetModifierAlt: boolean;
  129406. /**
  129407. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  129408. */
  129409. keysRotationOffsetModifierCtrl: boolean;
  129410. /**
  129411. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  129412. */
  129413. keysRotationOffsetModifierShift: boolean;
  129414. /**
  129415. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  129416. */
  129417. keysRadiusIncr: number[];
  129418. /**
  129419. * Defines the list of key codes associated with the zoom-out action (increase radius)
  129420. */
  129421. keysRadiusDecr: number[];
  129422. /**
  129423. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  129424. */
  129425. keysRadiusModifierAlt: boolean;
  129426. /**
  129427. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  129428. */
  129429. keysRadiusModifierCtrl: boolean;
  129430. /**
  129431. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  129432. */
  129433. keysRadiusModifierShift: boolean;
  129434. /**
  129435. * Defines the rate of change of heightOffset.
  129436. */
  129437. heightSensibility: number;
  129438. /**
  129439. * Defines the rate of change of rotationOffset.
  129440. */
  129441. rotationSensibility: number;
  129442. /**
  129443. * Defines the rate of change of radius.
  129444. */
  129445. radiusSensibility: number;
  129446. private _keys;
  129447. private _ctrlPressed;
  129448. private _altPressed;
  129449. private _shiftPressed;
  129450. private _onCanvasBlurObserver;
  129451. private _onKeyboardObserver;
  129452. private _engine;
  129453. private _scene;
  129454. /**
  129455. * Attach the input controls to a specific dom element to get the input from.
  129456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129457. */
  129458. attachControl(noPreventDefault?: boolean): void;
  129459. /**
  129460. * Detach the current controls from the specified dom element.
  129461. */
  129462. detachControl(): void;
  129463. /**
  129464. * Update the current camera state depending on the inputs that have been used this frame.
  129465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129466. */
  129467. checkInputs(): void;
  129468. /**
  129469. * Gets the class name of the current input.
  129470. * @returns the class name
  129471. */
  129472. getClassName(): string;
  129473. /**
  129474. * Get the friendly name associated with the input class.
  129475. * @returns the input friendly name
  129476. */
  129477. getSimpleName(): string;
  129478. /**
  129479. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129480. * allow modification of the heightOffset value.
  129481. */
  129482. private _modifierHeightOffset;
  129483. /**
  129484. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129485. * allow modification of the rotationOffset value.
  129486. */
  129487. private _modifierRotationOffset;
  129488. /**
  129489. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129490. * allow modification of the radius value.
  129491. */
  129492. private _modifierRadius;
  129493. }
  129494. }
  129495. declare module BABYLON {
  129496. interface FreeCameraInputsManager {
  129497. /**
  129498. * @hidden
  129499. */
  129500. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  129501. /**
  129502. * Add orientation input support to the input manager.
  129503. * @returns the current input manager
  129504. */
  129505. addDeviceOrientation(): FreeCameraInputsManager;
  129506. }
  129507. /**
  129508. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  129509. * Screen rotation is taken into account.
  129510. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129511. */
  129512. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  129513. private _camera;
  129514. private _screenOrientationAngle;
  129515. private _constantTranform;
  129516. private _screenQuaternion;
  129517. private _alpha;
  129518. private _beta;
  129519. private _gamma;
  129520. /**
  129521. * Can be used to detect if a device orientation sensor is available on a device
  129522. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  129523. * @returns a promise that will resolve on orientation change
  129524. */
  129525. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  129526. /**
  129527. * @hidden
  129528. */
  129529. _onDeviceOrientationChangedObservable: Observable<void>;
  129530. /**
  129531. * Instantiates a new input
  129532. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129533. */
  129534. constructor();
  129535. /**
  129536. * Define the camera controlled by the input.
  129537. */
  129538. get camera(): FreeCamera;
  129539. set camera(camera: FreeCamera);
  129540. /**
  129541. * Attach the input controls to a specific dom element to get the input from.
  129542. */
  129543. attachControl(): void;
  129544. private _orientationChanged;
  129545. private _deviceOrientation;
  129546. /**
  129547. * Detach the current controls from the specified dom element.
  129548. */
  129549. detachControl(): void;
  129550. /**
  129551. * Update the current camera state depending on the inputs that have been used this frame.
  129552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129553. */
  129554. checkInputs(): void;
  129555. /**
  129556. * Gets the class name of the current intput.
  129557. * @returns the class name
  129558. */
  129559. getClassName(): string;
  129560. /**
  129561. * Get the friendly name associated with the input class.
  129562. * @returns the input friendly name
  129563. */
  129564. getSimpleName(): string;
  129565. }
  129566. }
  129567. declare module BABYLON {
  129568. /**
  129569. * Manage the gamepad inputs to control a free camera.
  129570. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129571. */
  129572. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  129573. /**
  129574. * Define the camera the input is attached to.
  129575. */
  129576. camera: FreeCamera;
  129577. /**
  129578. * Define the Gamepad controlling the input
  129579. */
  129580. gamepad: Nullable<Gamepad>;
  129581. /**
  129582. * Defines the gamepad rotation sensiblity.
  129583. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129584. */
  129585. gamepadAngularSensibility: number;
  129586. /**
  129587. * Defines the gamepad move sensiblity.
  129588. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129589. */
  129590. gamepadMoveSensibility: number;
  129591. private _yAxisScale;
  129592. /**
  129593. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129594. */
  129595. get invertYAxis(): boolean;
  129596. set invertYAxis(value: boolean);
  129597. private _onGamepadConnectedObserver;
  129598. private _onGamepadDisconnectedObserver;
  129599. private _cameraTransform;
  129600. private _deltaTransform;
  129601. private _vector3;
  129602. private _vector2;
  129603. /**
  129604. * Attach the input controls to a specific dom element to get the input from.
  129605. */
  129606. attachControl(): void;
  129607. /**
  129608. * Detach the current controls from the specified dom element.
  129609. */
  129610. detachControl(): void;
  129611. /**
  129612. * Update the current camera state depending on the inputs that have been used this frame.
  129613. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129614. */
  129615. checkInputs(): void;
  129616. /**
  129617. * Gets the class name of the current intput.
  129618. * @returns the class name
  129619. */
  129620. getClassName(): string;
  129621. /**
  129622. * Get the friendly name associated with the input class.
  129623. * @returns the input friendly name
  129624. */
  129625. getSimpleName(): string;
  129626. }
  129627. }
  129628. declare module BABYLON {
  129629. /**
  129630. * Defines the potential axis of a Joystick
  129631. */
  129632. export enum JoystickAxis {
  129633. /** X axis */
  129634. X = 0,
  129635. /** Y axis */
  129636. Y = 1,
  129637. /** Z axis */
  129638. Z = 2
  129639. }
  129640. /**
  129641. * Represents the different customization options available
  129642. * for VirtualJoystick
  129643. */
  129644. interface VirtualJoystickCustomizations {
  129645. /**
  129646. * Size of the joystick's puck
  129647. */
  129648. puckSize: number;
  129649. /**
  129650. * Size of the joystick's container
  129651. */
  129652. containerSize: number;
  129653. /**
  129654. * Color of the joystick && puck
  129655. */
  129656. color: string;
  129657. /**
  129658. * Image URL for the joystick's puck
  129659. */
  129660. puckImage?: string;
  129661. /**
  129662. * Image URL for the joystick's container
  129663. */
  129664. containerImage?: string;
  129665. /**
  129666. * Defines the unmoving position of the joystick container
  129667. */
  129668. position?: {
  129669. x: number;
  129670. y: number;
  129671. };
  129672. /**
  129673. * Defines whether or not the joystick container is always visible
  129674. */
  129675. alwaysVisible: boolean;
  129676. /**
  129677. * Defines whether or not to limit the movement of the puck to the joystick's container
  129678. */
  129679. limitToContainer: boolean;
  129680. }
  129681. /**
  129682. * Class used to define virtual joystick (used in touch mode)
  129683. */
  129684. export class VirtualJoystick {
  129685. /**
  129686. * Gets or sets a boolean indicating that left and right values must be inverted
  129687. */
  129688. reverseLeftRight: boolean;
  129689. /**
  129690. * Gets or sets a boolean indicating that up and down values must be inverted
  129691. */
  129692. reverseUpDown: boolean;
  129693. /**
  129694. * Gets the offset value for the position (ie. the change of the position value)
  129695. */
  129696. deltaPosition: Vector3;
  129697. /**
  129698. * Gets a boolean indicating if the virtual joystick was pressed
  129699. */
  129700. pressed: boolean;
  129701. /**
  129702. * Canvas the virtual joystick will render onto, default z-index of this is 5
  129703. */
  129704. static Canvas: Nullable<HTMLCanvasElement>;
  129705. /**
  129706. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  129707. */
  129708. limitToContainer: boolean;
  129709. private static _globalJoystickIndex;
  129710. private static _alwaysVisibleSticks;
  129711. private static vjCanvasContext;
  129712. private static vjCanvasWidth;
  129713. private static vjCanvasHeight;
  129714. private static halfWidth;
  129715. private static _GetDefaultOptions;
  129716. private _action;
  129717. private _axisTargetedByLeftAndRight;
  129718. private _axisTargetedByUpAndDown;
  129719. private _joystickSensibility;
  129720. private _inversedSensibility;
  129721. private _joystickPointerID;
  129722. private _joystickColor;
  129723. private _joystickPointerPos;
  129724. private _joystickPreviousPointerPos;
  129725. private _joystickPointerStartPos;
  129726. private _deltaJoystickVector;
  129727. private _leftJoystick;
  129728. private _touches;
  129729. private _joystickPosition;
  129730. private _alwaysVisible;
  129731. private _puckImage;
  129732. private _containerImage;
  129733. private _joystickPuckSize;
  129734. private _joystickContainerSize;
  129735. private _clearPuckSize;
  129736. private _clearContainerSize;
  129737. private _clearPuckSizeOffset;
  129738. private _clearContainerSizeOffset;
  129739. private _onPointerDownHandlerRef;
  129740. private _onPointerMoveHandlerRef;
  129741. private _onPointerUpHandlerRef;
  129742. private _onResize;
  129743. /**
  129744. * Creates a new virtual joystick
  129745. * @param leftJoystick defines that the joystick is for left hand (false by default)
  129746. * @param customizations Defines the options we want to customize the VirtualJoystick
  129747. */
  129748. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  129749. /**
  129750. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  129751. * @param newJoystickSensibility defines the new sensibility
  129752. */
  129753. setJoystickSensibility(newJoystickSensibility: number): void;
  129754. private _onPointerDown;
  129755. private _onPointerMove;
  129756. private _onPointerUp;
  129757. /**
  129758. * Change the color of the virtual joystick
  129759. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  129760. */
  129761. setJoystickColor(newColor: string): void;
  129762. /**
  129763. * Size of the joystick's container
  129764. */
  129765. set containerSize(newSize: number);
  129766. get containerSize(): number;
  129767. /**
  129768. * Size of the joystick's puck
  129769. */
  129770. set puckSize(newSize: number);
  129771. get puckSize(): number;
  129772. /**
  129773. * Clears the set position of the joystick
  129774. */
  129775. clearPosition(): void;
  129776. /**
  129777. * Defines whether or not the joystick container is always visible
  129778. */
  129779. set alwaysVisible(value: boolean);
  129780. get alwaysVisible(): boolean;
  129781. /**
  129782. * Sets the constant position of the Joystick container
  129783. * @param x X axis coordinate
  129784. * @param y Y axis coordinate
  129785. */
  129786. setPosition(x: number, y: number): void;
  129787. /**
  129788. * Defines a callback to call when the joystick is touched
  129789. * @param action defines the callback
  129790. */
  129791. setActionOnTouch(action: () => any): void;
  129792. /**
  129793. * Defines which axis you'd like to control for left & right
  129794. * @param axis defines the axis to use
  129795. */
  129796. setAxisForLeftRight(axis: JoystickAxis): void;
  129797. /**
  129798. * Defines which axis you'd like to control for up & down
  129799. * @param axis defines the axis to use
  129800. */
  129801. setAxisForUpDown(axis: JoystickAxis): void;
  129802. /**
  129803. * Clears the canvas from the previous puck / container draw
  129804. */
  129805. private _clearPreviousDraw;
  129806. /**
  129807. * Loads `urlPath` to be used for the container's image
  129808. * @param urlPath defines the urlPath of an image to use
  129809. */
  129810. setContainerImage(urlPath: string): void;
  129811. /**
  129812. * Loads `urlPath` to be used for the puck's image
  129813. * @param urlPath defines the urlPath of an image to use
  129814. */
  129815. setPuckImage(urlPath: string): void;
  129816. /**
  129817. * Draws the Virtual Joystick's container
  129818. */
  129819. private _drawContainer;
  129820. /**
  129821. * Draws the Virtual Joystick's puck
  129822. */
  129823. private _drawPuck;
  129824. private _drawVirtualJoystick;
  129825. /**
  129826. * Release internal HTML canvas
  129827. */
  129828. releaseCanvas(): void;
  129829. }
  129830. }
  129831. declare module BABYLON {
  129832. interface FreeCameraInputsManager {
  129833. /**
  129834. * Add virtual joystick input support to the input manager.
  129835. * @returns the current input manager
  129836. */
  129837. addVirtualJoystick(): FreeCameraInputsManager;
  129838. }
  129839. /**
  129840. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129841. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129842. */
  129843. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129844. /**
  129845. * Defines the camera the input is attached to.
  129846. */
  129847. camera: FreeCamera;
  129848. private _leftjoystick;
  129849. private _rightjoystick;
  129850. /**
  129851. * Gets the left stick of the virtual joystick.
  129852. * @returns The virtual Joystick
  129853. */
  129854. getLeftJoystick(): VirtualJoystick;
  129855. /**
  129856. * Gets the right stick of the virtual joystick.
  129857. * @returns The virtual Joystick
  129858. */
  129859. getRightJoystick(): VirtualJoystick;
  129860. /**
  129861. * Update the current camera state depending on the inputs that have been used this frame.
  129862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129863. */
  129864. checkInputs(): void;
  129865. /**
  129866. * Attach the input controls to a specific dom element to get the input from.
  129867. */
  129868. attachControl(): void;
  129869. /**
  129870. * Detach the current controls from the specified dom element.
  129871. */
  129872. detachControl(): void;
  129873. /**
  129874. * Gets the class name of the current intput.
  129875. * @returns the class name
  129876. */
  129877. getClassName(): string;
  129878. /**
  129879. * Get the friendly name associated with the input class.
  129880. * @returns the input friendly name
  129881. */
  129882. getSimpleName(): string;
  129883. }
  129884. }
  129885. declare module BABYLON {
  129886. /**
  129887. * This represents a FPS type of camera controlled by touch.
  129888. * This is like a universal camera minus the Gamepad controls.
  129889. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129890. */
  129891. export class TouchCamera extends FreeCamera {
  129892. /**
  129893. * Defines the touch sensibility for rotation.
  129894. * The higher the faster.
  129895. */
  129896. get touchAngularSensibility(): number;
  129897. set touchAngularSensibility(value: number);
  129898. /**
  129899. * Defines the touch sensibility for move.
  129900. * The higher the faster.
  129901. */
  129902. get touchMoveSensibility(): number;
  129903. set touchMoveSensibility(value: number);
  129904. /**
  129905. * Instantiates a new touch camera.
  129906. * This represents a FPS type of camera controlled by touch.
  129907. * This is like a universal camera minus the Gamepad controls.
  129908. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129909. * @param name Define the name of the camera in the scene
  129910. * @param position Define the start position of the camera in the scene
  129911. * @param scene Define the scene the camera belongs to
  129912. */
  129913. constructor(name: string, position: Vector3, scene: Scene);
  129914. /**
  129915. * Gets the current object class name.
  129916. * @return the class name
  129917. */
  129918. getClassName(): string;
  129919. /** @hidden */
  129920. _setupInputs(): void;
  129921. }
  129922. }
  129923. declare module BABYLON {
  129924. /**
  129925. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129926. * being tilted forward or back and left or right.
  129927. */
  129928. export class DeviceOrientationCamera extends FreeCamera {
  129929. private _initialQuaternion;
  129930. private _quaternionCache;
  129931. private _tmpDragQuaternion;
  129932. private _disablePointerInputWhenUsingDeviceOrientation;
  129933. /**
  129934. * Creates a new device orientation camera
  129935. * @param name The name of the camera
  129936. * @param position The start position camera
  129937. * @param scene The scene the camera belongs to
  129938. */
  129939. constructor(name: string, position: Vector3, scene: Scene);
  129940. /**
  129941. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129942. */
  129943. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129944. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129945. private _dragFactor;
  129946. /**
  129947. * Enabled turning on the y axis when the orientation sensor is active
  129948. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129949. */
  129950. enableHorizontalDragging(dragFactor?: number): void;
  129951. /**
  129952. * Gets the current instance class name ("DeviceOrientationCamera").
  129953. * This helps avoiding instanceof at run time.
  129954. * @returns the class name
  129955. */
  129956. getClassName(): string;
  129957. /**
  129958. * @hidden
  129959. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129960. */
  129961. _checkInputs(): void;
  129962. /**
  129963. * Reset the camera to its default orientation on the specified axis only.
  129964. * @param axis The axis to reset
  129965. */
  129966. resetToCurrentRotation(axis?: Axis): void;
  129967. }
  129968. }
  129969. declare module BABYLON {
  129970. /**
  129971. * Defines supported buttons for XBox360 compatible gamepads
  129972. */
  129973. export enum Xbox360Button {
  129974. /** A */
  129975. A = 0,
  129976. /** B */
  129977. B = 1,
  129978. /** X */
  129979. X = 2,
  129980. /** Y */
  129981. Y = 3,
  129982. /** Left button */
  129983. LB = 4,
  129984. /** Right button */
  129985. RB = 5,
  129986. /** Back */
  129987. Back = 8,
  129988. /** Start */
  129989. Start = 9,
  129990. /** Left stick */
  129991. LeftStick = 10,
  129992. /** Right stick */
  129993. RightStick = 11
  129994. }
  129995. /** Defines values for XBox360 DPad */
  129996. export enum Xbox360Dpad {
  129997. /** Up */
  129998. Up = 12,
  129999. /** Down */
  130000. Down = 13,
  130001. /** Left */
  130002. Left = 14,
  130003. /** Right */
  130004. Right = 15
  130005. }
  130006. /**
  130007. * Defines a XBox360 gamepad
  130008. */
  130009. export class Xbox360Pad extends Gamepad {
  130010. private _leftTrigger;
  130011. private _rightTrigger;
  130012. private _onlefttriggerchanged;
  130013. private _onrighttriggerchanged;
  130014. private _onbuttondown;
  130015. private _onbuttonup;
  130016. private _ondpaddown;
  130017. private _ondpadup;
  130018. /** Observable raised when a button is pressed */
  130019. onButtonDownObservable: Observable<Xbox360Button>;
  130020. /** Observable raised when a button is released */
  130021. onButtonUpObservable: Observable<Xbox360Button>;
  130022. /** Observable raised when a pad is pressed */
  130023. onPadDownObservable: Observable<Xbox360Dpad>;
  130024. /** Observable raised when a pad is released */
  130025. onPadUpObservable: Observable<Xbox360Dpad>;
  130026. private _buttonA;
  130027. private _buttonB;
  130028. private _buttonX;
  130029. private _buttonY;
  130030. private _buttonBack;
  130031. private _buttonStart;
  130032. private _buttonLB;
  130033. private _buttonRB;
  130034. private _buttonLeftStick;
  130035. private _buttonRightStick;
  130036. private _dPadUp;
  130037. private _dPadDown;
  130038. private _dPadLeft;
  130039. private _dPadRight;
  130040. private _isXboxOnePad;
  130041. /**
  130042. * Creates a new XBox360 gamepad object
  130043. * @param id defines the id of this gamepad
  130044. * @param index defines its index
  130045. * @param gamepad defines the internal HTML gamepad object
  130046. * @param xboxOne defines if it is a XBox One gamepad
  130047. */
  130048. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130049. /**
  130050. * Defines the callback to call when left trigger is pressed
  130051. * @param callback defines the callback to use
  130052. */
  130053. onlefttriggerchanged(callback: (value: number) => void): void;
  130054. /**
  130055. * Defines the callback to call when right trigger is pressed
  130056. * @param callback defines the callback to use
  130057. */
  130058. onrighttriggerchanged(callback: (value: number) => void): void;
  130059. /**
  130060. * Gets the left trigger value
  130061. */
  130062. get leftTrigger(): number;
  130063. /**
  130064. * Sets the left trigger value
  130065. */
  130066. set leftTrigger(newValue: number);
  130067. /**
  130068. * Gets the right trigger value
  130069. */
  130070. get rightTrigger(): number;
  130071. /**
  130072. * Sets the right trigger value
  130073. */
  130074. set rightTrigger(newValue: number);
  130075. /**
  130076. * Defines the callback to call when a button is pressed
  130077. * @param callback defines the callback to use
  130078. */
  130079. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130080. /**
  130081. * Defines the callback to call when a button is released
  130082. * @param callback defines the callback to use
  130083. */
  130084. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130085. /**
  130086. * Defines the callback to call when a pad is pressed
  130087. * @param callback defines the callback to use
  130088. */
  130089. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130090. /**
  130091. * Defines the callback to call when a pad is released
  130092. * @param callback defines the callback to use
  130093. */
  130094. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130095. private _setButtonValue;
  130096. private _setDPadValue;
  130097. /**
  130098. * Gets the value of the `A` button
  130099. */
  130100. get buttonA(): number;
  130101. /**
  130102. * Sets the value of the `A` button
  130103. */
  130104. set buttonA(value: number);
  130105. /**
  130106. * Gets the value of the `B` button
  130107. */
  130108. get buttonB(): number;
  130109. /**
  130110. * Sets the value of the `B` button
  130111. */
  130112. set buttonB(value: number);
  130113. /**
  130114. * Gets the value of the `X` button
  130115. */
  130116. get buttonX(): number;
  130117. /**
  130118. * Sets the value of the `X` button
  130119. */
  130120. set buttonX(value: number);
  130121. /**
  130122. * Gets the value of the `Y` button
  130123. */
  130124. get buttonY(): number;
  130125. /**
  130126. * Sets the value of the `Y` button
  130127. */
  130128. set buttonY(value: number);
  130129. /**
  130130. * Gets the value of the `Start` button
  130131. */
  130132. get buttonStart(): number;
  130133. /**
  130134. * Sets the value of the `Start` button
  130135. */
  130136. set buttonStart(value: number);
  130137. /**
  130138. * Gets the value of the `Back` button
  130139. */
  130140. get buttonBack(): number;
  130141. /**
  130142. * Sets the value of the `Back` button
  130143. */
  130144. set buttonBack(value: number);
  130145. /**
  130146. * Gets the value of the `Left` button
  130147. */
  130148. get buttonLB(): number;
  130149. /**
  130150. * Sets the value of the `Left` button
  130151. */
  130152. set buttonLB(value: number);
  130153. /**
  130154. * Gets the value of the `Right` button
  130155. */
  130156. get buttonRB(): number;
  130157. /**
  130158. * Sets the value of the `Right` button
  130159. */
  130160. set buttonRB(value: number);
  130161. /**
  130162. * Gets the value of the Left joystick
  130163. */
  130164. get buttonLeftStick(): number;
  130165. /**
  130166. * Sets the value of the Left joystick
  130167. */
  130168. set buttonLeftStick(value: number);
  130169. /**
  130170. * Gets the value of the Right joystick
  130171. */
  130172. get buttonRightStick(): number;
  130173. /**
  130174. * Sets the value of the Right joystick
  130175. */
  130176. set buttonRightStick(value: number);
  130177. /**
  130178. * Gets the value of D-pad up
  130179. */
  130180. get dPadUp(): number;
  130181. /**
  130182. * Sets the value of D-pad up
  130183. */
  130184. set dPadUp(value: number);
  130185. /**
  130186. * Gets the value of D-pad down
  130187. */
  130188. get dPadDown(): number;
  130189. /**
  130190. * Sets the value of D-pad down
  130191. */
  130192. set dPadDown(value: number);
  130193. /**
  130194. * Gets the value of D-pad left
  130195. */
  130196. get dPadLeft(): number;
  130197. /**
  130198. * Sets the value of D-pad left
  130199. */
  130200. set dPadLeft(value: number);
  130201. /**
  130202. * Gets the value of D-pad right
  130203. */
  130204. get dPadRight(): number;
  130205. /**
  130206. * Sets the value of D-pad right
  130207. */
  130208. set dPadRight(value: number);
  130209. /**
  130210. * Force the gamepad to synchronize with device values
  130211. */
  130212. update(): void;
  130213. /**
  130214. * Disposes the gamepad
  130215. */
  130216. dispose(): void;
  130217. }
  130218. }
  130219. declare module BABYLON {
  130220. /**
  130221. * Defines supported buttons for DualShock compatible gamepads
  130222. */
  130223. export enum DualShockButton {
  130224. /** Cross */
  130225. Cross = 0,
  130226. /** Circle */
  130227. Circle = 1,
  130228. /** Square */
  130229. Square = 2,
  130230. /** Triangle */
  130231. Triangle = 3,
  130232. /** L1 */
  130233. L1 = 4,
  130234. /** R1 */
  130235. R1 = 5,
  130236. /** Share */
  130237. Share = 8,
  130238. /** Options */
  130239. Options = 9,
  130240. /** Left stick */
  130241. LeftStick = 10,
  130242. /** Right stick */
  130243. RightStick = 11
  130244. }
  130245. /** Defines values for DualShock DPad */
  130246. export enum DualShockDpad {
  130247. /** Up */
  130248. Up = 12,
  130249. /** Down */
  130250. Down = 13,
  130251. /** Left */
  130252. Left = 14,
  130253. /** Right */
  130254. Right = 15
  130255. }
  130256. /**
  130257. * Defines a DualShock gamepad
  130258. */
  130259. export class DualShockPad extends Gamepad {
  130260. private _leftTrigger;
  130261. private _rightTrigger;
  130262. private _onlefttriggerchanged;
  130263. private _onrighttriggerchanged;
  130264. private _onbuttondown;
  130265. private _onbuttonup;
  130266. private _ondpaddown;
  130267. private _ondpadup;
  130268. /** Observable raised when a button is pressed */
  130269. onButtonDownObservable: Observable<DualShockButton>;
  130270. /** Observable raised when a button is released */
  130271. onButtonUpObservable: Observable<DualShockButton>;
  130272. /** Observable raised when a pad is pressed */
  130273. onPadDownObservable: Observable<DualShockDpad>;
  130274. /** Observable raised when a pad is released */
  130275. onPadUpObservable: Observable<DualShockDpad>;
  130276. private _buttonCross;
  130277. private _buttonCircle;
  130278. private _buttonSquare;
  130279. private _buttonTriangle;
  130280. private _buttonShare;
  130281. private _buttonOptions;
  130282. private _buttonL1;
  130283. private _buttonR1;
  130284. private _buttonLeftStick;
  130285. private _buttonRightStick;
  130286. private _dPadUp;
  130287. private _dPadDown;
  130288. private _dPadLeft;
  130289. private _dPadRight;
  130290. /**
  130291. * Creates a new DualShock gamepad object
  130292. * @param id defines the id of this gamepad
  130293. * @param index defines its index
  130294. * @param gamepad defines the internal HTML gamepad object
  130295. */
  130296. constructor(id: string, index: number, gamepad: any);
  130297. /**
  130298. * Defines the callback to call when left trigger is pressed
  130299. * @param callback defines the callback to use
  130300. */
  130301. onlefttriggerchanged(callback: (value: number) => void): void;
  130302. /**
  130303. * Defines the callback to call when right trigger is pressed
  130304. * @param callback defines the callback to use
  130305. */
  130306. onrighttriggerchanged(callback: (value: number) => void): void;
  130307. /**
  130308. * Gets the left trigger value
  130309. */
  130310. get leftTrigger(): number;
  130311. /**
  130312. * Sets the left trigger value
  130313. */
  130314. set leftTrigger(newValue: number);
  130315. /**
  130316. * Gets the right trigger value
  130317. */
  130318. get rightTrigger(): number;
  130319. /**
  130320. * Sets the right trigger value
  130321. */
  130322. set rightTrigger(newValue: number);
  130323. /**
  130324. * Defines the callback to call when a button is pressed
  130325. * @param callback defines the callback to use
  130326. */
  130327. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  130328. /**
  130329. * Defines the callback to call when a button is released
  130330. * @param callback defines the callback to use
  130331. */
  130332. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  130333. /**
  130334. * Defines the callback to call when a pad is pressed
  130335. * @param callback defines the callback to use
  130336. */
  130337. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  130338. /**
  130339. * Defines the callback to call when a pad is released
  130340. * @param callback defines the callback to use
  130341. */
  130342. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  130343. private _setButtonValue;
  130344. private _setDPadValue;
  130345. /**
  130346. * Gets the value of the `Cross` button
  130347. */
  130348. get buttonCross(): number;
  130349. /**
  130350. * Sets the value of the `Cross` button
  130351. */
  130352. set buttonCross(value: number);
  130353. /**
  130354. * Gets the value of the `Circle` button
  130355. */
  130356. get buttonCircle(): number;
  130357. /**
  130358. * Sets the value of the `Circle` button
  130359. */
  130360. set buttonCircle(value: number);
  130361. /**
  130362. * Gets the value of the `Square` button
  130363. */
  130364. get buttonSquare(): number;
  130365. /**
  130366. * Sets the value of the `Square` button
  130367. */
  130368. set buttonSquare(value: number);
  130369. /**
  130370. * Gets the value of the `Triangle` button
  130371. */
  130372. get buttonTriangle(): number;
  130373. /**
  130374. * Sets the value of the `Triangle` button
  130375. */
  130376. set buttonTriangle(value: number);
  130377. /**
  130378. * Gets the value of the `Options` button
  130379. */
  130380. get buttonOptions(): number;
  130381. /**
  130382. * Sets the value of the `Options` button
  130383. */
  130384. set buttonOptions(value: number);
  130385. /**
  130386. * Gets the value of the `Share` button
  130387. */
  130388. get buttonShare(): number;
  130389. /**
  130390. * Sets the value of the `Share` button
  130391. */
  130392. set buttonShare(value: number);
  130393. /**
  130394. * Gets the value of the `L1` button
  130395. */
  130396. get buttonL1(): number;
  130397. /**
  130398. * Sets the value of the `L1` button
  130399. */
  130400. set buttonL1(value: number);
  130401. /**
  130402. * Gets the value of the `R1` button
  130403. */
  130404. get buttonR1(): number;
  130405. /**
  130406. * Sets the value of the `R1` button
  130407. */
  130408. set buttonR1(value: number);
  130409. /**
  130410. * Gets the value of the Left joystick
  130411. */
  130412. get buttonLeftStick(): number;
  130413. /**
  130414. * Sets the value of the Left joystick
  130415. */
  130416. set buttonLeftStick(value: number);
  130417. /**
  130418. * Gets the value of the Right joystick
  130419. */
  130420. get buttonRightStick(): number;
  130421. /**
  130422. * Sets the value of the Right joystick
  130423. */
  130424. set buttonRightStick(value: number);
  130425. /**
  130426. * Gets the value of D-pad up
  130427. */
  130428. get dPadUp(): number;
  130429. /**
  130430. * Sets the value of D-pad up
  130431. */
  130432. set dPadUp(value: number);
  130433. /**
  130434. * Gets the value of D-pad down
  130435. */
  130436. get dPadDown(): number;
  130437. /**
  130438. * Sets the value of D-pad down
  130439. */
  130440. set dPadDown(value: number);
  130441. /**
  130442. * Gets the value of D-pad left
  130443. */
  130444. get dPadLeft(): number;
  130445. /**
  130446. * Sets the value of D-pad left
  130447. */
  130448. set dPadLeft(value: number);
  130449. /**
  130450. * Gets the value of D-pad right
  130451. */
  130452. get dPadRight(): number;
  130453. /**
  130454. * Sets the value of D-pad right
  130455. */
  130456. set dPadRight(value: number);
  130457. /**
  130458. * Force the gamepad to synchronize with device values
  130459. */
  130460. update(): void;
  130461. /**
  130462. * Disposes the gamepad
  130463. */
  130464. dispose(): void;
  130465. }
  130466. }
  130467. declare module BABYLON {
  130468. /**
  130469. * Manager for handling gamepads
  130470. */
  130471. export class GamepadManager {
  130472. private _scene?;
  130473. private _babylonGamepads;
  130474. private _oneGamepadConnected;
  130475. /** @hidden */
  130476. _isMonitoring: boolean;
  130477. private _gamepadEventSupported;
  130478. private _gamepadSupport?;
  130479. /**
  130480. * observable to be triggered when the gamepad controller has been connected
  130481. */
  130482. onGamepadConnectedObservable: Observable<Gamepad>;
  130483. /**
  130484. * observable to be triggered when the gamepad controller has been disconnected
  130485. */
  130486. onGamepadDisconnectedObservable: Observable<Gamepad>;
  130487. private _onGamepadConnectedEvent;
  130488. private _onGamepadDisconnectedEvent;
  130489. /**
  130490. * Initializes the gamepad manager
  130491. * @param _scene BabylonJS scene
  130492. */
  130493. constructor(_scene?: Scene | undefined);
  130494. /**
  130495. * The gamepads in the game pad manager
  130496. */
  130497. get gamepads(): Gamepad[];
  130498. /**
  130499. * Get the gamepad controllers based on type
  130500. * @param type The type of gamepad controller
  130501. * @returns Nullable gamepad
  130502. */
  130503. getGamepadByType(type?: number): Nullable<Gamepad>;
  130504. /**
  130505. * Disposes the gamepad manager
  130506. */
  130507. dispose(): void;
  130508. private _addNewGamepad;
  130509. private _startMonitoringGamepads;
  130510. private _stopMonitoringGamepads;
  130511. /** @hidden */
  130512. _checkGamepadsStatus(): void;
  130513. private _updateGamepadObjects;
  130514. }
  130515. }
  130516. declare module BABYLON {
  130517. interface Scene {
  130518. /** @hidden */
  130519. _gamepadManager: Nullable<GamepadManager>;
  130520. /**
  130521. * Gets the gamepad manager associated with the scene
  130522. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  130523. */
  130524. gamepadManager: GamepadManager;
  130525. }
  130526. /**
  130527. * Interface representing a free camera inputs manager
  130528. */
  130529. interface FreeCameraInputsManager {
  130530. /**
  130531. * Adds gamepad input support to the FreeCameraInputsManager.
  130532. * @returns the FreeCameraInputsManager
  130533. */
  130534. addGamepad(): FreeCameraInputsManager;
  130535. }
  130536. /**
  130537. * Interface representing an arc rotate camera inputs manager
  130538. */
  130539. interface ArcRotateCameraInputsManager {
  130540. /**
  130541. * Adds gamepad input support to the ArcRotateCamera InputManager.
  130542. * @returns the camera inputs manager
  130543. */
  130544. addGamepad(): ArcRotateCameraInputsManager;
  130545. }
  130546. /**
  130547. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  130548. */
  130549. export class GamepadSystemSceneComponent implements ISceneComponent {
  130550. /**
  130551. * The component name helpfull to identify the component in the list of scene components.
  130552. */
  130553. readonly name: string;
  130554. /**
  130555. * The scene the component belongs to.
  130556. */
  130557. scene: Scene;
  130558. /**
  130559. * Creates a new instance of the component for the given scene
  130560. * @param scene Defines the scene to register the component in
  130561. */
  130562. constructor(scene: Scene);
  130563. /**
  130564. * Registers the component in a given scene
  130565. */
  130566. register(): void;
  130567. /**
  130568. * Rebuilds the elements related to this component in case of
  130569. * context lost for instance.
  130570. */
  130571. rebuild(): void;
  130572. /**
  130573. * Disposes the component and the associated ressources
  130574. */
  130575. dispose(): void;
  130576. private _beforeCameraUpdate;
  130577. }
  130578. }
  130579. declare module BABYLON {
  130580. /**
  130581. * 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,
  130582. * which still works and will still be found in many Playgrounds.
  130583. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130584. */
  130585. export class UniversalCamera extends TouchCamera {
  130586. /**
  130587. * Defines the gamepad rotation sensiblity.
  130588. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130589. */
  130590. get gamepadAngularSensibility(): number;
  130591. set gamepadAngularSensibility(value: number);
  130592. /**
  130593. * Defines the gamepad move sensiblity.
  130594. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130595. */
  130596. get gamepadMoveSensibility(): number;
  130597. set gamepadMoveSensibility(value: number);
  130598. /**
  130599. * 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,
  130600. * which still works and will still be found in many Playgrounds.
  130601. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130602. * @param name Define the name of the camera in the scene
  130603. * @param position Define the start position of the camera in the scene
  130604. * @param scene Define the scene the camera belongs to
  130605. */
  130606. constructor(name: string, position: Vector3, scene: Scene);
  130607. /**
  130608. * Gets the current object class name.
  130609. * @return the class name
  130610. */
  130611. getClassName(): string;
  130612. }
  130613. }
  130614. declare module BABYLON {
  130615. /**
  130616. * This represents a FPS type of camera. This is only here for back compat purpose.
  130617. * Please use the UniversalCamera instead as both are identical.
  130618. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130619. */
  130620. export class GamepadCamera extends UniversalCamera {
  130621. /**
  130622. * Instantiates a new Gamepad Camera
  130623. * This represents a FPS type of camera. This is only here for back compat purpose.
  130624. * Please use the UniversalCamera instead as both are identical.
  130625. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130626. * @param name Define the name of the camera in the scene
  130627. * @param position Define the start position of the camera in the scene
  130628. * @param scene Define the scene the camera belongs to
  130629. */
  130630. constructor(name: string, position: Vector3, scene: Scene);
  130631. /**
  130632. * Gets the current object class name.
  130633. * @return the class name
  130634. */
  130635. getClassName(): string;
  130636. }
  130637. }
  130638. declare module BABYLON {
  130639. /** @hidden */
  130640. export var passPixelShader: {
  130641. name: string;
  130642. shader: string;
  130643. };
  130644. }
  130645. declare module BABYLON {
  130646. /** @hidden */
  130647. export var passCubePixelShader: {
  130648. name: string;
  130649. shader: string;
  130650. };
  130651. }
  130652. declare module BABYLON {
  130653. /**
  130654. * PassPostProcess which produces an output the same as it's input
  130655. */
  130656. export class PassPostProcess extends PostProcess {
  130657. /**
  130658. * Gets a string identifying the name of the class
  130659. * @returns "PassPostProcess" string
  130660. */
  130661. getClassName(): string;
  130662. /**
  130663. * Creates the PassPostProcess
  130664. * @param name The name of the effect.
  130665. * @param options The required width/height ratio to downsize to before computing the render pass.
  130666. * @param camera The camera to apply the render pass to.
  130667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130668. * @param engine The engine which the post process will be applied. (default: current engine)
  130669. * @param reusable If the post process can be reused on the same frame. (default: false)
  130670. * @param textureType The type of texture to be used when performing the post processing.
  130671. * @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)
  130672. */
  130673. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130674. /** @hidden */
  130675. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  130676. }
  130677. /**
  130678. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  130679. */
  130680. export class PassCubePostProcess extends PostProcess {
  130681. private _face;
  130682. /**
  130683. * Gets or sets the cube face to display.
  130684. * * 0 is +X
  130685. * * 1 is -X
  130686. * * 2 is +Y
  130687. * * 3 is -Y
  130688. * * 4 is +Z
  130689. * * 5 is -Z
  130690. */
  130691. get face(): number;
  130692. set face(value: number);
  130693. /**
  130694. * Gets a string identifying the name of the class
  130695. * @returns "PassCubePostProcess" string
  130696. */
  130697. getClassName(): string;
  130698. /**
  130699. * Creates the PassCubePostProcess
  130700. * @param name The name of the effect.
  130701. * @param options The required width/height ratio to downsize to before computing the render pass.
  130702. * @param camera The camera to apply the render pass to.
  130703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130704. * @param engine The engine which the post process will be applied. (default: current engine)
  130705. * @param reusable If the post process can be reused on the same frame. (default: false)
  130706. * @param textureType The type of texture to be used when performing the post processing.
  130707. * @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)
  130708. */
  130709. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130710. /** @hidden */
  130711. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  130712. }
  130713. }
  130714. declare module BABYLON {
  130715. /** @hidden */
  130716. export var anaglyphPixelShader: {
  130717. name: string;
  130718. shader: string;
  130719. };
  130720. }
  130721. declare module BABYLON {
  130722. /**
  130723. * Postprocess used to generate anaglyphic rendering
  130724. */
  130725. export class AnaglyphPostProcess extends PostProcess {
  130726. private _passedProcess;
  130727. /**
  130728. * Gets a string identifying the name of the class
  130729. * @returns "AnaglyphPostProcess" string
  130730. */
  130731. getClassName(): string;
  130732. /**
  130733. * Creates a new AnaglyphPostProcess
  130734. * @param name defines postprocess name
  130735. * @param options defines creation options or target ratio scale
  130736. * @param rigCameras defines cameras using this postprocess
  130737. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  130738. * @param engine defines hosting engine
  130739. * @param reusable defines if the postprocess will be reused multiple times per frame
  130740. */
  130741. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  130742. }
  130743. }
  130744. declare module BABYLON {
  130745. /**
  130746. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  130747. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130748. */
  130749. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  130750. /**
  130751. * Creates a new AnaglyphArcRotateCamera
  130752. * @param name defines camera name
  130753. * @param alpha defines alpha angle (in radians)
  130754. * @param beta defines beta angle (in radians)
  130755. * @param radius defines radius
  130756. * @param target defines camera target
  130757. * @param interaxialDistance defines distance between each color axis
  130758. * @param scene defines the hosting scene
  130759. */
  130760. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  130761. /**
  130762. * Gets camera class name
  130763. * @returns AnaglyphArcRotateCamera
  130764. */
  130765. getClassName(): string;
  130766. }
  130767. }
  130768. declare module BABYLON {
  130769. /**
  130770. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  130771. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130772. */
  130773. export class AnaglyphFreeCamera extends FreeCamera {
  130774. /**
  130775. * Creates a new AnaglyphFreeCamera
  130776. * @param name defines camera name
  130777. * @param position defines initial position
  130778. * @param interaxialDistance defines distance between each color axis
  130779. * @param scene defines the hosting scene
  130780. */
  130781. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130782. /**
  130783. * Gets camera class name
  130784. * @returns AnaglyphFreeCamera
  130785. */
  130786. getClassName(): string;
  130787. }
  130788. }
  130789. declare module BABYLON {
  130790. /**
  130791. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130792. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130793. */
  130794. export class AnaglyphGamepadCamera extends GamepadCamera {
  130795. /**
  130796. * Creates a new AnaglyphGamepadCamera
  130797. * @param name defines camera name
  130798. * @param position defines initial position
  130799. * @param interaxialDistance defines distance between each color axis
  130800. * @param scene defines the hosting scene
  130801. */
  130802. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130803. /**
  130804. * Gets camera class name
  130805. * @returns AnaglyphGamepadCamera
  130806. */
  130807. getClassName(): string;
  130808. }
  130809. }
  130810. declare module BABYLON {
  130811. /**
  130812. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130813. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130814. */
  130815. export class AnaglyphUniversalCamera extends UniversalCamera {
  130816. /**
  130817. * Creates a new AnaglyphUniversalCamera
  130818. * @param name defines camera name
  130819. * @param position defines initial position
  130820. * @param interaxialDistance defines distance between each color axis
  130821. * @param scene defines the hosting scene
  130822. */
  130823. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130824. /**
  130825. * Gets camera class name
  130826. * @returns AnaglyphUniversalCamera
  130827. */
  130828. getClassName(): string;
  130829. }
  130830. }
  130831. declare module BABYLON {
  130832. /**
  130833. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130834. * @see https://doc.babylonjs.com/features/cameras
  130835. */
  130836. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130837. /**
  130838. * Creates a new StereoscopicArcRotateCamera
  130839. * @param name defines camera name
  130840. * @param alpha defines alpha angle (in radians)
  130841. * @param beta defines beta angle (in radians)
  130842. * @param radius defines radius
  130843. * @param target defines camera target
  130844. * @param interaxialDistance defines distance between each color axis
  130845. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130846. * @param scene defines the hosting scene
  130847. */
  130848. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130849. /**
  130850. * Gets camera class name
  130851. * @returns StereoscopicArcRotateCamera
  130852. */
  130853. getClassName(): string;
  130854. }
  130855. }
  130856. declare module BABYLON {
  130857. /**
  130858. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130859. * @see https://doc.babylonjs.com/features/cameras
  130860. */
  130861. export class StereoscopicFreeCamera extends FreeCamera {
  130862. /**
  130863. * Creates a new StereoscopicFreeCamera
  130864. * @param name defines camera name
  130865. * @param position defines initial position
  130866. * @param interaxialDistance defines distance between each color axis
  130867. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130868. * @param scene defines the hosting scene
  130869. */
  130870. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130871. /**
  130872. * Gets camera class name
  130873. * @returns StereoscopicFreeCamera
  130874. */
  130875. getClassName(): string;
  130876. }
  130877. }
  130878. declare module BABYLON {
  130879. /**
  130880. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130881. * @see https://doc.babylonjs.com/features/cameras
  130882. */
  130883. export class StereoscopicGamepadCamera extends GamepadCamera {
  130884. /**
  130885. * Creates a new StereoscopicGamepadCamera
  130886. * @param name defines camera name
  130887. * @param position defines initial position
  130888. * @param interaxialDistance defines distance between each color axis
  130889. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130890. * @param scene defines the hosting scene
  130891. */
  130892. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130893. /**
  130894. * Gets camera class name
  130895. * @returns StereoscopicGamepadCamera
  130896. */
  130897. getClassName(): string;
  130898. }
  130899. }
  130900. declare module BABYLON {
  130901. /**
  130902. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130903. * @see https://doc.babylonjs.com/features/cameras
  130904. */
  130905. export class StereoscopicUniversalCamera extends UniversalCamera {
  130906. /**
  130907. * Creates a new StereoscopicUniversalCamera
  130908. * @param name defines camera name
  130909. * @param position defines initial position
  130910. * @param interaxialDistance defines distance between each color axis
  130911. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130912. * @param scene defines the hosting scene
  130913. */
  130914. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130915. /**
  130916. * Gets camera class name
  130917. * @returns StereoscopicUniversalCamera
  130918. */
  130919. getClassName(): string;
  130920. }
  130921. }
  130922. declare module BABYLON {
  130923. /**
  130924. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130925. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130926. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130927. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130928. */
  130929. export class VirtualJoysticksCamera extends FreeCamera {
  130930. /**
  130931. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130932. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130933. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130934. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130935. * @param name Define the name of the camera in the scene
  130936. * @param position Define the start position of the camera in the scene
  130937. * @param scene Define the scene the camera belongs to
  130938. */
  130939. constructor(name: string, position: Vector3, scene: Scene);
  130940. /**
  130941. * Gets the current object class name.
  130942. * @return the class name
  130943. */
  130944. getClassName(): string;
  130945. }
  130946. }
  130947. declare module BABYLON {
  130948. /**
  130949. * This represents all the required metrics to create a VR camera.
  130950. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130951. */
  130952. export class VRCameraMetrics {
  130953. /**
  130954. * Define the horizontal resolution off the screen.
  130955. */
  130956. hResolution: number;
  130957. /**
  130958. * Define the vertical resolution off the screen.
  130959. */
  130960. vResolution: number;
  130961. /**
  130962. * Define the horizontal screen size.
  130963. */
  130964. hScreenSize: number;
  130965. /**
  130966. * Define the vertical screen size.
  130967. */
  130968. vScreenSize: number;
  130969. /**
  130970. * Define the vertical screen center position.
  130971. */
  130972. vScreenCenter: number;
  130973. /**
  130974. * Define the distance of the eyes to the screen.
  130975. */
  130976. eyeToScreenDistance: number;
  130977. /**
  130978. * Define the distance between both lenses
  130979. */
  130980. lensSeparationDistance: number;
  130981. /**
  130982. * Define the distance between both viewer's eyes.
  130983. */
  130984. interpupillaryDistance: number;
  130985. /**
  130986. * Define the distortion factor of the VR postprocess.
  130987. * Please, touch with care.
  130988. */
  130989. distortionK: number[];
  130990. /**
  130991. * Define the chromatic aberration correction factors for the VR post process.
  130992. */
  130993. chromaAbCorrection: number[];
  130994. /**
  130995. * Define the scale factor of the post process.
  130996. * The smaller the better but the slower.
  130997. */
  130998. postProcessScaleFactor: number;
  130999. /**
  131000. * Define an offset for the lens center.
  131001. */
  131002. lensCenterOffset: number;
  131003. /**
  131004. * Define if the current vr camera should compensate the distortion of the lense or not.
  131005. */
  131006. compensateDistortion: boolean;
  131007. /**
  131008. * Defines if multiview should be enabled when rendering (Default: false)
  131009. */
  131010. multiviewEnabled: boolean;
  131011. /**
  131012. * Gets the rendering aspect ratio based on the provided resolutions.
  131013. */
  131014. get aspectRatio(): number;
  131015. /**
  131016. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131017. */
  131018. get aspectRatioFov(): number;
  131019. /**
  131020. * @hidden
  131021. */
  131022. get leftHMatrix(): Matrix;
  131023. /**
  131024. * @hidden
  131025. */
  131026. get rightHMatrix(): Matrix;
  131027. /**
  131028. * @hidden
  131029. */
  131030. get leftPreViewMatrix(): Matrix;
  131031. /**
  131032. * @hidden
  131033. */
  131034. get rightPreViewMatrix(): Matrix;
  131035. /**
  131036. * Get the default VRMetrics based on the most generic setup.
  131037. * @returns the default vr metrics
  131038. */
  131039. static GetDefault(): VRCameraMetrics;
  131040. }
  131041. }
  131042. declare module BABYLON {
  131043. /** @hidden */
  131044. export var vrDistortionCorrectionPixelShader: {
  131045. name: string;
  131046. shader: string;
  131047. };
  131048. }
  131049. declare module BABYLON {
  131050. /**
  131051. * VRDistortionCorrectionPostProcess used for mobile VR
  131052. */
  131053. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131054. private _isRightEye;
  131055. private _distortionFactors;
  131056. private _postProcessScaleFactor;
  131057. private _lensCenterOffset;
  131058. private _scaleIn;
  131059. private _scaleFactor;
  131060. private _lensCenter;
  131061. /**
  131062. * Gets a string identifying the name of the class
  131063. * @returns "VRDistortionCorrectionPostProcess" string
  131064. */
  131065. getClassName(): string;
  131066. /**
  131067. * Initializes the VRDistortionCorrectionPostProcess
  131068. * @param name The name of the effect.
  131069. * @param camera The camera to apply the render pass to.
  131070. * @param isRightEye If this is for the right eye distortion
  131071. * @param vrMetrics All the required metrics for the VR camera
  131072. */
  131073. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131074. }
  131075. }
  131076. declare module BABYLON {
  131077. /**
  131078. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131079. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131080. */
  131081. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131082. /**
  131083. * Creates a new VRDeviceOrientationArcRotateCamera
  131084. * @param name defines camera name
  131085. * @param alpha defines the camera rotation along the logitudinal axis
  131086. * @param beta defines the camera rotation along the latitudinal axis
  131087. * @param radius defines the camera distance from its target
  131088. * @param target defines the camera target
  131089. * @param scene defines the scene the camera belongs to
  131090. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131091. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131092. */
  131093. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131094. /**
  131095. * Gets camera class name
  131096. * @returns VRDeviceOrientationArcRotateCamera
  131097. */
  131098. getClassName(): string;
  131099. }
  131100. }
  131101. declare module BABYLON {
  131102. /**
  131103. * Camera used to simulate VR rendering (based on FreeCamera)
  131104. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131105. */
  131106. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131107. /**
  131108. * Creates a new VRDeviceOrientationFreeCamera
  131109. * @param name defines camera name
  131110. * @param position defines the start position of the camera
  131111. * @param scene defines the scene the camera belongs to
  131112. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131113. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131114. */
  131115. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131116. /**
  131117. * Gets camera class name
  131118. * @returns VRDeviceOrientationFreeCamera
  131119. */
  131120. getClassName(): string;
  131121. }
  131122. }
  131123. declare module BABYLON {
  131124. /**
  131125. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131126. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131127. */
  131128. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131129. /**
  131130. * Creates a new VRDeviceOrientationGamepadCamera
  131131. * @param name defines camera name
  131132. * @param position defines the start position of the camera
  131133. * @param scene defines the scene the camera belongs to
  131134. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131135. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131136. */
  131137. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131138. /**
  131139. * Gets camera class name
  131140. * @returns VRDeviceOrientationGamepadCamera
  131141. */
  131142. getClassName(): string;
  131143. }
  131144. }
  131145. declare module BABYLON {
  131146. /**
  131147. * A class extending Texture allowing drawing on a texture
  131148. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131149. */
  131150. export class DynamicTexture extends Texture {
  131151. private _generateMipMaps;
  131152. private _canvas;
  131153. private _context;
  131154. /**
  131155. * Creates a DynamicTexture
  131156. * @param name defines the name of the texture
  131157. * @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
  131158. * @param scene defines the scene where you want the texture
  131159. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131160. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131161. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131162. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131163. */
  131164. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131165. /**
  131166. * Get the current class name of the texture useful for serialization or dynamic coding.
  131167. * @returns "DynamicTexture"
  131168. */
  131169. getClassName(): string;
  131170. /**
  131171. * Gets the current state of canRescale
  131172. */
  131173. get canRescale(): boolean;
  131174. private _recreate;
  131175. /**
  131176. * Scales the texture
  131177. * @param ratio the scale factor to apply to both width and height
  131178. */
  131179. scale(ratio: number): void;
  131180. /**
  131181. * Resizes the texture
  131182. * @param width the new width
  131183. * @param height the new height
  131184. */
  131185. scaleTo(width: number, height: number): void;
  131186. /**
  131187. * Gets the context of the canvas used by the texture
  131188. * @returns the canvas context of the dynamic texture
  131189. */
  131190. getContext(): CanvasRenderingContext2D;
  131191. /**
  131192. * Clears the texture
  131193. */
  131194. clear(): void;
  131195. /**
  131196. * Updates the texture
  131197. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131198. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131199. */
  131200. update(invertY?: boolean, premulAlpha?: boolean): void;
  131201. /**
  131202. * Draws text onto the texture
  131203. * @param text defines the text to be drawn
  131204. * @param x defines the placement of the text from the left
  131205. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131206. * @param font defines the font to be used with font-style, font-size, font-name
  131207. * @param color defines the color used for the text
  131208. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131209. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131210. * @param update defines whether texture is immediately update (default is true)
  131211. */
  131212. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131213. /**
  131214. * Clones the texture
  131215. * @returns the clone of the texture.
  131216. */
  131217. clone(): DynamicTexture;
  131218. /**
  131219. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131220. * @returns a serialized dynamic texture object
  131221. */
  131222. serialize(): any;
  131223. private _IsCanvasElement;
  131224. /** @hidden */
  131225. _rebuild(): void;
  131226. }
  131227. }
  131228. declare module BABYLON {
  131229. /**
  131230. * Class containing static functions to help procedurally build meshes
  131231. */
  131232. export class GroundBuilder {
  131233. /**
  131234. * Creates a ground mesh
  131235. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131236. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131238. * @param name defines the name of the mesh
  131239. * @param options defines the options used to create the mesh
  131240. * @param scene defines the hosting scene
  131241. * @returns the ground mesh
  131242. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131243. */
  131244. static CreateGround(name: string, options: {
  131245. width?: number;
  131246. height?: number;
  131247. subdivisions?: number;
  131248. subdivisionsX?: number;
  131249. subdivisionsY?: number;
  131250. updatable?: boolean;
  131251. }, scene: any): Mesh;
  131252. /**
  131253. * Creates a tiled ground mesh
  131254. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131255. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131256. * * 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
  131257. * * 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
  131258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131259. * @param name defines the name of the mesh
  131260. * @param options defines the options used to create the mesh
  131261. * @param scene defines the hosting scene
  131262. * @returns the tiled ground mesh
  131263. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131264. */
  131265. static CreateTiledGround(name: string, options: {
  131266. xmin: number;
  131267. zmin: number;
  131268. xmax: number;
  131269. zmax: number;
  131270. subdivisions?: {
  131271. w: number;
  131272. h: number;
  131273. };
  131274. precision?: {
  131275. w: number;
  131276. h: number;
  131277. };
  131278. updatable?: boolean;
  131279. }, scene?: Nullable<Scene>): Mesh;
  131280. /**
  131281. * Creates a ground mesh from a height map
  131282. * * The parameter `url` sets the URL of the height map image resource.
  131283. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131284. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131285. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131286. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131287. * * 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.
  131288. * * 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).
  131289. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131291. * @param name defines the name of the mesh
  131292. * @param url defines the url to the height map
  131293. * @param options defines the options used to create the mesh
  131294. * @param scene defines the hosting scene
  131295. * @returns the ground mesh
  131296. * @see https://doc.babylonjs.com/babylon101/height_map
  131297. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131298. */
  131299. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131300. width?: number;
  131301. height?: number;
  131302. subdivisions?: number;
  131303. minHeight?: number;
  131304. maxHeight?: number;
  131305. colorFilter?: Color3;
  131306. alphaFilter?: number;
  131307. updatable?: boolean;
  131308. onReady?: (mesh: GroundMesh) => void;
  131309. }, scene?: Nullable<Scene>): GroundMesh;
  131310. }
  131311. }
  131312. declare module BABYLON {
  131313. /**
  131314. * Class containing static functions to help procedurally build meshes
  131315. */
  131316. export class TorusBuilder {
  131317. /**
  131318. * Creates a torus mesh
  131319. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131320. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131321. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131325. * @param name defines the name of the mesh
  131326. * @param options defines the options used to create the mesh
  131327. * @param scene defines the hosting scene
  131328. * @returns the torus mesh
  131329. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131330. */
  131331. static CreateTorus(name: string, options: {
  131332. diameter?: number;
  131333. thickness?: number;
  131334. tessellation?: number;
  131335. updatable?: boolean;
  131336. sideOrientation?: number;
  131337. frontUVs?: Vector4;
  131338. backUVs?: Vector4;
  131339. }, scene: any): Mesh;
  131340. }
  131341. }
  131342. declare module BABYLON {
  131343. /**
  131344. * Class containing static functions to help procedurally build meshes
  131345. */
  131346. export class CylinderBuilder {
  131347. /**
  131348. * Creates a cylinder or a cone mesh
  131349. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131350. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131351. * * 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.
  131352. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131353. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131354. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131355. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131356. * * 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).
  131357. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131358. * * 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).
  131359. * * 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
  131360. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131361. * * 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
  131362. * * 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.
  131363. * * If `enclose` is false, a ring surface is one element.
  131364. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131365. * * 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
  131366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131369. * @param name defines the name of the mesh
  131370. * @param options defines the options used to create the mesh
  131371. * @param scene defines the hosting scene
  131372. * @returns the cylinder mesh
  131373. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131374. */
  131375. static CreateCylinder(name: string, options: {
  131376. height?: number;
  131377. diameterTop?: number;
  131378. diameterBottom?: number;
  131379. diameter?: number;
  131380. tessellation?: number;
  131381. subdivisions?: number;
  131382. arc?: number;
  131383. faceColors?: Color4[];
  131384. faceUV?: Vector4[];
  131385. updatable?: boolean;
  131386. hasRings?: boolean;
  131387. enclose?: boolean;
  131388. cap?: number;
  131389. sideOrientation?: number;
  131390. frontUVs?: Vector4;
  131391. backUVs?: Vector4;
  131392. }, scene: any): Mesh;
  131393. }
  131394. }
  131395. declare module BABYLON {
  131396. /**
  131397. * States of the webXR experience
  131398. */
  131399. export enum WebXRState {
  131400. /**
  131401. * Transitioning to being in XR mode
  131402. */
  131403. ENTERING_XR = 0,
  131404. /**
  131405. * Transitioning to non XR mode
  131406. */
  131407. EXITING_XR = 1,
  131408. /**
  131409. * In XR mode and presenting
  131410. */
  131411. IN_XR = 2,
  131412. /**
  131413. * Not entered XR mode
  131414. */
  131415. NOT_IN_XR = 3
  131416. }
  131417. /**
  131418. * The state of the XR camera's tracking
  131419. */
  131420. export enum WebXRTrackingState {
  131421. /**
  131422. * No transformation received, device is not being tracked
  131423. */
  131424. NOT_TRACKING = 0,
  131425. /**
  131426. * Tracking lost - using emulated position
  131427. */
  131428. TRACKING_LOST = 1,
  131429. /**
  131430. * Transformation tracking works normally
  131431. */
  131432. TRACKING = 2
  131433. }
  131434. /**
  131435. * Abstraction of the XR render target
  131436. */
  131437. export interface WebXRRenderTarget extends IDisposable {
  131438. /**
  131439. * xrpresent context of the canvas which can be used to display/mirror xr content
  131440. */
  131441. canvasContext: WebGLRenderingContext;
  131442. /**
  131443. * xr layer for the canvas
  131444. */
  131445. xrLayer: Nullable<XRWebGLLayer>;
  131446. /**
  131447. * Initializes the xr layer for the session
  131448. * @param xrSession xr session
  131449. * @returns a promise that will resolve once the XR Layer has been created
  131450. */
  131451. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131452. }
  131453. }
  131454. declare module BABYLON {
  131455. /**
  131456. * COnfiguration object for WebXR output canvas
  131457. */
  131458. export class WebXRManagedOutputCanvasOptions {
  131459. /**
  131460. * An optional canvas in case you wish to create it yourself and provide it here.
  131461. * If not provided, a new canvas will be created
  131462. */
  131463. canvasElement?: HTMLCanvasElement;
  131464. /**
  131465. * Options for this XR Layer output
  131466. */
  131467. canvasOptions?: XRWebGLLayerInit;
  131468. /**
  131469. * CSS styling for a newly created canvas (if not provided)
  131470. */
  131471. newCanvasCssStyle?: string;
  131472. /**
  131473. * Get the default values of the configuration object
  131474. * @param engine defines the engine to use (can be null)
  131475. * @returns default values of this configuration object
  131476. */
  131477. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  131478. }
  131479. /**
  131480. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  131481. */
  131482. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  131483. private _options;
  131484. private _canvas;
  131485. private _engine;
  131486. private _originalCanvasSize;
  131487. /**
  131488. * Rendering context of the canvas which can be used to display/mirror xr content
  131489. */
  131490. canvasContext: WebGLRenderingContext;
  131491. /**
  131492. * xr layer for the canvas
  131493. */
  131494. xrLayer: Nullable<XRWebGLLayer>;
  131495. /**
  131496. * Obseervers registered here will be triggered when the xr layer was initialized
  131497. */
  131498. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  131499. /**
  131500. * Initializes the canvas to be added/removed upon entering/exiting xr
  131501. * @param _xrSessionManager The XR Session manager
  131502. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  131503. */
  131504. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  131505. /**
  131506. * Disposes of the object
  131507. */
  131508. dispose(): void;
  131509. /**
  131510. * Initializes the xr layer for the session
  131511. * @param xrSession xr session
  131512. * @returns a promise that will resolve once the XR Layer has been created
  131513. */
  131514. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131515. private _addCanvas;
  131516. private _removeCanvas;
  131517. private _setCanvasSize;
  131518. private _setManagedOutputCanvas;
  131519. }
  131520. }
  131521. declare module BABYLON {
  131522. /**
  131523. * Manages an XRSession to work with Babylon's engine
  131524. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  131525. */
  131526. export class WebXRSessionManager implements IDisposable {
  131527. /** The scene which the session should be created for */
  131528. scene: Scene;
  131529. private _referenceSpace;
  131530. private _rttProvider;
  131531. private _sessionEnded;
  131532. private _xrNavigator;
  131533. private baseLayer;
  131534. /**
  131535. * The base reference space from which the session started. good if you want to reset your
  131536. * reference space
  131537. */
  131538. baseReferenceSpace: XRReferenceSpace;
  131539. /**
  131540. * Current XR frame
  131541. */
  131542. currentFrame: Nullable<XRFrame>;
  131543. /** WebXR timestamp updated every frame */
  131544. currentTimestamp: number;
  131545. /**
  131546. * Used just in case of a failure to initialize an immersive session.
  131547. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  131548. */
  131549. defaultHeightCompensation: number;
  131550. /**
  131551. * Fires every time a new xrFrame arrives which can be used to update the camera
  131552. */
  131553. onXRFrameObservable: Observable<XRFrame>;
  131554. /**
  131555. * Fires when the reference space changed
  131556. */
  131557. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  131558. /**
  131559. * Fires when the xr session is ended either by the device or manually done
  131560. */
  131561. onXRSessionEnded: Observable<any>;
  131562. /**
  131563. * Fires when the xr session is ended either by the device or manually done
  131564. */
  131565. onXRSessionInit: Observable<XRSession>;
  131566. /**
  131567. * Underlying xr session
  131568. */
  131569. session: XRSession;
  131570. /**
  131571. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  131572. * or get the offset the player is currently at.
  131573. */
  131574. viewerReferenceSpace: XRReferenceSpace;
  131575. /**
  131576. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  131577. * @param scene The scene which the session should be created for
  131578. */
  131579. constructor(
  131580. /** The scene which the session should be created for */
  131581. scene: Scene);
  131582. /**
  131583. * The current reference space used in this session. This reference space can constantly change!
  131584. * It is mainly used to offset the camera's position.
  131585. */
  131586. get referenceSpace(): XRReferenceSpace;
  131587. /**
  131588. * Set a new reference space and triggers the observable
  131589. */
  131590. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  131591. /**
  131592. * Disposes of the session manager
  131593. */
  131594. dispose(): void;
  131595. /**
  131596. * Stops the xrSession and restores the render loop
  131597. * @returns Promise which resolves after it exits XR
  131598. */
  131599. exitXRAsync(): Promise<void>;
  131600. /**
  131601. * Gets the correct render target texture to be rendered this frame for this eye
  131602. * @param eye the eye for which to get the render target
  131603. * @returns the render target for the specified eye
  131604. */
  131605. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  131606. /**
  131607. * Creates a WebXRRenderTarget object for the XR session
  131608. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  131609. * @param options optional options to provide when creating a new render target
  131610. * @returns a WebXR render target to which the session can render
  131611. */
  131612. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  131613. /**
  131614. * Initializes the manager
  131615. * After initialization enterXR can be called to start an XR session
  131616. * @returns Promise which resolves after it is initialized
  131617. */
  131618. initializeAsync(): Promise<void>;
  131619. /**
  131620. * Initializes an xr session
  131621. * @param xrSessionMode mode to initialize
  131622. * @param xrSessionInit defines optional and required values to pass to the session builder
  131623. * @returns a promise which will resolve once the session has been initialized
  131624. */
  131625. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  131626. /**
  131627. * Checks if a session would be supported for the creation options specified
  131628. * @param sessionMode session mode to check if supported eg. immersive-vr
  131629. * @returns A Promise that resolves to true if supported and false if not
  131630. */
  131631. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131632. /**
  131633. * Resets the reference space to the one started the session
  131634. */
  131635. resetReferenceSpace(): void;
  131636. /**
  131637. * Starts rendering to the xr layer
  131638. */
  131639. runXRRenderLoop(): void;
  131640. /**
  131641. * Sets the reference space on the xr session
  131642. * @param referenceSpaceType space to set
  131643. * @returns a promise that will resolve once the reference space has been set
  131644. */
  131645. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131646. /**
  131647. * Updates the render state of the session
  131648. * @param state state to set
  131649. * @returns a promise that resolves once the render state has been updated
  131650. */
  131651. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  131652. /**
  131653. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  131654. * @param sessionMode defines the session to test
  131655. * @returns a promise with boolean as final value
  131656. */
  131657. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131658. private _createRenderTargetTexture;
  131659. }
  131660. }
  131661. declare module BABYLON {
  131662. /**
  131663. * WebXR Camera which holds the views for the xrSession
  131664. * @see https://doc.babylonjs.com/how_to/webxr_camera
  131665. */
  131666. export class WebXRCamera extends FreeCamera {
  131667. private _xrSessionManager;
  131668. private _firstFrame;
  131669. private _referenceQuaternion;
  131670. private _referencedPosition;
  131671. private _xrInvPositionCache;
  131672. private _xrInvQuaternionCache;
  131673. private _trackingState;
  131674. /**
  131675. * Observable raised before camera teleportation
  131676. */
  131677. onBeforeCameraTeleport: Observable<Vector3>;
  131678. /**
  131679. * Observable raised after camera teleportation
  131680. */
  131681. onAfterCameraTeleport: Observable<Vector3>;
  131682. /**
  131683. * Notifies when the camera's tracking state has changed.
  131684. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  131685. */
  131686. onTrackingStateChanged: Observable<WebXRTrackingState>;
  131687. /**
  131688. * Should position compensation execute on first frame.
  131689. * This is used when copying the position from a native (non XR) camera
  131690. */
  131691. compensateOnFirstFrame: boolean;
  131692. /**
  131693. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  131694. * @param name the name of the camera
  131695. * @param scene the scene to add the camera to
  131696. * @param _xrSessionManager a constructed xr session manager
  131697. */
  131698. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  131699. /**
  131700. * Get the current XR tracking state of the camera
  131701. */
  131702. get trackingState(): WebXRTrackingState;
  131703. private _setTrackingState;
  131704. /**
  131705. * Return the user's height, unrelated to the current ground.
  131706. * This will be the y position of this camera, when ground level is 0.
  131707. */
  131708. get realWorldHeight(): number;
  131709. /** @hidden */
  131710. _updateForDualEyeDebugging(): void;
  131711. /**
  131712. * Sets this camera's transformation based on a non-vr camera
  131713. * @param otherCamera the non-vr camera to copy the transformation from
  131714. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  131715. */
  131716. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  131717. /**
  131718. * Gets the current instance class name ("WebXRCamera").
  131719. * @returns the class name
  131720. */
  131721. getClassName(): string;
  131722. private _rotate180;
  131723. private _updateFromXRSession;
  131724. private _updateNumberOfRigCameras;
  131725. private _updateReferenceSpace;
  131726. private _updateReferenceSpaceOffset;
  131727. }
  131728. }
  131729. declare module BABYLON {
  131730. /**
  131731. * Defining the interface required for a (webxr) feature
  131732. */
  131733. export interface IWebXRFeature extends IDisposable {
  131734. /**
  131735. * Is this feature attached
  131736. */
  131737. attached: boolean;
  131738. /**
  131739. * Should auto-attach be disabled?
  131740. */
  131741. disableAutoAttach: boolean;
  131742. /**
  131743. * Attach the feature to the session
  131744. * Will usually be called by the features manager
  131745. *
  131746. * @param force should attachment be forced (even when already attached)
  131747. * @returns true if successful.
  131748. */
  131749. attach(force?: boolean): boolean;
  131750. /**
  131751. * Detach the feature from the session
  131752. * Will usually be called by the features manager
  131753. *
  131754. * @returns true if successful.
  131755. */
  131756. detach(): boolean;
  131757. /**
  131758. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  131759. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  131760. *
  131761. * @returns whether or not the feature is compatible in this environment
  131762. */
  131763. isCompatible(): boolean;
  131764. /**
  131765. * Was this feature disposed;
  131766. */
  131767. isDisposed: boolean;
  131768. /**
  131769. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  131770. */
  131771. xrNativeFeatureName?: string;
  131772. /**
  131773. * A list of (Babylon WebXR) features this feature depends on
  131774. */
  131775. dependsOn?: string[];
  131776. }
  131777. /**
  131778. * A list of the currently available features without referencing them
  131779. */
  131780. export class WebXRFeatureName {
  131781. /**
  131782. * The name of the anchor system feature
  131783. */
  131784. static readonly ANCHOR_SYSTEM: string;
  131785. /**
  131786. * The name of the background remover feature
  131787. */
  131788. static readonly BACKGROUND_REMOVER: string;
  131789. /**
  131790. * The name of the hit test feature
  131791. */
  131792. static readonly HIT_TEST: string;
  131793. /**
  131794. * physics impostors for xr controllers feature
  131795. */
  131796. static readonly PHYSICS_CONTROLLERS: string;
  131797. /**
  131798. * The name of the plane detection feature
  131799. */
  131800. static readonly PLANE_DETECTION: string;
  131801. /**
  131802. * The name of the pointer selection feature
  131803. */
  131804. static readonly POINTER_SELECTION: string;
  131805. /**
  131806. * The name of the teleportation feature
  131807. */
  131808. static readonly TELEPORTATION: string;
  131809. /**
  131810. * The name of the feature points feature.
  131811. */
  131812. static readonly FEATURE_POINTS: string;
  131813. /**
  131814. * The name of the hand tracking feature.
  131815. */
  131816. static readonly HAND_TRACKING: string;
  131817. }
  131818. /**
  131819. * Defining the constructor of a feature. Used to register the modules.
  131820. */
  131821. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131822. /**
  131823. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131824. * It is mainly used in AR sessions.
  131825. *
  131826. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131827. */
  131828. export class WebXRFeaturesManager implements IDisposable {
  131829. private _xrSessionManager;
  131830. private static readonly _AvailableFeatures;
  131831. private _features;
  131832. /**
  131833. * constructs a new features manages.
  131834. *
  131835. * @param _xrSessionManager an instance of WebXRSessionManager
  131836. */
  131837. constructor(_xrSessionManager: WebXRSessionManager);
  131838. /**
  131839. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131840. * Mainly used internally.
  131841. *
  131842. * @param featureName the name of the feature to register
  131843. * @param constructorFunction the function used to construct the module
  131844. * @param version the (babylon) version of the module
  131845. * @param stable is that a stable version of this module
  131846. */
  131847. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131848. /**
  131849. * Returns a constructor of a specific feature.
  131850. *
  131851. * @param featureName the name of the feature to construct
  131852. * @param version the version of the feature to load
  131853. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131854. * @param options optional options provided to the module.
  131855. * @returns a function that, when called, will return a new instance of this feature
  131856. */
  131857. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131858. /**
  131859. * Can be used to return the list of features currently registered
  131860. *
  131861. * @returns an Array of available features
  131862. */
  131863. static GetAvailableFeatures(): string[];
  131864. /**
  131865. * Gets the versions available for a specific feature
  131866. * @param featureName the name of the feature
  131867. * @returns an array with the available versions
  131868. */
  131869. static GetAvailableVersions(featureName: string): string[];
  131870. /**
  131871. * Return the latest unstable version of this feature
  131872. * @param featureName the name of the feature to search
  131873. * @returns the version number. if not found will return -1
  131874. */
  131875. static GetLatestVersionOfFeature(featureName: string): number;
  131876. /**
  131877. * Return the latest stable version of this feature
  131878. * @param featureName the name of the feature to search
  131879. * @returns the version number. if not found will return -1
  131880. */
  131881. static GetStableVersionOfFeature(featureName: string): number;
  131882. /**
  131883. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131884. * Can be used during a session to start a feature
  131885. * @param featureName the name of feature to attach
  131886. */
  131887. attachFeature(featureName: string): void;
  131888. /**
  131889. * Can be used inside a session or when the session ends to detach a specific feature
  131890. * @param featureName the name of the feature to detach
  131891. */
  131892. detachFeature(featureName: string): void;
  131893. /**
  131894. * Used to disable an already-enabled feature
  131895. * The feature will be disposed and will be recreated once enabled.
  131896. * @param featureName the feature to disable
  131897. * @returns true if disable was successful
  131898. */
  131899. disableFeature(featureName: string | {
  131900. Name: string;
  131901. }): boolean;
  131902. /**
  131903. * dispose this features manager
  131904. */
  131905. dispose(): void;
  131906. /**
  131907. * 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.
  131908. * 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.
  131909. *
  131910. * @param featureName the name of the feature to load or the class of the feature
  131911. * @param version optional version to load. if not provided the latest version will be enabled
  131912. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131913. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131914. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131915. * @returns a new constructed feature or throws an error if feature not found.
  131916. */
  131917. enableFeature(featureName: string | {
  131918. Name: string;
  131919. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131920. /**
  131921. * get the implementation of an enabled feature.
  131922. * @param featureName the name of the feature to load
  131923. * @returns the feature class, if found
  131924. */
  131925. getEnabledFeature(featureName: string): IWebXRFeature;
  131926. /**
  131927. * Get the list of enabled features
  131928. * @returns an array of enabled features
  131929. */
  131930. getEnabledFeatures(): string[];
  131931. /**
  131932. * This function will exten the session creation configuration object with enabled features.
  131933. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131934. * according to the defined "required" variable, provided during enableFeature call
  131935. * @param xrSessionInit the xr Session init object to extend
  131936. *
  131937. * @returns an extended XRSessionInit object
  131938. */
  131939. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131940. }
  131941. }
  131942. declare module BABYLON {
  131943. /**
  131944. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131945. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131946. */
  131947. export class WebXRExperienceHelper implements IDisposable {
  131948. private scene;
  131949. private _nonVRCamera;
  131950. private _originalSceneAutoClear;
  131951. private _supported;
  131952. /**
  131953. * Camera used to render xr content
  131954. */
  131955. camera: WebXRCamera;
  131956. /** A features manager for this xr session */
  131957. featuresManager: WebXRFeaturesManager;
  131958. /**
  131959. * Observers registered here will be triggered after the camera's initial transformation is set
  131960. * This can be used to set a different ground level or an extra rotation.
  131961. *
  131962. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131963. * to the position set after this observable is done executing.
  131964. */
  131965. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131966. /**
  131967. * Fires when the state of the experience helper has changed
  131968. */
  131969. onStateChangedObservable: Observable<WebXRState>;
  131970. /** Session manager used to keep track of xr session */
  131971. sessionManager: WebXRSessionManager;
  131972. /**
  131973. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131974. */
  131975. state: WebXRState;
  131976. /**
  131977. * Creates a WebXRExperienceHelper
  131978. * @param scene The scene the helper should be created in
  131979. */
  131980. private constructor();
  131981. /**
  131982. * Creates the experience helper
  131983. * @param scene the scene to attach the experience helper to
  131984. * @returns a promise for the experience helper
  131985. */
  131986. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131987. /**
  131988. * Disposes of the experience helper
  131989. */
  131990. dispose(): void;
  131991. /**
  131992. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131993. * @param sessionMode options for the XR session
  131994. * @param referenceSpaceType frame of reference of the XR session
  131995. * @param renderTarget the output canvas that will be used to enter XR mode
  131996. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131997. * @returns promise that resolves after xr mode has entered
  131998. */
  131999. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  132000. /**
  132001. * Exits XR mode and returns the scene to its original state
  132002. * @returns promise that resolves after xr mode has exited
  132003. */
  132004. exitXRAsync(): Promise<void>;
  132005. private _nonXRToXRCamera;
  132006. private _setState;
  132007. }
  132008. }
  132009. declare module BABYLON {
  132010. /**
  132011. * X-Y values for axes in WebXR
  132012. */
  132013. export interface IWebXRMotionControllerAxesValue {
  132014. /**
  132015. * The value of the x axis
  132016. */
  132017. x: number;
  132018. /**
  132019. * The value of the y-axis
  132020. */
  132021. y: number;
  132022. }
  132023. /**
  132024. * changed / previous values for the values of this component
  132025. */
  132026. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132027. /**
  132028. * current (this frame) value
  132029. */
  132030. current: T;
  132031. /**
  132032. * previous (last change) value
  132033. */
  132034. previous: T;
  132035. }
  132036. /**
  132037. * Represents changes in the component between current frame and last values recorded
  132038. */
  132039. export interface IWebXRMotionControllerComponentChanges {
  132040. /**
  132041. * will be populated with previous and current values if axes changed
  132042. */
  132043. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132044. /**
  132045. * will be populated with previous and current values if pressed changed
  132046. */
  132047. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132048. /**
  132049. * will be populated with previous and current values if touched changed
  132050. */
  132051. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132052. /**
  132053. * will be populated with previous and current values if value changed
  132054. */
  132055. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132056. }
  132057. /**
  132058. * This class represents a single component (for example button or thumbstick) of a motion controller
  132059. */
  132060. export class WebXRControllerComponent implements IDisposable {
  132061. /**
  132062. * the id of this component
  132063. */
  132064. id: string;
  132065. /**
  132066. * the type of the component
  132067. */
  132068. type: MotionControllerComponentType;
  132069. private _buttonIndex;
  132070. private _axesIndices;
  132071. private _axes;
  132072. private _changes;
  132073. private _currentValue;
  132074. private _hasChanges;
  132075. private _pressed;
  132076. private _touched;
  132077. /**
  132078. * button component type
  132079. */
  132080. static BUTTON_TYPE: MotionControllerComponentType;
  132081. /**
  132082. * squeeze component type
  132083. */
  132084. static SQUEEZE_TYPE: MotionControllerComponentType;
  132085. /**
  132086. * Thumbstick component type
  132087. */
  132088. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132089. /**
  132090. * Touchpad component type
  132091. */
  132092. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132093. /**
  132094. * trigger component type
  132095. */
  132096. static TRIGGER_TYPE: MotionControllerComponentType;
  132097. /**
  132098. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132099. * the axes data changes
  132100. */
  132101. onAxisValueChangedObservable: Observable<{
  132102. x: number;
  132103. y: number;
  132104. }>;
  132105. /**
  132106. * Observers registered here will be triggered when the state of a button changes
  132107. * State change is either pressed / touched / value
  132108. */
  132109. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132110. /**
  132111. * Creates a new component for a motion controller.
  132112. * It is created by the motion controller itself
  132113. *
  132114. * @param id the id of this component
  132115. * @param type the type of the component
  132116. * @param _buttonIndex index in the buttons array of the gamepad
  132117. * @param _axesIndices indices of the values in the axes array of the gamepad
  132118. */
  132119. constructor(
  132120. /**
  132121. * the id of this component
  132122. */
  132123. id: string,
  132124. /**
  132125. * the type of the component
  132126. */
  132127. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132128. /**
  132129. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132130. */
  132131. get axes(): IWebXRMotionControllerAxesValue;
  132132. /**
  132133. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132134. */
  132135. get changes(): IWebXRMotionControllerComponentChanges;
  132136. /**
  132137. * Return whether or not the component changed the last frame
  132138. */
  132139. get hasChanges(): boolean;
  132140. /**
  132141. * is the button currently pressed
  132142. */
  132143. get pressed(): boolean;
  132144. /**
  132145. * is the button currently touched
  132146. */
  132147. get touched(): boolean;
  132148. /**
  132149. * Get the current value of this component
  132150. */
  132151. get value(): number;
  132152. /**
  132153. * Dispose this component
  132154. */
  132155. dispose(): void;
  132156. /**
  132157. * Are there axes correlating to this component
  132158. * @return true is axes data is available
  132159. */
  132160. isAxes(): boolean;
  132161. /**
  132162. * Is this component a button (hence - pressable)
  132163. * @returns true if can be pressed
  132164. */
  132165. isButton(): boolean;
  132166. /**
  132167. * update this component using the gamepad object it is in. Called on every frame
  132168. * @param nativeController the native gamepad controller object
  132169. */
  132170. update(nativeController: IMinimalMotionControllerObject): void;
  132171. }
  132172. }
  132173. declare module BABYLON {
  132174. /**
  132175. * Interface used to represent data loading progression
  132176. */
  132177. export interface ISceneLoaderProgressEvent {
  132178. /**
  132179. * Defines if data length to load can be evaluated
  132180. */
  132181. readonly lengthComputable: boolean;
  132182. /**
  132183. * Defines the loaded data length
  132184. */
  132185. readonly loaded: number;
  132186. /**
  132187. * Defines the data length to load
  132188. */
  132189. readonly total: number;
  132190. }
  132191. /**
  132192. * Interface used by SceneLoader plugins to define supported file extensions
  132193. */
  132194. export interface ISceneLoaderPluginExtensions {
  132195. /**
  132196. * Defines the list of supported extensions
  132197. */
  132198. [extension: string]: {
  132199. isBinary: boolean;
  132200. };
  132201. }
  132202. /**
  132203. * Interface used by SceneLoader plugin factory
  132204. */
  132205. export interface ISceneLoaderPluginFactory {
  132206. /**
  132207. * Defines the name of the factory
  132208. */
  132209. name: string;
  132210. /**
  132211. * Function called to create a new plugin
  132212. * @return the new plugin
  132213. */
  132214. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132215. /**
  132216. * The callback that returns true if the data can be directly loaded.
  132217. * @param data string containing the file data
  132218. * @returns if the data can be loaded directly
  132219. */
  132220. canDirectLoad?(data: string): boolean;
  132221. }
  132222. /**
  132223. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132224. */
  132225. export interface ISceneLoaderPluginBase {
  132226. /**
  132227. * The friendly name of this plugin.
  132228. */
  132229. name: string;
  132230. /**
  132231. * The file extensions supported by this plugin.
  132232. */
  132233. extensions: string | ISceneLoaderPluginExtensions;
  132234. /**
  132235. * The callback called when loading from a url.
  132236. * @param scene scene loading this url
  132237. * @param url url to load
  132238. * @param onSuccess callback called when the file successfully loads
  132239. * @param onProgress callback called while file is loading (if the server supports this mode)
  132240. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132241. * @param onError callback called when the file fails to load
  132242. * @returns a file request object
  132243. */
  132244. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132245. /**
  132246. * The callback called when loading from a file object.
  132247. * @param scene scene loading this file
  132248. * @param file defines the file to load
  132249. * @param onSuccess defines the callback to call when data is loaded
  132250. * @param onProgress defines the callback to call during loading process
  132251. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132252. * @param onError defines the callback to call when an error occurs
  132253. * @returns a file request object
  132254. */
  132255. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132256. /**
  132257. * The callback that returns true if the data can be directly loaded.
  132258. * @param data string containing the file data
  132259. * @returns if the data can be loaded directly
  132260. */
  132261. canDirectLoad?(data: string): boolean;
  132262. /**
  132263. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132264. * @param scene scene loading this data
  132265. * @param data string containing the data
  132266. * @returns data to pass to the plugin
  132267. */
  132268. directLoad?(scene: Scene, data: string): any;
  132269. /**
  132270. * The callback that allows custom handling of the root url based on the response url.
  132271. * @param rootUrl the original root url
  132272. * @param responseURL the response url if available
  132273. * @returns the new root url
  132274. */
  132275. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132276. }
  132277. /**
  132278. * Interface used to define a SceneLoader plugin
  132279. */
  132280. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  132281. /**
  132282. * Import meshes into a scene.
  132283. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132284. * @param scene The scene to import into
  132285. * @param data The data to import
  132286. * @param rootUrl The root url for scene and resources
  132287. * @param meshes The meshes array to import into
  132288. * @param particleSystems The particle systems array to import into
  132289. * @param skeletons The skeletons array to import into
  132290. * @param onError The callback when import fails
  132291. * @returns True if successful or false otherwise
  132292. */
  132293. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  132294. /**
  132295. * Load into a scene.
  132296. * @param scene The scene to load into
  132297. * @param data The data to import
  132298. * @param rootUrl The root url for scene and resources
  132299. * @param onError The callback when import fails
  132300. * @returns True if successful or false otherwise
  132301. */
  132302. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  132303. /**
  132304. * Load into an asset container.
  132305. * @param scene The scene to load into
  132306. * @param data The data to import
  132307. * @param rootUrl The root url for scene and resources
  132308. * @param onError The callback when import fails
  132309. * @returns The loaded asset container
  132310. */
  132311. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  132312. }
  132313. /**
  132314. * Interface used to define an async SceneLoader plugin
  132315. */
  132316. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  132317. /**
  132318. * Import meshes into a scene.
  132319. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132320. * @param scene The scene to import into
  132321. * @param data The data to import
  132322. * @param rootUrl The root url for scene and resources
  132323. * @param onProgress The callback when the load progresses
  132324. * @param fileName Defines the name of the file to load
  132325. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  132326. */
  132327. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  132328. meshes: AbstractMesh[];
  132329. particleSystems: IParticleSystem[];
  132330. skeletons: Skeleton[];
  132331. animationGroups: AnimationGroup[];
  132332. }>;
  132333. /**
  132334. * Load into a scene.
  132335. * @param scene The scene to load into
  132336. * @param data The data to import
  132337. * @param rootUrl The root url for scene and resources
  132338. * @param onProgress The callback when the load progresses
  132339. * @param fileName Defines the name of the file to load
  132340. * @returns Nothing
  132341. */
  132342. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  132343. /**
  132344. * Load into an asset container.
  132345. * @param scene The scene to load into
  132346. * @param data The data to import
  132347. * @param rootUrl The root url for scene and resources
  132348. * @param onProgress The callback when the load progresses
  132349. * @param fileName Defines the name of the file to load
  132350. * @returns The loaded asset container
  132351. */
  132352. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  132353. }
  132354. /**
  132355. * Mode that determines how to handle old animation groups before loading new ones.
  132356. */
  132357. export enum SceneLoaderAnimationGroupLoadingMode {
  132358. /**
  132359. * Reset all old animations to initial state then dispose them.
  132360. */
  132361. Clean = 0,
  132362. /**
  132363. * Stop all old animations.
  132364. */
  132365. Stop = 1,
  132366. /**
  132367. * Restart old animations from first frame.
  132368. */
  132369. Sync = 2,
  132370. /**
  132371. * Old animations remains untouched.
  132372. */
  132373. NoSync = 3
  132374. }
  132375. /**
  132376. * Defines a plugin registered by the SceneLoader
  132377. */
  132378. interface IRegisteredPlugin {
  132379. /**
  132380. * Defines the plugin to use
  132381. */
  132382. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132383. /**
  132384. * Defines if the plugin supports binary data
  132385. */
  132386. isBinary: boolean;
  132387. }
  132388. /**
  132389. * Class used to load scene from various file formats using registered plugins
  132390. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  132391. */
  132392. export class SceneLoader {
  132393. /**
  132394. * No logging while loading
  132395. */
  132396. static readonly NO_LOGGING: number;
  132397. /**
  132398. * Minimal logging while loading
  132399. */
  132400. static readonly MINIMAL_LOGGING: number;
  132401. /**
  132402. * Summary logging while loading
  132403. */
  132404. static readonly SUMMARY_LOGGING: number;
  132405. /**
  132406. * Detailled logging while loading
  132407. */
  132408. static readonly DETAILED_LOGGING: number;
  132409. /**
  132410. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  132411. */
  132412. static get ForceFullSceneLoadingForIncremental(): boolean;
  132413. static set ForceFullSceneLoadingForIncremental(value: boolean);
  132414. /**
  132415. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  132416. */
  132417. static get ShowLoadingScreen(): boolean;
  132418. static set ShowLoadingScreen(value: boolean);
  132419. /**
  132420. * Defines the current logging level (while loading the scene)
  132421. * @ignorenaming
  132422. */
  132423. static get loggingLevel(): number;
  132424. static set loggingLevel(value: number);
  132425. /**
  132426. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  132427. */
  132428. static get CleanBoneMatrixWeights(): boolean;
  132429. static set CleanBoneMatrixWeights(value: boolean);
  132430. /**
  132431. * Event raised when a plugin is used to load a scene
  132432. */
  132433. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132434. private static _registeredPlugins;
  132435. private static _showingLoadingScreen;
  132436. /**
  132437. * Gets the default plugin (used to load Babylon files)
  132438. * @returns the .babylon plugin
  132439. */
  132440. static GetDefaultPlugin(): IRegisteredPlugin;
  132441. private static _GetPluginForExtension;
  132442. private static _GetPluginForDirectLoad;
  132443. private static _GetPluginForFilename;
  132444. private static _GetDirectLoad;
  132445. private static _LoadData;
  132446. private static _GetFileInfo;
  132447. /**
  132448. * Gets a plugin that can load the given extension
  132449. * @param extension defines the extension to load
  132450. * @returns a plugin or null if none works
  132451. */
  132452. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132453. /**
  132454. * Gets a boolean indicating that the given extension can be loaded
  132455. * @param extension defines the extension to load
  132456. * @returns true if the extension is supported
  132457. */
  132458. static IsPluginForExtensionAvailable(extension: string): boolean;
  132459. /**
  132460. * Adds a new plugin to the list of registered plugins
  132461. * @param plugin defines the plugin to add
  132462. */
  132463. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  132464. /**
  132465. * Import meshes into a scene
  132466. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132467. * @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)
  132468. * @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)
  132469. * @param scene the instance of BABYLON.Scene to append to
  132470. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  132471. * @param onProgress a callback with a progress event for each file being loaded
  132472. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132473. * @param pluginExtension the extension used to determine the plugin
  132474. * @returns The loaded plugin
  132475. */
  132476. 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>;
  132477. /**
  132478. * Import meshes into a scene
  132479. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132480. * @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)
  132481. * @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)
  132482. * @param scene the instance of BABYLON.Scene to append to
  132483. * @param onProgress a callback with a progress event for each file being loaded
  132484. * @param pluginExtension the extension used to determine the plugin
  132485. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  132486. */
  132487. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  132488. meshes: AbstractMesh[];
  132489. particleSystems: IParticleSystem[];
  132490. skeletons: Skeleton[];
  132491. animationGroups: AnimationGroup[];
  132492. }>;
  132493. /**
  132494. * Load a scene
  132495. * @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)
  132496. * @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)
  132497. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132498. * @param onSuccess a callback with the scene when import succeeds
  132499. * @param onProgress a callback with a progress event for each file being loaded
  132500. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132501. * @param pluginExtension the extension used to determine the plugin
  132502. * @returns The loaded plugin
  132503. */
  132504. 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>;
  132505. /**
  132506. * Load a scene
  132507. * @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)
  132508. * @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)
  132509. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132510. * @param onProgress a callback with a progress event for each file being loaded
  132511. * @param pluginExtension the extension used to determine the plugin
  132512. * @returns The loaded scene
  132513. */
  132514. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132515. /**
  132516. * Append a scene
  132517. * @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)
  132518. * @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)
  132519. * @param scene is the instance of BABYLON.Scene to append to
  132520. * @param onSuccess a callback with the scene when import succeeds
  132521. * @param onProgress a callback with a progress event for each file being loaded
  132522. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132523. * @param pluginExtension the extension used to determine the plugin
  132524. * @returns The loaded plugin
  132525. */
  132526. 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>;
  132527. /**
  132528. * Append a scene
  132529. * @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)
  132530. * @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)
  132531. * @param scene is the instance of BABYLON.Scene to append to
  132532. * @param onProgress a callback with a progress event for each file being loaded
  132533. * @param pluginExtension the extension used to determine the plugin
  132534. * @returns The given scene
  132535. */
  132536. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132537. /**
  132538. * Load a scene into an asset container
  132539. * @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)
  132540. * @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)
  132541. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132542. * @param onSuccess a callback with the scene when import succeeds
  132543. * @param onProgress a callback with a progress event for each file being loaded
  132544. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132545. * @param pluginExtension the extension used to determine the plugin
  132546. * @returns The loaded plugin
  132547. */
  132548. 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>;
  132549. /**
  132550. * Load a scene into an asset container
  132551. * @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)
  132552. * @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)
  132553. * @param scene is the instance of Scene to append to
  132554. * @param onProgress a callback with a progress event for each file being loaded
  132555. * @param pluginExtension the extension used to determine the plugin
  132556. * @returns The loaded asset container
  132557. */
  132558. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  132559. /**
  132560. * Import animations from a file into a scene
  132561. * @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)
  132562. * @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)
  132563. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132564. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132565. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132566. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132567. * @param onSuccess a callback with the scene when import succeeds
  132568. * @param onProgress a callback with a progress event for each file being loaded
  132569. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132570. * @param pluginExtension the extension used to determine the plugin
  132571. */
  132572. 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;
  132573. /**
  132574. * Import animations from a file into a scene
  132575. * @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)
  132576. * @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)
  132577. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132578. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132579. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132580. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132581. * @param onSuccess a callback with the scene when import succeeds
  132582. * @param onProgress a callback with a progress event for each file being loaded
  132583. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132584. * @param pluginExtension the extension used to determine the plugin
  132585. * @returns the updated scene with imported animations
  132586. */
  132587. 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>;
  132588. }
  132589. }
  132590. declare module BABYLON {
  132591. /**
  132592. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  132593. */
  132594. export type MotionControllerHandedness = "none" | "left" | "right";
  132595. /**
  132596. * The type of components available in motion controllers.
  132597. * This is not the name of the component.
  132598. */
  132599. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  132600. /**
  132601. * The state of a controller component
  132602. */
  132603. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  132604. /**
  132605. * The schema of motion controller layout.
  132606. * No object will be initialized using this interface
  132607. * This is used just to define the profile.
  132608. */
  132609. export interface IMotionControllerLayout {
  132610. /**
  132611. * Path to load the assets. Usually relative to the base path
  132612. */
  132613. assetPath: string;
  132614. /**
  132615. * Available components (unsorted)
  132616. */
  132617. components: {
  132618. /**
  132619. * A map of component Ids
  132620. */
  132621. [componentId: string]: {
  132622. /**
  132623. * The type of input the component outputs
  132624. */
  132625. type: MotionControllerComponentType;
  132626. /**
  132627. * The indices of this component in the gamepad object
  132628. */
  132629. gamepadIndices: {
  132630. /**
  132631. * Index of button
  132632. */
  132633. button?: number;
  132634. /**
  132635. * If available, index of x-axis
  132636. */
  132637. xAxis?: number;
  132638. /**
  132639. * If available, index of y-axis
  132640. */
  132641. yAxis?: number;
  132642. };
  132643. /**
  132644. * The mesh's root node name
  132645. */
  132646. rootNodeName: string;
  132647. /**
  132648. * Animation definitions for this model
  132649. */
  132650. visualResponses: {
  132651. [stateKey: string]: {
  132652. /**
  132653. * What property will be animated
  132654. */
  132655. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  132656. /**
  132657. * What states influence this visual response
  132658. */
  132659. states: MotionControllerComponentStateType[];
  132660. /**
  132661. * Type of animation - movement or visibility
  132662. */
  132663. valueNodeProperty: "transform" | "visibility";
  132664. /**
  132665. * Base node name to move. Its position will be calculated according to the min and max nodes
  132666. */
  132667. valueNodeName?: string;
  132668. /**
  132669. * Minimum movement node
  132670. */
  132671. minNodeName?: string;
  132672. /**
  132673. * Max movement node
  132674. */
  132675. maxNodeName?: string;
  132676. };
  132677. };
  132678. /**
  132679. * If touch enabled, what is the name of node to display user feedback
  132680. */
  132681. touchPointNodeName?: string;
  132682. };
  132683. };
  132684. /**
  132685. * Is it xr standard mapping or not
  132686. */
  132687. gamepadMapping: "" | "xr-standard";
  132688. /**
  132689. * Base root node of this entire model
  132690. */
  132691. rootNodeName: string;
  132692. /**
  132693. * Defines the main button component id
  132694. */
  132695. selectComponentId: string;
  132696. }
  132697. /**
  132698. * A definition for the layout map in the input profile
  132699. */
  132700. export interface IMotionControllerLayoutMap {
  132701. /**
  132702. * Layouts with handedness type as a key
  132703. */
  132704. [handedness: string]: IMotionControllerLayout;
  132705. }
  132706. /**
  132707. * The XR Input profile schema
  132708. * Profiles can be found here:
  132709. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  132710. */
  132711. export interface IMotionControllerProfile {
  132712. /**
  132713. * fallback profiles for this profileId
  132714. */
  132715. fallbackProfileIds: string[];
  132716. /**
  132717. * The layout map, with handedness as key
  132718. */
  132719. layouts: IMotionControllerLayoutMap;
  132720. /**
  132721. * The id of this profile
  132722. * correlates to the profile(s) in the xrInput.profiles array
  132723. */
  132724. profileId: string;
  132725. }
  132726. /**
  132727. * A helper-interface for the 3 meshes needed for controller button animation
  132728. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  132729. */
  132730. export interface IMotionControllerButtonMeshMap {
  132731. /**
  132732. * the mesh that defines the pressed value mesh position.
  132733. * This is used to find the max-position of this button
  132734. */
  132735. pressedMesh: AbstractMesh;
  132736. /**
  132737. * the mesh that defines the unpressed value mesh position.
  132738. * This is used to find the min (or initial) position of this button
  132739. */
  132740. unpressedMesh: AbstractMesh;
  132741. /**
  132742. * The mesh that will be changed when value changes
  132743. */
  132744. valueMesh: AbstractMesh;
  132745. }
  132746. /**
  132747. * A helper-interface for the 3 meshes needed for controller axis animation.
  132748. * This will be expanded when touchpad animations are fully supported
  132749. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  132750. */
  132751. export interface IMotionControllerMeshMap {
  132752. /**
  132753. * the mesh that defines the maximum value mesh position.
  132754. */
  132755. maxMesh?: AbstractMesh;
  132756. /**
  132757. * the mesh that defines the minimum value mesh position.
  132758. */
  132759. minMesh?: AbstractMesh;
  132760. /**
  132761. * The mesh that will be changed when axis value changes
  132762. */
  132763. valueMesh?: AbstractMesh;
  132764. }
  132765. /**
  132766. * The elements needed for change-detection of the gamepad objects in motion controllers
  132767. */
  132768. export interface IMinimalMotionControllerObject {
  132769. /**
  132770. * Available axes of this controller
  132771. */
  132772. axes: number[];
  132773. /**
  132774. * An array of available buttons
  132775. */
  132776. buttons: Array<{
  132777. /**
  132778. * Value of the button/trigger
  132779. */
  132780. value: number;
  132781. /**
  132782. * If the button/trigger is currently touched
  132783. */
  132784. touched: boolean;
  132785. /**
  132786. * If the button/trigger is currently pressed
  132787. */
  132788. pressed: boolean;
  132789. }>;
  132790. /**
  132791. * EXPERIMENTAL haptic support.
  132792. */
  132793. hapticActuators?: Array<{
  132794. pulse: (value: number, duration: number) => Promise<boolean>;
  132795. }>;
  132796. }
  132797. /**
  132798. * An Abstract Motion controller
  132799. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132800. * Each component has an observable to check for changes in value and state
  132801. */
  132802. export abstract class WebXRAbstractMotionController implements IDisposable {
  132803. protected scene: Scene;
  132804. protected layout: IMotionControllerLayout;
  132805. /**
  132806. * The gamepad object correlating to this controller
  132807. */
  132808. gamepadObject: IMinimalMotionControllerObject;
  132809. /**
  132810. * handedness (left/right/none) of this controller
  132811. */
  132812. handedness: MotionControllerHandedness;
  132813. private _initComponent;
  132814. private _modelReady;
  132815. /**
  132816. * A map of components (WebXRControllerComponent) in this motion controller
  132817. * Components have a ComponentType and can also have both button and axis definitions
  132818. */
  132819. readonly components: {
  132820. [id: string]: WebXRControllerComponent;
  132821. };
  132822. /**
  132823. * Disable the model's animation. Can be set at any time.
  132824. */
  132825. disableAnimation: boolean;
  132826. /**
  132827. * Observers registered here will be triggered when the model of this controller is done loading
  132828. */
  132829. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132830. /**
  132831. * The profile id of this motion controller
  132832. */
  132833. abstract profileId: string;
  132834. /**
  132835. * The root mesh of the model. It is null if the model was not yet initialized
  132836. */
  132837. rootMesh: Nullable<AbstractMesh>;
  132838. /**
  132839. * constructs a new abstract motion controller
  132840. * @param scene the scene to which the model of the controller will be added
  132841. * @param layout The profile layout to load
  132842. * @param gamepadObject The gamepad object correlating to this controller
  132843. * @param handedness handedness (left/right/none) of this controller
  132844. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132845. */
  132846. constructor(scene: Scene, layout: IMotionControllerLayout,
  132847. /**
  132848. * The gamepad object correlating to this controller
  132849. */
  132850. gamepadObject: IMinimalMotionControllerObject,
  132851. /**
  132852. * handedness (left/right/none) of this controller
  132853. */
  132854. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132855. /**
  132856. * Dispose this controller, the model mesh and all its components
  132857. */
  132858. dispose(): void;
  132859. /**
  132860. * Returns all components of specific type
  132861. * @param type the type to search for
  132862. * @return an array of components with this type
  132863. */
  132864. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132865. /**
  132866. * get a component based an its component id as defined in layout.components
  132867. * @param id the id of the component
  132868. * @returns the component correlates to the id or undefined if not found
  132869. */
  132870. getComponent(id: string): WebXRControllerComponent;
  132871. /**
  132872. * Get the list of components available in this motion controller
  132873. * @returns an array of strings correlating to available components
  132874. */
  132875. getComponentIds(): string[];
  132876. /**
  132877. * Get the first component of specific type
  132878. * @param type type of component to find
  132879. * @return a controller component or null if not found
  132880. */
  132881. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132882. /**
  132883. * Get the main (Select) component of this controller as defined in the layout
  132884. * @returns the main component of this controller
  132885. */
  132886. getMainComponent(): WebXRControllerComponent;
  132887. /**
  132888. * Loads the model correlating to this controller
  132889. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132890. * @returns A promise fulfilled with the result of the model loading
  132891. */
  132892. loadModel(): Promise<boolean>;
  132893. /**
  132894. * Update this model using the current XRFrame
  132895. * @param xrFrame the current xr frame to use and update the model
  132896. */
  132897. updateFromXRFrame(xrFrame: XRFrame): void;
  132898. /**
  132899. * Backwards compatibility due to a deeply-integrated typo
  132900. */
  132901. get handness(): XREye;
  132902. /**
  132903. * Pulse (vibrate) this controller
  132904. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132905. * Consecutive calls to this function will cancel the last pulse call
  132906. *
  132907. * @param value the strength of the pulse in 0.0...1.0 range
  132908. * @param duration Duration of the pulse in milliseconds
  132909. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132910. * @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
  132911. */
  132912. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132913. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132914. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132915. /**
  132916. * Moves the axis on the controller mesh based on its current state
  132917. * @param axis the index of the axis
  132918. * @param axisValue the value of the axis which determines the meshes new position
  132919. * @hidden
  132920. */
  132921. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132922. /**
  132923. * Update the model itself with the current frame data
  132924. * @param xrFrame the frame to use for updating the model mesh
  132925. */
  132926. protected updateModel(xrFrame: XRFrame): void;
  132927. /**
  132928. * Get the filename and path for this controller's model
  132929. * @returns a map of filename and path
  132930. */
  132931. protected abstract _getFilenameAndPath(): {
  132932. filename: string;
  132933. path: string;
  132934. };
  132935. /**
  132936. * This function is called before the mesh is loaded. It checks for loading constraints.
  132937. * For example, this function can check if the GLB loader is available
  132938. * If this function returns false, the generic controller will be loaded instead
  132939. * @returns Is the client ready to load the mesh
  132940. */
  132941. protected abstract _getModelLoadingConstraints(): boolean;
  132942. /**
  132943. * This function will be called after the model was successfully loaded and can be used
  132944. * for mesh transformations before it is available for the user
  132945. * @param meshes the loaded meshes
  132946. */
  132947. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132948. /**
  132949. * Set the root mesh for this controller. Important for the WebXR controller class
  132950. * @param meshes the loaded meshes
  132951. */
  132952. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132953. /**
  132954. * A function executed each frame that updates the mesh (if needed)
  132955. * @param xrFrame the current xrFrame
  132956. */
  132957. protected abstract _updateModel(xrFrame: XRFrame): void;
  132958. private _getGenericFilenameAndPath;
  132959. private _getGenericParentMesh;
  132960. }
  132961. }
  132962. declare module BABYLON {
  132963. /**
  132964. * A generic trigger-only motion controller for WebXR
  132965. */
  132966. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132967. /**
  132968. * Static version of the profile id of this controller
  132969. */
  132970. static ProfileId: string;
  132971. profileId: string;
  132972. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132973. protected _getFilenameAndPath(): {
  132974. filename: string;
  132975. path: string;
  132976. };
  132977. protected _getModelLoadingConstraints(): boolean;
  132978. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132979. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132980. protected _updateModel(): void;
  132981. }
  132982. }
  132983. declare module BABYLON {
  132984. /**
  132985. * Class containing static functions to help procedurally build meshes
  132986. */
  132987. export class SphereBuilder {
  132988. /**
  132989. * Creates a sphere mesh
  132990. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132991. * * 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`)
  132992. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132993. * * 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
  132994. * * 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)
  132995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132998. * @param name defines the name of the mesh
  132999. * @param options defines the options used to create the mesh
  133000. * @param scene defines the hosting scene
  133001. * @returns the sphere mesh
  133002. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133003. */
  133004. static CreateSphere(name: string, options: {
  133005. segments?: number;
  133006. diameter?: number;
  133007. diameterX?: number;
  133008. diameterY?: number;
  133009. diameterZ?: number;
  133010. arc?: number;
  133011. slice?: number;
  133012. sideOrientation?: number;
  133013. frontUVs?: Vector4;
  133014. backUVs?: Vector4;
  133015. updatable?: boolean;
  133016. }, scene?: Nullable<Scene>): Mesh;
  133017. }
  133018. }
  133019. declare module BABYLON {
  133020. /**
  133021. * A profiled motion controller has its profile loaded from an online repository.
  133022. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133023. */
  133024. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133025. private _repositoryUrl;
  133026. private _buttonMeshMapping;
  133027. private _touchDots;
  133028. /**
  133029. * The profile ID of this controller. Will be populated when the controller initializes.
  133030. */
  133031. profileId: string;
  133032. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133033. dispose(): void;
  133034. protected _getFilenameAndPath(): {
  133035. filename: string;
  133036. path: string;
  133037. };
  133038. protected _getModelLoadingConstraints(): boolean;
  133039. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133040. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133041. protected _updateModel(_xrFrame: XRFrame): void;
  133042. }
  133043. }
  133044. declare module BABYLON {
  133045. /**
  133046. * A construction function type to create a new controller based on an xrInput object
  133047. */
  133048. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133049. /**
  133050. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133051. *
  133052. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133053. * it should be replaced with auto-loaded controllers.
  133054. *
  133055. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133056. */
  133057. export class WebXRMotionControllerManager {
  133058. private static _AvailableControllers;
  133059. private static _Fallbacks;
  133060. private static _ProfileLoadingPromises;
  133061. private static _ProfilesList;
  133062. /**
  133063. * The base URL of the online controller repository. Can be changed at any time.
  133064. */
  133065. static BaseRepositoryUrl: string;
  133066. /**
  133067. * Which repository gets priority - local or online
  133068. */
  133069. static PrioritizeOnlineRepository: boolean;
  133070. /**
  133071. * Use the online repository, or use only locally-defined controllers
  133072. */
  133073. static UseOnlineRepository: boolean;
  133074. /**
  133075. * Clear the cache used for profile loading and reload when requested again
  133076. */
  133077. static ClearProfilesCache(): void;
  133078. /**
  133079. * Register the default fallbacks.
  133080. * This function is called automatically when this file is imported.
  133081. */
  133082. static DefaultFallbacks(): void;
  133083. /**
  133084. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133085. * @param profileId the profile to which a fallback needs to be found
  133086. * @return an array with corresponding fallback profiles
  133087. */
  133088. static FindFallbackWithProfileId(profileId: string): string[];
  133089. /**
  133090. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133091. * The order of search:
  133092. *
  133093. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133094. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133095. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133096. * 4) return the generic trigger controller if none were found
  133097. *
  133098. * @param xrInput the xrInput to which a new controller is initialized
  133099. * @param scene the scene to which the model will be added
  133100. * @param forceProfile force a certain profile for this controller
  133101. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133102. */
  133103. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133104. /**
  133105. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133106. *
  133107. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133108. *
  133109. * @param type the profile type to register
  133110. * @param constructFunction the function to be called when loading this profile
  133111. */
  133112. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133113. /**
  133114. * Register a fallback to a specific profile.
  133115. * @param profileId the profileId that will receive the fallbacks
  133116. * @param fallbacks A list of fallback profiles
  133117. */
  133118. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133119. /**
  133120. * Will update the list of profiles available in the repository
  133121. * @return a promise that resolves to a map of profiles available online
  133122. */
  133123. static UpdateProfilesList(): Promise<{
  133124. [profile: string]: string;
  133125. }>;
  133126. private static _LoadProfileFromRepository;
  133127. private static _LoadProfilesFromAvailableControllers;
  133128. }
  133129. }
  133130. declare module BABYLON {
  133131. /**
  133132. * Configuration options for the WebXR controller creation
  133133. */
  133134. export interface IWebXRControllerOptions {
  133135. /**
  133136. * Should the controller mesh be animated when a user interacts with it
  133137. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133138. */
  133139. disableMotionControllerAnimation?: boolean;
  133140. /**
  133141. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133142. */
  133143. doNotLoadControllerMesh?: boolean;
  133144. /**
  133145. * Force a specific controller type for this controller.
  133146. * This can be used when creating your own profile or when testing different controllers
  133147. */
  133148. forceControllerProfile?: string;
  133149. /**
  133150. * Defines a rendering group ID for meshes that will be loaded.
  133151. * This is for the default controllers only.
  133152. */
  133153. renderingGroupId?: number;
  133154. }
  133155. /**
  133156. * Represents an XR controller
  133157. */
  133158. export class WebXRInputSource {
  133159. private _scene;
  133160. /** The underlying input source for the controller */
  133161. inputSource: XRInputSource;
  133162. private _options;
  133163. private _tmpVector;
  133164. private _uniqueId;
  133165. private _disposed;
  133166. /**
  133167. * 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
  133168. */
  133169. grip?: AbstractMesh;
  133170. /**
  133171. * If available, this is the gamepad object related to this controller.
  133172. * Using this object it is possible to get click events and trackpad changes of the
  133173. * webxr controller that is currently being used.
  133174. */
  133175. motionController?: WebXRAbstractMotionController;
  133176. /**
  133177. * Event that fires when the controller is removed/disposed.
  133178. * The object provided as event data is this controller, after associated assets were disposed.
  133179. * uniqueId is still available.
  133180. */
  133181. onDisposeObservable: Observable<WebXRInputSource>;
  133182. /**
  133183. * Will be triggered when the mesh associated with the motion controller is done loading.
  133184. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133185. * A shortened version of controller -> motion controller -> on mesh loaded.
  133186. */
  133187. onMeshLoadedObservable: Observable<AbstractMesh>;
  133188. /**
  133189. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133190. */
  133191. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133192. /**
  133193. * Pointer which can be used to select objects or attach a visible laser to
  133194. */
  133195. pointer: AbstractMesh;
  133196. /**
  133197. * Creates the input source object
  133198. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133199. * @param _scene the scene which the controller should be associated to
  133200. * @param inputSource the underlying input source for the controller
  133201. * @param _options options for this controller creation
  133202. */
  133203. constructor(_scene: Scene,
  133204. /** The underlying input source for the controller */
  133205. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133206. /**
  133207. * Get this controllers unique id
  133208. */
  133209. get uniqueId(): string;
  133210. /**
  133211. * Disposes of the object
  133212. */
  133213. dispose(): void;
  133214. /**
  133215. * Gets a world space ray coming from the pointer or grip
  133216. * @param result the resulting ray
  133217. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133218. */
  133219. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133220. /**
  133221. * Updates the controller pose based on the given XRFrame
  133222. * @param xrFrame xr frame to update the pose with
  133223. * @param referenceSpace reference space to use
  133224. */
  133225. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133226. }
  133227. }
  133228. declare module BABYLON {
  133229. /**
  133230. * The schema for initialization options of the XR Input class
  133231. */
  133232. export interface IWebXRInputOptions {
  133233. /**
  133234. * If set to true no model will be automatically loaded
  133235. */
  133236. doNotLoadControllerMeshes?: boolean;
  133237. /**
  133238. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133239. * If not found, the xr input profile data will be used.
  133240. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133241. */
  133242. forceInputProfile?: string;
  133243. /**
  133244. * Do not send a request to the controller repository to load the profile.
  133245. *
  133246. * Instead, use the controllers available in babylon itself.
  133247. */
  133248. disableOnlineControllerRepository?: boolean;
  133249. /**
  133250. * A custom URL for the controllers repository
  133251. */
  133252. customControllersRepositoryURL?: string;
  133253. /**
  133254. * Should the controller model's components not move according to the user input
  133255. */
  133256. disableControllerAnimation?: boolean;
  133257. /**
  133258. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133259. */
  133260. controllerOptions?: IWebXRControllerOptions;
  133261. }
  133262. /**
  133263. * XR input used to track XR inputs such as controllers/rays
  133264. */
  133265. export class WebXRInput implements IDisposable {
  133266. /**
  133267. * the xr session manager for this session
  133268. */
  133269. xrSessionManager: WebXRSessionManager;
  133270. /**
  133271. * the WebXR camera for this session. Mainly used for teleportation
  133272. */
  133273. xrCamera: WebXRCamera;
  133274. private readonly options;
  133275. /**
  133276. * XR controllers being tracked
  133277. */
  133278. controllers: Array<WebXRInputSource>;
  133279. private _frameObserver;
  133280. private _sessionEndedObserver;
  133281. private _sessionInitObserver;
  133282. /**
  133283. * Event when a controller has been connected/added
  133284. */
  133285. onControllerAddedObservable: Observable<WebXRInputSource>;
  133286. /**
  133287. * Event when a controller has been removed/disconnected
  133288. */
  133289. onControllerRemovedObservable: Observable<WebXRInputSource>;
  133290. /**
  133291. * Initializes the WebXRInput
  133292. * @param xrSessionManager the xr session manager for this session
  133293. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  133294. * @param options = initialization options for this xr input
  133295. */
  133296. constructor(
  133297. /**
  133298. * the xr session manager for this session
  133299. */
  133300. xrSessionManager: WebXRSessionManager,
  133301. /**
  133302. * the WebXR camera for this session. Mainly used for teleportation
  133303. */
  133304. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  133305. private _onInputSourcesChange;
  133306. private _addAndRemoveControllers;
  133307. /**
  133308. * Disposes of the object
  133309. */
  133310. dispose(): void;
  133311. }
  133312. }
  133313. declare module BABYLON {
  133314. /**
  133315. * This is the base class for all WebXR features.
  133316. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  133317. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  133318. */
  133319. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  133320. protected _xrSessionManager: WebXRSessionManager;
  133321. private _attached;
  133322. private _removeOnDetach;
  133323. /**
  133324. * Is this feature disposed?
  133325. */
  133326. isDisposed: boolean;
  133327. /**
  133328. * Should auto-attach be disabled?
  133329. */
  133330. disableAutoAttach: boolean;
  133331. /**
  133332. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  133333. */
  133334. xrNativeFeatureName: string;
  133335. /**
  133336. * Construct a new (abstract) WebXR feature
  133337. * @param _xrSessionManager the xr session manager for this feature
  133338. */
  133339. constructor(_xrSessionManager: WebXRSessionManager);
  133340. /**
  133341. * Is this feature attached
  133342. */
  133343. get attached(): boolean;
  133344. /**
  133345. * attach this feature
  133346. *
  133347. * @param force should attachment be forced (even when already attached)
  133348. * @returns true if successful, false is failed or already attached
  133349. */
  133350. attach(force?: boolean): boolean;
  133351. /**
  133352. * detach this feature.
  133353. *
  133354. * @returns true if successful, false if failed or already detached
  133355. */
  133356. detach(): boolean;
  133357. /**
  133358. * Dispose this feature and all of the resources attached
  133359. */
  133360. dispose(): void;
  133361. /**
  133362. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  133363. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  133364. *
  133365. * @returns whether or not the feature is compatible in this environment
  133366. */
  133367. isCompatible(): boolean;
  133368. /**
  133369. * This is used to register callbacks that will automatically be removed when detach is called.
  133370. * @param observable the observable to which the observer will be attached
  133371. * @param callback the callback to register
  133372. */
  133373. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  133374. /**
  133375. * Code in this function will be executed on each xrFrame received from the browser.
  133376. * This function will not execute after the feature is detached.
  133377. * @param _xrFrame the current frame
  133378. */
  133379. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  133380. }
  133381. }
  133382. declare module BABYLON {
  133383. /**
  133384. * Renders a layer on top of an existing scene
  133385. */
  133386. export class UtilityLayerRenderer implements IDisposable {
  133387. /** the original scene that will be rendered on top of */
  133388. originalScene: Scene;
  133389. private _pointerCaptures;
  133390. private _lastPointerEvents;
  133391. private static _DefaultUtilityLayer;
  133392. private static _DefaultKeepDepthUtilityLayer;
  133393. private _sharedGizmoLight;
  133394. private _renderCamera;
  133395. /**
  133396. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  133397. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  133398. * @returns the camera that is used when rendering the utility layer
  133399. */
  133400. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  133401. /**
  133402. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  133403. * @param cam the camera that should be used when rendering the utility layer
  133404. */
  133405. setRenderCamera(cam: Nullable<Camera>): void;
  133406. /**
  133407. * @hidden
  133408. * Light which used by gizmos to get light shading
  133409. */
  133410. _getSharedGizmoLight(): HemisphericLight;
  133411. /**
  133412. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  133413. */
  133414. pickUtilitySceneFirst: boolean;
  133415. /**
  133416. * 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)
  133417. */
  133418. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  133419. /**
  133420. * 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)
  133421. */
  133422. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  133423. /**
  133424. * The scene that is rendered on top of the original scene
  133425. */
  133426. utilityLayerScene: Scene;
  133427. /**
  133428. * If the utility layer should automatically be rendered on top of existing scene
  133429. */
  133430. shouldRender: boolean;
  133431. /**
  133432. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  133433. */
  133434. onlyCheckPointerDownEvents: boolean;
  133435. /**
  133436. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  133437. */
  133438. processAllEvents: boolean;
  133439. /**
  133440. * Observable raised when the pointer move from the utility layer scene to the main scene
  133441. */
  133442. onPointerOutObservable: Observable<number>;
  133443. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  133444. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  133445. private _afterRenderObserver;
  133446. private _sceneDisposeObserver;
  133447. private _originalPointerObserver;
  133448. /**
  133449. * Instantiates a UtilityLayerRenderer
  133450. * @param originalScene the original scene that will be rendered on top of
  133451. * @param handleEvents boolean indicating if the utility layer should handle events
  133452. */
  133453. constructor(
  133454. /** the original scene that will be rendered on top of */
  133455. originalScene: Scene, handleEvents?: boolean);
  133456. private _notifyObservers;
  133457. /**
  133458. * Renders the utility layers scene on top of the original scene
  133459. */
  133460. render(): void;
  133461. /**
  133462. * Disposes of the renderer
  133463. */
  133464. dispose(): void;
  133465. private _updateCamera;
  133466. }
  133467. }
  133468. declare module BABYLON {
  133469. /**
  133470. * Options interface for the pointer selection module
  133471. */
  133472. export interface IWebXRControllerPointerSelectionOptions {
  133473. /**
  133474. * if provided, this scene will be used to render meshes.
  133475. */
  133476. customUtilityLayerScene?: Scene;
  133477. /**
  133478. * 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)
  133479. * If not disabled, the last picked point will be used to execute a pointer up event
  133480. * If disabled, pointer up event will be triggered right after the pointer down event.
  133481. * Used in screen and gaze target ray mode only
  133482. */
  133483. disablePointerUpOnTouchOut: boolean;
  133484. /**
  133485. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  133486. */
  133487. forceGazeMode: boolean;
  133488. /**
  133489. * 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
  133490. * to start a new countdown to the pointer down event.
  133491. * Defaults to 1.
  133492. */
  133493. gazeModePointerMovedFactor?: number;
  133494. /**
  133495. * Different button type to use instead of the main component
  133496. */
  133497. overrideButtonId?: string;
  133498. /**
  133499. * use this rendering group id for the meshes (optional)
  133500. */
  133501. renderingGroupId?: number;
  133502. /**
  133503. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  133504. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  133505. * 3000 means 3 seconds between pointing at something and selecting it
  133506. */
  133507. timeToSelect?: number;
  133508. /**
  133509. * Should meshes created here be added to a utility layer or the main scene
  133510. */
  133511. useUtilityLayer?: boolean;
  133512. /**
  133513. * Optional WebXR camera to be used for gaze selection
  133514. */
  133515. gazeCamera?: WebXRCamera;
  133516. /**
  133517. * the xr input to use with this pointer selection
  133518. */
  133519. xrInput: WebXRInput;
  133520. /**
  133521. * Should the scene pointerX and pointerY update be disabled
  133522. * This is required for fullscreen AR GUI, but might slow down other experiences.
  133523. * Disable in VR, if not needed.
  133524. * The first rig camera (left eye) will be used to calculate the projection
  133525. */
  133526. disableScenePointerVectorUpdate: boolean;
  133527. /**
  133528. * Enable pointer selection on all controllers instead of switching between them
  133529. */
  133530. enablePointerSelectionOnAllControllers?: boolean;
  133531. /**
  133532. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  133533. * If switch is enabled, it will still allow the user to switch between the different controllers
  133534. */
  133535. preferredHandedness?: XRHandedness;
  133536. /**
  133537. * Disable switching the pointer selection from one controller to the other.
  133538. * 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
  133539. */
  133540. disableSwitchOnClick?: boolean;
  133541. /**
  133542. * The maximum distance of the pointer selection feature. Defaults to 100.
  133543. */
  133544. maxPointerDistance?: number;
  133545. }
  133546. /**
  133547. * A module that will enable pointer selection for motion controllers of XR Input Sources
  133548. */
  133549. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  133550. private readonly _options;
  133551. private static _idCounter;
  133552. private _attachController;
  133553. private _controllers;
  133554. private _scene;
  133555. private _tmpVectorForPickCompare;
  133556. private _attachedController;
  133557. /**
  133558. * The module's name
  133559. */
  133560. static readonly Name: string;
  133561. /**
  133562. * The (Babylon) version of this module.
  133563. * This is an integer representing the implementation version.
  133564. * This number does not correspond to the WebXR specs version
  133565. */
  133566. static readonly Version: number;
  133567. /**
  133568. * Disable lighting on the laser pointer (so it will always be visible)
  133569. */
  133570. disablePointerLighting: boolean;
  133571. /**
  133572. * Disable lighting on the selection mesh (so it will always be visible)
  133573. */
  133574. disableSelectionMeshLighting: boolean;
  133575. /**
  133576. * Should the laser pointer be displayed
  133577. */
  133578. displayLaserPointer: boolean;
  133579. /**
  133580. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  133581. */
  133582. displaySelectionMesh: boolean;
  133583. /**
  133584. * This color will be set to the laser pointer when selection is triggered
  133585. */
  133586. laserPointerPickedColor: Color3;
  133587. /**
  133588. * Default color of the laser pointer
  133589. */
  133590. laserPointerDefaultColor: Color3;
  133591. /**
  133592. * default color of the selection ring
  133593. */
  133594. selectionMeshDefaultColor: Color3;
  133595. /**
  133596. * This color will be applied to the selection ring when selection is triggered
  133597. */
  133598. selectionMeshPickedColor: Color3;
  133599. /**
  133600. * Optional filter to be used for ray selection. This predicate shares behavior with
  133601. * scene.pointerMovePredicate which takes priority if it is also assigned.
  133602. */
  133603. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133604. /**
  133605. * constructs a new background remover module
  133606. * @param _xrSessionManager the session manager for this module
  133607. * @param _options read-only options to be used in this module
  133608. */
  133609. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  133610. /**
  133611. * attach this feature
  133612. * Will usually be called by the features manager
  133613. *
  133614. * @returns true if successful.
  133615. */
  133616. attach(): boolean;
  133617. /**
  133618. * detach this feature.
  133619. * Will usually be called by the features manager
  133620. *
  133621. * @returns true if successful.
  133622. */
  133623. detach(): boolean;
  133624. /**
  133625. * Will get the mesh under a specific pointer.
  133626. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  133627. * @param controllerId the controllerId to check
  133628. * @returns The mesh under pointer or null if no mesh is under the pointer
  133629. */
  133630. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  133631. /**
  133632. * Get the xr controller that correlates to the pointer id in the pointer event
  133633. *
  133634. * @param id the pointer id to search for
  133635. * @returns the controller that correlates to this id or null if not found
  133636. */
  133637. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  133638. private _identityMatrix;
  133639. private _screenCoordinatesRef;
  133640. private _viewportRef;
  133641. protected _onXRFrame(_xrFrame: XRFrame): void;
  133642. private _attachGazeMode;
  133643. private _attachScreenRayMode;
  133644. private _attachTrackedPointerRayMode;
  133645. private _convertNormalToDirectionOfRay;
  133646. private _detachController;
  133647. private _generateNewMeshPair;
  133648. private _pickingMoved;
  133649. private _updatePointerDistance;
  133650. /** @hidden */
  133651. get lasterPointerDefaultColor(): Color3;
  133652. }
  133653. }
  133654. declare module BABYLON {
  133655. /**
  133656. * Button which can be used to enter a different mode of XR
  133657. */
  133658. export class WebXREnterExitUIButton {
  133659. /** button element */
  133660. element: HTMLElement;
  133661. /** XR initialization options for the button */
  133662. sessionMode: XRSessionMode;
  133663. /** Reference space type */
  133664. referenceSpaceType: XRReferenceSpaceType;
  133665. /**
  133666. * Creates a WebXREnterExitUIButton
  133667. * @param element button element
  133668. * @param sessionMode XR initialization session mode
  133669. * @param referenceSpaceType the type of reference space to be used
  133670. */
  133671. constructor(
  133672. /** button element */
  133673. element: HTMLElement,
  133674. /** XR initialization options for the button */
  133675. sessionMode: XRSessionMode,
  133676. /** Reference space type */
  133677. referenceSpaceType: XRReferenceSpaceType);
  133678. /**
  133679. * Extendable function which can be used to update the button's visuals when the state changes
  133680. * @param activeButton the current active button in the UI
  133681. */
  133682. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  133683. }
  133684. /**
  133685. * Options to create the webXR UI
  133686. */
  133687. export class WebXREnterExitUIOptions {
  133688. /**
  133689. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  133690. */
  133691. customButtons?: Array<WebXREnterExitUIButton>;
  133692. /**
  133693. * A reference space type to use when creating the default button.
  133694. * Default is local-floor
  133695. */
  133696. referenceSpaceType?: XRReferenceSpaceType;
  133697. /**
  133698. * Context to enter xr with
  133699. */
  133700. renderTarget?: Nullable<WebXRRenderTarget>;
  133701. /**
  133702. * A session mode to use when creating the default button.
  133703. * Default is immersive-vr
  133704. */
  133705. sessionMode?: XRSessionMode;
  133706. /**
  133707. * A list of optional features to init the session with
  133708. */
  133709. optionalFeatures?: string[];
  133710. /**
  133711. * A list of optional features to init the session with
  133712. */
  133713. requiredFeatures?: string[];
  133714. /**
  133715. * If defined, this function will be executed if the UI encounters an error when entering XR
  133716. */
  133717. onError?: (error: any) => void;
  133718. }
  133719. /**
  133720. * UI to allow the user to enter/exit XR mode
  133721. */
  133722. export class WebXREnterExitUI implements IDisposable {
  133723. private scene;
  133724. /** version of the options passed to this UI */
  133725. options: WebXREnterExitUIOptions;
  133726. private _activeButton;
  133727. private _buttons;
  133728. /**
  133729. * The HTML Div Element to which buttons are added.
  133730. */
  133731. readonly overlay: HTMLDivElement;
  133732. /**
  133733. * Fired every time the active button is changed.
  133734. *
  133735. * When xr is entered via a button that launches xr that button will be the callback parameter
  133736. *
  133737. * When exiting xr the callback parameter will be null)
  133738. */
  133739. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  133740. /**
  133741. *
  133742. * @param scene babylon scene object to use
  133743. * @param options (read-only) version of the options passed to this UI
  133744. */
  133745. private constructor();
  133746. /**
  133747. * Creates UI to allow the user to enter/exit XR mode
  133748. * @param scene the scene to add the ui to
  133749. * @param helper the xr experience helper to enter/exit xr with
  133750. * @param options options to configure the UI
  133751. * @returns the created ui
  133752. */
  133753. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  133754. /**
  133755. * Disposes of the XR UI component
  133756. */
  133757. dispose(): void;
  133758. private _updateButtons;
  133759. }
  133760. }
  133761. declare module BABYLON {
  133762. /**
  133763. * Class containing static functions to help procedurally build meshes
  133764. */
  133765. export class LinesBuilder {
  133766. /**
  133767. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133768. * * 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
  133769. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133770. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133771. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133772. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133773. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133774. * * 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
  133775. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133778. * @param name defines the name of the new line system
  133779. * @param options defines the options used to create the line system
  133780. * @param scene defines the hosting scene
  133781. * @returns a new line system mesh
  133782. */
  133783. static CreateLineSystem(name: string, options: {
  133784. lines: Vector3[][];
  133785. updatable?: boolean;
  133786. instance?: Nullable<LinesMesh>;
  133787. colors?: Nullable<Color4[][]>;
  133788. useVertexAlpha?: boolean;
  133789. }, scene: Nullable<Scene>): LinesMesh;
  133790. /**
  133791. * Creates a line mesh
  133792. * 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
  133793. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133794. * * The parameter `points` is an array successive Vector3
  133795. * * 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
  133796. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133797. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133798. * * When updating an instance, remember that only point positions can change, not the number of points
  133799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133801. * @param name defines the name of the new line system
  133802. * @param options defines the options used to create the line system
  133803. * @param scene defines the hosting scene
  133804. * @returns a new line mesh
  133805. */
  133806. static CreateLines(name: string, options: {
  133807. points: Vector3[];
  133808. updatable?: boolean;
  133809. instance?: Nullable<LinesMesh>;
  133810. colors?: Color4[];
  133811. useVertexAlpha?: boolean;
  133812. }, scene?: Nullable<Scene>): LinesMesh;
  133813. /**
  133814. * Creates a dashed line mesh
  133815. * * 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
  133816. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133817. * * The parameter `points` is an array successive Vector3
  133818. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133819. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133820. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133821. * * 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
  133822. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133823. * * When updating an instance, remember that only point positions can change, not the number of points
  133824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133825. * @param name defines the name of the mesh
  133826. * @param options defines the options used to create the mesh
  133827. * @param scene defines the hosting scene
  133828. * @returns the dashed line mesh
  133829. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133830. */
  133831. static CreateDashedLines(name: string, options: {
  133832. points: Vector3[];
  133833. dashSize?: number;
  133834. gapSize?: number;
  133835. dashNb?: number;
  133836. updatable?: boolean;
  133837. instance?: LinesMesh;
  133838. useVertexAlpha?: boolean;
  133839. }, scene?: Nullable<Scene>): LinesMesh;
  133840. }
  133841. }
  133842. declare module BABYLON {
  133843. /**
  133844. * Construction options for a timer
  133845. */
  133846. export interface ITimerOptions<T> {
  133847. /**
  133848. * Time-to-end
  133849. */
  133850. timeout: number;
  133851. /**
  133852. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133853. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133854. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133855. */
  133856. contextObservable: Observable<T>;
  133857. /**
  133858. * Optional parameters when adding an observer to the observable
  133859. */
  133860. observableParameters?: {
  133861. mask?: number;
  133862. insertFirst?: boolean;
  133863. scope?: any;
  133864. };
  133865. /**
  133866. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133867. */
  133868. breakCondition?: (data?: ITimerData<T>) => boolean;
  133869. /**
  133870. * Will be triggered when the time condition has met
  133871. */
  133872. onEnded?: (data: ITimerData<any>) => void;
  133873. /**
  133874. * Will be triggered when the break condition has met (prematurely ended)
  133875. */
  133876. onAborted?: (data: ITimerData<any>) => void;
  133877. /**
  133878. * Optional function to execute on each tick (or count)
  133879. */
  133880. onTick?: (data: ITimerData<any>) => void;
  133881. }
  133882. /**
  133883. * An interface defining the data sent by the timer
  133884. */
  133885. export interface ITimerData<T> {
  133886. /**
  133887. * When did it start
  133888. */
  133889. startTime: number;
  133890. /**
  133891. * Time now
  133892. */
  133893. currentTime: number;
  133894. /**
  133895. * Time passed since started
  133896. */
  133897. deltaTime: number;
  133898. /**
  133899. * How much is completed, in [0.0...1.0].
  133900. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133901. */
  133902. completeRate: number;
  133903. /**
  133904. * What the registered observable sent in the last count
  133905. */
  133906. payload: T;
  133907. }
  133908. /**
  133909. * The current state of the timer
  133910. */
  133911. export enum TimerState {
  133912. /**
  133913. * Timer initialized, not yet started
  133914. */
  133915. INIT = 0,
  133916. /**
  133917. * Timer started and counting
  133918. */
  133919. STARTED = 1,
  133920. /**
  133921. * Timer ended (whether aborted or time reached)
  133922. */
  133923. ENDED = 2
  133924. }
  133925. /**
  133926. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133927. *
  133928. * @param options options with which to initialize this timer
  133929. */
  133930. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133931. /**
  133932. * An advanced implementation of a timer class
  133933. */
  133934. export class AdvancedTimer<T = any> implements IDisposable {
  133935. /**
  133936. * Will notify each time the timer calculates the remaining time
  133937. */
  133938. onEachCountObservable: Observable<ITimerData<T>>;
  133939. /**
  133940. * Will trigger when the timer was aborted due to the break condition
  133941. */
  133942. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133943. /**
  133944. * Will trigger when the timer ended successfully
  133945. */
  133946. onTimerEndedObservable: Observable<ITimerData<T>>;
  133947. /**
  133948. * Will trigger when the timer state has changed
  133949. */
  133950. onStateChangedObservable: Observable<TimerState>;
  133951. private _observer;
  133952. private _contextObservable;
  133953. private _observableParameters;
  133954. private _startTime;
  133955. private _timer;
  133956. private _state;
  133957. private _breakCondition;
  133958. private _timeToEnd;
  133959. private _breakOnNextTick;
  133960. /**
  133961. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133962. * @param options construction options for this advanced timer
  133963. */
  133964. constructor(options: ITimerOptions<T>);
  133965. /**
  133966. * set a breaking condition for this timer. Default is to never break during count
  133967. * @param predicate the new break condition. Returns true to break, false otherwise
  133968. */
  133969. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133970. /**
  133971. * Reset ALL associated observables in this advanced timer
  133972. */
  133973. clearObservables(): void;
  133974. /**
  133975. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133976. *
  133977. * @param timeToEnd how much time to measure until timer ended
  133978. */
  133979. start(timeToEnd?: number): void;
  133980. /**
  133981. * Will force a stop on the next tick.
  133982. */
  133983. stop(): void;
  133984. /**
  133985. * Dispose this timer, clearing all resources
  133986. */
  133987. dispose(): void;
  133988. private _setState;
  133989. private _tick;
  133990. private _stop;
  133991. }
  133992. }
  133993. declare module BABYLON {
  133994. /**
  133995. * The options container for the teleportation module
  133996. */
  133997. export interface IWebXRTeleportationOptions {
  133998. /**
  133999. * if provided, this scene will be used to render meshes.
  134000. */
  134001. customUtilityLayerScene?: Scene;
  134002. /**
  134003. * Values to configure the default target mesh
  134004. */
  134005. defaultTargetMeshOptions?: {
  134006. /**
  134007. * Fill color of the teleportation area
  134008. */
  134009. teleportationFillColor?: string;
  134010. /**
  134011. * Border color for the teleportation area
  134012. */
  134013. teleportationBorderColor?: string;
  134014. /**
  134015. * Disable the mesh's animation sequence
  134016. */
  134017. disableAnimation?: boolean;
  134018. /**
  134019. * Disable lighting on the material or the ring and arrow
  134020. */
  134021. disableLighting?: boolean;
  134022. /**
  134023. * Override the default material of the torus and arrow
  134024. */
  134025. torusArrowMaterial?: Material;
  134026. };
  134027. /**
  134028. * A list of meshes to use as floor meshes.
  134029. * Meshes can be added and removed after initializing the feature using the
  134030. * addFloorMesh and removeFloorMesh functions
  134031. * If empty, rotation will still work
  134032. */
  134033. floorMeshes?: AbstractMesh[];
  134034. /**
  134035. * use this rendering group id for the meshes (optional)
  134036. */
  134037. renderingGroupId?: number;
  134038. /**
  134039. * Should teleportation move only to snap points
  134040. */
  134041. snapPointsOnly?: boolean;
  134042. /**
  134043. * An array of points to which the teleportation will snap to.
  134044. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134045. */
  134046. snapPositions?: Vector3[];
  134047. /**
  134048. * How close should the teleportation ray be in order to snap to position.
  134049. * Default to 0.8 units (meters)
  134050. */
  134051. snapToPositionRadius?: number;
  134052. /**
  134053. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134054. * If you want to support rotation, make sure your mesh has a direction indicator.
  134055. *
  134056. * When left untouched, the default mesh will be initialized.
  134057. */
  134058. teleportationTargetMesh?: AbstractMesh;
  134059. /**
  134060. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134061. */
  134062. timeToTeleport?: number;
  134063. /**
  134064. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134065. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134066. */
  134067. useMainComponentOnly?: boolean;
  134068. /**
  134069. * Should meshes created here be added to a utility layer or the main scene
  134070. */
  134071. useUtilityLayer?: boolean;
  134072. /**
  134073. * Babylon XR Input class for controller
  134074. */
  134075. xrInput: WebXRInput;
  134076. /**
  134077. * Meshes that the teleportation ray cannot go through
  134078. */
  134079. pickBlockerMeshes?: AbstractMesh[];
  134080. }
  134081. /**
  134082. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134083. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134084. * the input of the attached controllers.
  134085. */
  134086. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134087. private _options;
  134088. private _controllers;
  134089. private _currentTeleportationControllerId;
  134090. private _floorMeshes;
  134091. private _quadraticBezierCurve;
  134092. private _selectionFeature;
  134093. private _snapToPositions;
  134094. private _snappedToPoint;
  134095. private _teleportationRingMaterial?;
  134096. private _tmpRay;
  134097. private _tmpVector;
  134098. private _tmpQuaternion;
  134099. /**
  134100. * The module's name
  134101. */
  134102. static readonly Name: string;
  134103. /**
  134104. * The (Babylon) version of this module.
  134105. * This is an integer representing the implementation version.
  134106. * This number does not correspond to the webxr specs version
  134107. */
  134108. static readonly Version: number;
  134109. /**
  134110. * Is movement backwards enabled
  134111. */
  134112. backwardsMovementEnabled: boolean;
  134113. /**
  134114. * Distance to travel when moving backwards
  134115. */
  134116. backwardsTeleportationDistance: number;
  134117. /**
  134118. * The distance from the user to the inspection point in the direction of the controller
  134119. * A higher number will allow the user to move further
  134120. * defaults to 5 (meters, in xr units)
  134121. */
  134122. parabolicCheckRadius: number;
  134123. /**
  134124. * Should the module support parabolic ray on top of direct ray
  134125. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134126. * Very helpful when moving between floors / different heights
  134127. */
  134128. parabolicRayEnabled: boolean;
  134129. /**
  134130. * How much rotation should be applied when rotating right and left
  134131. */
  134132. rotationAngle: number;
  134133. /**
  134134. * Is rotation enabled when moving forward?
  134135. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134136. */
  134137. rotationEnabled: boolean;
  134138. /**
  134139. * constructs a new anchor system
  134140. * @param _xrSessionManager an instance of WebXRSessionManager
  134141. * @param _options configuration object for this feature
  134142. */
  134143. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134144. /**
  134145. * Get the snapPointsOnly flag
  134146. */
  134147. get snapPointsOnly(): boolean;
  134148. /**
  134149. * Sets the snapPointsOnly flag
  134150. * @param snapToPoints should teleportation be exclusively to snap points
  134151. */
  134152. set snapPointsOnly(snapToPoints: boolean);
  134153. /**
  134154. * Add a new mesh to the floor meshes array
  134155. * @param mesh the mesh to use as floor mesh
  134156. */
  134157. addFloorMesh(mesh: AbstractMesh): void;
  134158. /**
  134159. * Add a new snap-to point to fix teleportation to this position
  134160. * @param newSnapPoint The new Snap-To point
  134161. */
  134162. addSnapPoint(newSnapPoint: Vector3): void;
  134163. attach(): boolean;
  134164. detach(): boolean;
  134165. dispose(): void;
  134166. /**
  134167. * Remove a mesh from the floor meshes array
  134168. * @param mesh the mesh to remove
  134169. */
  134170. removeFloorMesh(mesh: AbstractMesh): void;
  134171. /**
  134172. * Remove a mesh from the floor meshes array using its name
  134173. * @param name the mesh name to remove
  134174. */
  134175. removeFloorMeshByName(name: string): void;
  134176. /**
  134177. * 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
  134178. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134179. * @returns was the point found and removed or not
  134180. */
  134181. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134182. /**
  134183. * This function sets a selection feature that will be disabled when
  134184. * the forward ray is shown and will be reattached when hidden.
  134185. * This is used to remove the selection rays when moving.
  134186. * @param selectionFeature the feature to disable when forward movement is enabled
  134187. */
  134188. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134189. protected _onXRFrame(_xrFrame: XRFrame): void;
  134190. private _attachController;
  134191. private _createDefaultTargetMesh;
  134192. private _detachController;
  134193. private _findClosestSnapPointWithRadius;
  134194. private _setTargetMeshPosition;
  134195. private _setTargetMeshVisibility;
  134196. private _showParabolicPath;
  134197. private _teleportForward;
  134198. }
  134199. }
  134200. declare module BABYLON {
  134201. /**
  134202. * Options for the default xr helper
  134203. */
  134204. export class WebXRDefaultExperienceOptions {
  134205. /**
  134206. * Enable or disable default UI to enter XR
  134207. */
  134208. disableDefaultUI?: boolean;
  134209. /**
  134210. * Should teleportation not initialize. defaults to false.
  134211. */
  134212. disableTeleportation?: boolean;
  134213. /**
  134214. * Floor meshes that will be used for teleport
  134215. */
  134216. floorMeshes?: Array<AbstractMesh>;
  134217. /**
  134218. * If set to true, the first frame will not be used to reset position
  134219. * The first frame is mainly used when copying transformation from the old camera
  134220. * Mainly used in AR
  134221. */
  134222. ignoreNativeCameraTransformation?: boolean;
  134223. /**
  134224. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134225. */
  134226. inputOptions?: IWebXRInputOptions;
  134227. /**
  134228. * optional configuration for the output canvas
  134229. */
  134230. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134231. /**
  134232. * optional UI options. This can be used among other to change session mode and reference space type
  134233. */
  134234. uiOptions?: WebXREnterExitUIOptions;
  134235. /**
  134236. * When loading teleportation and pointer select, use stable versions instead of latest.
  134237. */
  134238. useStablePlugins?: boolean;
  134239. /**
  134240. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134241. */
  134242. renderingGroupId?: number;
  134243. /**
  134244. * A list of optional features to init the session with
  134245. * If set to true, all features we support will be added
  134246. */
  134247. optionalFeatures?: boolean | string[];
  134248. }
  134249. /**
  134250. * Default experience which provides a similar setup to the previous webVRExperience
  134251. */
  134252. export class WebXRDefaultExperience {
  134253. /**
  134254. * Base experience
  134255. */
  134256. baseExperience: WebXRExperienceHelper;
  134257. /**
  134258. * Enables ui for entering/exiting xr
  134259. */
  134260. enterExitUI: WebXREnterExitUI;
  134261. /**
  134262. * Input experience extension
  134263. */
  134264. input: WebXRInput;
  134265. /**
  134266. * Enables laser pointer and selection
  134267. */
  134268. pointerSelection: WebXRControllerPointerSelection;
  134269. /**
  134270. * Default target xr should render to
  134271. */
  134272. renderTarget: WebXRRenderTarget;
  134273. /**
  134274. * Enables teleportation
  134275. */
  134276. teleportation: WebXRMotionControllerTeleportation;
  134277. private constructor();
  134278. /**
  134279. * Creates the default xr experience
  134280. * @param scene scene
  134281. * @param options options for basic configuration
  134282. * @returns resulting WebXRDefaultExperience
  134283. */
  134284. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134285. /**
  134286. * DIsposes of the experience helper
  134287. */
  134288. dispose(): void;
  134289. }
  134290. }
  134291. declare module BABYLON {
  134292. /**
  134293. * Options to modify the vr teleportation behavior.
  134294. */
  134295. export interface VRTeleportationOptions {
  134296. /**
  134297. * The name of the mesh which should be used as the teleportation floor. (default: null)
  134298. */
  134299. floorMeshName?: string;
  134300. /**
  134301. * A list of meshes to be used as the teleportation floor. (default: empty)
  134302. */
  134303. floorMeshes?: Mesh[];
  134304. /**
  134305. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  134306. */
  134307. teleportationMode?: number;
  134308. /**
  134309. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  134310. */
  134311. teleportationTime?: number;
  134312. /**
  134313. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  134314. */
  134315. teleportationSpeed?: number;
  134316. /**
  134317. * The easing function used in the animation or null for Linear. (default CircleEase)
  134318. */
  134319. easingFunction?: EasingFunction;
  134320. }
  134321. /**
  134322. * Options to modify the vr experience helper's behavior.
  134323. */
  134324. export interface VRExperienceHelperOptions extends WebVROptions {
  134325. /**
  134326. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  134327. */
  134328. createDeviceOrientationCamera?: boolean;
  134329. /**
  134330. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  134331. */
  134332. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  134333. /**
  134334. * Uses the main button on the controller to toggle the laser casted. (default: true)
  134335. */
  134336. laserToggle?: boolean;
  134337. /**
  134338. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  134339. */
  134340. floorMeshes?: Mesh[];
  134341. /**
  134342. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  134343. */
  134344. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  134345. /**
  134346. * Defines if WebXR should be used instead of WebVR (if available)
  134347. */
  134348. useXR?: boolean;
  134349. }
  134350. /**
  134351. * Event containing information after VR has been entered
  134352. */
  134353. export class OnAfterEnteringVRObservableEvent {
  134354. /**
  134355. * If entering vr was successful
  134356. */
  134357. success: boolean;
  134358. }
  134359. /**
  134360. * Helps to quickly add VR support to an existing scene.
  134361. * See https://doc.babylonjs.com/how_to/webvr_helper
  134362. */
  134363. export class VRExperienceHelper {
  134364. /** Options to modify the vr experience helper's behavior. */
  134365. webVROptions: VRExperienceHelperOptions;
  134366. private _scene;
  134367. private _position;
  134368. private _btnVR;
  134369. private _btnVRDisplayed;
  134370. private _webVRsupported;
  134371. private _webVRready;
  134372. private _webVRrequesting;
  134373. private _webVRpresenting;
  134374. private _hasEnteredVR;
  134375. private _fullscreenVRpresenting;
  134376. private _inputElement;
  134377. private _webVRCamera;
  134378. private _vrDeviceOrientationCamera;
  134379. private _deviceOrientationCamera;
  134380. private _existingCamera;
  134381. private _onKeyDown;
  134382. private _onVrDisplayPresentChange;
  134383. private _onVRDisplayChanged;
  134384. private _onVRRequestPresentStart;
  134385. private _onVRRequestPresentComplete;
  134386. /**
  134387. * 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)
  134388. */
  134389. enableGazeEvenWhenNoPointerLock: boolean;
  134390. /**
  134391. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  134392. */
  134393. exitVROnDoubleTap: boolean;
  134394. /**
  134395. * Observable raised right before entering VR.
  134396. */
  134397. onEnteringVRObservable: Observable<VRExperienceHelper>;
  134398. /**
  134399. * Observable raised when entering VR has completed.
  134400. */
  134401. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  134402. /**
  134403. * Observable raised when exiting VR.
  134404. */
  134405. onExitingVRObservable: Observable<VRExperienceHelper>;
  134406. /**
  134407. * Observable raised when controller mesh is loaded.
  134408. */
  134409. onControllerMeshLoadedObservable: Observable<WebVRController>;
  134410. /** Return this.onEnteringVRObservable
  134411. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  134412. */
  134413. get onEnteringVR(): Observable<VRExperienceHelper>;
  134414. /** Return this.onExitingVRObservable
  134415. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  134416. */
  134417. get onExitingVR(): Observable<VRExperienceHelper>;
  134418. /** Return this.onControllerMeshLoadedObservable
  134419. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  134420. */
  134421. get onControllerMeshLoaded(): Observable<WebVRController>;
  134422. private _rayLength;
  134423. private _useCustomVRButton;
  134424. private _teleportationRequested;
  134425. private _teleportActive;
  134426. private _floorMeshName;
  134427. private _floorMeshesCollection;
  134428. private _teleportationMode;
  134429. private _teleportationTime;
  134430. private _teleportationSpeed;
  134431. private _teleportationEasing;
  134432. private _rotationAllowed;
  134433. private _teleportBackwardsVector;
  134434. private _teleportationTarget;
  134435. private _isDefaultTeleportationTarget;
  134436. private _postProcessMove;
  134437. private _teleportationFillColor;
  134438. private _teleportationBorderColor;
  134439. private _rotationAngle;
  134440. private _haloCenter;
  134441. private _cameraGazer;
  134442. private _padSensibilityUp;
  134443. private _padSensibilityDown;
  134444. private _leftController;
  134445. private _rightController;
  134446. private _gazeColor;
  134447. private _laserColor;
  134448. private _pickedLaserColor;
  134449. private _pickedGazeColor;
  134450. /**
  134451. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  134452. */
  134453. onNewMeshSelected: Observable<AbstractMesh>;
  134454. /**
  134455. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  134456. * This observable will provide the mesh and the controller used to select the mesh
  134457. */
  134458. onMeshSelectedWithController: Observable<{
  134459. mesh: AbstractMesh;
  134460. controller: WebVRController;
  134461. }>;
  134462. /**
  134463. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  134464. */
  134465. onNewMeshPicked: Observable<PickingInfo>;
  134466. private _circleEase;
  134467. /**
  134468. * Observable raised before camera teleportation
  134469. */
  134470. onBeforeCameraTeleport: Observable<Vector3>;
  134471. /**
  134472. * Observable raised after camera teleportation
  134473. */
  134474. onAfterCameraTeleport: Observable<Vector3>;
  134475. /**
  134476. * Observable raised when current selected mesh gets unselected
  134477. */
  134478. onSelectedMeshUnselected: Observable<AbstractMesh>;
  134479. private _raySelectionPredicate;
  134480. /**
  134481. * To be optionaly changed by user to define custom ray selection
  134482. */
  134483. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134484. /**
  134485. * To be optionaly changed by user to define custom selection logic (after ray selection)
  134486. */
  134487. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134488. /**
  134489. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  134490. */
  134491. teleportationEnabled: boolean;
  134492. private _defaultHeight;
  134493. private _teleportationInitialized;
  134494. private _interactionsEnabled;
  134495. private _interactionsRequested;
  134496. private _displayGaze;
  134497. private _displayLaserPointer;
  134498. /**
  134499. * The mesh used to display where the user is going to teleport.
  134500. */
  134501. get teleportationTarget(): Mesh;
  134502. /**
  134503. * Sets the mesh to be used to display where the user is going to teleport.
  134504. */
  134505. set teleportationTarget(value: Mesh);
  134506. /**
  134507. * 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
  134508. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  134509. * See https://doc.babylonjs.com/resources/baking_transformations
  134510. */
  134511. get gazeTrackerMesh(): Mesh;
  134512. set gazeTrackerMesh(value: Mesh);
  134513. /**
  134514. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  134515. */
  134516. updateGazeTrackerScale: boolean;
  134517. /**
  134518. * If the gaze trackers color should be updated when selecting meshes
  134519. */
  134520. updateGazeTrackerColor: boolean;
  134521. /**
  134522. * If the controller laser color should be updated when selecting meshes
  134523. */
  134524. updateControllerLaserColor: boolean;
  134525. /**
  134526. * The gaze tracking mesh corresponding to the left controller
  134527. */
  134528. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  134529. /**
  134530. * The gaze tracking mesh corresponding to the right controller
  134531. */
  134532. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  134533. /**
  134534. * If the ray of the gaze should be displayed.
  134535. */
  134536. get displayGaze(): boolean;
  134537. /**
  134538. * Sets if the ray of the gaze should be displayed.
  134539. */
  134540. set displayGaze(value: boolean);
  134541. /**
  134542. * If the ray of the LaserPointer should be displayed.
  134543. */
  134544. get displayLaserPointer(): boolean;
  134545. /**
  134546. * Sets if the ray of the LaserPointer should be displayed.
  134547. */
  134548. set displayLaserPointer(value: boolean);
  134549. /**
  134550. * The deviceOrientationCamera used as the camera when not in VR.
  134551. */
  134552. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  134553. /**
  134554. * Based on the current WebVR support, returns the current VR camera used.
  134555. */
  134556. get currentVRCamera(): Nullable<Camera>;
  134557. /**
  134558. * The webVRCamera which is used when in VR.
  134559. */
  134560. get webVRCamera(): WebVRFreeCamera;
  134561. /**
  134562. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  134563. */
  134564. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  134565. /**
  134566. * The html button that is used to trigger entering into VR.
  134567. */
  134568. get vrButton(): Nullable<HTMLButtonElement>;
  134569. private get _teleportationRequestInitiated();
  134570. /**
  134571. * Defines whether or not Pointer lock should be requested when switching to
  134572. * full screen.
  134573. */
  134574. requestPointerLockOnFullScreen: boolean;
  134575. /**
  134576. * If asking to force XR, this will be populated with the default xr experience
  134577. */
  134578. xr: WebXRDefaultExperience;
  134579. /**
  134580. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  134581. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  134582. */
  134583. xrTestDone: boolean;
  134584. /**
  134585. * Instantiates a VRExperienceHelper.
  134586. * Helps to quickly add VR support to an existing scene.
  134587. * @param scene The scene the VRExperienceHelper belongs to.
  134588. * @param webVROptions Options to modify the vr experience helper's behavior.
  134589. */
  134590. constructor(scene: Scene,
  134591. /** Options to modify the vr experience helper's behavior. */
  134592. webVROptions?: VRExperienceHelperOptions);
  134593. private completeVRInit;
  134594. private _onDefaultMeshLoaded;
  134595. private _onResize;
  134596. private _onFullscreenChange;
  134597. /**
  134598. * Gets a value indicating if we are currently in VR mode.
  134599. */
  134600. get isInVRMode(): boolean;
  134601. private onVrDisplayPresentChange;
  134602. private onVRDisplayChanged;
  134603. private moveButtonToBottomRight;
  134604. private displayVRButton;
  134605. private updateButtonVisibility;
  134606. private _cachedAngularSensibility;
  134607. /**
  134608. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  134609. * Otherwise, will use the fullscreen API.
  134610. */
  134611. enterVR(): void;
  134612. /**
  134613. * Attempt to exit VR, or fullscreen.
  134614. */
  134615. exitVR(): void;
  134616. /**
  134617. * The position of the vr experience helper.
  134618. */
  134619. get position(): Vector3;
  134620. /**
  134621. * Sets the position of the vr experience helper.
  134622. */
  134623. set position(value: Vector3);
  134624. /**
  134625. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  134626. */
  134627. enableInteractions(): void;
  134628. private get _noControllerIsActive();
  134629. private beforeRender;
  134630. private _isTeleportationFloor;
  134631. /**
  134632. * Adds a floor mesh to be used for teleportation.
  134633. * @param floorMesh the mesh to be used for teleportation.
  134634. */
  134635. addFloorMesh(floorMesh: Mesh): void;
  134636. /**
  134637. * Removes a floor mesh from being used for teleportation.
  134638. * @param floorMesh the mesh to be removed.
  134639. */
  134640. removeFloorMesh(floorMesh: Mesh): void;
  134641. /**
  134642. * Enables interactions and teleportation using the VR controllers and gaze.
  134643. * @param vrTeleportationOptions options to modify teleportation behavior.
  134644. */
  134645. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  134646. private _onNewGamepadConnected;
  134647. private _tryEnableInteractionOnController;
  134648. private _onNewGamepadDisconnected;
  134649. private _enableInteractionOnController;
  134650. private _checkTeleportWithRay;
  134651. private _checkRotate;
  134652. private _checkTeleportBackwards;
  134653. private _enableTeleportationOnController;
  134654. private _createTeleportationCircles;
  134655. private _displayTeleportationTarget;
  134656. private _hideTeleportationTarget;
  134657. private _rotateCamera;
  134658. private _moveTeleportationSelectorTo;
  134659. private _workingVector;
  134660. private _workingQuaternion;
  134661. private _workingMatrix;
  134662. /**
  134663. * Time Constant Teleportation Mode
  134664. */
  134665. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  134666. /**
  134667. * Speed Constant Teleportation Mode
  134668. */
  134669. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  134670. /**
  134671. * Teleports the users feet to the desired location
  134672. * @param location The location where the user's feet should be placed
  134673. */
  134674. teleportCamera(location: Vector3): void;
  134675. private _convertNormalToDirectionOfRay;
  134676. private _castRayAndSelectObject;
  134677. private _notifySelectedMeshUnselected;
  134678. /**
  134679. * Permanently set new colors for the laser pointer
  134680. * @param color the new laser color
  134681. * @param pickedColor the new laser color when picked mesh detected
  134682. */
  134683. setLaserColor(color: Color3, pickedColor?: Color3): void;
  134684. /**
  134685. * Set lighting enabled / disabled on the laser pointer of both controllers
  134686. * @param enabled should the lighting be enabled on the laser pointer
  134687. */
  134688. setLaserLightingState(enabled?: boolean): void;
  134689. /**
  134690. * Permanently set new colors for the gaze pointer
  134691. * @param color the new gaze color
  134692. * @param pickedColor the new gaze color when picked mesh detected
  134693. */
  134694. setGazeColor(color: Color3, pickedColor?: Color3): void;
  134695. /**
  134696. * Sets the color of the laser ray from the vr controllers.
  134697. * @param color new color for the ray.
  134698. */
  134699. changeLaserColor(color: Color3): void;
  134700. /**
  134701. * Sets the color of the ray from the vr headsets gaze.
  134702. * @param color new color for the ray.
  134703. */
  134704. changeGazeColor(color: Color3): void;
  134705. /**
  134706. * Exits VR and disposes of the vr experience helper
  134707. */
  134708. dispose(): void;
  134709. /**
  134710. * Gets the name of the VRExperienceHelper class
  134711. * @returns "VRExperienceHelper"
  134712. */
  134713. getClassName(): string;
  134714. }
  134715. }
  134716. declare module BABYLON {
  134717. /**
  134718. * Contains an array of blocks representing the octree
  134719. */
  134720. export interface IOctreeContainer<T> {
  134721. /**
  134722. * Blocks within the octree
  134723. */
  134724. blocks: Array<OctreeBlock<T>>;
  134725. }
  134726. /**
  134727. * Class used to store a cell in an octree
  134728. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134729. */
  134730. export class OctreeBlock<T> {
  134731. /**
  134732. * Gets the content of the current block
  134733. */
  134734. entries: T[];
  134735. /**
  134736. * Gets the list of block children
  134737. */
  134738. blocks: Array<OctreeBlock<T>>;
  134739. private _depth;
  134740. private _maxDepth;
  134741. private _capacity;
  134742. private _minPoint;
  134743. private _maxPoint;
  134744. private _boundingVectors;
  134745. private _creationFunc;
  134746. /**
  134747. * Creates a new block
  134748. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  134749. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  134750. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134751. * @param depth defines the current depth of this block in the octree
  134752. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  134753. * @param creationFunc defines a callback to call when an element is added to the block
  134754. */
  134755. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  134756. /**
  134757. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134758. */
  134759. get capacity(): number;
  134760. /**
  134761. * Gets the minimum vector (in world space) of the block's bounding box
  134762. */
  134763. get minPoint(): Vector3;
  134764. /**
  134765. * Gets the maximum vector (in world space) of the block's bounding box
  134766. */
  134767. get maxPoint(): Vector3;
  134768. /**
  134769. * Add a new element to this block
  134770. * @param entry defines the element to add
  134771. */
  134772. addEntry(entry: T): void;
  134773. /**
  134774. * Remove an element from this block
  134775. * @param entry defines the element to remove
  134776. */
  134777. removeEntry(entry: T): void;
  134778. /**
  134779. * Add an array of elements to this block
  134780. * @param entries defines the array of elements to add
  134781. */
  134782. addEntries(entries: T[]): void;
  134783. /**
  134784. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  134785. * @param frustumPlanes defines the frustum planes to test
  134786. * @param selection defines the array to store current content if selection is positive
  134787. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134788. */
  134789. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134790. /**
  134791. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  134792. * @param sphereCenter defines the bounding sphere center
  134793. * @param sphereRadius defines the bounding sphere radius
  134794. * @param selection defines the array to store current content if selection is positive
  134795. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134796. */
  134797. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134798. /**
  134799. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134800. * @param ray defines the ray to test with
  134801. * @param selection defines the array to store current content if selection is positive
  134802. */
  134803. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134804. /**
  134805. * Subdivide the content into child blocks (this block will then be empty)
  134806. */
  134807. createInnerBlocks(): void;
  134808. /**
  134809. * @hidden
  134810. */
  134811. 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;
  134812. }
  134813. }
  134814. declare module BABYLON {
  134815. /**
  134816. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134817. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134818. */
  134819. export class Octree<T> {
  134820. /** 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.) */
  134821. maxDepth: number;
  134822. /**
  134823. * Blocks within the octree containing objects
  134824. */
  134825. blocks: Array<OctreeBlock<T>>;
  134826. /**
  134827. * Content stored in the octree
  134828. */
  134829. dynamicContent: T[];
  134830. private _maxBlockCapacity;
  134831. private _selectionContent;
  134832. private _creationFunc;
  134833. /**
  134834. * Creates a octree
  134835. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134836. * @param creationFunc function to be used to instatiate the octree
  134837. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134838. * @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.)
  134839. */
  134840. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134841. /** 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.) */
  134842. maxDepth?: number);
  134843. /**
  134844. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134845. * @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);
  134846. * @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);
  134847. * @param entries meshes to be added to the octree blocks
  134848. */
  134849. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134850. /**
  134851. * Adds a mesh to the octree
  134852. * @param entry Mesh to add to the octree
  134853. */
  134854. addMesh(entry: T): void;
  134855. /**
  134856. * Remove an element from the octree
  134857. * @param entry defines the element to remove
  134858. */
  134859. removeMesh(entry: T): void;
  134860. /**
  134861. * Selects an array of meshes within the frustum
  134862. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134863. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134864. * @returns array of meshes within the frustum
  134865. */
  134866. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134867. /**
  134868. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134869. * @param sphereCenter defines the bounding sphere center
  134870. * @param sphereRadius defines the bounding sphere radius
  134871. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134872. * @returns an array of objects that intersect the sphere
  134873. */
  134874. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134875. /**
  134876. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134877. * @param ray defines the ray to test with
  134878. * @returns array of intersected objects
  134879. */
  134880. intersectsRay(ray: Ray): SmartArray<T>;
  134881. /**
  134882. * Adds a mesh into the octree block if it intersects the block
  134883. */
  134884. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134885. /**
  134886. * Adds a submesh into the octree block if it intersects the block
  134887. */
  134888. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134889. }
  134890. }
  134891. declare module BABYLON {
  134892. interface Scene {
  134893. /**
  134894. * @hidden
  134895. * Backing Filed
  134896. */
  134897. _selectionOctree: Octree<AbstractMesh>;
  134898. /**
  134899. * Gets the octree used to boost mesh selection (picking)
  134900. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134901. */
  134902. selectionOctree: Octree<AbstractMesh>;
  134903. /**
  134904. * Creates or updates the octree used to boost selection (picking)
  134905. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134906. * @param maxCapacity defines the maximum capacity per leaf
  134907. * @param maxDepth defines the maximum depth of the octree
  134908. * @returns an octree of AbstractMesh
  134909. */
  134910. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134911. }
  134912. interface AbstractMesh {
  134913. /**
  134914. * @hidden
  134915. * Backing Field
  134916. */
  134917. _submeshesOctree: Octree<SubMesh>;
  134918. /**
  134919. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134920. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134921. * @param maxCapacity defines the maximum size of each block (64 by default)
  134922. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134923. * @returns the new octree
  134924. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134925. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134926. */
  134927. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134928. }
  134929. /**
  134930. * Defines the octree scene component responsible to manage any octrees
  134931. * in a given scene.
  134932. */
  134933. export class OctreeSceneComponent {
  134934. /**
  134935. * The component name help to identify the component in the list of scene components.
  134936. */
  134937. readonly name: string;
  134938. /**
  134939. * The scene the component belongs to.
  134940. */
  134941. scene: Scene;
  134942. /**
  134943. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134944. */
  134945. readonly checksIsEnabled: boolean;
  134946. /**
  134947. * Creates a new instance of the component for the given scene
  134948. * @param scene Defines the scene to register the component in
  134949. */
  134950. constructor(scene: Scene);
  134951. /**
  134952. * Registers the component in a given scene
  134953. */
  134954. register(): void;
  134955. /**
  134956. * Return the list of active meshes
  134957. * @returns the list of active meshes
  134958. */
  134959. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134960. /**
  134961. * Return the list of active sub meshes
  134962. * @param mesh The mesh to get the candidates sub meshes from
  134963. * @returns the list of active sub meshes
  134964. */
  134965. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134966. private _tempRay;
  134967. /**
  134968. * Return the list of sub meshes intersecting with a given local ray
  134969. * @param mesh defines the mesh to find the submesh for
  134970. * @param localRay defines the ray in local space
  134971. * @returns the list of intersecting sub meshes
  134972. */
  134973. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134974. /**
  134975. * Return the list of sub meshes colliding with a collider
  134976. * @param mesh defines the mesh to find the submesh for
  134977. * @param collider defines the collider to evaluate the collision against
  134978. * @returns the list of colliding sub meshes
  134979. */
  134980. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134981. /**
  134982. * Rebuilds the elements related to this component in case of
  134983. * context lost for instance.
  134984. */
  134985. rebuild(): void;
  134986. /**
  134987. * Disposes the component and the associated ressources.
  134988. */
  134989. dispose(): void;
  134990. }
  134991. }
  134992. declare module BABYLON {
  134993. /**
  134994. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134995. */
  134996. export class Gizmo implements IDisposable {
  134997. /** The utility layer the gizmo will be added to */
  134998. gizmoLayer: UtilityLayerRenderer;
  134999. /**
  135000. * The root mesh of the gizmo
  135001. */
  135002. _rootMesh: Mesh;
  135003. private _attachedMesh;
  135004. private _attachedNode;
  135005. /**
  135006. * Ratio for the scale of the gizmo (Default: 1)
  135007. */
  135008. protected _scaleRatio: number;
  135009. /**
  135010. * boolean updated by pointermove when a gizmo mesh is hovered
  135011. */
  135012. protected _isHovered: boolean;
  135013. /**
  135014. * Ratio for the scale of the gizmo (Default: 1)
  135015. */
  135016. set scaleRatio(value: number);
  135017. get scaleRatio(): number;
  135018. /**
  135019. * True when the mouse pointer is hovered a gizmo mesh
  135020. */
  135021. get isHovered(): boolean;
  135022. /**
  135023. * If a custom mesh has been set (Default: false)
  135024. */
  135025. protected _customMeshSet: boolean;
  135026. /**
  135027. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135028. * * When set, interactions will be enabled
  135029. */
  135030. get attachedMesh(): Nullable<AbstractMesh>;
  135031. set attachedMesh(value: Nullable<AbstractMesh>);
  135032. /**
  135033. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135034. * * When set, interactions will be enabled
  135035. */
  135036. get attachedNode(): Nullable<Node>;
  135037. set attachedNode(value: Nullable<Node>);
  135038. /**
  135039. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135040. * @param mesh The mesh to replace the default mesh of the gizmo
  135041. */
  135042. setCustomMesh(mesh: Mesh): void;
  135043. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135044. /**
  135045. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135046. */
  135047. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135048. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135049. /**
  135050. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135051. */
  135052. updateGizmoPositionToMatchAttachedMesh: boolean;
  135053. /**
  135054. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135055. */
  135056. updateScale: boolean;
  135057. protected _interactionsEnabled: boolean;
  135058. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135059. private _beforeRenderObserver;
  135060. private _tempQuaternion;
  135061. private _tempVector;
  135062. private _tempVector2;
  135063. private _tempMatrix1;
  135064. private _tempMatrix2;
  135065. private _rightHandtoLeftHandMatrix;
  135066. /**
  135067. * Creates a gizmo
  135068. * @param gizmoLayer The utility layer the gizmo will be added to
  135069. */
  135070. constructor(
  135071. /** The utility layer the gizmo will be added to */
  135072. gizmoLayer?: UtilityLayerRenderer);
  135073. /**
  135074. * Updates the gizmo to match the attached mesh's position/rotation
  135075. */
  135076. protected _update(): void;
  135077. /**
  135078. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135079. * @param value Node, TransformNode or mesh
  135080. */
  135081. protected _matrixChanged(): void;
  135082. /**
  135083. * Disposes of the gizmo
  135084. */
  135085. dispose(): void;
  135086. }
  135087. }
  135088. declare module BABYLON {
  135089. /**
  135090. * Single plane drag gizmo
  135091. */
  135092. export class PlaneDragGizmo extends Gizmo {
  135093. /**
  135094. * Drag behavior responsible for the gizmos dragging interactions
  135095. */
  135096. dragBehavior: PointerDragBehavior;
  135097. private _pointerObserver;
  135098. /**
  135099. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135100. */
  135101. snapDistance: number;
  135102. /**
  135103. * Event that fires each time the gizmo snaps to a new location.
  135104. * * snapDistance is the the change in distance
  135105. */
  135106. onSnapObservable: Observable<{
  135107. snapDistance: number;
  135108. }>;
  135109. private _plane;
  135110. private _coloredMaterial;
  135111. private _hoverMaterial;
  135112. private _isEnabled;
  135113. private _parent;
  135114. /** @hidden */
  135115. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135116. /** @hidden */
  135117. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  135118. /**
  135119. * Creates a PlaneDragGizmo
  135120. * @param gizmoLayer The utility layer the gizmo will be added to
  135121. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135122. * @param color The color of the gizmo
  135123. */
  135124. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135125. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135126. /**
  135127. * If the gizmo is enabled
  135128. */
  135129. set isEnabled(value: boolean);
  135130. get isEnabled(): boolean;
  135131. /**
  135132. * Disposes of the gizmo
  135133. */
  135134. dispose(): void;
  135135. }
  135136. }
  135137. declare module BABYLON {
  135138. /**
  135139. * Gizmo that enables dragging a mesh along 3 axis
  135140. */
  135141. export class PositionGizmo extends Gizmo {
  135142. /**
  135143. * Internal gizmo used for interactions on the x axis
  135144. */
  135145. xGizmo: AxisDragGizmo;
  135146. /**
  135147. * Internal gizmo used for interactions on the y axis
  135148. */
  135149. yGizmo: AxisDragGizmo;
  135150. /**
  135151. * Internal gizmo used for interactions on the z axis
  135152. */
  135153. zGizmo: AxisDragGizmo;
  135154. /**
  135155. * Internal gizmo used for interactions on the yz plane
  135156. */
  135157. xPlaneGizmo: PlaneDragGizmo;
  135158. /**
  135159. * Internal gizmo used for interactions on the xz plane
  135160. */
  135161. yPlaneGizmo: PlaneDragGizmo;
  135162. /**
  135163. * Internal gizmo used for interactions on the xy plane
  135164. */
  135165. zPlaneGizmo: PlaneDragGizmo;
  135166. /**
  135167. * private variables
  135168. */
  135169. private _meshAttached;
  135170. private _nodeAttached;
  135171. private _snapDistance;
  135172. /** Fires an event when any of it's sub gizmos are dragged */
  135173. onDragStartObservable: Observable<unknown>;
  135174. /** Fires an event when any of it's sub gizmos are released from dragging */
  135175. onDragEndObservable: Observable<unknown>;
  135176. /**
  135177. * If set to true, planar drag is enabled
  135178. */
  135179. private _planarGizmoEnabled;
  135180. get attachedMesh(): Nullable<AbstractMesh>;
  135181. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135182. get attachedNode(): Nullable<Node>;
  135183. set attachedNode(node: Nullable<Node>);
  135184. /**
  135185. * True when the mouse pointer is hovering a gizmo mesh
  135186. */
  135187. get isHovered(): boolean;
  135188. /**
  135189. * Creates a PositionGizmo
  135190. * @param gizmoLayer The utility layer the gizmo will be added to
  135191. @param thickness display gizmo axis thickness
  135192. */
  135193. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  135194. /**
  135195. * If the planar drag gizmo is enabled
  135196. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  135197. */
  135198. set planarGizmoEnabled(value: boolean);
  135199. get planarGizmoEnabled(): boolean;
  135200. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135201. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135202. /**
  135203. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135204. */
  135205. set snapDistance(value: number);
  135206. get snapDistance(): number;
  135207. /**
  135208. * Ratio for the scale of the gizmo (Default: 1)
  135209. */
  135210. set scaleRatio(value: number);
  135211. get scaleRatio(): number;
  135212. /**
  135213. * Disposes of the gizmo
  135214. */
  135215. dispose(): void;
  135216. /**
  135217. * CustomMeshes are not supported by this gizmo
  135218. * @param mesh The mesh to replace the default mesh of the gizmo
  135219. */
  135220. setCustomMesh(mesh: Mesh): void;
  135221. }
  135222. }
  135223. declare module BABYLON {
  135224. /**
  135225. * Single axis drag gizmo
  135226. */
  135227. export class AxisDragGizmo extends Gizmo {
  135228. /**
  135229. * Drag behavior responsible for the gizmos dragging interactions
  135230. */
  135231. dragBehavior: PointerDragBehavior;
  135232. private _pointerObserver;
  135233. /**
  135234. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135235. */
  135236. snapDistance: number;
  135237. /**
  135238. * Event that fires each time the gizmo snaps to a new location.
  135239. * * snapDistance is the the change in distance
  135240. */
  135241. onSnapObservable: Observable<{
  135242. snapDistance: number;
  135243. }>;
  135244. private _isEnabled;
  135245. private _parent;
  135246. private _arrow;
  135247. private _coloredMaterial;
  135248. private _hoverMaterial;
  135249. /** @hidden */
  135250. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  135251. /** @hidden */
  135252. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  135253. /**
  135254. * Creates an AxisDragGizmo
  135255. * @param gizmoLayer The utility layer the gizmo will be added to
  135256. * @param dragAxis The axis which the gizmo will be able to drag on
  135257. * @param color The color of the gizmo
  135258. * @param thickness display gizmo axis thickness
  135259. */
  135260. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  135261. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135262. /**
  135263. * If the gizmo is enabled
  135264. */
  135265. set isEnabled(value: boolean);
  135266. get isEnabled(): boolean;
  135267. /**
  135268. * Disposes of the gizmo
  135269. */
  135270. dispose(): void;
  135271. }
  135272. }
  135273. declare module BABYLON.Debug {
  135274. /**
  135275. * The Axes viewer will show 3 axes in a specific point in space
  135276. */
  135277. export class AxesViewer {
  135278. private _xAxis;
  135279. private _yAxis;
  135280. private _zAxis;
  135281. private _scaleLinesFactor;
  135282. private _instanced;
  135283. /**
  135284. * Gets the hosting scene
  135285. */
  135286. scene: Nullable<Scene>;
  135287. /**
  135288. * Gets or sets a number used to scale line length
  135289. */
  135290. scaleLines: number;
  135291. /** Gets the node hierarchy used to render x-axis */
  135292. get xAxis(): TransformNode;
  135293. /** Gets the node hierarchy used to render y-axis */
  135294. get yAxis(): TransformNode;
  135295. /** Gets the node hierarchy used to render z-axis */
  135296. get zAxis(): TransformNode;
  135297. /**
  135298. * Creates a new AxesViewer
  135299. * @param scene defines the hosting scene
  135300. * @param scaleLines defines a number used to scale line length (1 by default)
  135301. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  135302. * @param xAxis defines the node hierarchy used to render the x-axis
  135303. * @param yAxis defines the node hierarchy used to render the y-axis
  135304. * @param zAxis defines the node hierarchy used to render the z-axis
  135305. */
  135306. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  135307. /**
  135308. * Force the viewer to update
  135309. * @param position defines the position of the viewer
  135310. * @param xaxis defines the x axis of the viewer
  135311. * @param yaxis defines the y axis of the viewer
  135312. * @param zaxis defines the z axis of the viewer
  135313. */
  135314. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  135315. /**
  135316. * Creates an instance of this axes viewer.
  135317. * @returns a new axes viewer with instanced meshes
  135318. */
  135319. createInstance(): AxesViewer;
  135320. /** Releases resources */
  135321. dispose(): void;
  135322. private static _SetRenderingGroupId;
  135323. }
  135324. }
  135325. declare module BABYLON.Debug {
  135326. /**
  135327. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  135328. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  135329. */
  135330. export class BoneAxesViewer extends AxesViewer {
  135331. /**
  135332. * Gets or sets the target mesh where to display the axes viewer
  135333. */
  135334. mesh: Nullable<Mesh>;
  135335. /**
  135336. * Gets or sets the target bone where to display the axes viewer
  135337. */
  135338. bone: Nullable<Bone>;
  135339. /** Gets current position */
  135340. pos: Vector3;
  135341. /** Gets direction of X axis */
  135342. xaxis: Vector3;
  135343. /** Gets direction of Y axis */
  135344. yaxis: Vector3;
  135345. /** Gets direction of Z axis */
  135346. zaxis: Vector3;
  135347. /**
  135348. * Creates a new BoneAxesViewer
  135349. * @param scene defines the hosting scene
  135350. * @param bone defines the target bone
  135351. * @param mesh defines the target mesh
  135352. * @param scaleLines defines a scaling factor for line length (1 by default)
  135353. */
  135354. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  135355. /**
  135356. * Force the viewer to update
  135357. */
  135358. update(): void;
  135359. /** Releases resources */
  135360. dispose(): void;
  135361. }
  135362. }
  135363. declare module BABYLON {
  135364. /**
  135365. * Interface used to define scene explorer extensibility option
  135366. */
  135367. export interface IExplorerExtensibilityOption {
  135368. /**
  135369. * Define the option label
  135370. */
  135371. label: string;
  135372. /**
  135373. * Defines the action to execute on click
  135374. */
  135375. action: (entity: any) => void;
  135376. }
  135377. /**
  135378. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  135379. */
  135380. export interface IExplorerExtensibilityGroup {
  135381. /**
  135382. * Defines a predicate to test if a given type mut be extended
  135383. */
  135384. predicate: (entity: any) => boolean;
  135385. /**
  135386. * Gets the list of options added to a type
  135387. */
  135388. entries: IExplorerExtensibilityOption[];
  135389. }
  135390. /**
  135391. * Interface used to define the options to use to create the Inspector
  135392. */
  135393. export interface IInspectorOptions {
  135394. /**
  135395. * Display in overlay mode (default: false)
  135396. */
  135397. overlay?: boolean;
  135398. /**
  135399. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  135400. */
  135401. globalRoot?: HTMLElement;
  135402. /**
  135403. * Display the Scene explorer
  135404. */
  135405. showExplorer?: boolean;
  135406. /**
  135407. * Display the property inspector
  135408. */
  135409. showInspector?: boolean;
  135410. /**
  135411. * Display in embed mode (both panes on the right)
  135412. */
  135413. embedMode?: boolean;
  135414. /**
  135415. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  135416. */
  135417. handleResize?: boolean;
  135418. /**
  135419. * Allow the panes to popup (default: true)
  135420. */
  135421. enablePopup?: boolean;
  135422. /**
  135423. * Allow the panes to be closed by users (default: true)
  135424. */
  135425. enableClose?: boolean;
  135426. /**
  135427. * Optional list of extensibility entries
  135428. */
  135429. explorerExtensibility?: IExplorerExtensibilityGroup[];
  135430. /**
  135431. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  135432. */
  135433. inspectorURL?: string;
  135434. /**
  135435. * Optional initial tab (default to DebugLayerTab.Properties)
  135436. */
  135437. initialTab?: DebugLayerTab;
  135438. }
  135439. interface Scene {
  135440. /**
  135441. * @hidden
  135442. * Backing field
  135443. */
  135444. _debugLayer: DebugLayer;
  135445. /**
  135446. * Gets the debug layer (aka Inspector) associated with the scene
  135447. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135448. */
  135449. debugLayer: DebugLayer;
  135450. }
  135451. /**
  135452. * Enum of inspector action tab
  135453. */
  135454. export enum DebugLayerTab {
  135455. /**
  135456. * Properties tag (default)
  135457. */
  135458. Properties = 0,
  135459. /**
  135460. * Debug tab
  135461. */
  135462. Debug = 1,
  135463. /**
  135464. * Statistics tab
  135465. */
  135466. Statistics = 2,
  135467. /**
  135468. * Tools tab
  135469. */
  135470. Tools = 3,
  135471. /**
  135472. * Settings tab
  135473. */
  135474. Settings = 4
  135475. }
  135476. /**
  135477. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135478. * what is happening in your scene
  135479. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135480. */
  135481. export class DebugLayer {
  135482. /**
  135483. * Define the url to get the inspector script from.
  135484. * By default it uses the babylonjs CDN.
  135485. * @ignoreNaming
  135486. */
  135487. static InspectorURL: string;
  135488. private _scene;
  135489. private BJSINSPECTOR;
  135490. private _onPropertyChangedObservable?;
  135491. /**
  135492. * Observable triggered when a property is changed through the inspector.
  135493. */
  135494. get onPropertyChangedObservable(): any;
  135495. /**
  135496. * Instantiates a new debug layer.
  135497. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135498. * what is happening in your scene
  135499. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135500. * @param scene Defines the scene to inspect
  135501. */
  135502. constructor(scene: Scene);
  135503. /** Creates the inspector window. */
  135504. private _createInspector;
  135505. /**
  135506. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  135507. * @param entity defines the entity to select
  135508. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  135509. */
  135510. select(entity: any, lineContainerTitles?: string | string[]): void;
  135511. /** Get the inspector from bundle or global */
  135512. private _getGlobalInspector;
  135513. /**
  135514. * Get if the inspector is visible or not.
  135515. * @returns true if visible otherwise, false
  135516. */
  135517. isVisible(): boolean;
  135518. /**
  135519. * Hide the inspector and close its window.
  135520. */
  135521. hide(): void;
  135522. /**
  135523. * Update the scene in the inspector
  135524. */
  135525. setAsActiveScene(): void;
  135526. /**
  135527. * Launch the debugLayer.
  135528. * @param config Define the configuration of the inspector
  135529. * @return a promise fulfilled when the debug layer is visible
  135530. */
  135531. show(config?: IInspectorOptions): Promise<DebugLayer>;
  135532. }
  135533. }
  135534. declare module BABYLON {
  135535. /**
  135536. * Class containing static functions to help procedurally build meshes
  135537. */
  135538. export class BoxBuilder {
  135539. /**
  135540. * Creates a box mesh
  135541. * * The parameter `size` sets the size (float) of each box side (default 1)
  135542. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135543. * * 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)
  135544. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135548. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135549. * @param name defines the name of the mesh
  135550. * @param options defines the options used to create the mesh
  135551. * @param scene defines the hosting scene
  135552. * @returns the box mesh
  135553. */
  135554. static CreateBox(name: string, options: {
  135555. size?: number;
  135556. width?: number;
  135557. height?: number;
  135558. depth?: number;
  135559. faceUV?: Vector4[];
  135560. faceColors?: Color4[];
  135561. sideOrientation?: number;
  135562. frontUVs?: Vector4;
  135563. backUVs?: Vector4;
  135564. wrap?: boolean;
  135565. topBaseAt?: number;
  135566. bottomBaseAt?: number;
  135567. updatable?: boolean;
  135568. }, scene?: Nullable<Scene>): Mesh;
  135569. }
  135570. }
  135571. declare module BABYLON.Debug {
  135572. /**
  135573. * Used to show the physics impostor around the specific mesh
  135574. */
  135575. export class PhysicsViewer {
  135576. /** @hidden */
  135577. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  135578. /** @hidden */
  135579. protected _meshes: Array<Nullable<AbstractMesh>>;
  135580. /** @hidden */
  135581. protected _scene: Nullable<Scene>;
  135582. /** @hidden */
  135583. protected _numMeshes: number;
  135584. /** @hidden */
  135585. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  135586. private _renderFunction;
  135587. private _utilityLayer;
  135588. private _debugBoxMesh;
  135589. private _debugSphereMesh;
  135590. private _debugCylinderMesh;
  135591. private _debugMaterial;
  135592. private _debugMeshMeshes;
  135593. /**
  135594. * Creates a new PhysicsViewer
  135595. * @param scene defines the hosting scene
  135596. */
  135597. constructor(scene: Scene);
  135598. /** @hidden */
  135599. protected _updateDebugMeshes(): void;
  135600. /**
  135601. * Renders a specified physic impostor
  135602. * @param impostor defines the impostor to render
  135603. * @param targetMesh defines the mesh represented by the impostor
  135604. * @returns the new debug mesh used to render the impostor
  135605. */
  135606. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  135607. /**
  135608. * Hides a specified physic impostor
  135609. * @param impostor defines the impostor to hide
  135610. */
  135611. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  135612. private _getDebugMaterial;
  135613. private _getDebugBoxMesh;
  135614. private _getDebugSphereMesh;
  135615. private _getDebugCylinderMesh;
  135616. private _getDebugMeshMesh;
  135617. private _getDebugMesh;
  135618. /** Releases all resources */
  135619. dispose(): void;
  135620. }
  135621. }
  135622. declare module BABYLON {
  135623. /**
  135624. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135625. * in order to better appreciate the issue one might have.
  135626. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135627. */
  135628. export class RayHelper {
  135629. /**
  135630. * Defines the ray we are currently tryin to visualize.
  135631. */
  135632. ray: Nullable<Ray>;
  135633. private _renderPoints;
  135634. private _renderLine;
  135635. private _renderFunction;
  135636. private _scene;
  135637. private _onAfterRenderObserver;
  135638. private _onAfterStepObserver;
  135639. private _attachedToMesh;
  135640. private _meshSpaceDirection;
  135641. private _meshSpaceOrigin;
  135642. /**
  135643. * Helper function to create a colored helper in a scene in one line.
  135644. * @param ray Defines the ray we are currently tryin to visualize
  135645. * @param scene Defines the scene the ray is used in
  135646. * @param color Defines the color we want to see the ray in
  135647. * @returns The newly created ray helper.
  135648. */
  135649. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  135650. /**
  135651. * Instantiate a new ray helper.
  135652. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135653. * in order to better appreciate the issue one might have.
  135654. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135655. * @param ray Defines the ray we are currently tryin to visualize
  135656. */
  135657. constructor(ray: Ray);
  135658. /**
  135659. * Shows the ray we are willing to debug.
  135660. * @param scene Defines the scene the ray needs to be rendered in
  135661. * @param color Defines the color the ray needs to be rendered in
  135662. */
  135663. show(scene: Scene, color?: Color3): void;
  135664. /**
  135665. * Hides the ray we are debugging.
  135666. */
  135667. hide(): void;
  135668. private _render;
  135669. /**
  135670. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  135671. * @param mesh Defines the mesh we want the helper attached to
  135672. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  135673. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  135674. * @param length Defines the length of the ray
  135675. */
  135676. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  135677. /**
  135678. * Detach the ray helper from the mesh it has previously been attached to.
  135679. */
  135680. detachFromMesh(): void;
  135681. private _updateToMesh;
  135682. /**
  135683. * Dispose the helper and release its associated resources.
  135684. */
  135685. dispose(): void;
  135686. }
  135687. }
  135688. declare module BABYLON {
  135689. /**
  135690. * Defines the options associated with the creation of a SkeletonViewer.
  135691. */
  135692. export interface ISkeletonViewerOptions {
  135693. /** Should the system pause animations before building the Viewer? */
  135694. pauseAnimations: boolean;
  135695. /** Should the system return the skeleton to rest before building? */
  135696. returnToRest: boolean;
  135697. /** public Display Mode of the Viewer */
  135698. displayMode: number;
  135699. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135700. displayOptions: ISkeletonViewerDisplayOptions;
  135701. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135702. computeBonesUsingShaders: boolean;
  135703. /** Flag ignore non weighted bones */
  135704. useAllBones: boolean;
  135705. }
  135706. /**
  135707. * Defines how to display the various bone meshes for the viewer.
  135708. */
  135709. export interface ISkeletonViewerDisplayOptions {
  135710. /** How far down to start tapering the bone spurs */
  135711. midStep?: number;
  135712. /** How big is the midStep? */
  135713. midStepFactor?: number;
  135714. /** Base for the Sphere Size */
  135715. sphereBaseSize?: number;
  135716. /** The ratio of the sphere to the longest bone in units */
  135717. sphereScaleUnit?: number;
  135718. /** Ratio for the Sphere Size */
  135719. sphereFactor?: number;
  135720. /** Whether a spur should attach its far end to the child bone position */
  135721. spurFollowsChild?: boolean;
  135722. /** Whether to show local axes or not */
  135723. showLocalAxes?: boolean;
  135724. /** Length of each local axis */
  135725. localAxesSize?: number;
  135726. }
  135727. /**
  135728. * Defines the constructor options for the BoneWeight Shader.
  135729. */
  135730. export interface IBoneWeightShaderOptions {
  135731. /** Skeleton to Map */
  135732. skeleton: Skeleton;
  135733. /** Colors for Uninfluenced bones */
  135734. colorBase?: Color3;
  135735. /** Colors for 0.0-0.25 Weight bones */
  135736. colorZero?: Color3;
  135737. /** Color for 0.25-0.5 Weight Influence */
  135738. colorQuarter?: Color3;
  135739. /** Color for 0.5-0.75 Weight Influence */
  135740. colorHalf?: Color3;
  135741. /** Color for 0.75-1 Weight Influence */
  135742. colorFull?: Color3;
  135743. /** Color for Zero Weight Influence */
  135744. targetBoneIndex?: number;
  135745. }
  135746. /**
  135747. * Simple structure of the gradient steps for the Color Map.
  135748. */
  135749. export interface ISkeletonMapShaderColorMapKnot {
  135750. /** Color of the Knot */
  135751. color: Color3;
  135752. /** Location of the Knot */
  135753. location: number;
  135754. }
  135755. /**
  135756. * Defines the constructor options for the SkeletonMap Shader.
  135757. */
  135758. export interface ISkeletonMapShaderOptions {
  135759. /** Skeleton to Map */
  135760. skeleton: Skeleton;
  135761. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  135762. colorMap?: ISkeletonMapShaderColorMapKnot[];
  135763. }
  135764. }
  135765. declare module BABYLON {
  135766. /**
  135767. * Class containing static functions to help procedurally build meshes
  135768. */
  135769. export class RibbonBuilder {
  135770. /**
  135771. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135772. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135773. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135774. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135775. * * 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
  135776. * * 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
  135777. * * 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
  135778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135780. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135781. * * 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
  135782. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135783. * * 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
  135784. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135786. * @param name defines the name of the mesh
  135787. * @param options defines the options used to create the mesh
  135788. * @param scene defines the hosting scene
  135789. * @returns the ribbon mesh
  135790. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135791. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135792. */
  135793. static CreateRibbon(name: string, options: {
  135794. pathArray: Vector3[][];
  135795. closeArray?: boolean;
  135796. closePath?: boolean;
  135797. offset?: number;
  135798. updatable?: boolean;
  135799. sideOrientation?: number;
  135800. frontUVs?: Vector4;
  135801. backUVs?: Vector4;
  135802. instance?: Mesh;
  135803. invertUV?: boolean;
  135804. uvs?: Vector2[];
  135805. colors?: Color4[];
  135806. }, scene?: Nullable<Scene>): Mesh;
  135807. }
  135808. }
  135809. declare module BABYLON {
  135810. /**
  135811. * Class containing static functions to help procedurally build meshes
  135812. */
  135813. export class ShapeBuilder {
  135814. /**
  135815. * 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.
  135816. * * 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.
  135817. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135818. * * 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.
  135819. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135820. * * 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
  135821. * * 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
  135822. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135827. * @param name defines the name of the mesh
  135828. * @param options defines the options used to create the mesh
  135829. * @param scene defines the hosting scene
  135830. * @returns the extruded shape mesh
  135831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135833. */
  135834. static ExtrudeShape(name: string, options: {
  135835. shape: Vector3[];
  135836. path: Vector3[];
  135837. scale?: number;
  135838. rotation?: number;
  135839. cap?: number;
  135840. updatable?: boolean;
  135841. sideOrientation?: number;
  135842. frontUVs?: Vector4;
  135843. backUVs?: Vector4;
  135844. instance?: Mesh;
  135845. invertUV?: boolean;
  135846. }, scene?: Nullable<Scene>): Mesh;
  135847. /**
  135848. * Creates an custom extruded shape mesh.
  135849. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135850. * * 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.
  135851. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135852. * * 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
  135853. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135854. * * 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
  135855. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135856. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135857. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135858. * * 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
  135859. * * 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
  135860. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135865. * @param name defines the name of the mesh
  135866. * @param options defines the options used to create the mesh
  135867. * @param scene defines the hosting scene
  135868. * @returns the custom extruded shape mesh
  135869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135872. */
  135873. static ExtrudeShapeCustom(name: string, options: {
  135874. shape: Vector3[];
  135875. path: Vector3[];
  135876. scaleFunction?: any;
  135877. rotationFunction?: any;
  135878. ribbonCloseArray?: boolean;
  135879. ribbonClosePath?: boolean;
  135880. cap?: number;
  135881. updatable?: boolean;
  135882. sideOrientation?: number;
  135883. frontUVs?: Vector4;
  135884. backUVs?: Vector4;
  135885. instance?: Mesh;
  135886. invertUV?: boolean;
  135887. }, scene?: Nullable<Scene>): Mesh;
  135888. private static _ExtrudeShapeGeneric;
  135889. }
  135890. }
  135891. declare module BABYLON.Debug {
  135892. /**
  135893. * Class used to render a debug view of a given skeleton
  135894. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135895. */
  135896. export class SkeletonViewer {
  135897. /** defines the skeleton to render */
  135898. skeleton: Skeleton;
  135899. /** defines the mesh attached to the skeleton */
  135900. mesh: AbstractMesh;
  135901. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135902. autoUpdateBonesMatrices: boolean;
  135903. /** defines the rendering group id to use with the viewer */
  135904. renderingGroupId: number;
  135905. /** is the options for the viewer */
  135906. options: Partial<ISkeletonViewerOptions>;
  135907. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135908. static readonly DISPLAY_LINES: number;
  135909. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135910. static readonly DISPLAY_SPHERES: number;
  135911. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135912. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135913. /** public static method to create a BoneWeight Shader
  135914. * @param options The constructor options
  135915. * @param scene The scene that the shader is scoped to
  135916. * @returns The created ShaderMaterial
  135917. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135918. */
  135919. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135920. /** public static method to create a BoneWeight Shader
  135921. * @param options The constructor options
  135922. * @param scene The scene that the shader is scoped to
  135923. * @returns The created ShaderMaterial
  135924. */
  135925. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135926. /** private static method to create a BoneWeight Shader
  135927. * @param size The size of the buffer to create (usually the bone count)
  135928. * @param colorMap The gradient data to generate
  135929. * @param scene The scene that the shader is scoped to
  135930. * @returns an Array of floats from the color gradient values
  135931. */
  135932. private static _CreateBoneMapColorBuffer;
  135933. /** If SkeletonViewer scene scope. */
  135934. private _scene;
  135935. /** Gets or sets the color used to render the skeleton */
  135936. color: Color3;
  135937. /** Array of the points of the skeleton fo the line view. */
  135938. private _debugLines;
  135939. /** The SkeletonViewers Mesh. */
  135940. private _debugMesh;
  135941. /** The local axes Meshes. */
  135942. private _localAxes;
  135943. /** If SkeletonViewer is enabled. */
  135944. private _isEnabled;
  135945. /** If SkeletonViewer is ready. */
  135946. private _ready;
  135947. /** SkeletonViewer render observable. */
  135948. private _obs;
  135949. /** The Utility Layer to render the gizmos in. */
  135950. private _utilityLayer;
  135951. private _boneIndices;
  135952. /** Gets the Scene. */
  135953. get scene(): Scene;
  135954. /** Gets the utilityLayer. */
  135955. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135956. /** Checks Ready Status. */
  135957. get isReady(): Boolean;
  135958. /** Sets Ready Status. */
  135959. set ready(value: boolean);
  135960. /** Gets the debugMesh */
  135961. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135962. /** Sets the debugMesh */
  135963. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135964. /** Gets the displayMode */
  135965. get displayMode(): number;
  135966. /** Sets the displayMode */
  135967. set displayMode(value: number);
  135968. /**
  135969. * Creates a new SkeletonViewer
  135970. * @param skeleton defines the skeleton to render
  135971. * @param mesh defines the mesh attached to the skeleton
  135972. * @param scene defines the hosting scene
  135973. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135974. * @param renderingGroupId defines the rendering group id to use with the viewer
  135975. * @param options All of the extra constructor options for the SkeletonViewer
  135976. */
  135977. constructor(
  135978. /** defines the skeleton to render */
  135979. skeleton: Skeleton,
  135980. /** defines the mesh attached to the skeleton */
  135981. mesh: AbstractMesh,
  135982. /** The Scene scope*/
  135983. scene: Scene,
  135984. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135985. autoUpdateBonesMatrices?: boolean,
  135986. /** defines the rendering group id to use with the viewer */
  135987. renderingGroupId?: number,
  135988. /** is the options for the viewer */
  135989. options?: Partial<ISkeletonViewerOptions>);
  135990. /** The Dynamic bindings for the update functions */
  135991. private _bindObs;
  135992. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135993. update(): void;
  135994. /** Gets or sets a boolean indicating if the viewer is enabled */
  135995. set isEnabled(value: boolean);
  135996. get isEnabled(): boolean;
  135997. private _getBonePosition;
  135998. private _getLinesForBonesWithLength;
  135999. private _getLinesForBonesNoLength;
  136000. /** function to revert the mesh and scene back to the initial state. */
  136001. private _revert;
  136002. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  136003. private _getAbsoluteBindPoseToRef;
  136004. /** function to build and bind sphere joint points and spur bone representations. */
  136005. private _buildSpheresAndSpurs;
  136006. private _buildLocalAxes;
  136007. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  136008. private _displayLinesUpdate;
  136009. /** Changes the displayMode of the skeleton viewer
  136010. * @param mode The displayMode numerical value
  136011. */
  136012. changeDisplayMode(mode: number): void;
  136013. /** Sets a display option of the skeleton viewer
  136014. *
  136015. * | Option | Type | Default | Description |
  136016. * | ---------------- | ------- | ------- | ----------- |
  136017. * | 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`. |
  136018. * | 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`. |
  136019. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  136020. * | 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`. |
  136021. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  136022. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  136023. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  136024. *
  136025. * @param option String of the option name
  136026. * @param value The numerical option value
  136027. */
  136028. changeDisplayOptions(option: string, value: number): void;
  136029. /** Release associated resources */
  136030. dispose(): void;
  136031. }
  136032. }
  136033. declare module BABYLON {
  136034. /**
  136035. * Enum for Device Types
  136036. */
  136037. export enum DeviceType {
  136038. /** Generic */
  136039. Generic = 0,
  136040. /** Keyboard */
  136041. Keyboard = 1,
  136042. /** Mouse */
  136043. Mouse = 2,
  136044. /** Touch Pointers */
  136045. Touch = 3,
  136046. /** PS4 Dual Shock */
  136047. DualShock = 4,
  136048. /** Xbox */
  136049. Xbox = 5,
  136050. /** Switch Controller */
  136051. Switch = 6
  136052. }
  136053. /**
  136054. * Enum for All Pointers (Touch/Mouse)
  136055. */
  136056. export enum PointerInput {
  136057. /** Horizontal Axis */
  136058. Horizontal = 0,
  136059. /** Vertical Axis */
  136060. Vertical = 1,
  136061. /** Left Click or Touch */
  136062. LeftClick = 2,
  136063. /** Middle Click */
  136064. MiddleClick = 3,
  136065. /** Right Click */
  136066. RightClick = 4,
  136067. /** Browser Back */
  136068. BrowserBack = 5,
  136069. /** Browser Forward */
  136070. BrowserForward = 6
  136071. }
  136072. /**
  136073. * Enum for Dual Shock Gamepad
  136074. */
  136075. export enum DualShockInput {
  136076. /** Cross */
  136077. Cross = 0,
  136078. /** Circle */
  136079. Circle = 1,
  136080. /** Square */
  136081. Square = 2,
  136082. /** Triangle */
  136083. Triangle = 3,
  136084. /** L1 */
  136085. L1 = 4,
  136086. /** R1 */
  136087. R1 = 5,
  136088. /** L2 */
  136089. L2 = 6,
  136090. /** R2 */
  136091. R2 = 7,
  136092. /** Share */
  136093. Share = 8,
  136094. /** Options */
  136095. Options = 9,
  136096. /** L3 */
  136097. L3 = 10,
  136098. /** R3 */
  136099. R3 = 11,
  136100. /** DPadUp */
  136101. DPadUp = 12,
  136102. /** DPadDown */
  136103. DPadDown = 13,
  136104. /** DPadLeft */
  136105. DPadLeft = 14,
  136106. /** DRight */
  136107. DPadRight = 15,
  136108. /** Home */
  136109. Home = 16,
  136110. /** TouchPad */
  136111. TouchPad = 17,
  136112. /** LStickXAxis */
  136113. LStickXAxis = 18,
  136114. /** LStickYAxis */
  136115. LStickYAxis = 19,
  136116. /** RStickXAxis */
  136117. RStickXAxis = 20,
  136118. /** RStickYAxis */
  136119. RStickYAxis = 21
  136120. }
  136121. /**
  136122. * Enum for Xbox Gamepad
  136123. */
  136124. export enum XboxInput {
  136125. /** A */
  136126. A = 0,
  136127. /** B */
  136128. B = 1,
  136129. /** X */
  136130. X = 2,
  136131. /** Y */
  136132. Y = 3,
  136133. /** LB */
  136134. LB = 4,
  136135. /** RB */
  136136. RB = 5,
  136137. /** LT */
  136138. LT = 6,
  136139. /** RT */
  136140. RT = 7,
  136141. /** Back */
  136142. Back = 8,
  136143. /** Start */
  136144. Start = 9,
  136145. /** LS */
  136146. LS = 10,
  136147. /** RS */
  136148. RS = 11,
  136149. /** DPadUp */
  136150. DPadUp = 12,
  136151. /** DPadDown */
  136152. DPadDown = 13,
  136153. /** DPadLeft */
  136154. DPadLeft = 14,
  136155. /** DRight */
  136156. DPadRight = 15,
  136157. /** Home */
  136158. Home = 16,
  136159. /** LStickXAxis */
  136160. LStickXAxis = 17,
  136161. /** LStickYAxis */
  136162. LStickYAxis = 18,
  136163. /** RStickXAxis */
  136164. RStickXAxis = 19,
  136165. /** RStickYAxis */
  136166. RStickYAxis = 20
  136167. }
  136168. /**
  136169. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  136170. */
  136171. export enum SwitchInput {
  136172. /** B */
  136173. B = 0,
  136174. /** A */
  136175. A = 1,
  136176. /** Y */
  136177. Y = 2,
  136178. /** X */
  136179. X = 3,
  136180. /** L */
  136181. L = 4,
  136182. /** R */
  136183. R = 5,
  136184. /** ZL */
  136185. ZL = 6,
  136186. /** ZR */
  136187. ZR = 7,
  136188. /** Minus */
  136189. Minus = 8,
  136190. /** Plus */
  136191. Plus = 9,
  136192. /** LS */
  136193. LS = 10,
  136194. /** RS */
  136195. RS = 11,
  136196. /** DPadUp */
  136197. DPadUp = 12,
  136198. /** DPadDown */
  136199. DPadDown = 13,
  136200. /** DPadLeft */
  136201. DPadLeft = 14,
  136202. /** DRight */
  136203. DPadRight = 15,
  136204. /** Home */
  136205. Home = 16,
  136206. /** Capture */
  136207. Capture = 17,
  136208. /** LStickXAxis */
  136209. LStickXAxis = 18,
  136210. /** LStickYAxis */
  136211. LStickYAxis = 19,
  136212. /** RStickXAxis */
  136213. RStickXAxis = 20,
  136214. /** RStickYAxis */
  136215. RStickYAxis = 21
  136216. }
  136217. }
  136218. declare module BABYLON {
  136219. /**
  136220. * This class will take all inputs from Keyboard, Pointer, and
  136221. * any Gamepads and provide a polling system that all devices
  136222. * will use. This class assumes that there will only be one
  136223. * pointer device and one keyboard.
  136224. */
  136225. export class DeviceInputSystem implements IDisposable {
  136226. /**
  136227. * Returns onDeviceConnected callback property
  136228. * @returns Callback with function to execute when a device is connected
  136229. */
  136230. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  136231. /**
  136232. * Sets callback function when a device is connected and executes against all connected devices
  136233. * @param callback Function to execute when a device is connected
  136234. */
  136235. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  136236. /**
  136237. * Callback to be triggered when a device is disconnected
  136238. */
  136239. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  136240. /**
  136241. * Callback to be triggered when event driven input is updated
  136242. */
  136243. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  136244. private _inputs;
  136245. private _gamepads;
  136246. private _keyboardActive;
  136247. private _pointerActive;
  136248. private _elementToAttachTo;
  136249. private _keyboardDownEvent;
  136250. private _keyboardUpEvent;
  136251. private _pointerMoveEvent;
  136252. private _pointerDownEvent;
  136253. private _pointerUpEvent;
  136254. private _gamepadConnectedEvent;
  136255. private _gamepadDisconnectedEvent;
  136256. private _onDeviceConnected;
  136257. private static _MAX_KEYCODES;
  136258. private static _MAX_POINTER_INPUTS;
  136259. private constructor();
  136260. /**
  136261. * Creates a new DeviceInputSystem instance
  136262. * @param engine Engine to pull input element from
  136263. * @returns The new instance
  136264. */
  136265. static Create(engine: Engine): DeviceInputSystem;
  136266. /**
  136267. * Checks for current device input value, given an id and input index
  136268. * @param deviceName Id of connected device
  136269. * @param inputIndex Index of device input
  136270. * @returns Current value of input
  136271. */
  136272. /**
  136273. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  136274. * @param deviceType Enum specifiying device type
  136275. * @param deviceSlot "Slot" or index that device is referenced in
  136276. * @param inputIndex Id of input to be checked
  136277. * @returns Current value of input
  136278. */
  136279. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  136280. /**
  136281. * Dispose of all the eventlisteners
  136282. */
  136283. dispose(): void;
  136284. /**
  136285. * Checks for existing connections to devices and register them, if necessary
  136286. * Currently handles gamepads and mouse
  136287. */
  136288. private _checkForConnectedDevices;
  136289. /**
  136290. * Add a gamepad to the DeviceInputSystem
  136291. * @param gamepad A single DOM Gamepad object
  136292. */
  136293. private _addGamePad;
  136294. /**
  136295. * Add pointer device to DeviceInputSystem
  136296. * @param deviceType Type of Pointer to add
  136297. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  136298. * @param currentX Current X at point of adding
  136299. * @param currentY Current Y at point of adding
  136300. */
  136301. private _addPointerDevice;
  136302. /**
  136303. * Add device and inputs to device array
  136304. * @param deviceType Enum specifiying device type
  136305. * @param deviceSlot "Slot" or index that device is referenced in
  136306. * @param numberOfInputs Number of input entries to create for given device
  136307. */
  136308. private _registerDevice;
  136309. /**
  136310. * Given a specific device name, remove that device from the device map
  136311. * @param deviceType Enum specifiying device type
  136312. * @param deviceSlot "Slot" or index that device is referenced in
  136313. */
  136314. private _unregisterDevice;
  136315. /**
  136316. * Handle all actions that come from keyboard interaction
  136317. */
  136318. private _handleKeyActions;
  136319. /**
  136320. * Handle all actions that come from pointer interaction
  136321. */
  136322. private _handlePointerActions;
  136323. /**
  136324. * Handle all actions that come from gamepad interaction
  136325. */
  136326. private _handleGamepadActions;
  136327. /**
  136328. * Update all non-event based devices with each frame
  136329. * @param deviceType Enum specifiying device type
  136330. * @param deviceSlot "Slot" or index that device is referenced in
  136331. * @param inputIndex Id of input to be checked
  136332. */
  136333. private _updateDevice;
  136334. /**
  136335. * Gets DeviceType from the device name
  136336. * @param deviceName Name of Device from DeviceInputSystem
  136337. * @returns DeviceType enum value
  136338. */
  136339. private _getGamepadDeviceType;
  136340. }
  136341. }
  136342. declare module BABYLON {
  136343. /**
  136344. * Type to handle enforcement of inputs
  136345. */
  136346. 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;
  136347. }
  136348. declare module BABYLON {
  136349. /**
  136350. * Class that handles all input for a specific device
  136351. */
  136352. export class DeviceSource<T extends DeviceType> {
  136353. /** Type of device */
  136354. readonly deviceType: DeviceType;
  136355. /** "Slot" or index that device is referenced in */
  136356. readonly deviceSlot: number;
  136357. /**
  136358. * Observable to handle device input changes per device
  136359. */
  136360. readonly onInputChangedObservable: Observable<{
  136361. inputIndex: DeviceInput<T>;
  136362. previousState: Nullable<number>;
  136363. currentState: Nullable<number>;
  136364. }>;
  136365. private readonly _deviceInputSystem;
  136366. /**
  136367. * Default Constructor
  136368. * @param deviceInputSystem Reference to DeviceInputSystem
  136369. * @param deviceType Type of device
  136370. * @param deviceSlot "Slot" or index that device is referenced in
  136371. */
  136372. constructor(deviceInputSystem: DeviceInputSystem,
  136373. /** Type of device */
  136374. deviceType: DeviceType,
  136375. /** "Slot" or index that device is referenced in */
  136376. deviceSlot?: number);
  136377. /**
  136378. * Get input for specific input
  136379. * @param inputIndex index of specific input on device
  136380. * @returns Input value from DeviceInputSystem
  136381. */
  136382. getInput(inputIndex: DeviceInput<T>): number;
  136383. }
  136384. /**
  136385. * Class to keep track of devices
  136386. */
  136387. export class DeviceSourceManager implements IDisposable {
  136388. /**
  136389. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  136390. */
  136391. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  136392. /**
  136393. * Observable to be triggered when after a device is disconnected
  136394. */
  136395. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  136396. private readonly _devices;
  136397. private readonly _firstDevice;
  136398. private readonly _deviceInputSystem;
  136399. /**
  136400. * Default Constructor
  136401. * @param engine engine to pull input element from
  136402. */
  136403. constructor(engine: Engine);
  136404. /**
  136405. * Gets a DeviceSource, given a type and slot
  136406. * @param deviceType Enum specifying device type
  136407. * @param deviceSlot "Slot" or index that device is referenced in
  136408. * @returns DeviceSource object
  136409. */
  136410. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  136411. /**
  136412. * Gets an array of DeviceSource objects for a given device type
  136413. * @param deviceType Enum specifying device type
  136414. * @returns Array of DeviceSource objects
  136415. */
  136416. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  136417. /**
  136418. * Returns a read-only list of all available devices
  136419. * @returns Read-only array with active devices
  136420. */
  136421. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  136422. /**
  136423. * Dispose of DeviceInputSystem and other parts
  136424. */
  136425. dispose(): void;
  136426. /**
  136427. * Function to add device name to device list
  136428. * @param deviceType Enum specifying device type
  136429. * @param deviceSlot "Slot" or index that device is referenced in
  136430. */
  136431. private _addDevice;
  136432. /**
  136433. * Function to remove device name to device list
  136434. * @param deviceType Enum specifying device type
  136435. * @param deviceSlot "Slot" or index that device is referenced in
  136436. */
  136437. private _removeDevice;
  136438. /**
  136439. * Updates array storing first connected device of each type
  136440. * @param type Type of Device
  136441. */
  136442. private _updateFirstDevices;
  136443. }
  136444. }
  136445. declare module BABYLON {
  136446. /**
  136447. * Options to create the null engine
  136448. */
  136449. export class NullEngineOptions {
  136450. /**
  136451. * Render width (Default: 512)
  136452. */
  136453. renderWidth: number;
  136454. /**
  136455. * Render height (Default: 256)
  136456. */
  136457. renderHeight: number;
  136458. /**
  136459. * Texture size (Default: 512)
  136460. */
  136461. textureSize: number;
  136462. /**
  136463. * If delta time between frames should be constant
  136464. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136465. */
  136466. deterministicLockstep: boolean;
  136467. /**
  136468. * Maximum about of steps between frames (Default: 4)
  136469. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136470. */
  136471. lockstepMaxSteps: number;
  136472. /**
  136473. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  136474. */
  136475. useHighPrecisionMatrix?: boolean;
  136476. }
  136477. /**
  136478. * The null engine class provides support for headless version of babylon.js.
  136479. * This can be used in server side scenario or for testing purposes
  136480. */
  136481. export class NullEngine extends Engine {
  136482. private _options;
  136483. /**
  136484. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  136485. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136486. * @returns true if engine is in deterministic lock step mode
  136487. */
  136488. isDeterministicLockStep(): boolean;
  136489. /**
  136490. * Gets the max steps when engine is running in deterministic lock step
  136491. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136492. * @returns the max steps
  136493. */
  136494. getLockstepMaxSteps(): number;
  136495. /**
  136496. * Gets the current hardware scaling level.
  136497. * By default the hardware scaling level is computed from the window device ratio.
  136498. * 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.
  136499. * @returns a number indicating the current hardware scaling level
  136500. */
  136501. getHardwareScalingLevel(): number;
  136502. constructor(options?: NullEngineOptions);
  136503. /**
  136504. * Creates a vertex buffer
  136505. * @param vertices the data for the vertex buffer
  136506. * @returns the new WebGL static buffer
  136507. */
  136508. createVertexBuffer(vertices: FloatArray): DataBuffer;
  136509. /**
  136510. * Creates a new index buffer
  136511. * @param indices defines the content of the index buffer
  136512. * @param updatable defines if the index buffer must be updatable
  136513. * @returns a new webGL buffer
  136514. */
  136515. createIndexBuffer(indices: IndicesArray): DataBuffer;
  136516. /**
  136517. * Clear the current render buffer or the current render target (if any is set up)
  136518. * @param color defines the color to use
  136519. * @param backBuffer defines if the back buffer must be cleared
  136520. * @param depth defines if the depth buffer must be cleared
  136521. * @param stencil defines if the stencil buffer must be cleared
  136522. */
  136523. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136524. /**
  136525. * Gets the current render width
  136526. * @param useScreen defines if screen size must be used (or the current render target if any)
  136527. * @returns a number defining the current render width
  136528. */
  136529. getRenderWidth(useScreen?: boolean): number;
  136530. /**
  136531. * Gets the current render height
  136532. * @param useScreen defines if screen size must be used (or the current render target if any)
  136533. * @returns a number defining the current render height
  136534. */
  136535. getRenderHeight(useScreen?: boolean): number;
  136536. /**
  136537. * Set the WebGL's viewport
  136538. * @param viewport defines the viewport element to be used
  136539. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  136540. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  136541. */
  136542. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  136543. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  136544. /**
  136545. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  136546. * @param pipelineContext defines the pipeline context to use
  136547. * @param uniformsNames defines the list of uniform names
  136548. * @returns an array of webGL uniform locations
  136549. */
  136550. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  136551. /**
  136552. * Gets the lsit of active attributes for a given webGL program
  136553. * @param pipelineContext defines the pipeline context to use
  136554. * @param attributesNames defines the list of attribute names to get
  136555. * @returns an array of indices indicating the offset of each attribute
  136556. */
  136557. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136558. /**
  136559. * Binds an effect to the webGL context
  136560. * @param effect defines the effect to bind
  136561. */
  136562. bindSamplers(effect: Effect): void;
  136563. /**
  136564. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  136565. * @param effect defines the effect to activate
  136566. */
  136567. enableEffect(effect: Effect): void;
  136568. /**
  136569. * Set various states to the webGL context
  136570. * @param culling defines backface culling state
  136571. * @param zOffset defines the value to apply to zOffset (0 by default)
  136572. * @param force defines if states must be applied even if cache is up to date
  136573. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  136574. */
  136575. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136576. /**
  136577. * Set the value of an uniform to an array of int32
  136578. * @param uniform defines the webGL uniform location where to store the value
  136579. * @param array defines the array of int32 to store
  136580. * @returns true if value was set
  136581. */
  136582. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136583. /**
  136584. * Set the value of an uniform to an array of int32 (stored as vec2)
  136585. * @param uniform defines the webGL uniform location where to store the value
  136586. * @param array defines the array of int32 to store
  136587. * @returns true if value was set
  136588. */
  136589. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136590. /**
  136591. * Set the value of an uniform to an array of int32 (stored as vec3)
  136592. * @param uniform defines the webGL uniform location where to store the value
  136593. * @param array defines the array of int32 to store
  136594. * @returns true if value was set
  136595. */
  136596. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136597. /**
  136598. * Set the value of an uniform to an array of int32 (stored as vec4)
  136599. * @param uniform defines the webGL uniform location where to store the value
  136600. * @param array defines the array of int32 to store
  136601. * @returns true if value was set
  136602. */
  136603. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136604. /**
  136605. * Set the value of an uniform to an array of float32
  136606. * @param uniform defines the webGL uniform location where to store the value
  136607. * @param array defines the array of float32 to store
  136608. * @returns true if value was set
  136609. */
  136610. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136611. /**
  136612. * Set the value of an uniform to an array of float32 (stored as vec2)
  136613. * @param uniform defines the webGL uniform location where to store the value
  136614. * @param array defines the array of float32 to store
  136615. * @returns true if value was set
  136616. */
  136617. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136618. /**
  136619. * Set the value of an uniform to an array of float32 (stored as vec3)
  136620. * @param uniform defines the webGL uniform location where to store the value
  136621. * @param array defines the array of float32 to store
  136622. * @returns true if value was set
  136623. */
  136624. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136625. /**
  136626. * Set the value of an uniform to an array of float32 (stored as vec4)
  136627. * @param uniform defines the webGL uniform location where to store the value
  136628. * @param array defines the array of float32 to store
  136629. * @returns true if value was set
  136630. */
  136631. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136632. /**
  136633. * Set the value of an uniform to an array of number
  136634. * @param uniform defines the webGL uniform location where to store the value
  136635. * @param array defines the array of number to store
  136636. * @returns true if value was set
  136637. */
  136638. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136639. /**
  136640. * Set the value of an uniform to an array of number (stored as vec2)
  136641. * @param uniform defines the webGL uniform location where to store the value
  136642. * @param array defines the array of number to store
  136643. * @returns true if value was set
  136644. */
  136645. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136646. /**
  136647. * Set the value of an uniform to an array of number (stored as vec3)
  136648. * @param uniform defines the webGL uniform location where to store the value
  136649. * @param array defines the array of number to store
  136650. * @returns true if value was set
  136651. */
  136652. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136653. /**
  136654. * Set the value of an uniform to an array of number (stored as vec4)
  136655. * @param uniform defines the webGL uniform location where to store the value
  136656. * @param array defines the array of number to store
  136657. * @returns true if value was set
  136658. */
  136659. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136660. /**
  136661. * Set the value of an uniform to an array of float32 (stored as matrices)
  136662. * @param uniform defines the webGL uniform location where to store the value
  136663. * @param matrices defines the array of float32 to store
  136664. * @returns true if value was set
  136665. */
  136666. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136667. /**
  136668. * Set the value of an uniform to a matrix (3x3)
  136669. * @param uniform defines the webGL uniform location where to store the value
  136670. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  136671. * @returns true if value was set
  136672. */
  136673. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136674. /**
  136675. * Set the value of an uniform to a matrix (2x2)
  136676. * @param uniform defines the webGL uniform location where to store the value
  136677. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  136678. * @returns true if value was set
  136679. */
  136680. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136681. /**
  136682. * Set the value of an uniform to a number (float)
  136683. * @param uniform defines the webGL uniform location where to store the value
  136684. * @param value defines the float number to store
  136685. * @returns true if value was set
  136686. */
  136687. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136688. /**
  136689. * Set the value of an uniform to a vec2
  136690. * @param uniform defines the webGL uniform location where to store the value
  136691. * @param x defines the 1st component of the value
  136692. * @param y defines the 2nd component of the value
  136693. * @returns true if value was set
  136694. */
  136695. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136696. /**
  136697. * Set the value of an uniform to a vec3
  136698. * @param uniform defines the webGL uniform location where to store the value
  136699. * @param x defines the 1st component of the value
  136700. * @param y defines the 2nd component of the value
  136701. * @param z defines the 3rd component of the value
  136702. * @returns true if value was set
  136703. */
  136704. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136705. /**
  136706. * Set the value of an uniform to a boolean
  136707. * @param uniform defines the webGL uniform location where to store the value
  136708. * @param bool defines the boolean to store
  136709. * @returns true if value was set
  136710. */
  136711. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  136712. /**
  136713. * Set the value of an uniform to a vec4
  136714. * @param uniform defines the webGL uniform location where to store the value
  136715. * @param x defines the 1st component of the value
  136716. * @param y defines the 2nd component of the value
  136717. * @param z defines the 3rd component of the value
  136718. * @param w defines the 4th component of the value
  136719. * @returns true if value was set
  136720. */
  136721. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136722. /**
  136723. * Sets the current alpha mode
  136724. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  136725. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136726. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136727. */
  136728. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136729. /**
  136730. * Bind webGl buffers directly to the webGL context
  136731. * @param vertexBuffers defines the vertex buffer to bind
  136732. * @param indexBuffer defines the index buffer to bind
  136733. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  136734. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  136735. * @param effect defines the effect associated with the vertex buffer
  136736. */
  136737. bindBuffers(vertexBuffers: {
  136738. [key: string]: VertexBuffer;
  136739. }, indexBuffer: DataBuffer, effect: Effect): void;
  136740. /**
  136741. * Force the entire cache to be cleared
  136742. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  136743. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  136744. */
  136745. wipeCaches(bruteForce?: boolean): void;
  136746. /**
  136747. * Send a draw order
  136748. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  136749. * @param indexStart defines the starting index
  136750. * @param indexCount defines the number of index to draw
  136751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136752. */
  136753. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  136754. /**
  136755. * Draw a list of indexed primitives
  136756. * @param fillMode defines the primitive to use
  136757. * @param indexStart defines the starting index
  136758. * @param indexCount defines the number of index to draw
  136759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136760. */
  136761. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136762. /**
  136763. * Draw a list of unindexed primitives
  136764. * @param fillMode defines the primitive to use
  136765. * @param verticesStart defines the index of first vertex to draw
  136766. * @param verticesCount defines the count of vertices to draw
  136767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136768. */
  136769. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136770. /** @hidden */
  136771. _createTexture(): WebGLTexture;
  136772. /** @hidden */
  136773. _releaseTexture(texture: InternalTexture): void;
  136774. /**
  136775. * Usually called from Texture.ts.
  136776. * Passed information to create a WebGLTexture
  136777. * @param urlArg defines a value which contains one of the following:
  136778. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136779. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136780. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136781. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136782. * @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)
  136783. * @param scene needed for loading to the correct scene
  136784. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136785. * @param onLoad optional callback to be called upon successful completion
  136786. * @param onError optional callback to be called upon failure
  136787. * @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
  136788. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136789. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136790. * @param forcedExtension defines the extension to use to pick the right loader
  136791. * @param mimeType defines an optional mime type
  136792. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136793. */
  136794. 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;
  136795. /**
  136796. * Creates a new render target texture
  136797. * @param size defines the size of the texture
  136798. * @param options defines the options used to create the texture
  136799. * @returns a new render target texture stored in an InternalTexture
  136800. */
  136801. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  136802. /**
  136803. * Update the sampling mode of a given texture
  136804. * @param samplingMode defines the required sampling mode
  136805. * @param texture defines the texture to update
  136806. */
  136807. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136808. /**
  136809. * Binds the frame buffer to the specified texture.
  136810. * @param texture The texture to render to or null for the default canvas
  136811. * @param faceIndex The face of the texture to render to in case of cube texture
  136812. * @param requiredWidth The width of the target to render to
  136813. * @param requiredHeight The height of the target to render to
  136814. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136815. * @param lodLevel defines le lod level to bind to the frame buffer
  136816. */
  136817. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136818. /**
  136819. * Unbind the current render target texture from the webGL context
  136820. * @param texture defines the render target texture to unbind
  136821. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136822. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136823. */
  136824. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136825. /**
  136826. * Creates a dynamic vertex buffer
  136827. * @param vertices the data for the dynamic vertex buffer
  136828. * @returns the new WebGL dynamic buffer
  136829. */
  136830. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136831. /**
  136832. * Update the content of a dynamic texture
  136833. * @param texture defines the texture to update
  136834. * @param canvas defines the canvas containing the source
  136835. * @param invertY defines if data must be stored with Y axis inverted
  136836. * @param premulAlpha defines if alpha is stored as premultiplied
  136837. * @param format defines the format of the data
  136838. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136839. */
  136840. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136841. /**
  136842. * Gets a boolean indicating if all created effects are ready
  136843. * @returns true if all effects are ready
  136844. */
  136845. areAllEffectsReady(): boolean;
  136846. /**
  136847. * @hidden
  136848. * Get the current error code of the webGL context
  136849. * @returns the error code
  136850. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136851. */
  136852. getError(): number;
  136853. /** @hidden */
  136854. _getUnpackAlignement(): number;
  136855. /** @hidden */
  136856. _unpackFlipY(value: boolean): void;
  136857. /**
  136858. * Update a dynamic index buffer
  136859. * @param indexBuffer defines the target index buffer
  136860. * @param indices defines the data to update
  136861. * @param offset defines the offset in the target index buffer where update should start
  136862. */
  136863. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136864. /**
  136865. * Updates a dynamic vertex buffer.
  136866. * @param vertexBuffer the vertex buffer to update
  136867. * @param vertices the data used to update the vertex buffer
  136868. * @param byteOffset the byte offset of the data (optional)
  136869. * @param byteLength the byte length of the data (optional)
  136870. */
  136871. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136872. /** @hidden */
  136873. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136874. /** @hidden */
  136875. _bindTexture(channel: number, texture: InternalTexture): void;
  136876. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136877. /**
  136878. * 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
  136879. */
  136880. releaseEffects(): void;
  136881. displayLoadingUI(): void;
  136882. hideLoadingUI(): void;
  136883. /** @hidden */
  136884. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136885. /** @hidden */
  136886. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136887. /** @hidden */
  136888. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136889. /** @hidden */
  136890. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136891. }
  136892. }
  136893. declare module BABYLON {
  136894. /**
  136895. * @hidden
  136896. **/
  136897. export class _TimeToken {
  136898. _startTimeQuery: Nullable<WebGLQuery>;
  136899. _endTimeQuery: Nullable<WebGLQuery>;
  136900. _timeElapsedQuery: Nullable<WebGLQuery>;
  136901. _timeElapsedQueryEnded: boolean;
  136902. }
  136903. }
  136904. declare module BABYLON {
  136905. /** @hidden */
  136906. export class _OcclusionDataStorage {
  136907. /** @hidden */
  136908. occlusionInternalRetryCounter: number;
  136909. /** @hidden */
  136910. isOcclusionQueryInProgress: boolean;
  136911. /** @hidden */
  136912. isOccluded: boolean;
  136913. /** @hidden */
  136914. occlusionRetryCount: number;
  136915. /** @hidden */
  136916. occlusionType: number;
  136917. /** @hidden */
  136918. occlusionQueryAlgorithmType: number;
  136919. }
  136920. interface Engine {
  136921. /**
  136922. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136923. * @return the new query
  136924. */
  136925. createQuery(): WebGLQuery;
  136926. /**
  136927. * Delete and release a webGL query
  136928. * @param query defines the query to delete
  136929. * @return the current engine
  136930. */
  136931. deleteQuery(query: WebGLQuery): Engine;
  136932. /**
  136933. * Check if a given query has resolved and got its value
  136934. * @param query defines the query to check
  136935. * @returns true if the query got its value
  136936. */
  136937. isQueryResultAvailable(query: WebGLQuery): boolean;
  136938. /**
  136939. * Gets the value of a given query
  136940. * @param query defines the query to check
  136941. * @returns the value of the query
  136942. */
  136943. getQueryResult(query: WebGLQuery): number;
  136944. /**
  136945. * Initiates an occlusion query
  136946. * @param algorithmType defines the algorithm to use
  136947. * @param query defines the query to use
  136948. * @returns the current engine
  136949. * @see https://doc.babylonjs.com/features/occlusionquery
  136950. */
  136951. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136952. /**
  136953. * Ends an occlusion query
  136954. * @see https://doc.babylonjs.com/features/occlusionquery
  136955. * @param algorithmType defines the algorithm to use
  136956. * @returns the current engine
  136957. */
  136958. endOcclusionQuery(algorithmType: number): Engine;
  136959. /**
  136960. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136961. * Please note that only one query can be issued at a time
  136962. * @returns a time token used to track the time span
  136963. */
  136964. startTimeQuery(): Nullable<_TimeToken>;
  136965. /**
  136966. * Ends a time query
  136967. * @param token defines the token used to measure the time span
  136968. * @returns the time spent (in ns)
  136969. */
  136970. endTimeQuery(token: _TimeToken): int;
  136971. /** @hidden */
  136972. _currentNonTimestampToken: Nullable<_TimeToken>;
  136973. /** @hidden */
  136974. _createTimeQuery(): WebGLQuery;
  136975. /** @hidden */
  136976. _deleteTimeQuery(query: WebGLQuery): void;
  136977. /** @hidden */
  136978. _getGlAlgorithmType(algorithmType: number): number;
  136979. /** @hidden */
  136980. _getTimeQueryResult(query: WebGLQuery): any;
  136981. /** @hidden */
  136982. _getTimeQueryAvailability(query: WebGLQuery): any;
  136983. }
  136984. interface AbstractMesh {
  136985. /**
  136986. * Backing filed
  136987. * @hidden
  136988. */
  136989. __occlusionDataStorage: _OcclusionDataStorage;
  136990. /**
  136991. * Access property
  136992. * @hidden
  136993. */
  136994. _occlusionDataStorage: _OcclusionDataStorage;
  136995. /**
  136996. * 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.
  136997. * The default value is -1 which means don't break the query and wait till the result
  136998. * @see https://doc.babylonjs.com/features/occlusionquery
  136999. */
  137000. occlusionRetryCount: number;
  137001. /**
  137002. * 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:
  137003. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  137004. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  137005. * * 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.
  137006. * @see https://doc.babylonjs.com/features/occlusionquery
  137007. */
  137008. occlusionType: number;
  137009. /**
  137010. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  137011. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  137012. * * 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.
  137013. * @see https://doc.babylonjs.com/features/occlusionquery
  137014. */
  137015. occlusionQueryAlgorithmType: number;
  137016. /**
  137017. * 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
  137018. * @see https://doc.babylonjs.com/features/occlusionquery
  137019. */
  137020. isOccluded: boolean;
  137021. /**
  137022. * Flag to check the progress status of the query
  137023. * @see https://doc.babylonjs.com/features/occlusionquery
  137024. */
  137025. isOcclusionQueryInProgress: boolean;
  137026. }
  137027. }
  137028. declare module BABYLON {
  137029. /** @hidden */
  137030. export var _forceTransformFeedbackToBundle: boolean;
  137031. interface Engine {
  137032. /**
  137033. * Creates a webGL transform feedback object
  137034. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  137035. * @returns the webGL transform feedback object
  137036. */
  137037. createTransformFeedback(): WebGLTransformFeedback;
  137038. /**
  137039. * Delete a webGL transform feedback object
  137040. * @param value defines the webGL transform feedback object to delete
  137041. */
  137042. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  137043. /**
  137044. * Bind a webGL transform feedback object to the webgl context
  137045. * @param value defines the webGL transform feedback object to bind
  137046. */
  137047. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  137048. /**
  137049. * Begins a transform feedback operation
  137050. * @param usePoints defines if points or triangles must be used
  137051. */
  137052. beginTransformFeedback(usePoints: boolean): void;
  137053. /**
  137054. * Ends a transform feedback operation
  137055. */
  137056. endTransformFeedback(): void;
  137057. /**
  137058. * Specify the varyings to use with transform feedback
  137059. * @param program defines the associated webGL program
  137060. * @param value defines the list of strings representing the varying names
  137061. */
  137062. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  137063. /**
  137064. * Bind a webGL buffer for a transform feedback operation
  137065. * @param value defines the webGL buffer to bind
  137066. */
  137067. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  137068. }
  137069. }
  137070. declare module BABYLON {
  137071. /**
  137072. * Class used to define an additional view for the engine
  137073. * @see https://doc.babylonjs.com/how_to/multi_canvases
  137074. */
  137075. export class EngineView {
  137076. /** Defines the canvas where to render the view */
  137077. target: HTMLCanvasElement;
  137078. /** Defines an optional camera used to render the view (will use active camera else) */
  137079. camera?: Camera;
  137080. }
  137081. interface Engine {
  137082. /**
  137083. * Gets or sets the HTML element to use for attaching events
  137084. */
  137085. inputElement: Nullable<HTMLElement>;
  137086. /**
  137087. * Gets the current engine view
  137088. * @see https://doc.babylonjs.com/how_to/multi_canvases
  137089. */
  137090. activeView: Nullable<EngineView>;
  137091. /** Gets or sets the list of views */
  137092. views: EngineView[];
  137093. /**
  137094. * Register a new child canvas
  137095. * @param canvas defines the canvas to register
  137096. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  137097. * @returns the associated view
  137098. */
  137099. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  137100. /**
  137101. * Remove a registered child canvas
  137102. * @param canvas defines the canvas to remove
  137103. * @returns the current engine
  137104. */
  137105. unRegisterView(canvas: HTMLCanvasElement): Engine;
  137106. }
  137107. }
  137108. declare module BABYLON {
  137109. interface Engine {
  137110. /** @hidden */
  137111. _excludedCompressedTextures: string[];
  137112. /** @hidden */
  137113. _textureFormatInUse: string;
  137114. /**
  137115. * Gets the list of texture formats supported
  137116. */
  137117. readonly texturesSupported: Array<string>;
  137118. /**
  137119. * Gets the texture format in use
  137120. */
  137121. readonly textureFormatInUse: Nullable<string>;
  137122. /**
  137123. * Set the compressed texture extensions or file names to skip.
  137124. *
  137125. * @param skippedFiles defines the list of those texture files you want to skip
  137126. * Example: [".dds", ".env", "myfile.png"]
  137127. */
  137128. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  137129. /**
  137130. * Set the compressed texture format to use, based on the formats you have, and the formats
  137131. * supported by the hardware / browser.
  137132. *
  137133. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  137134. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  137135. * to API arguments needed to compressed textures. This puts the burden on the container
  137136. * generator to house the arcane code for determining these for current & future formats.
  137137. *
  137138. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137139. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137140. *
  137141. * Note: The result of this call is not taken into account when a texture is base64.
  137142. *
  137143. * @param formatsAvailable defines the list of those format families you have created
  137144. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  137145. *
  137146. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  137147. * @returns The extension selected.
  137148. */
  137149. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  137150. }
  137151. }
  137152. declare module BABYLON {
  137153. /** @hidden */
  137154. export var rgbdEncodePixelShader: {
  137155. name: string;
  137156. shader: string;
  137157. };
  137158. }
  137159. declare module BABYLON {
  137160. /**
  137161. * Raw texture data and descriptor sufficient for WebGL texture upload
  137162. */
  137163. export interface EnvironmentTextureInfo {
  137164. /**
  137165. * Version of the environment map
  137166. */
  137167. version: number;
  137168. /**
  137169. * Width of image
  137170. */
  137171. width: number;
  137172. /**
  137173. * Irradiance information stored in the file.
  137174. */
  137175. irradiance: any;
  137176. /**
  137177. * Specular information stored in the file.
  137178. */
  137179. specular: any;
  137180. }
  137181. /**
  137182. * Defines One Image in the file. It requires only the position in the file
  137183. * as well as the length.
  137184. */
  137185. interface BufferImageData {
  137186. /**
  137187. * Length of the image data.
  137188. */
  137189. length: number;
  137190. /**
  137191. * Position of the data from the null terminator delimiting the end of the JSON.
  137192. */
  137193. position: number;
  137194. }
  137195. /**
  137196. * Defines the specular data enclosed in the file.
  137197. * This corresponds to the version 1 of the data.
  137198. */
  137199. export interface EnvironmentTextureSpecularInfoV1 {
  137200. /**
  137201. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  137202. */
  137203. specularDataPosition?: number;
  137204. /**
  137205. * This contains all the images data needed to reconstruct the cubemap.
  137206. */
  137207. mipmaps: Array<BufferImageData>;
  137208. /**
  137209. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  137210. */
  137211. lodGenerationScale: number;
  137212. }
  137213. /**
  137214. * Sets of helpers addressing the serialization and deserialization of environment texture
  137215. * stored in a BabylonJS env file.
  137216. * Those files are usually stored as .env files.
  137217. */
  137218. export class EnvironmentTextureTools {
  137219. /**
  137220. * Magic number identifying the env file.
  137221. */
  137222. private static _MagicBytes;
  137223. /**
  137224. * Gets the environment info from an env file.
  137225. * @param data The array buffer containing the .env bytes.
  137226. * @returns the environment file info (the json header) if successfully parsed.
  137227. */
  137228. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  137229. /**
  137230. * Creates an environment texture from a loaded cube texture.
  137231. * @param texture defines the cube texture to convert in env file
  137232. * @return a promise containing the environment data if succesfull.
  137233. */
  137234. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  137235. /**
  137236. * Creates a JSON representation of the spherical data.
  137237. * @param texture defines the texture containing the polynomials
  137238. * @return the JSON representation of the spherical info
  137239. */
  137240. private static _CreateEnvTextureIrradiance;
  137241. /**
  137242. * Creates the ArrayBufferViews used for initializing environment texture image data.
  137243. * @param data the image data
  137244. * @param info parameters that determine what views will be created for accessing the underlying buffer
  137245. * @return the views described by info providing access to the underlying buffer
  137246. */
  137247. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  137248. /**
  137249. * Uploads the texture info contained in the env file to the GPU.
  137250. * @param texture defines the internal texture to upload to
  137251. * @param data defines the data to load
  137252. * @param info defines the texture info retrieved through the GetEnvInfo method
  137253. * @returns a promise
  137254. */
  137255. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  137256. private static _OnImageReadyAsync;
  137257. /**
  137258. * Uploads the levels of image data to the GPU.
  137259. * @param texture defines the internal texture to upload to
  137260. * @param imageData defines the array buffer views of image data [mipmap][face]
  137261. * @returns a promise
  137262. */
  137263. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  137264. /**
  137265. * Uploads spherical polynomials information to the texture.
  137266. * @param texture defines the texture we are trying to upload the information to
  137267. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  137268. */
  137269. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  137270. /** @hidden */
  137271. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137272. }
  137273. }
  137274. declare module BABYLON {
  137275. /**
  137276. * Class used to inline functions in shader code
  137277. */
  137278. export class ShaderCodeInliner {
  137279. private static readonly _RegexpFindFunctionNameAndType;
  137280. private _sourceCode;
  137281. private _functionDescr;
  137282. private _numMaxIterations;
  137283. /** Gets or sets the token used to mark the functions to inline */
  137284. inlineToken: string;
  137285. /** Gets or sets the debug mode */
  137286. debug: boolean;
  137287. /** Gets the code after the inlining process */
  137288. get code(): string;
  137289. /**
  137290. * Initializes the inliner
  137291. * @param sourceCode shader code source to inline
  137292. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  137293. */
  137294. constructor(sourceCode: string, numMaxIterations?: number);
  137295. /**
  137296. * Start the processing of the shader code
  137297. */
  137298. processCode(): void;
  137299. private _collectFunctions;
  137300. private _processInlining;
  137301. private _extractBetweenMarkers;
  137302. private _skipWhitespaces;
  137303. private _removeComments;
  137304. private _replaceFunctionCallsByCode;
  137305. private _findBackward;
  137306. private _escapeRegExp;
  137307. private _replaceNames;
  137308. }
  137309. }
  137310. declare module BABYLON {
  137311. /**
  137312. * Container for accessors for natively-stored mesh data buffers.
  137313. */
  137314. class NativeDataBuffer extends DataBuffer {
  137315. /**
  137316. * Accessor value used to identify/retrieve a natively-stored index buffer.
  137317. */
  137318. nativeIndexBuffer?: any;
  137319. /**
  137320. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  137321. */
  137322. nativeVertexBuffer?: any;
  137323. }
  137324. /** @hidden */
  137325. class NativeTexture extends InternalTexture {
  137326. getInternalTexture(): InternalTexture;
  137327. getViewCount(): number;
  137328. }
  137329. /** @hidden */
  137330. export class NativeEngine extends Engine {
  137331. private readonly _native;
  137332. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  137333. private readonly INVALID_HANDLE;
  137334. private _boundBuffersVertexArray;
  137335. private _currentDepthTest;
  137336. getHardwareScalingLevel(): number;
  137337. constructor();
  137338. dispose(): void;
  137339. /**
  137340. * Can be used to override the current requestAnimationFrame requester.
  137341. * @hidden
  137342. */
  137343. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  137344. /**
  137345. * Override default engine behavior.
  137346. * @param color
  137347. * @param backBuffer
  137348. * @param depth
  137349. * @param stencil
  137350. */
  137351. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  137352. /**
  137353. * Gets host document
  137354. * @returns the host document object
  137355. */
  137356. getHostDocument(): Nullable<Document>;
  137357. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137358. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  137359. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  137360. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  137361. [key: string]: VertexBuffer;
  137362. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137363. bindBuffers(vertexBuffers: {
  137364. [key: string]: VertexBuffer;
  137365. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137366. recordVertexArrayObject(vertexBuffers: {
  137367. [key: string]: VertexBuffer;
  137368. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  137369. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137370. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137371. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137372. /**
  137373. * Draw a list of indexed primitives
  137374. * @param fillMode defines the primitive to use
  137375. * @param indexStart defines the starting index
  137376. * @param indexCount defines the number of index to draw
  137377. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137378. */
  137379. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  137380. /**
  137381. * Draw a list of unindexed primitives
  137382. * @param fillMode defines the primitive to use
  137383. * @param verticesStart defines the index of first vertex to draw
  137384. * @param verticesCount defines the count of vertices to draw
  137385. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137386. */
  137387. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  137388. createPipelineContext(): IPipelineContext;
  137389. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  137390. /** @hidden */
  137391. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  137392. /** @hidden */
  137393. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  137394. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137395. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137396. protected _setProgram(program: WebGLProgram): void;
  137397. _releaseEffect(effect: Effect): void;
  137398. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  137399. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  137400. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  137401. bindSamplers(effect: Effect): void;
  137402. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  137403. getRenderWidth(useScreen?: boolean): number;
  137404. getRenderHeight(useScreen?: boolean): number;
  137405. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  137406. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137407. /**
  137408. * Set the z offset to apply to current rendering
  137409. * @param value defines the offset to apply
  137410. */
  137411. setZOffset(value: number): void;
  137412. /**
  137413. * Gets the current value of the zOffset
  137414. * @returns the current zOffset state
  137415. */
  137416. getZOffset(): number;
  137417. /**
  137418. * Enable or disable depth buffering
  137419. * @param enable defines the state to set
  137420. */
  137421. setDepthBuffer(enable: boolean): void;
  137422. /**
  137423. * Gets a boolean indicating if depth writing is enabled
  137424. * @returns the current depth writing state
  137425. */
  137426. getDepthWrite(): boolean;
  137427. setDepthFunctionToGreater(): void;
  137428. setDepthFunctionToGreaterOrEqual(): void;
  137429. setDepthFunctionToLess(): void;
  137430. setDepthFunctionToLessOrEqual(): void;
  137431. /**
  137432. * Enable or disable depth writing
  137433. * @param enable defines the state to set
  137434. */
  137435. setDepthWrite(enable: boolean): void;
  137436. /**
  137437. * Enable or disable color writing
  137438. * @param enable defines the state to set
  137439. */
  137440. setColorWrite(enable: boolean): void;
  137441. /**
  137442. * Gets a boolean indicating if color writing is enabled
  137443. * @returns the current color writing state
  137444. */
  137445. getColorWrite(): boolean;
  137446. /**
  137447. * Sets alpha constants used by some alpha blending modes
  137448. * @param r defines the red component
  137449. * @param g defines the green component
  137450. * @param b defines the blue component
  137451. * @param a defines the alpha component
  137452. */
  137453. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  137454. /**
  137455. * Sets the current alpha mode
  137456. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  137457. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  137458. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137459. */
  137460. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  137461. /**
  137462. * Gets the current alpha mode
  137463. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137464. * @returns the current alpha mode
  137465. */
  137466. getAlphaMode(): number;
  137467. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  137468. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137469. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137470. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137471. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137472. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137473. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137474. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137475. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137476. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137477. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137478. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137479. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137480. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  137481. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137482. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137483. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  137484. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  137485. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  137486. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  137487. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  137488. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  137489. wipeCaches(bruteForce?: boolean): void;
  137490. _createTexture(): WebGLTexture;
  137491. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  137492. /**
  137493. * Update the content of a dynamic texture
  137494. * @param texture defines the texture to update
  137495. * @param canvas defines the canvas containing the source
  137496. * @param invertY defines if data must be stored with Y axis inverted
  137497. * @param premulAlpha defines if alpha is stored as premultiplied
  137498. * @param format defines the format of the data
  137499. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  137500. */
  137501. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  137502. /**
  137503. * Usually called from Texture.ts.
  137504. * Passed information to create a WebGLTexture
  137505. * @param url defines a value which contains one of the following:
  137506. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  137507. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  137508. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  137509. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  137510. * @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)
  137511. * @param scene needed for loading to the correct scene
  137512. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  137513. * @param onLoad optional callback to be called upon successful completion
  137514. * @param onError optional callback to be called upon failure
  137515. * @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
  137516. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  137517. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  137518. * @param forcedExtension defines the extension to use to pick the right loader
  137519. * @param mimeType defines an optional mime type
  137520. * @param loaderOptions options to be passed to the loader
  137521. * @returns a InternalTexture for assignment back into BABYLON.Texture
  137522. */
  137523. 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;
  137524. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  137525. _releaseFramebufferObjects(texture: InternalTexture): void;
  137526. /**
  137527. * Creates a cube texture
  137528. * @param rootUrl defines the url where the files to load is located
  137529. * @param scene defines the current scene
  137530. * @param files defines the list of files to load (1 per face)
  137531. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  137532. * @param onLoad defines an optional callback raised when the texture is loaded
  137533. * @param onError defines an optional callback raised if there is an issue to load the texture
  137534. * @param format defines the format of the data
  137535. * @param forcedExtension defines the extension to use to pick the right loader
  137536. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  137537. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137538. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137539. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  137540. * @returns the cube texture as an InternalTexture
  137541. */
  137542. 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;
  137543. createRenderTargetTexture(size: number | {
  137544. width: number;
  137545. height: number;
  137546. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  137547. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  137548. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  137549. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  137550. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  137551. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  137552. /**
  137553. * Updates a dynamic vertex buffer.
  137554. * @param vertexBuffer the vertex buffer to update
  137555. * @param data the data used to update the vertex buffer
  137556. * @param byteOffset the byte offset of the data (optional)
  137557. * @param byteLength the byte length of the data (optional)
  137558. */
  137559. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  137560. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  137561. private _updateAnisotropicLevel;
  137562. private _getAddressMode;
  137563. /** @hidden */
  137564. _bindTexture(channel: number, texture: InternalTexture): void;
  137565. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  137566. releaseEffects(): void;
  137567. /** @hidden */
  137568. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137569. /** @hidden */
  137570. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137571. /** @hidden */
  137572. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137573. /** @hidden */
  137574. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  137575. private _getNativeSamplingMode;
  137576. private _getNativeTextureFormat;
  137577. private _getNativeAlphaMode;
  137578. private _getNativeAttribType;
  137579. }
  137580. }
  137581. declare module BABYLON {
  137582. /**
  137583. * Gather the list of clipboard event types as constants.
  137584. */
  137585. export class ClipboardEventTypes {
  137586. /**
  137587. * The clipboard event is fired when a copy command is active (pressed).
  137588. */
  137589. static readonly COPY: number;
  137590. /**
  137591. * The clipboard event is fired when a cut command is active (pressed).
  137592. */
  137593. static readonly CUT: number;
  137594. /**
  137595. * The clipboard event is fired when a paste command is active (pressed).
  137596. */
  137597. static readonly PASTE: number;
  137598. }
  137599. /**
  137600. * This class is used to store clipboard related info for the onClipboardObservable event.
  137601. */
  137602. export class ClipboardInfo {
  137603. /**
  137604. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137605. */
  137606. type: number;
  137607. /**
  137608. * Defines the related dom event
  137609. */
  137610. event: ClipboardEvent;
  137611. /**
  137612. *Creates an instance of ClipboardInfo.
  137613. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  137614. * @param event Defines the related dom event
  137615. */
  137616. constructor(
  137617. /**
  137618. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137619. */
  137620. type: number,
  137621. /**
  137622. * Defines the related dom event
  137623. */
  137624. event: ClipboardEvent);
  137625. /**
  137626. * Get the clipboard event's type from the keycode.
  137627. * @param keyCode Defines the keyCode for the current keyboard event.
  137628. * @return {number}
  137629. */
  137630. static GetTypeFromCharacter(keyCode: number): number;
  137631. }
  137632. }
  137633. declare module BABYLON {
  137634. /**
  137635. * Google Daydream controller
  137636. */
  137637. export class DaydreamController extends WebVRController {
  137638. /**
  137639. * Base Url for the controller model.
  137640. */
  137641. static MODEL_BASE_URL: string;
  137642. /**
  137643. * File name for the controller model.
  137644. */
  137645. static MODEL_FILENAME: string;
  137646. /**
  137647. * Gamepad Id prefix used to identify Daydream Controller.
  137648. */
  137649. static readonly GAMEPAD_ID_PREFIX: string;
  137650. /**
  137651. * Creates a new DaydreamController from a gamepad
  137652. * @param vrGamepad the gamepad that the controller should be created from
  137653. */
  137654. constructor(vrGamepad: any);
  137655. /**
  137656. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137657. * @param scene scene in which to add meshes
  137658. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137659. */
  137660. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137661. /**
  137662. * Called once for each button that changed state since the last frame
  137663. * @param buttonIdx Which button index changed
  137664. * @param state New state of the button
  137665. * @param changes Which properties on the state changed since last frame
  137666. */
  137667. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137668. }
  137669. }
  137670. declare module BABYLON {
  137671. /**
  137672. * Gear VR Controller
  137673. */
  137674. export class GearVRController extends WebVRController {
  137675. /**
  137676. * Base Url for the controller model.
  137677. */
  137678. static MODEL_BASE_URL: string;
  137679. /**
  137680. * File name for the controller model.
  137681. */
  137682. static MODEL_FILENAME: string;
  137683. /**
  137684. * Gamepad Id prefix used to identify this controller.
  137685. */
  137686. static readonly GAMEPAD_ID_PREFIX: string;
  137687. private readonly _buttonIndexToObservableNameMap;
  137688. /**
  137689. * Creates a new GearVRController from a gamepad
  137690. * @param vrGamepad the gamepad that the controller should be created from
  137691. */
  137692. constructor(vrGamepad: any);
  137693. /**
  137694. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137695. * @param scene scene in which to add meshes
  137696. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137697. */
  137698. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137699. /**
  137700. * Called once for each button that changed state since the last frame
  137701. * @param buttonIdx Which button index changed
  137702. * @param state New state of the button
  137703. * @param changes Which properties on the state changed since last frame
  137704. */
  137705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137706. }
  137707. }
  137708. declare module BABYLON {
  137709. /**
  137710. * Generic Controller
  137711. */
  137712. export class GenericController extends WebVRController {
  137713. /**
  137714. * Base Url for the controller model.
  137715. */
  137716. static readonly MODEL_BASE_URL: string;
  137717. /**
  137718. * File name for the controller model.
  137719. */
  137720. static readonly MODEL_FILENAME: string;
  137721. /**
  137722. * Creates a new GenericController from a gamepad
  137723. * @param vrGamepad the gamepad that the controller should be created from
  137724. */
  137725. constructor(vrGamepad: any);
  137726. /**
  137727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137728. * @param scene scene in which to add meshes
  137729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137730. */
  137731. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137732. /**
  137733. * Called once for each button that changed state since the last frame
  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. * Oculus Touch Controller
  137744. */
  137745. export class OculusTouchController extends WebVRController {
  137746. /**
  137747. * Base Url for the controller model.
  137748. */
  137749. static MODEL_BASE_URL: string;
  137750. /**
  137751. * File name for the left controller model.
  137752. */
  137753. static MODEL_LEFT_FILENAME: string;
  137754. /**
  137755. * File name for the right controller model.
  137756. */
  137757. static MODEL_RIGHT_FILENAME: string;
  137758. /**
  137759. * Base Url for the Quest controller model.
  137760. */
  137761. static QUEST_MODEL_BASE_URL: string;
  137762. /**
  137763. * @hidden
  137764. * If the controllers are running on a device that needs the updated Quest controller models
  137765. */
  137766. static _IsQuest: boolean;
  137767. /**
  137768. * Fired when the secondary trigger on this controller is modified
  137769. */
  137770. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  137771. /**
  137772. * Fired when the thumb rest on this controller is modified
  137773. */
  137774. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  137775. /**
  137776. * Creates a new OculusTouchController from a gamepad
  137777. * @param vrGamepad the gamepad that the controller should be created from
  137778. */
  137779. constructor(vrGamepad: any);
  137780. /**
  137781. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137782. * @param scene scene in which to add meshes
  137783. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137784. */
  137785. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137786. /**
  137787. * Fired when the A button on this controller is modified
  137788. */
  137789. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137790. /**
  137791. * Fired when the B button on this controller is modified
  137792. */
  137793. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137794. /**
  137795. * Fired when the X button on this controller is modified
  137796. */
  137797. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137798. /**
  137799. * Fired when the Y button on this controller is modified
  137800. */
  137801. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137802. /**
  137803. * Called once for each button that changed state since the last frame
  137804. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  137805. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  137806. * 2) secondary trigger (same)
  137807. * 3) A (right) X (left), touch, pressed = value
  137808. * 4) B / Y
  137809. * 5) thumb rest
  137810. * @param buttonIdx Which button index changed
  137811. * @param state New state of the button
  137812. * @param changes Which properties on the state changed since last frame
  137813. */
  137814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137815. }
  137816. }
  137817. declare module BABYLON {
  137818. /**
  137819. * Vive Controller
  137820. */
  137821. export class ViveController extends WebVRController {
  137822. /**
  137823. * Base Url for the controller model.
  137824. */
  137825. static MODEL_BASE_URL: string;
  137826. /**
  137827. * File name for the controller model.
  137828. */
  137829. static MODEL_FILENAME: string;
  137830. /**
  137831. * Creates a new ViveController from a gamepad
  137832. * @param vrGamepad the gamepad that the controller should be created from
  137833. */
  137834. constructor(vrGamepad: any);
  137835. /**
  137836. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137837. * @param scene scene in which to add meshes
  137838. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137839. */
  137840. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137841. /**
  137842. * Fired when the left button on this controller is modified
  137843. */
  137844. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137845. /**
  137846. * Fired when the right button on this controller is modified
  137847. */
  137848. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137849. /**
  137850. * Fired when the menu button on this controller is modified
  137851. */
  137852. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137853. /**
  137854. * Called once for each button that changed state since the last frame
  137855. * Vive mapping:
  137856. * 0: touchpad
  137857. * 1: trigger
  137858. * 2: left AND right buttons
  137859. * 3: menu button
  137860. * @param buttonIdx Which button index changed
  137861. * @param state New state of the button
  137862. * @param changes Which properties on the state changed since last frame
  137863. */
  137864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137865. }
  137866. }
  137867. declare module BABYLON {
  137868. /**
  137869. * Defines the WindowsMotionController object that the state of the windows motion controller
  137870. */
  137871. export class WindowsMotionController extends WebVRController {
  137872. /**
  137873. * The base url used to load the left and right controller models
  137874. */
  137875. static MODEL_BASE_URL: string;
  137876. /**
  137877. * The name of the left controller model file
  137878. */
  137879. static MODEL_LEFT_FILENAME: string;
  137880. /**
  137881. * The name of the right controller model file
  137882. */
  137883. static MODEL_RIGHT_FILENAME: string;
  137884. /**
  137885. * The controller name prefix for this controller type
  137886. */
  137887. static readonly GAMEPAD_ID_PREFIX: string;
  137888. /**
  137889. * The controller id pattern for this controller type
  137890. */
  137891. private static readonly GAMEPAD_ID_PATTERN;
  137892. private _loadedMeshInfo;
  137893. protected readonly _mapping: {
  137894. buttons: string[];
  137895. buttonMeshNames: {
  137896. trigger: string;
  137897. menu: string;
  137898. grip: string;
  137899. thumbstick: string;
  137900. trackpad: string;
  137901. };
  137902. buttonObservableNames: {
  137903. trigger: string;
  137904. menu: string;
  137905. grip: string;
  137906. thumbstick: string;
  137907. trackpad: string;
  137908. };
  137909. axisMeshNames: string[];
  137910. pointingPoseMeshName: string;
  137911. };
  137912. /**
  137913. * Fired when the trackpad on this controller is clicked
  137914. */
  137915. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137916. /**
  137917. * Fired when the trackpad on this controller is modified
  137918. */
  137919. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137920. /**
  137921. * The current x and y values of this controller's trackpad
  137922. */
  137923. trackpad: StickValues;
  137924. /**
  137925. * Creates a new WindowsMotionController from a gamepad
  137926. * @param vrGamepad the gamepad that the controller should be created from
  137927. */
  137928. constructor(vrGamepad: any);
  137929. /**
  137930. * Fired when the trigger on this controller is modified
  137931. */
  137932. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137933. /**
  137934. * Fired when the menu button on this controller is modified
  137935. */
  137936. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137937. /**
  137938. * Fired when the grip button on this controller is modified
  137939. */
  137940. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137941. /**
  137942. * Fired when the thumbstick button on this controller is modified
  137943. */
  137944. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137945. /**
  137946. * Fired when the touchpad button on this controller is modified
  137947. */
  137948. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137949. /**
  137950. * Fired when the touchpad values on this controller are modified
  137951. */
  137952. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137953. protected _updateTrackpad(): void;
  137954. /**
  137955. * Called once per frame by the engine.
  137956. */
  137957. update(): void;
  137958. /**
  137959. * Called once for each button that changed state since the last frame
  137960. * @param buttonIdx Which button index changed
  137961. * @param state New state of the button
  137962. * @param changes Which properties on the state changed since last frame
  137963. */
  137964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137965. /**
  137966. * Moves the buttons on the controller mesh based on their current state
  137967. * @param buttonName the name of the button to move
  137968. * @param buttonValue the value of the button which determines the buttons new position
  137969. */
  137970. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137971. /**
  137972. * Moves the axis on the controller mesh based on its current state
  137973. * @param axis the index of the axis
  137974. * @param axisValue the value of the axis which determines the meshes new position
  137975. * @hidden
  137976. */
  137977. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137978. /**
  137979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137980. * @param scene scene in which to add meshes
  137981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137982. */
  137983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137984. /**
  137985. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137986. * can be transformed by button presses and axes values, based on this._mapping.
  137987. *
  137988. * @param scene scene in which the meshes exist
  137989. * @param meshes list of meshes that make up the controller model to process
  137990. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137991. */
  137992. private processModel;
  137993. private createMeshInfo;
  137994. /**
  137995. * Gets the ray of the controller in the direction the controller is pointing
  137996. * @param length the length the resulting ray should be
  137997. * @returns a ray in the direction the controller is pointing
  137998. */
  137999. getForwardRay(length?: number): Ray;
  138000. /**
  138001. * Disposes of the controller
  138002. */
  138003. dispose(): void;
  138004. }
  138005. /**
  138006. * This class represents a new windows motion controller in XR.
  138007. */
  138008. export class XRWindowsMotionController extends WindowsMotionController {
  138009. /**
  138010. * Changing the original WIndowsMotionController mapping to fir the new mapping
  138011. */
  138012. protected readonly _mapping: {
  138013. buttons: string[];
  138014. buttonMeshNames: {
  138015. trigger: string;
  138016. menu: string;
  138017. grip: string;
  138018. thumbstick: string;
  138019. trackpad: string;
  138020. };
  138021. buttonObservableNames: {
  138022. trigger: string;
  138023. menu: string;
  138024. grip: string;
  138025. thumbstick: string;
  138026. trackpad: string;
  138027. };
  138028. axisMeshNames: string[];
  138029. pointingPoseMeshName: string;
  138030. };
  138031. /**
  138032. * Construct a new XR-Based windows motion controller
  138033. *
  138034. * @param gamepadInfo the gamepad object from the browser
  138035. */
  138036. constructor(gamepadInfo: any);
  138037. /**
  138038. * holds the thumbstick values (X,Y)
  138039. */
  138040. thumbstickValues: StickValues;
  138041. /**
  138042. * Fired when the thumbstick on this controller is clicked
  138043. */
  138044. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  138045. /**
  138046. * Fired when the thumbstick on this controller is modified
  138047. */
  138048. onThumbstickValuesChangedObservable: Observable<StickValues>;
  138049. /**
  138050. * Fired when the touchpad button on this controller is modified
  138051. */
  138052. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  138053. /**
  138054. * Fired when the touchpad values on this controller are modified
  138055. */
  138056. onTrackpadValuesChangedObservable: Observable<StickValues>;
  138057. /**
  138058. * Fired when the thumbstick button on this controller is modified
  138059. * here to prevent breaking changes
  138060. */
  138061. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138062. /**
  138063. * updating the thumbstick(!) and not the trackpad.
  138064. * This is named this way due to the difference between WebVR and XR and to avoid
  138065. * changing the parent class.
  138066. */
  138067. protected _updateTrackpad(): void;
  138068. /**
  138069. * Disposes the class with joy
  138070. */
  138071. dispose(): void;
  138072. }
  138073. }
  138074. declare module BABYLON {
  138075. /**
  138076. * Class containing static functions to help procedurally build meshes
  138077. */
  138078. export class PolyhedronBuilder {
  138079. /**
  138080. * Creates a polyhedron mesh
  138081. * * 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
  138082. * * The parameter `size` (positive float, default 1) sets the polygon size
  138083. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  138084. * * 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`
  138085. * * 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
  138086. * * 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)`)
  138087. * * 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
  138088. * * 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
  138089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138092. * @param name defines the name of the mesh
  138093. * @param options defines the options used to create the mesh
  138094. * @param scene defines the hosting scene
  138095. * @returns the polyhedron mesh
  138096. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  138097. */
  138098. static CreatePolyhedron(name: string, options: {
  138099. type?: number;
  138100. size?: number;
  138101. sizeX?: number;
  138102. sizeY?: number;
  138103. sizeZ?: number;
  138104. custom?: any;
  138105. faceUV?: Vector4[];
  138106. faceColors?: Color4[];
  138107. flat?: boolean;
  138108. updatable?: boolean;
  138109. sideOrientation?: number;
  138110. frontUVs?: Vector4;
  138111. backUVs?: Vector4;
  138112. }, scene?: Nullable<Scene>): Mesh;
  138113. }
  138114. }
  138115. declare module BABYLON {
  138116. /**
  138117. * Gizmo that enables scaling a mesh along 3 axis
  138118. */
  138119. export class ScaleGizmo extends Gizmo {
  138120. /**
  138121. * Internal gizmo used for interactions on the x axis
  138122. */
  138123. xGizmo: AxisScaleGizmo;
  138124. /**
  138125. * Internal gizmo used for interactions on the y axis
  138126. */
  138127. yGizmo: AxisScaleGizmo;
  138128. /**
  138129. * Internal gizmo used for interactions on the z axis
  138130. */
  138131. zGizmo: AxisScaleGizmo;
  138132. /**
  138133. * Internal gizmo used to scale all axis equally
  138134. */
  138135. uniformScaleGizmo: AxisScaleGizmo;
  138136. private _meshAttached;
  138137. private _nodeAttached;
  138138. private _snapDistance;
  138139. private _uniformScalingMesh;
  138140. private _octahedron;
  138141. private _sensitivity;
  138142. /** Fires an event when any of it's sub gizmos are dragged */
  138143. onDragStartObservable: Observable<unknown>;
  138144. /** Fires an event when any of it's sub gizmos are released from dragging */
  138145. onDragEndObservable: Observable<unknown>;
  138146. get attachedMesh(): Nullable<AbstractMesh>;
  138147. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138148. get attachedNode(): Nullable<Node>;
  138149. set attachedNode(node: Nullable<Node>);
  138150. /**
  138151. * True when the mouse pointer is hovering a gizmo mesh
  138152. */
  138153. get isHovered(): boolean;
  138154. /**
  138155. * Creates a ScaleGizmo
  138156. * @param gizmoLayer The utility layer the gizmo will be added to
  138157. * @param thickness display gizmo axis thickness
  138158. */
  138159. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  138160. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138161. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138162. /**
  138163. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138164. */
  138165. set snapDistance(value: number);
  138166. get snapDistance(): number;
  138167. /**
  138168. * Ratio for the scale of the gizmo (Default: 1)
  138169. */
  138170. set scaleRatio(value: number);
  138171. get scaleRatio(): number;
  138172. /**
  138173. * Sensitivity factor for dragging (Default: 1)
  138174. */
  138175. set sensitivity(value: number);
  138176. get sensitivity(): number;
  138177. /**
  138178. * Disposes of the gizmo
  138179. */
  138180. dispose(): void;
  138181. }
  138182. }
  138183. declare module BABYLON {
  138184. /**
  138185. * Single axis scale gizmo
  138186. */
  138187. export class AxisScaleGizmo extends Gizmo {
  138188. /**
  138189. * Drag behavior responsible for the gizmos dragging interactions
  138190. */
  138191. dragBehavior: PointerDragBehavior;
  138192. private _pointerObserver;
  138193. /**
  138194. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138195. */
  138196. snapDistance: number;
  138197. /**
  138198. * Event that fires each time the gizmo snaps to a new location.
  138199. * * snapDistance is the the change in distance
  138200. */
  138201. onSnapObservable: Observable<{
  138202. snapDistance: number;
  138203. }>;
  138204. /**
  138205. * If the scaling operation should be done on all axis (default: false)
  138206. */
  138207. uniformScaling: boolean;
  138208. /**
  138209. * Custom sensitivity value for the drag strength
  138210. */
  138211. sensitivity: number;
  138212. private _isEnabled;
  138213. private _parent;
  138214. private _arrow;
  138215. private _coloredMaterial;
  138216. private _hoverMaterial;
  138217. /**
  138218. * Creates an AxisScaleGizmo
  138219. * @param gizmoLayer The utility layer the gizmo will be added to
  138220. * @param dragAxis The axis which the gizmo will be able to scale on
  138221. * @param color The color of the gizmo
  138222. * @param thickness display gizmo axis thickness
  138223. */
  138224. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  138225. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138226. /**
  138227. * If the gizmo is enabled
  138228. */
  138229. set isEnabled(value: boolean);
  138230. get isEnabled(): boolean;
  138231. /**
  138232. * Disposes of the gizmo
  138233. */
  138234. dispose(): void;
  138235. /**
  138236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  138237. * @param mesh The mesh to replace the default mesh of the gizmo
  138238. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  138239. */
  138240. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  138241. }
  138242. }
  138243. declare module BABYLON {
  138244. /**
  138245. * Bounding box gizmo
  138246. */
  138247. export class BoundingBoxGizmo extends Gizmo {
  138248. private _lineBoundingBox;
  138249. private _rotateSpheresParent;
  138250. private _scaleBoxesParent;
  138251. private _boundingDimensions;
  138252. private _renderObserver;
  138253. private _pointerObserver;
  138254. private _scaleDragSpeed;
  138255. private _tmpQuaternion;
  138256. private _tmpVector;
  138257. private _tmpRotationMatrix;
  138258. /**
  138259. * 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)
  138260. */
  138261. ignoreChildren: boolean;
  138262. /**
  138263. * 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)
  138264. */
  138265. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  138266. /**
  138267. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  138268. */
  138269. rotationSphereSize: number;
  138270. /**
  138271. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  138272. */
  138273. scaleBoxSize: number;
  138274. /**
  138275. * 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)
  138276. */
  138277. fixedDragMeshScreenSize: boolean;
  138278. /**
  138279. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  138280. */
  138281. fixedDragMeshScreenSizeDistanceFactor: number;
  138282. /**
  138283. * Fired when a rotation sphere or scale box is dragged
  138284. */
  138285. onDragStartObservable: Observable<{}>;
  138286. /**
  138287. * Fired when a scale box is dragged
  138288. */
  138289. onScaleBoxDragObservable: Observable<{}>;
  138290. /**
  138291. * Fired when a scale box drag is ended
  138292. */
  138293. onScaleBoxDragEndObservable: Observable<{}>;
  138294. /**
  138295. * Fired when a rotation sphere is dragged
  138296. */
  138297. onRotationSphereDragObservable: Observable<{}>;
  138298. /**
  138299. * Fired when a rotation sphere drag is ended
  138300. */
  138301. onRotationSphereDragEndObservable: Observable<{}>;
  138302. /**
  138303. * 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)
  138304. */
  138305. scalePivot: Nullable<Vector3>;
  138306. /**
  138307. * Mesh used as a pivot to rotate the attached node
  138308. */
  138309. private _anchorMesh;
  138310. private _existingMeshScale;
  138311. private _dragMesh;
  138312. private pointerDragBehavior;
  138313. private coloredMaterial;
  138314. private hoverColoredMaterial;
  138315. /**
  138316. * Sets the color of the bounding box gizmo
  138317. * @param color the color to set
  138318. */
  138319. setColor(color: Color3): void;
  138320. /**
  138321. * Creates an BoundingBoxGizmo
  138322. * @param gizmoLayer The utility layer the gizmo will be added to
  138323. * @param color The color of the gizmo
  138324. */
  138325. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  138326. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  138327. private _selectNode;
  138328. /**
  138329. * Updates the bounding box information for the Gizmo
  138330. */
  138331. updateBoundingBox(): void;
  138332. private _updateRotationSpheres;
  138333. private _updateScaleBoxes;
  138334. /**
  138335. * Enables rotation on the specified axis and disables rotation on the others
  138336. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  138337. */
  138338. setEnabledRotationAxis(axis: string): void;
  138339. /**
  138340. * Enables/disables scaling
  138341. * @param enable if scaling should be enabled
  138342. * @param homogeneousScaling defines if scaling should only be homogeneous
  138343. */
  138344. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  138345. private _updateDummy;
  138346. /**
  138347. * Enables a pointer drag behavior on the bounding box of the gizmo
  138348. */
  138349. enableDragBehavior(): void;
  138350. /**
  138351. * Disposes of the gizmo
  138352. */
  138353. dispose(): void;
  138354. /**
  138355. * 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)
  138356. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  138357. * @returns the bounding box mesh with the passed in mesh as a child
  138358. */
  138359. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  138360. /**
  138361. * CustomMeshes are not supported by this gizmo
  138362. * @param mesh The mesh to replace the default mesh of the gizmo
  138363. */
  138364. setCustomMesh(mesh: Mesh): void;
  138365. }
  138366. }
  138367. declare module BABYLON {
  138368. /**
  138369. * Single plane rotation gizmo
  138370. */
  138371. export class PlaneRotationGizmo extends Gizmo {
  138372. /**
  138373. * Drag behavior responsible for the gizmos dragging interactions
  138374. */
  138375. dragBehavior: PointerDragBehavior;
  138376. private _pointerObserver;
  138377. /**
  138378. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  138379. */
  138380. snapDistance: number;
  138381. /**
  138382. * Event that fires each time the gizmo snaps to a new location.
  138383. * * snapDistance is the the change in distance
  138384. */
  138385. onSnapObservable: Observable<{
  138386. snapDistance: number;
  138387. }>;
  138388. private _isEnabled;
  138389. private _parent;
  138390. /**
  138391. * Creates a PlaneRotationGizmo
  138392. * @param gizmoLayer The utility layer the gizmo will be added to
  138393. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  138394. * @param color The color of the gizmo
  138395. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138396. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138397. * @param thickness display gizmo axis thickness
  138398. */
  138399. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  138400. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138401. /**
  138402. * If the gizmo is enabled
  138403. */
  138404. set isEnabled(value: boolean);
  138405. get isEnabled(): boolean;
  138406. /**
  138407. * Disposes of the gizmo
  138408. */
  138409. dispose(): void;
  138410. }
  138411. }
  138412. declare module BABYLON {
  138413. /**
  138414. * Gizmo that enables rotating a mesh along 3 axis
  138415. */
  138416. export class RotationGizmo extends Gizmo {
  138417. /**
  138418. * Internal gizmo used for interactions on the x axis
  138419. */
  138420. xGizmo: PlaneRotationGizmo;
  138421. /**
  138422. * Internal gizmo used for interactions on the y axis
  138423. */
  138424. yGizmo: PlaneRotationGizmo;
  138425. /**
  138426. * Internal gizmo used for interactions on the z axis
  138427. */
  138428. zGizmo: PlaneRotationGizmo;
  138429. /** Fires an event when any of it's sub gizmos are dragged */
  138430. onDragStartObservable: Observable<unknown>;
  138431. /** Fires an event when any of it's sub gizmos are released from dragging */
  138432. onDragEndObservable: Observable<unknown>;
  138433. private _meshAttached;
  138434. private _nodeAttached;
  138435. get attachedMesh(): Nullable<AbstractMesh>;
  138436. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138437. get attachedNode(): Nullable<Node>;
  138438. set attachedNode(node: Nullable<Node>);
  138439. protected _checkBillboardTransform(): void;
  138440. /**
  138441. * True when the mouse pointer is hovering a gizmo mesh
  138442. */
  138443. get isHovered(): boolean;
  138444. /**
  138445. * Creates a RotationGizmo
  138446. * @param gizmoLayer The utility layer the gizmo will be added to
  138447. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138448. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138449. * @param thickness display gizmo axis thickness
  138450. */
  138451. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  138452. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138453. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138454. /**
  138455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138456. */
  138457. set snapDistance(value: number);
  138458. get snapDistance(): number;
  138459. /**
  138460. * Ratio for the scale of the gizmo (Default: 1)
  138461. */
  138462. set scaleRatio(value: number);
  138463. get scaleRatio(): number;
  138464. /**
  138465. * Disposes of the gizmo
  138466. */
  138467. dispose(): void;
  138468. /**
  138469. * CustomMeshes are not supported by this gizmo
  138470. * @param mesh The mesh to replace the default mesh of the gizmo
  138471. */
  138472. setCustomMesh(mesh: Mesh): void;
  138473. }
  138474. }
  138475. declare module BABYLON {
  138476. /**
  138477. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  138478. */
  138479. export class GizmoManager implements IDisposable {
  138480. private scene;
  138481. /**
  138482. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  138483. */
  138484. gizmos: {
  138485. positionGizmo: Nullable<PositionGizmo>;
  138486. rotationGizmo: Nullable<RotationGizmo>;
  138487. scaleGizmo: Nullable<ScaleGizmo>;
  138488. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  138489. };
  138490. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  138491. clearGizmoOnEmptyPointerEvent: boolean;
  138492. /** Fires an event when the manager is attached to a mesh */
  138493. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  138494. /** Fires an event when the manager is attached to a node */
  138495. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  138496. private _gizmosEnabled;
  138497. private _pointerObserver;
  138498. private _attachedMesh;
  138499. private _attachedNode;
  138500. private _boundingBoxColor;
  138501. private _defaultUtilityLayer;
  138502. private _defaultKeepDepthUtilityLayer;
  138503. private _thickness;
  138504. /**
  138505. * When bounding box gizmo is enabled, this can be used to track drag/end events
  138506. */
  138507. boundingBoxDragBehavior: SixDofDragBehavior;
  138508. /**
  138509. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  138510. */
  138511. attachableMeshes: Nullable<Array<AbstractMesh>>;
  138512. /**
  138513. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  138514. */
  138515. attachableNodes: Nullable<Array<Node>>;
  138516. /**
  138517. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  138518. */
  138519. usePointerToAttachGizmos: boolean;
  138520. /**
  138521. * Utility layer that the bounding box gizmo belongs to
  138522. */
  138523. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  138524. /**
  138525. * Utility layer that all gizmos besides bounding box belong to
  138526. */
  138527. get utilityLayer(): UtilityLayerRenderer;
  138528. /**
  138529. * True when the mouse pointer is hovering a gizmo mesh
  138530. */
  138531. get isHovered(): boolean;
  138532. /**
  138533. * Instatiates a gizmo manager
  138534. * @param scene the scene to overlay the gizmos on top of
  138535. * @param thickness display gizmo axis thickness
  138536. */
  138537. constructor(scene: Scene, thickness?: number);
  138538. /**
  138539. * Attaches a set of gizmos to the specified mesh
  138540. * @param mesh The mesh the gizmo's should be attached to
  138541. */
  138542. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138543. /**
  138544. * Attaches a set of gizmos to the specified node
  138545. * @param node The node the gizmo's should be attached to
  138546. */
  138547. attachToNode(node: Nullable<Node>): void;
  138548. /**
  138549. * If the position gizmo is enabled
  138550. */
  138551. set positionGizmoEnabled(value: boolean);
  138552. get positionGizmoEnabled(): boolean;
  138553. /**
  138554. * If the rotation gizmo is enabled
  138555. */
  138556. set rotationGizmoEnabled(value: boolean);
  138557. get rotationGizmoEnabled(): boolean;
  138558. /**
  138559. * If the scale gizmo is enabled
  138560. */
  138561. set scaleGizmoEnabled(value: boolean);
  138562. get scaleGizmoEnabled(): boolean;
  138563. /**
  138564. * If the boundingBox gizmo is enabled
  138565. */
  138566. set boundingBoxGizmoEnabled(value: boolean);
  138567. get boundingBoxGizmoEnabled(): boolean;
  138568. /**
  138569. * Disposes of the gizmo manager
  138570. */
  138571. dispose(): void;
  138572. }
  138573. }
  138574. declare module BABYLON {
  138575. /**
  138576. * A directional light is defined by a direction (what a surprise!).
  138577. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  138578. * 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.
  138579. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138580. */
  138581. export class DirectionalLight extends ShadowLight {
  138582. private _shadowFrustumSize;
  138583. /**
  138584. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  138585. */
  138586. get shadowFrustumSize(): number;
  138587. /**
  138588. * Specifies a fix frustum size for the shadow generation.
  138589. */
  138590. set shadowFrustumSize(value: number);
  138591. private _shadowOrthoScale;
  138592. /**
  138593. * Gets the shadow projection scale against the optimal computed one.
  138594. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138595. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138596. */
  138597. get shadowOrthoScale(): number;
  138598. /**
  138599. * Sets the shadow projection scale against the optimal computed one.
  138600. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138601. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138602. */
  138603. set shadowOrthoScale(value: number);
  138604. /**
  138605. * Automatically compute the projection matrix to best fit (including all the casters)
  138606. * on each frame.
  138607. */
  138608. autoUpdateExtends: boolean;
  138609. /**
  138610. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  138611. * on each frame. autoUpdateExtends must be set to true for this to work
  138612. */
  138613. autoCalcShadowZBounds: boolean;
  138614. private _orthoLeft;
  138615. private _orthoRight;
  138616. private _orthoTop;
  138617. private _orthoBottom;
  138618. /**
  138619. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  138620. * The directional light is emitted from everywhere in the given direction.
  138621. * It can cast shadows.
  138622. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138623. * @param name The friendly name of the light
  138624. * @param direction The direction of the light
  138625. * @param scene The scene the light belongs to
  138626. */
  138627. constructor(name: string, direction: Vector3, scene: Scene);
  138628. /**
  138629. * Returns the string "DirectionalLight".
  138630. * @return The class name
  138631. */
  138632. getClassName(): string;
  138633. /**
  138634. * Returns the integer 1.
  138635. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138636. */
  138637. getTypeID(): number;
  138638. /**
  138639. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  138640. * Returns the DirectionalLight Shadow projection matrix.
  138641. */
  138642. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138643. /**
  138644. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  138645. * Returns the DirectionalLight Shadow projection matrix.
  138646. */
  138647. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  138648. /**
  138649. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  138650. * Returns the DirectionalLight Shadow projection matrix.
  138651. */
  138652. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138653. protected _buildUniformLayout(): void;
  138654. /**
  138655. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  138656. * @param effect The effect to update
  138657. * @param lightIndex The index of the light in the effect to update
  138658. * @returns The directional light
  138659. */
  138660. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  138661. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  138662. /**
  138663. * Gets the minZ used for shadow according to both the scene and the light.
  138664. *
  138665. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138666. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138667. * @param activeCamera The camera we are returning the min for
  138668. * @returns the depth min z
  138669. */
  138670. getDepthMinZ(activeCamera: Camera): number;
  138671. /**
  138672. * Gets the maxZ used for shadow according to both the scene and the light.
  138673. *
  138674. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138675. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138676. * @param activeCamera The camera we are returning the max for
  138677. * @returns the depth max z
  138678. */
  138679. getDepthMaxZ(activeCamera: Camera): number;
  138680. /**
  138681. * Prepares the list of defines specific to the light type.
  138682. * @param defines the list of defines
  138683. * @param lightIndex defines the index of the light for the effect
  138684. */
  138685. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138686. }
  138687. }
  138688. declare module BABYLON {
  138689. /**
  138690. * Class containing static functions to help procedurally build meshes
  138691. */
  138692. export class HemisphereBuilder {
  138693. /**
  138694. * Creates a hemisphere mesh
  138695. * @param name defines the name of the mesh
  138696. * @param options defines the options used to create the mesh
  138697. * @param scene defines the hosting scene
  138698. * @returns the hemisphere mesh
  138699. */
  138700. static CreateHemisphere(name: string, options: {
  138701. segments?: number;
  138702. diameter?: number;
  138703. sideOrientation?: number;
  138704. }, scene: any): Mesh;
  138705. }
  138706. }
  138707. declare module BABYLON {
  138708. /**
  138709. * A spot light is defined by a position, a direction, an angle, and an exponent.
  138710. * These values define a cone of light starting from the position, emitting toward the direction.
  138711. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  138712. * and the exponent defines the speed of the decay of the light with distance (reach).
  138713. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138714. */
  138715. export class SpotLight extends ShadowLight {
  138716. private _angle;
  138717. private _innerAngle;
  138718. private _cosHalfAngle;
  138719. private _lightAngleScale;
  138720. private _lightAngleOffset;
  138721. /**
  138722. * Gets the cone angle of the spot light in Radians.
  138723. */
  138724. get angle(): number;
  138725. /**
  138726. * Sets the cone angle of the spot light in Radians.
  138727. */
  138728. set angle(value: number);
  138729. /**
  138730. * Only used in gltf falloff mode, this defines the angle where
  138731. * the directional falloff will start before cutting at angle which could be seen
  138732. * as outer angle.
  138733. */
  138734. get innerAngle(): number;
  138735. /**
  138736. * Only used in gltf falloff mode, this defines the angle where
  138737. * the directional falloff will start before cutting at angle which could be seen
  138738. * as outer angle.
  138739. */
  138740. set innerAngle(value: number);
  138741. private _shadowAngleScale;
  138742. /**
  138743. * Allows scaling the angle of the light for shadow generation only.
  138744. */
  138745. get shadowAngleScale(): number;
  138746. /**
  138747. * Allows scaling the angle of the light for shadow generation only.
  138748. */
  138749. set shadowAngleScale(value: number);
  138750. /**
  138751. * The light decay speed with the distance from the emission spot.
  138752. */
  138753. exponent: number;
  138754. private _projectionTextureMatrix;
  138755. /**
  138756. * Allows reading the projecton texture
  138757. */
  138758. get projectionTextureMatrix(): Matrix;
  138759. protected _projectionTextureLightNear: number;
  138760. /**
  138761. * Gets the near clip of the Spotlight for texture projection.
  138762. */
  138763. get projectionTextureLightNear(): number;
  138764. /**
  138765. * Sets the near clip of the Spotlight for texture projection.
  138766. */
  138767. set projectionTextureLightNear(value: number);
  138768. protected _projectionTextureLightFar: number;
  138769. /**
  138770. * Gets the far clip of the Spotlight for texture projection.
  138771. */
  138772. get projectionTextureLightFar(): number;
  138773. /**
  138774. * Sets the far clip of the Spotlight for texture projection.
  138775. */
  138776. set projectionTextureLightFar(value: number);
  138777. protected _projectionTextureUpDirection: Vector3;
  138778. /**
  138779. * Gets the Up vector of the Spotlight for texture projection.
  138780. */
  138781. get projectionTextureUpDirection(): Vector3;
  138782. /**
  138783. * Sets the Up vector of the Spotlight for texture projection.
  138784. */
  138785. set projectionTextureUpDirection(value: Vector3);
  138786. private _projectionTexture;
  138787. /**
  138788. * Gets the projection texture of the light.
  138789. */
  138790. get projectionTexture(): Nullable<BaseTexture>;
  138791. /**
  138792. * Sets the projection texture of the light.
  138793. */
  138794. set projectionTexture(value: Nullable<BaseTexture>);
  138795. private static _IsProceduralTexture;
  138796. private static _IsTexture;
  138797. private _projectionTextureViewLightDirty;
  138798. private _projectionTextureProjectionLightDirty;
  138799. private _projectionTextureDirty;
  138800. private _projectionTextureViewTargetVector;
  138801. private _projectionTextureViewLightMatrix;
  138802. private _projectionTextureProjectionLightMatrix;
  138803. private _projectionTextureScalingMatrix;
  138804. /**
  138805. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  138806. * It can cast shadows.
  138807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138808. * @param name The light friendly name
  138809. * @param position The position of the spot light in the scene
  138810. * @param direction The direction of the light in the scene
  138811. * @param angle The cone angle of the light in Radians
  138812. * @param exponent The light decay speed with the distance from the emission spot
  138813. * @param scene The scene the lights belongs to
  138814. */
  138815. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138816. /**
  138817. * Returns the string "SpotLight".
  138818. * @returns the class name
  138819. */
  138820. getClassName(): string;
  138821. /**
  138822. * Returns the integer 2.
  138823. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138824. */
  138825. getTypeID(): number;
  138826. /**
  138827. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138828. */
  138829. protected _setDirection(value: Vector3): void;
  138830. /**
  138831. * Overrides the position setter to recompute the projection texture view light Matrix.
  138832. */
  138833. protected _setPosition(value: Vector3): void;
  138834. /**
  138835. * 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.
  138836. * Returns the SpotLight.
  138837. */
  138838. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138839. protected _computeProjectionTextureViewLightMatrix(): void;
  138840. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138841. /**
  138842. * Main function for light texture projection matrix computing.
  138843. */
  138844. protected _computeProjectionTextureMatrix(): void;
  138845. protected _buildUniformLayout(): void;
  138846. private _computeAngleValues;
  138847. /**
  138848. * Sets the passed Effect "effect" with the Light textures.
  138849. * @param effect The effect to update
  138850. * @param lightIndex The index of the light in the effect to update
  138851. * @returns The light
  138852. */
  138853. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138854. /**
  138855. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138856. * @param effect The effect to update
  138857. * @param lightIndex The index of the light in the effect to update
  138858. * @returns The spot light
  138859. */
  138860. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138861. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138862. /**
  138863. * Disposes the light and the associated resources.
  138864. */
  138865. dispose(): void;
  138866. /**
  138867. * Prepares the list of defines specific to the light type.
  138868. * @param defines the list of defines
  138869. * @param lightIndex defines the index of the light for the effect
  138870. */
  138871. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138872. }
  138873. }
  138874. declare module BABYLON {
  138875. /**
  138876. * Gizmo that enables viewing a light
  138877. */
  138878. export class LightGizmo extends Gizmo {
  138879. private _lightMesh;
  138880. private _material;
  138881. private _cachedPosition;
  138882. private _cachedForward;
  138883. private _attachedMeshParent;
  138884. private _pointerObserver;
  138885. /**
  138886. * Event that fires each time the gizmo is clicked
  138887. */
  138888. onClickedObservable: Observable<Light>;
  138889. /**
  138890. * Creates a LightGizmo
  138891. * @param gizmoLayer The utility layer the gizmo will be added to
  138892. */
  138893. constructor(gizmoLayer?: UtilityLayerRenderer);
  138894. private _light;
  138895. /**
  138896. * The light that the gizmo is attached to
  138897. */
  138898. set light(light: Nullable<Light>);
  138899. get light(): Nullable<Light>;
  138900. /**
  138901. * Gets the material used to render the light gizmo
  138902. */
  138903. get material(): StandardMaterial;
  138904. /**
  138905. * @hidden
  138906. * Updates the gizmo to match the attached mesh's position/rotation
  138907. */
  138908. protected _update(): void;
  138909. private static _Scale;
  138910. /**
  138911. * Creates the lines for a light mesh
  138912. */
  138913. private static _CreateLightLines;
  138914. /**
  138915. * Disposes of the light gizmo
  138916. */
  138917. dispose(): void;
  138918. private static _CreateHemisphericLightMesh;
  138919. private static _CreatePointLightMesh;
  138920. private static _CreateSpotLightMesh;
  138921. private static _CreateDirectionalLightMesh;
  138922. }
  138923. }
  138924. declare module BABYLON {
  138925. /**
  138926. * Gizmo that enables viewing a camera
  138927. */
  138928. export class CameraGizmo extends Gizmo {
  138929. private _cameraMesh;
  138930. private _cameraLinesMesh;
  138931. private _material;
  138932. private _pointerObserver;
  138933. /**
  138934. * Event that fires each time the gizmo is clicked
  138935. */
  138936. onClickedObservable: Observable<Camera>;
  138937. /**
  138938. * Creates a CameraGizmo
  138939. * @param gizmoLayer The utility layer the gizmo will be added to
  138940. */
  138941. constructor(gizmoLayer?: UtilityLayerRenderer);
  138942. private _camera;
  138943. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138944. get displayFrustum(): boolean;
  138945. set displayFrustum(value: boolean);
  138946. /**
  138947. * The camera that the gizmo is attached to
  138948. */
  138949. set camera(camera: Nullable<Camera>);
  138950. get camera(): Nullable<Camera>;
  138951. /**
  138952. * Gets the material used to render the camera gizmo
  138953. */
  138954. get material(): StandardMaterial;
  138955. /**
  138956. * @hidden
  138957. * Updates the gizmo to match the attached mesh's position/rotation
  138958. */
  138959. protected _update(): void;
  138960. private static _Scale;
  138961. private _invProjection;
  138962. /**
  138963. * Disposes of the camera gizmo
  138964. */
  138965. dispose(): void;
  138966. private static _CreateCameraMesh;
  138967. private static _CreateCameraFrustum;
  138968. }
  138969. }
  138970. declare module BABYLON {
  138971. /** @hidden */
  138972. export var backgroundFragmentDeclaration: {
  138973. name: string;
  138974. shader: string;
  138975. };
  138976. }
  138977. declare module BABYLON {
  138978. /** @hidden */
  138979. export var backgroundUboDeclaration: {
  138980. name: string;
  138981. shader: string;
  138982. };
  138983. }
  138984. declare module BABYLON {
  138985. /** @hidden */
  138986. export var backgroundPixelShader: {
  138987. name: string;
  138988. shader: string;
  138989. };
  138990. }
  138991. declare module BABYLON {
  138992. /** @hidden */
  138993. export var backgroundVertexDeclaration: {
  138994. name: string;
  138995. shader: string;
  138996. };
  138997. }
  138998. declare module BABYLON {
  138999. /** @hidden */
  139000. export var backgroundVertexShader: {
  139001. name: string;
  139002. shader: string;
  139003. };
  139004. }
  139005. declare module BABYLON {
  139006. /**
  139007. * Background material used to create an efficient environement around your scene.
  139008. */
  139009. export class BackgroundMaterial extends PushMaterial {
  139010. /**
  139011. * Standard reflectance value at parallel view angle.
  139012. */
  139013. static StandardReflectance0: number;
  139014. /**
  139015. * Standard reflectance value at grazing angle.
  139016. */
  139017. static StandardReflectance90: number;
  139018. protected _primaryColor: Color3;
  139019. /**
  139020. * Key light Color (multiply against the environement texture)
  139021. */
  139022. primaryColor: Color3;
  139023. protected __perceptualColor: Nullable<Color3>;
  139024. /**
  139025. * Experimental Internal Use Only.
  139026. *
  139027. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139028. * This acts as a helper to set the primary color to a more "human friendly" value.
  139029. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139030. * output color as close as possible from the chosen value.
  139031. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139032. * part of lighting setup.)
  139033. */
  139034. get _perceptualColor(): Nullable<Color3>;
  139035. set _perceptualColor(value: Nullable<Color3>);
  139036. protected _primaryColorShadowLevel: float;
  139037. /**
  139038. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139039. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139040. */
  139041. get primaryColorShadowLevel(): float;
  139042. set primaryColorShadowLevel(value: float);
  139043. protected _primaryColorHighlightLevel: float;
  139044. /**
  139045. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139046. * The primary color is used at the level chosen to define what the white area would look.
  139047. */
  139048. get primaryColorHighlightLevel(): float;
  139049. set primaryColorHighlightLevel(value: float);
  139050. protected _reflectionTexture: Nullable<BaseTexture>;
  139051. /**
  139052. * Reflection Texture used in the material.
  139053. * Should be author in a specific way for the best result (refer to the documentation).
  139054. */
  139055. reflectionTexture: Nullable<BaseTexture>;
  139056. protected _reflectionBlur: float;
  139057. /**
  139058. * Reflection Texture level of blur.
  139059. *
  139060. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139061. * texture twice.
  139062. */
  139063. reflectionBlur: float;
  139064. protected _diffuseTexture: Nullable<BaseTexture>;
  139065. /**
  139066. * Diffuse Texture used in the material.
  139067. * Should be author in a specific way for the best result (refer to the documentation).
  139068. */
  139069. diffuseTexture: Nullable<BaseTexture>;
  139070. protected _shadowLights: Nullable<IShadowLight[]>;
  139071. /**
  139072. * Specify the list of lights casting shadow on the material.
  139073. * All scene shadow lights will be included if null.
  139074. */
  139075. shadowLights: Nullable<IShadowLight[]>;
  139076. protected _shadowLevel: float;
  139077. /**
  139078. * Helps adjusting the shadow to a softer level if required.
  139079. * 0 means black shadows and 1 means no shadows.
  139080. */
  139081. shadowLevel: float;
  139082. protected _sceneCenter: Vector3;
  139083. /**
  139084. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  139085. * It is usually zero but might be interesting to modify according to your setup.
  139086. */
  139087. sceneCenter: Vector3;
  139088. protected _opacityFresnel: boolean;
  139089. /**
  139090. * This helps specifying that the material is falling off to the sky box at grazing angle.
  139091. * This helps ensuring a nice transition when the camera goes under the ground.
  139092. */
  139093. opacityFresnel: boolean;
  139094. protected _reflectionFresnel: boolean;
  139095. /**
  139096. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  139097. * This helps adding a mirror texture on the ground.
  139098. */
  139099. reflectionFresnel: boolean;
  139100. protected _reflectionFalloffDistance: number;
  139101. /**
  139102. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  139103. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  139104. */
  139105. reflectionFalloffDistance: number;
  139106. protected _reflectionAmount: number;
  139107. /**
  139108. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  139109. */
  139110. reflectionAmount: number;
  139111. protected _reflectionReflectance0: number;
  139112. /**
  139113. * This specifies the weight of the reflection at grazing angle.
  139114. */
  139115. reflectionReflectance0: number;
  139116. protected _reflectionReflectance90: number;
  139117. /**
  139118. * This specifies the weight of the reflection at a perpendicular point of view.
  139119. */
  139120. reflectionReflectance90: number;
  139121. /**
  139122. * Sets the reflection reflectance fresnel values according to the default standard
  139123. * empirically know to work well :-)
  139124. */
  139125. set reflectionStandardFresnelWeight(value: number);
  139126. protected _useRGBColor: boolean;
  139127. /**
  139128. * Helps to directly use the maps channels instead of their level.
  139129. */
  139130. useRGBColor: boolean;
  139131. protected _enableNoise: boolean;
  139132. /**
  139133. * This helps reducing the banding effect that could occur on the background.
  139134. */
  139135. enableNoise: boolean;
  139136. /**
  139137. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139138. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139139. * Recommended to be keep at 1.0 except for special cases.
  139140. */
  139141. get fovMultiplier(): number;
  139142. set fovMultiplier(value: number);
  139143. private _fovMultiplier;
  139144. /**
  139145. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139146. */
  139147. useEquirectangularFOV: boolean;
  139148. private _maxSimultaneousLights;
  139149. /**
  139150. * Number of Simultaneous lights allowed on the material.
  139151. */
  139152. maxSimultaneousLights: int;
  139153. private _shadowOnly;
  139154. /**
  139155. * Make the material only render shadows
  139156. */
  139157. shadowOnly: boolean;
  139158. /**
  139159. * Default configuration related to image processing available in the Background Material.
  139160. */
  139161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139162. /**
  139163. * Keep track of the image processing observer to allow dispose and replace.
  139164. */
  139165. private _imageProcessingObserver;
  139166. /**
  139167. * Attaches a new image processing configuration to the PBR Material.
  139168. * @param configuration (if null the scene configuration will be use)
  139169. */
  139170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  139171. /**
  139172. * Gets the image processing configuration used either in this material.
  139173. */
  139174. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  139175. /**
  139176. * Sets the Default image processing configuration used either in the this material.
  139177. *
  139178. * If sets to null, the scene one is in use.
  139179. */
  139180. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  139181. /**
  139182. * Gets wether the color curves effect is enabled.
  139183. */
  139184. get cameraColorCurvesEnabled(): boolean;
  139185. /**
  139186. * Sets wether the color curves effect is enabled.
  139187. */
  139188. set cameraColorCurvesEnabled(value: boolean);
  139189. /**
  139190. * Gets wether the color grading effect is enabled.
  139191. */
  139192. get cameraColorGradingEnabled(): boolean;
  139193. /**
  139194. * Gets wether the color grading effect is enabled.
  139195. */
  139196. set cameraColorGradingEnabled(value: boolean);
  139197. /**
  139198. * Gets wether tonemapping is enabled or not.
  139199. */
  139200. get cameraToneMappingEnabled(): boolean;
  139201. /**
  139202. * Sets wether tonemapping is enabled or not
  139203. */
  139204. set cameraToneMappingEnabled(value: boolean);
  139205. /**
  139206. * The camera exposure used on this material.
  139207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139208. * This corresponds to a photographic exposure.
  139209. */
  139210. get cameraExposure(): float;
  139211. /**
  139212. * The camera exposure used on this material.
  139213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139214. * This corresponds to a photographic exposure.
  139215. */
  139216. set cameraExposure(value: float);
  139217. /**
  139218. * Gets The camera contrast used on this material.
  139219. */
  139220. get cameraContrast(): float;
  139221. /**
  139222. * Sets The camera contrast used on this material.
  139223. */
  139224. set cameraContrast(value: float);
  139225. /**
  139226. * Gets the Color Grading 2D Lookup Texture.
  139227. */
  139228. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  139229. /**
  139230. * Sets the Color Grading 2D Lookup Texture.
  139231. */
  139232. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  139233. /**
  139234. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139235. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139236. * 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;
  139237. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139238. */
  139239. get cameraColorCurves(): Nullable<ColorCurves>;
  139240. /**
  139241. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139242. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139243. * 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;
  139244. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139245. */
  139246. set cameraColorCurves(value: Nullable<ColorCurves>);
  139247. /**
  139248. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  139249. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  139250. */
  139251. switchToBGR: boolean;
  139252. private _renderTargets;
  139253. private _reflectionControls;
  139254. private _white;
  139255. private _primaryShadowColor;
  139256. private _primaryHighlightColor;
  139257. /**
  139258. * Instantiates a Background Material in the given scene
  139259. * @param name The friendly name of the material
  139260. * @param scene The scene to add the material to
  139261. */
  139262. constructor(name: string, scene: Scene);
  139263. /**
  139264. * Gets a boolean indicating that current material needs to register RTT
  139265. */
  139266. get hasRenderTargetTextures(): boolean;
  139267. /**
  139268. * The entire material has been created in order to prevent overdraw.
  139269. * @returns false
  139270. */
  139271. needAlphaTesting(): boolean;
  139272. /**
  139273. * The entire material has been created in order to prevent overdraw.
  139274. * @returns true if blending is enable
  139275. */
  139276. needAlphaBlending(): boolean;
  139277. /**
  139278. * Checks wether the material is ready to be rendered for a given mesh.
  139279. * @param mesh The mesh to render
  139280. * @param subMesh The submesh to check against
  139281. * @param useInstances Specify wether or not the material is used with instances
  139282. * @returns true if all the dependencies are ready (Textures, Effects...)
  139283. */
  139284. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  139285. /**
  139286. * Compute the primary color according to the chosen perceptual color.
  139287. */
  139288. private _computePrimaryColorFromPerceptualColor;
  139289. /**
  139290. * Compute the highlights and shadow colors according to their chosen levels.
  139291. */
  139292. private _computePrimaryColors;
  139293. /**
  139294. * Build the uniform buffer used in the material.
  139295. */
  139296. buildUniformLayout(): void;
  139297. /**
  139298. * Unbind the material.
  139299. */
  139300. unbind(): void;
  139301. /**
  139302. * Bind only the world matrix to the material.
  139303. * @param world The world matrix to bind.
  139304. */
  139305. bindOnlyWorldMatrix(world: Matrix): void;
  139306. /**
  139307. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  139308. * @param world The world matrix to bind.
  139309. * @param subMesh The submesh to bind for.
  139310. */
  139311. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  139312. /**
  139313. * Checks to see if a texture is used in the material.
  139314. * @param texture - Base texture to use.
  139315. * @returns - Boolean specifying if a texture is used in the material.
  139316. */
  139317. hasTexture(texture: BaseTexture): boolean;
  139318. /**
  139319. * Dispose the material.
  139320. * @param forceDisposeEffect Force disposal of the associated effect.
  139321. * @param forceDisposeTextures Force disposal of the associated textures.
  139322. */
  139323. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  139324. /**
  139325. * Clones the material.
  139326. * @param name The cloned name.
  139327. * @returns The cloned material.
  139328. */
  139329. clone(name: string): BackgroundMaterial;
  139330. /**
  139331. * Serializes the current material to its JSON representation.
  139332. * @returns The JSON representation.
  139333. */
  139334. serialize(): any;
  139335. /**
  139336. * Gets the class name of the material
  139337. * @returns "BackgroundMaterial"
  139338. */
  139339. getClassName(): string;
  139340. /**
  139341. * Parse a JSON input to create back a background material.
  139342. * @param source The JSON data to parse
  139343. * @param scene The scene to create the parsed material in
  139344. * @param rootUrl The root url of the assets the material depends upon
  139345. * @returns the instantiated BackgroundMaterial.
  139346. */
  139347. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  139348. }
  139349. }
  139350. declare module BABYLON {
  139351. /**
  139352. * Represents the different options available during the creation of
  139353. * a Environment helper.
  139354. *
  139355. * This can control the default ground, skybox and image processing setup of your scene.
  139356. */
  139357. export interface IEnvironmentHelperOptions {
  139358. /**
  139359. * Specifies whether or not to create a ground.
  139360. * True by default.
  139361. */
  139362. createGround: boolean;
  139363. /**
  139364. * Specifies the ground size.
  139365. * 15 by default.
  139366. */
  139367. groundSize: number;
  139368. /**
  139369. * The texture used on the ground for the main color.
  139370. * Comes from the BabylonJS CDN by default.
  139371. *
  139372. * Remarks: Can be either a texture or a url.
  139373. */
  139374. groundTexture: string | BaseTexture;
  139375. /**
  139376. * The color mixed in the ground texture by default.
  139377. * BabylonJS clearColor by default.
  139378. */
  139379. groundColor: Color3;
  139380. /**
  139381. * Specifies the ground opacity.
  139382. * 1 by default.
  139383. */
  139384. groundOpacity: number;
  139385. /**
  139386. * Enables the ground to receive shadows.
  139387. * True by default.
  139388. */
  139389. enableGroundShadow: boolean;
  139390. /**
  139391. * Helps preventing the shadow to be fully black on the ground.
  139392. * 0.5 by default.
  139393. */
  139394. groundShadowLevel: number;
  139395. /**
  139396. * Creates a mirror texture attach to the ground.
  139397. * false by default.
  139398. */
  139399. enableGroundMirror: boolean;
  139400. /**
  139401. * Specifies the ground mirror size ratio.
  139402. * 0.3 by default as the default kernel is 64.
  139403. */
  139404. groundMirrorSizeRatio: number;
  139405. /**
  139406. * Specifies the ground mirror blur kernel size.
  139407. * 64 by default.
  139408. */
  139409. groundMirrorBlurKernel: number;
  139410. /**
  139411. * Specifies the ground mirror visibility amount.
  139412. * 1 by default
  139413. */
  139414. groundMirrorAmount: number;
  139415. /**
  139416. * Specifies the ground mirror reflectance weight.
  139417. * This uses the standard weight of the background material to setup the fresnel effect
  139418. * of the mirror.
  139419. * 1 by default.
  139420. */
  139421. groundMirrorFresnelWeight: number;
  139422. /**
  139423. * Specifies the ground mirror Falloff distance.
  139424. * This can helps reducing the size of the reflection.
  139425. * 0 by Default.
  139426. */
  139427. groundMirrorFallOffDistance: number;
  139428. /**
  139429. * Specifies the ground mirror texture type.
  139430. * Unsigned Int by Default.
  139431. */
  139432. groundMirrorTextureType: number;
  139433. /**
  139434. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  139435. * the shown objects.
  139436. */
  139437. groundYBias: number;
  139438. /**
  139439. * Specifies whether or not to create a skybox.
  139440. * True by default.
  139441. */
  139442. createSkybox: boolean;
  139443. /**
  139444. * Specifies the skybox size.
  139445. * 20 by default.
  139446. */
  139447. skyboxSize: number;
  139448. /**
  139449. * The texture used on the skybox for the main color.
  139450. * Comes from the BabylonJS CDN by default.
  139451. *
  139452. * Remarks: Can be either a texture or a url.
  139453. */
  139454. skyboxTexture: string | BaseTexture;
  139455. /**
  139456. * The color mixed in the skybox texture by default.
  139457. * BabylonJS clearColor by default.
  139458. */
  139459. skyboxColor: Color3;
  139460. /**
  139461. * The background rotation around the Y axis of the scene.
  139462. * This helps aligning the key lights of your scene with the background.
  139463. * 0 by default.
  139464. */
  139465. backgroundYRotation: number;
  139466. /**
  139467. * Compute automatically the size of the elements to best fit with the scene.
  139468. */
  139469. sizeAuto: boolean;
  139470. /**
  139471. * Default position of the rootMesh if autoSize is not true.
  139472. */
  139473. rootPosition: Vector3;
  139474. /**
  139475. * Sets up the image processing in the scene.
  139476. * true by default.
  139477. */
  139478. setupImageProcessing: boolean;
  139479. /**
  139480. * The texture used as your environment texture in the scene.
  139481. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  139482. *
  139483. * Remarks: Can be either a texture or a url.
  139484. */
  139485. environmentTexture: string | BaseTexture;
  139486. /**
  139487. * The value of the exposure to apply to the scene.
  139488. * 0.6 by default if setupImageProcessing is true.
  139489. */
  139490. cameraExposure: number;
  139491. /**
  139492. * The value of the contrast to apply to the scene.
  139493. * 1.6 by default if setupImageProcessing is true.
  139494. */
  139495. cameraContrast: number;
  139496. /**
  139497. * Specifies whether or not tonemapping should be enabled in the scene.
  139498. * true by default if setupImageProcessing is true.
  139499. */
  139500. toneMappingEnabled: boolean;
  139501. }
  139502. /**
  139503. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  139504. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  139505. * It also helps with the default setup of your imageProcessing configuration.
  139506. */
  139507. export class EnvironmentHelper {
  139508. /**
  139509. * Default ground texture URL.
  139510. */
  139511. private static _groundTextureCDNUrl;
  139512. /**
  139513. * Default skybox texture URL.
  139514. */
  139515. private static _skyboxTextureCDNUrl;
  139516. /**
  139517. * Default environment texture URL.
  139518. */
  139519. private static _environmentTextureCDNUrl;
  139520. /**
  139521. * Creates the default options for the helper.
  139522. */
  139523. private static _getDefaultOptions;
  139524. private _rootMesh;
  139525. /**
  139526. * Gets the root mesh created by the helper.
  139527. */
  139528. get rootMesh(): Mesh;
  139529. private _skybox;
  139530. /**
  139531. * Gets the skybox created by the helper.
  139532. */
  139533. get skybox(): Nullable<Mesh>;
  139534. private _skyboxTexture;
  139535. /**
  139536. * Gets the skybox texture created by the helper.
  139537. */
  139538. get skyboxTexture(): Nullable<BaseTexture>;
  139539. private _skyboxMaterial;
  139540. /**
  139541. * Gets the skybox material created by the helper.
  139542. */
  139543. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  139544. private _ground;
  139545. /**
  139546. * Gets the ground mesh created by the helper.
  139547. */
  139548. get ground(): Nullable<Mesh>;
  139549. private _groundTexture;
  139550. /**
  139551. * Gets the ground texture created by the helper.
  139552. */
  139553. get groundTexture(): Nullable<BaseTexture>;
  139554. private _groundMirror;
  139555. /**
  139556. * Gets the ground mirror created by the helper.
  139557. */
  139558. get groundMirror(): Nullable<MirrorTexture>;
  139559. /**
  139560. * Gets the ground mirror render list to helps pushing the meshes
  139561. * you wish in the ground reflection.
  139562. */
  139563. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  139564. private _groundMaterial;
  139565. /**
  139566. * Gets the ground material created by the helper.
  139567. */
  139568. get groundMaterial(): Nullable<BackgroundMaterial>;
  139569. /**
  139570. * Stores the creation options.
  139571. */
  139572. private readonly _scene;
  139573. private _options;
  139574. /**
  139575. * This observable will be notified with any error during the creation of the environment,
  139576. * mainly texture creation errors.
  139577. */
  139578. onErrorObservable: Observable<{
  139579. message?: string;
  139580. exception?: any;
  139581. }>;
  139582. /**
  139583. * constructor
  139584. * @param options Defines the options we want to customize the helper
  139585. * @param scene The scene to add the material to
  139586. */
  139587. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  139588. /**
  139589. * Updates the background according to the new options
  139590. * @param options
  139591. */
  139592. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  139593. /**
  139594. * Sets the primary color of all the available elements.
  139595. * @param color the main color to affect to the ground and the background
  139596. */
  139597. setMainColor(color: Color3): void;
  139598. /**
  139599. * Setup the image processing according to the specified options.
  139600. */
  139601. private _setupImageProcessing;
  139602. /**
  139603. * Setup the environment texture according to the specified options.
  139604. */
  139605. private _setupEnvironmentTexture;
  139606. /**
  139607. * Setup the background according to the specified options.
  139608. */
  139609. private _setupBackground;
  139610. /**
  139611. * Get the scene sizes according to the setup.
  139612. */
  139613. private _getSceneSize;
  139614. /**
  139615. * Setup the ground according to the specified options.
  139616. */
  139617. private _setupGround;
  139618. /**
  139619. * Setup the ground material according to the specified options.
  139620. */
  139621. private _setupGroundMaterial;
  139622. /**
  139623. * Setup the ground diffuse texture according to the specified options.
  139624. */
  139625. private _setupGroundDiffuseTexture;
  139626. /**
  139627. * Setup the ground mirror texture according to the specified options.
  139628. */
  139629. private _setupGroundMirrorTexture;
  139630. /**
  139631. * Setup the ground to receive the mirror texture.
  139632. */
  139633. private _setupMirrorInGroundMaterial;
  139634. /**
  139635. * Setup the skybox according to the specified options.
  139636. */
  139637. private _setupSkybox;
  139638. /**
  139639. * Setup the skybox material according to the specified options.
  139640. */
  139641. private _setupSkyboxMaterial;
  139642. /**
  139643. * Setup the skybox reflection texture according to the specified options.
  139644. */
  139645. private _setupSkyboxReflectionTexture;
  139646. private _errorHandler;
  139647. /**
  139648. * Dispose all the elements created by the Helper.
  139649. */
  139650. dispose(): void;
  139651. }
  139652. }
  139653. declare module BABYLON {
  139654. /**
  139655. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  139656. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  139657. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139658. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139659. */
  139660. export abstract class TextureDome<T extends Texture> extends TransformNode {
  139661. protected onError: Nullable<(message?: string, exception?: any) => void>;
  139662. /**
  139663. * Define the source as a Monoscopic panoramic 360/180.
  139664. */
  139665. static readonly MODE_MONOSCOPIC: number;
  139666. /**
  139667. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  139668. */
  139669. static readonly MODE_TOPBOTTOM: number;
  139670. /**
  139671. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  139672. */
  139673. static readonly MODE_SIDEBYSIDE: number;
  139674. private _halfDome;
  139675. private _crossEye;
  139676. protected _useDirectMapping: boolean;
  139677. /**
  139678. * The texture being displayed on the sphere
  139679. */
  139680. protected _texture: T;
  139681. /**
  139682. * Gets the texture being displayed on the sphere
  139683. */
  139684. get texture(): T;
  139685. /**
  139686. * Sets the texture being displayed on the sphere
  139687. */
  139688. set texture(newTexture: T);
  139689. /**
  139690. * The skybox material
  139691. */
  139692. protected _material: BackgroundMaterial;
  139693. /**
  139694. * The surface used for the dome
  139695. */
  139696. protected _mesh: Mesh;
  139697. /**
  139698. * Gets the mesh used for the dome.
  139699. */
  139700. get mesh(): Mesh;
  139701. /**
  139702. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  139703. */
  139704. private _halfDomeMask;
  139705. /**
  139706. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139707. * Also see the options.resolution property.
  139708. */
  139709. get fovMultiplier(): number;
  139710. set fovMultiplier(value: number);
  139711. protected _textureMode: number;
  139712. /**
  139713. * Gets or set the current texture mode for the texture. It can be:
  139714. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139715. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139716. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139717. */
  139718. get textureMode(): number;
  139719. /**
  139720. * Sets the current texture mode for the texture. It can be:
  139721. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139722. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139723. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139724. */
  139725. set textureMode(value: number);
  139726. /**
  139727. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  139728. */
  139729. get halfDome(): boolean;
  139730. /**
  139731. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  139732. */
  139733. set halfDome(enabled: boolean);
  139734. /**
  139735. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  139736. */
  139737. set crossEye(enabled: boolean);
  139738. /**
  139739. * Is it a cross-eye texture?
  139740. */
  139741. get crossEye(): boolean;
  139742. /**
  139743. * The background material of this dome.
  139744. */
  139745. get material(): BackgroundMaterial;
  139746. /**
  139747. * Oberserver used in Stereoscopic VR Mode.
  139748. */
  139749. private _onBeforeCameraRenderObserver;
  139750. /**
  139751. * Observable raised when an error occured while loading the 360 image
  139752. */
  139753. onLoadErrorObservable: Observable<string>;
  139754. /**
  139755. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  139756. * @param name Element's name, child elements will append suffixes for their own names.
  139757. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  139758. * @param options An object containing optional or exposed sub element properties
  139759. */
  139760. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  139761. resolution?: number;
  139762. clickToPlay?: boolean;
  139763. autoPlay?: boolean;
  139764. loop?: boolean;
  139765. size?: number;
  139766. poster?: string;
  139767. faceForward?: boolean;
  139768. useDirectMapping?: boolean;
  139769. halfDomeMode?: boolean;
  139770. crossEyeMode?: boolean;
  139771. generateMipMaps?: boolean;
  139772. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  139773. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  139774. protected _changeTextureMode(value: number): void;
  139775. /**
  139776. * Releases resources associated with this node.
  139777. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  139778. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  139779. */
  139780. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  139781. }
  139782. }
  139783. declare module BABYLON {
  139784. /**
  139785. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  139786. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  139787. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139788. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139789. */
  139790. export class PhotoDome extends TextureDome<Texture> {
  139791. /**
  139792. * Define the image as a Monoscopic panoramic 360 image.
  139793. */
  139794. static readonly MODE_MONOSCOPIC: number;
  139795. /**
  139796. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  139797. */
  139798. static readonly MODE_TOPBOTTOM: number;
  139799. /**
  139800. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  139801. */
  139802. static readonly MODE_SIDEBYSIDE: number;
  139803. /**
  139804. * Gets or sets the texture being displayed on the sphere
  139805. */
  139806. get photoTexture(): Texture;
  139807. /**
  139808. * sets the texture being displayed on the sphere
  139809. */
  139810. set photoTexture(value: Texture);
  139811. /**
  139812. * Gets the current video mode for the video. It can be:
  139813. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139814. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139815. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139816. */
  139817. get imageMode(): number;
  139818. /**
  139819. * Sets the current video mode for the video. It can be:
  139820. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139821. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139822. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139823. */
  139824. set imageMode(value: number);
  139825. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139826. }
  139827. }
  139828. declare module BABYLON {
  139829. /**
  139830. * Direct draw surface info
  139831. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139832. */
  139833. export interface DDSInfo {
  139834. /**
  139835. * Width of the texture
  139836. */
  139837. width: number;
  139838. /**
  139839. * Width of the texture
  139840. */
  139841. height: number;
  139842. /**
  139843. * Number of Mipmaps for the texture
  139844. * @see https://en.wikipedia.org/wiki/Mipmap
  139845. */
  139846. mipmapCount: number;
  139847. /**
  139848. * If the textures format is a known fourCC format
  139849. * @see https://www.fourcc.org/
  139850. */
  139851. isFourCC: boolean;
  139852. /**
  139853. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139854. */
  139855. isRGB: boolean;
  139856. /**
  139857. * If the texture is a lumincance format
  139858. */
  139859. isLuminance: boolean;
  139860. /**
  139861. * If this is a cube texture
  139862. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139863. */
  139864. isCube: boolean;
  139865. /**
  139866. * If the texture is a compressed format eg. FOURCC_DXT1
  139867. */
  139868. isCompressed: boolean;
  139869. /**
  139870. * The dxgiFormat of the texture
  139871. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139872. */
  139873. dxgiFormat: number;
  139874. /**
  139875. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139876. */
  139877. textureType: number;
  139878. /**
  139879. * Sphericle polynomial created for the dds texture
  139880. */
  139881. sphericalPolynomial?: SphericalPolynomial;
  139882. }
  139883. /**
  139884. * Class used to provide DDS decompression tools
  139885. */
  139886. export class DDSTools {
  139887. /**
  139888. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139889. */
  139890. static StoreLODInAlphaChannel: boolean;
  139891. /**
  139892. * Gets DDS information from an array buffer
  139893. * @param data defines the array buffer view to read data from
  139894. * @returns the DDS information
  139895. */
  139896. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139897. private static _FloatView;
  139898. private static _Int32View;
  139899. private static _ToHalfFloat;
  139900. private static _FromHalfFloat;
  139901. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139902. private static _GetHalfFloatRGBAArrayBuffer;
  139903. private static _GetFloatRGBAArrayBuffer;
  139904. private static _GetFloatAsUIntRGBAArrayBuffer;
  139905. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139906. private static _GetRGBAArrayBuffer;
  139907. private static _ExtractLongWordOrder;
  139908. private static _GetRGBArrayBuffer;
  139909. private static _GetLuminanceArrayBuffer;
  139910. /**
  139911. * Uploads DDS Levels to a Babylon Texture
  139912. * @hidden
  139913. */
  139914. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139915. }
  139916. interface ThinEngine {
  139917. /**
  139918. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139919. * @param rootUrl defines the url where the file to load is located
  139920. * @param scene defines the current scene
  139921. * @param lodScale defines scale to apply to the mip map selection
  139922. * @param lodOffset defines offset to apply to the mip map selection
  139923. * @param onLoad defines an optional callback raised when the texture is loaded
  139924. * @param onError defines an optional callback raised if there is an issue to load the texture
  139925. * @param format defines the format of the data
  139926. * @param forcedExtension defines the extension to use to pick the right loader
  139927. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139928. * @returns the cube texture as an InternalTexture
  139929. */
  139930. 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;
  139931. }
  139932. }
  139933. declare module BABYLON {
  139934. /**
  139935. * Implementation of the DDS Texture Loader.
  139936. * @hidden
  139937. */
  139938. export class _DDSTextureLoader implements IInternalTextureLoader {
  139939. /**
  139940. * Defines wether the loader supports cascade loading the different faces.
  139941. */
  139942. readonly supportCascades: boolean;
  139943. /**
  139944. * This returns if the loader support the current file information.
  139945. * @param extension defines the file extension of the file being loaded
  139946. * @returns true if the loader can load the specified file
  139947. */
  139948. canLoad(extension: string): boolean;
  139949. /**
  139950. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139951. * @param data contains the texture data
  139952. * @param texture defines the BabylonJS internal texture
  139953. * @param createPolynomials will be true if polynomials have been requested
  139954. * @param onLoad defines the callback to trigger once the texture is ready
  139955. * @param onError defines the callback to trigger in case of error
  139956. */
  139957. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139958. /**
  139959. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139960. * @param data contains the texture data
  139961. * @param texture defines the BabylonJS internal texture
  139962. * @param callback defines the method to call once ready to upload
  139963. */
  139964. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139965. }
  139966. }
  139967. declare module BABYLON {
  139968. /**
  139969. * Implementation of the ENV Texture Loader.
  139970. * @hidden
  139971. */
  139972. export class _ENVTextureLoader implements IInternalTextureLoader {
  139973. /**
  139974. * Defines wether the loader supports cascade loading the different faces.
  139975. */
  139976. readonly supportCascades: boolean;
  139977. /**
  139978. * This returns if the loader support the current file information.
  139979. * @param extension defines the file extension of the file being loaded
  139980. * @returns true if the loader can load the specified file
  139981. */
  139982. canLoad(extension: string): boolean;
  139983. /**
  139984. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139985. * @param data contains the texture data
  139986. * @param texture defines the BabylonJS internal texture
  139987. * @param createPolynomials will be true if polynomials have been requested
  139988. * @param onLoad defines the callback to trigger once the texture is ready
  139989. * @param onError defines the callback to trigger in case of error
  139990. */
  139991. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139992. /**
  139993. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139994. * @param data contains the texture data
  139995. * @param texture defines the BabylonJS internal texture
  139996. * @param callback defines the method to call once ready to upload
  139997. */
  139998. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139999. }
  140000. }
  140001. declare module BABYLON {
  140002. /**
  140003. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  140004. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  140005. */
  140006. export class KhronosTextureContainer {
  140007. /** contents of the KTX container file */
  140008. data: ArrayBufferView;
  140009. private static HEADER_LEN;
  140010. private static COMPRESSED_2D;
  140011. private static COMPRESSED_3D;
  140012. private static TEX_2D;
  140013. private static TEX_3D;
  140014. /**
  140015. * Gets the openGL type
  140016. */
  140017. glType: number;
  140018. /**
  140019. * Gets the openGL type size
  140020. */
  140021. glTypeSize: number;
  140022. /**
  140023. * Gets the openGL format
  140024. */
  140025. glFormat: number;
  140026. /**
  140027. * Gets the openGL internal format
  140028. */
  140029. glInternalFormat: number;
  140030. /**
  140031. * Gets the base internal format
  140032. */
  140033. glBaseInternalFormat: number;
  140034. /**
  140035. * Gets image width in pixel
  140036. */
  140037. pixelWidth: number;
  140038. /**
  140039. * Gets image height in pixel
  140040. */
  140041. pixelHeight: number;
  140042. /**
  140043. * Gets image depth in pixels
  140044. */
  140045. pixelDepth: number;
  140046. /**
  140047. * Gets the number of array elements
  140048. */
  140049. numberOfArrayElements: number;
  140050. /**
  140051. * Gets the number of faces
  140052. */
  140053. numberOfFaces: number;
  140054. /**
  140055. * Gets the number of mipmap levels
  140056. */
  140057. numberOfMipmapLevels: number;
  140058. /**
  140059. * Gets the bytes of key value data
  140060. */
  140061. bytesOfKeyValueData: number;
  140062. /**
  140063. * Gets the load type
  140064. */
  140065. loadType: number;
  140066. /**
  140067. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140068. */
  140069. isInvalid: boolean;
  140070. /**
  140071. * Creates a new KhronosTextureContainer
  140072. * @param data contents of the KTX container file
  140073. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140074. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140075. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140076. */
  140077. constructor(
  140078. /** contents of the KTX container file */
  140079. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  140080. /**
  140081. * Uploads KTX content to a Babylon Texture.
  140082. * It is assumed that the texture has already been created & is currently bound
  140083. * @hidden
  140084. */
  140085. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  140086. private _upload2DCompressedLevels;
  140087. /**
  140088. * Checks if the given data starts with a KTX file identifier.
  140089. * @param data the data to check
  140090. * @returns true if the data is a KTX file or false otherwise
  140091. */
  140092. static IsValid(data: ArrayBufferView): boolean;
  140093. }
  140094. }
  140095. declare module BABYLON {
  140096. /**
  140097. * Helper class to push actions to a pool of workers.
  140098. */
  140099. export class WorkerPool implements IDisposable {
  140100. private _workerInfos;
  140101. private _pendingActions;
  140102. /**
  140103. * Constructor
  140104. * @param workers Array of workers to use for actions
  140105. */
  140106. constructor(workers: Array<Worker>);
  140107. /**
  140108. * Terminates all workers and clears any pending actions.
  140109. */
  140110. dispose(): void;
  140111. /**
  140112. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140113. * pended until a worker has completed its action.
  140114. * @param action The action to perform. Call onComplete when the action is complete.
  140115. */
  140116. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140117. private _execute;
  140118. }
  140119. }
  140120. declare module BABYLON {
  140121. /**
  140122. * Class for loading KTX2 files
  140123. */
  140124. export class KhronosTextureContainer2 {
  140125. private static _WorkerPoolPromise?;
  140126. private static _Initialized;
  140127. private static _Ktx2Decoder;
  140128. /**
  140129. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140130. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140131. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140132. * Urls you can change:
  140133. * URLConfig.jsDecoderModule
  140134. * URLConfig.wasmUASTCToASTC
  140135. * URLConfig.wasmUASTCToBC7
  140136. * URLConfig.wasmUASTCToRGBA_UNORM
  140137. * URLConfig.wasmUASTCToRGBA_SRGB
  140138. * URLConfig.jsMSCTranscoder
  140139. * URLConfig.wasmMSCTranscoder
  140140. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140141. */
  140142. static URLConfig: {
  140143. jsDecoderModule: string;
  140144. wasmUASTCToASTC: null;
  140145. wasmUASTCToBC7: null;
  140146. wasmUASTCToRGBA_UNORM: null;
  140147. wasmUASTCToRGBA_SRGB: null;
  140148. jsMSCTranscoder: null;
  140149. wasmMSCTranscoder: null;
  140150. };
  140151. /**
  140152. * Default number of workers used to handle data decoding
  140153. */
  140154. static DefaultNumWorkers: number;
  140155. private static GetDefaultNumWorkers;
  140156. private _engine;
  140157. private static _CreateWorkerPool;
  140158. /**
  140159. * Constructor
  140160. * @param engine The engine to use
  140161. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140162. */
  140163. constructor(engine: ThinEngine, numWorkers?: number);
  140164. /** @hidden */
  140165. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140166. /**
  140167. * Stop all async operations and release resources.
  140168. */
  140169. dispose(): void;
  140170. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  140171. /**
  140172. * Checks if the given data starts with a KTX2 file identifier.
  140173. * @param data the data to check
  140174. * @returns true if the data is a KTX2 file or false otherwise
  140175. */
  140176. static IsValid(data: ArrayBufferView): boolean;
  140177. }
  140178. }
  140179. declare module BABYLON {
  140180. /**
  140181. * Implementation of the KTX Texture Loader.
  140182. * @hidden
  140183. */
  140184. export class _KTXTextureLoader implements IInternalTextureLoader {
  140185. /**
  140186. * Defines wether the loader supports cascade loading the different faces.
  140187. */
  140188. readonly supportCascades: boolean;
  140189. /**
  140190. * This returns if the loader support the current file information.
  140191. * @param extension defines the file extension of the file being loaded
  140192. * @param mimeType defines the optional mime type of the file being loaded
  140193. * @returns true if the loader can load the specified file
  140194. */
  140195. canLoad(extension: string, mimeType?: string): boolean;
  140196. /**
  140197. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140198. * @param data contains the texture data
  140199. * @param texture defines the BabylonJS internal texture
  140200. * @param createPolynomials will be true if polynomials have been requested
  140201. * @param onLoad defines the callback to trigger once the texture is ready
  140202. * @param onError defines the callback to trigger in case of error
  140203. */
  140204. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140205. /**
  140206. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140207. * @param data contains the texture data
  140208. * @param texture defines the BabylonJS internal texture
  140209. * @param callback defines the method to call once ready to upload
  140210. */
  140211. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  140212. }
  140213. }
  140214. declare module BABYLON {
  140215. /** @hidden */
  140216. export var _forceSceneHelpersToBundle: boolean;
  140217. interface Scene {
  140218. /**
  140219. * Creates a default light for the scene.
  140220. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  140221. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  140222. */
  140223. createDefaultLight(replace?: boolean): void;
  140224. /**
  140225. * Creates a default camera for the scene.
  140226. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  140227. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140228. * @param replace has default false, when true replaces the active camera in the scene
  140229. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  140230. */
  140231. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140232. /**
  140233. * Creates a default camera and a default light.
  140234. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  140235. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140236. * @param replace has the default false, when true replaces the active camera/light in the scene
  140237. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  140238. */
  140239. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140240. /**
  140241. * Creates a new sky box
  140242. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  140243. * @param environmentTexture defines the texture to use as environment texture
  140244. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  140245. * @param scale defines the overall scale of the skybox
  140246. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  140247. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  140248. * @returns a new mesh holding the sky box
  140249. */
  140250. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  140251. /**
  140252. * Creates a new environment
  140253. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  140254. * @param options defines the options you can use to configure the environment
  140255. * @returns the new EnvironmentHelper
  140256. */
  140257. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  140258. /**
  140259. * Creates a new VREXperienceHelper
  140260. * @see https://doc.babylonjs.com/how_to/webvr_helper
  140261. * @param webVROptions defines the options used to create the new VREXperienceHelper
  140262. * @returns a new VREXperienceHelper
  140263. */
  140264. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  140265. /**
  140266. * Creates a new WebXRDefaultExperience
  140267. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  140268. * @param options experience options
  140269. * @returns a promise for a new WebXRDefaultExperience
  140270. */
  140271. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140272. }
  140273. }
  140274. declare module BABYLON {
  140275. /**
  140276. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  140277. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  140278. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  140279. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140280. */
  140281. export class VideoDome extends TextureDome<VideoTexture> {
  140282. /**
  140283. * Define the video source as a Monoscopic panoramic 360 video.
  140284. */
  140285. static readonly MODE_MONOSCOPIC: number;
  140286. /**
  140287. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  140288. */
  140289. static readonly MODE_TOPBOTTOM: number;
  140290. /**
  140291. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  140292. */
  140293. static readonly MODE_SIDEBYSIDE: number;
  140294. /**
  140295. * Get the video texture associated with this video dome
  140296. */
  140297. get videoTexture(): VideoTexture;
  140298. /**
  140299. * Get the video mode of this dome
  140300. */
  140301. get videoMode(): number;
  140302. /**
  140303. * Set the video mode of this dome.
  140304. * @see textureMode
  140305. */
  140306. set videoMode(value: number);
  140307. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  140308. }
  140309. }
  140310. declare module BABYLON {
  140311. /**
  140312. * This class can be used to get instrumentation data from a Babylon engine
  140313. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140314. */
  140315. export class EngineInstrumentation implements IDisposable {
  140316. /**
  140317. * Define the instrumented engine.
  140318. */
  140319. engine: Engine;
  140320. private _captureGPUFrameTime;
  140321. private _gpuFrameTimeToken;
  140322. private _gpuFrameTime;
  140323. private _captureShaderCompilationTime;
  140324. private _shaderCompilationTime;
  140325. private _onBeginFrameObserver;
  140326. private _onEndFrameObserver;
  140327. private _onBeforeShaderCompilationObserver;
  140328. private _onAfterShaderCompilationObserver;
  140329. /**
  140330. * Gets the perf counter used for GPU frame time
  140331. */
  140332. get gpuFrameTimeCounter(): PerfCounter;
  140333. /**
  140334. * Gets the GPU frame time capture status
  140335. */
  140336. get captureGPUFrameTime(): boolean;
  140337. /**
  140338. * Enable or disable the GPU frame time capture
  140339. */
  140340. set captureGPUFrameTime(value: boolean);
  140341. /**
  140342. * Gets the perf counter used for shader compilation time
  140343. */
  140344. get shaderCompilationTimeCounter(): PerfCounter;
  140345. /**
  140346. * Gets the shader compilation time capture status
  140347. */
  140348. get captureShaderCompilationTime(): boolean;
  140349. /**
  140350. * Enable or disable the shader compilation time capture
  140351. */
  140352. set captureShaderCompilationTime(value: boolean);
  140353. /**
  140354. * Instantiates a new engine instrumentation.
  140355. * This class can be used to get instrumentation data from a Babylon engine
  140356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140357. * @param engine Defines the engine to instrument
  140358. */
  140359. constructor(
  140360. /**
  140361. * Define the instrumented engine.
  140362. */
  140363. engine: Engine);
  140364. /**
  140365. * Dispose and release associated resources.
  140366. */
  140367. dispose(): void;
  140368. }
  140369. }
  140370. declare module BABYLON {
  140371. /**
  140372. * This class can be used to get instrumentation data from a Babylon engine
  140373. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140374. */
  140375. export class SceneInstrumentation implements IDisposable {
  140376. /**
  140377. * Defines the scene to instrument
  140378. */
  140379. scene: Scene;
  140380. private _captureActiveMeshesEvaluationTime;
  140381. private _activeMeshesEvaluationTime;
  140382. private _captureRenderTargetsRenderTime;
  140383. private _renderTargetsRenderTime;
  140384. private _captureFrameTime;
  140385. private _frameTime;
  140386. private _captureRenderTime;
  140387. private _renderTime;
  140388. private _captureInterFrameTime;
  140389. private _interFrameTime;
  140390. private _captureParticlesRenderTime;
  140391. private _particlesRenderTime;
  140392. private _captureSpritesRenderTime;
  140393. private _spritesRenderTime;
  140394. private _capturePhysicsTime;
  140395. private _physicsTime;
  140396. private _captureAnimationsTime;
  140397. private _animationsTime;
  140398. private _captureCameraRenderTime;
  140399. private _cameraRenderTime;
  140400. private _onBeforeActiveMeshesEvaluationObserver;
  140401. private _onAfterActiveMeshesEvaluationObserver;
  140402. private _onBeforeRenderTargetsRenderObserver;
  140403. private _onAfterRenderTargetsRenderObserver;
  140404. private _onAfterRenderObserver;
  140405. private _onBeforeDrawPhaseObserver;
  140406. private _onAfterDrawPhaseObserver;
  140407. private _onBeforeAnimationsObserver;
  140408. private _onBeforeParticlesRenderingObserver;
  140409. private _onAfterParticlesRenderingObserver;
  140410. private _onBeforeSpritesRenderingObserver;
  140411. private _onAfterSpritesRenderingObserver;
  140412. private _onBeforePhysicsObserver;
  140413. private _onAfterPhysicsObserver;
  140414. private _onAfterAnimationsObserver;
  140415. private _onBeforeCameraRenderObserver;
  140416. private _onAfterCameraRenderObserver;
  140417. /**
  140418. * Gets the perf counter used for active meshes evaluation time
  140419. */
  140420. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  140421. /**
  140422. * Gets the active meshes evaluation time capture status
  140423. */
  140424. get captureActiveMeshesEvaluationTime(): boolean;
  140425. /**
  140426. * Enable or disable the active meshes evaluation time capture
  140427. */
  140428. set captureActiveMeshesEvaluationTime(value: boolean);
  140429. /**
  140430. * Gets the perf counter used for render targets render time
  140431. */
  140432. get renderTargetsRenderTimeCounter(): PerfCounter;
  140433. /**
  140434. * Gets the render targets render time capture status
  140435. */
  140436. get captureRenderTargetsRenderTime(): boolean;
  140437. /**
  140438. * Enable or disable the render targets render time capture
  140439. */
  140440. set captureRenderTargetsRenderTime(value: boolean);
  140441. /**
  140442. * Gets the perf counter used for particles render time
  140443. */
  140444. get particlesRenderTimeCounter(): PerfCounter;
  140445. /**
  140446. * Gets the particles render time capture status
  140447. */
  140448. get captureParticlesRenderTime(): boolean;
  140449. /**
  140450. * Enable or disable the particles render time capture
  140451. */
  140452. set captureParticlesRenderTime(value: boolean);
  140453. /**
  140454. * Gets the perf counter used for sprites render time
  140455. */
  140456. get spritesRenderTimeCounter(): PerfCounter;
  140457. /**
  140458. * Gets the sprites render time capture status
  140459. */
  140460. get captureSpritesRenderTime(): boolean;
  140461. /**
  140462. * Enable or disable the sprites render time capture
  140463. */
  140464. set captureSpritesRenderTime(value: boolean);
  140465. /**
  140466. * Gets the perf counter used for physics time
  140467. */
  140468. get physicsTimeCounter(): PerfCounter;
  140469. /**
  140470. * Gets the physics time capture status
  140471. */
  140472. get capturePhysicsTime(): boolean;
  140473. /**
  140474. * Enable or disable the physics time capture
  140475. */
  140476. set capturePhysicsTime(value: boolean);
  140477. /**
  140478. * Gets the perf counter used for animations time
  140479. */
  140480. get animationsTimeCounter(): PerfCounter;
  140481. /**
  140482. * Gets the animations time capture status
  140483. */
  140484. get captureAnimationsTime(): boolean;
  140485. /**
  140486. * Enable or disable the animations time capture
  140487. */
  140488. set captureAnimationsTime(value: boolean);
  140489. /**
  140490. * Gets the perf counter used for frame time capture
  140491. */
  140492. get frameTimeCounter(): PerfCounter;
  140493. /**
  140494. * Gets the frame time capture status
  140495. */
  140496. get captureFrameTime(): boolean;
  140497. /**
  140498. * Enable or disable the frame time capture
  140499. */
  140500. set captureFrameTime(value: boolean);
  140501. /**
  140502. * Gets the perf counter used for inter-frames time capture
  140503. */
  140504. get interFrameTimeCounter(): PerfCounter;
  140505. /**
  140506. * Gets the inter-frames time capture status
  140507. */
  140508. get captureInterFrameTime(): boolean;
  140509. /**
  140510. * Enable or disable the inter-frames time capture
  140511. */
  140512. set captureInterFrameTime(value: boolean);
  140513. /**
  140514. * Gets the perf counter used for render time capture
  140515. */
  140516. get renderTimeCounter(): PerfCounter;
  140517. /**
  140518. * Gets the render time capture status
  140519. */
  140520. get captureRenderTime(): boolean;
  140521. /**
  140522. * Enable or disable the render time capture
  140523. */
  140524. set captureRenderTime(value: boolean);
  140525. /**
  140526. * Gets the perf counter used for camera render time capture
  140527. */
  140528. get cameraRenderTimeCounter(): PerfCounter;
  140529. /**
  140530. * Gets the camera render time capture status
  140531. */
  140532. get captureCameraRenderTime(): boolean;
  140533. /**
  140534. * Enable or disable the camera render time capture
  140535. */
  140536. set captureCameraRenderTime(value: boolean);
  140537. /**
  140538. * Gets the perf counter used for draw calls
  140539. */
  140540. get drawCallsCounter(): PerfCounter;
  140541. /**
  140542. * Instantiates a new scene instrumentation.
  140543. * This class can be used to get instrumentation data from a Babylon engine
  140544. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140545. * @param scene Defines the scene to instrument
  140546. */
  140547. constructor(
  140548. /**
  140549. * Defines the scene to instrument
  140550. */
  140551. scene: Scene);
  140552. /**
  140553. * Dispose and release associated resources.
  140554. */
  140555. dispose(): void;
  140556. }
  140557. }
  140558. declare module BABYLON {
  140559. /** @hidden */
  140560. export var glowMapGenerationPixelShader: {
  140561. name: string;
  140562. shader: string;
  140563. };
  140564. }
  140565. declare module BABYLON {
  140566. /** @hidden */
  140567. export var glowMapGenerationVertexShader: {
  140568. name: string;
  140569. shader: string;
  140570. };
  140571. }
  140572. declare module BABYLON {
  140573. /**
  140574. * Effect layer options. This helps customizing the behaviour
  140575. * of the effect layer.
  140576. */
  140577. export interface IEffectLayerOptions {
  140578. /**
  140579. * Multiplication factor apply to the canvas size to compute the render target size
  140580. * used to generated the objects (the smaller the faster).
  140581. */
  140582. mainTextureRatio: number;
  140583. /**
  140584. * Enforces a fixed size texture to ensure effect stability across devices.
  140585. */
  140586. mainTextureFixedSize?: number;
  140587. /**
  140588. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  140589. */
  140590. alphaBlendingMode: number;
  140591. /**
  140592. * The camera attached to the layer.
  140593. */
  140594. camera: Nullable<Camera>;
  140595. /**
  140596. * The rendering group to draw the layer in.
  140597. */
  140598. renderingGroupId: number;
  140599. }
  140600. /**
  140601. * The effect layer Helps adding post process effect blended with the main pass.
  140602. *
  140603. * This can be for instance use to generate glow or higlight effects on the scene.
  140604. *
  140605. * The effect layer class can not be used directly and is intented to inherited from to be
  140606. * customized per effects.
  140607. */
  140608. export abstract class EffectLayer {
  140609. private _vertexBuffers;
  140610. private _indexBuffer;
  140611. private _cachedDefines;
  140612. private _effectLayerMapGenerationEffect;
  140613. private _effectLayerOptions;
  140614. private _mergeEffect;
  140615. protected _scene: Scene;
  140616. protected _engine: Engine;
  140617. protected _maxSize: number;
  140618. protected _mainTextureDesiredSize: ISize;
  140619. protected _mainTexture: RenderTargetTexture;
  140620. protected _shouldRender: boolean;
  140621. protected _postProcesses: PostProcess[];
  140622. protected _textures: BaseTexture[];
  140623. protected _emissiveTextureAndColor: {
  140624. texture: Nullable<BaseTexture>;
  140625. color: Color4;
  140626. };
  140627. /**
  140628. * The name of the layer
  140629. */
  140630. name: string;
  140631. /**
  140632. * The clear color of the texture used to generate the glow map.
  140633. */
  140634. neutralColor: Color4;
  140635. /**
  140636. * Specifies whether the highlight layer is enabled or not.
  140637. */
  140638. isEnabled: boolean;
  140639. /**
  140640. * Gets the camera attached to the layer.
  140641. */
  140642. get camera(): Nullable<Camera>;
  140643. /**
  140644. * Gets the rendering group id the layer should render in.
  140645. */
  140646. get renderingGroupId(): number;
  140647. set renderingGroupId(renderingGroupId: number);
  140648. /**
  140649. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  140650. */
  140651. disableBoundingBoxesFromEffectLayer: boolean;
  140652. /**
  140653. * An event triggered when the effect layer has been disposed.
  140654. */
  140655. onDisposeObservable: Observable<EffectLayer>;
  140656. /**
  140657. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  140658. */
  140659. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  140660. /**
  140661. * An event triggered when the generated texture is being merged in the scene.
  140662. */
  140663. onBeforeComposeObservable: Observable<EffectLayer>;
  140664. /**
  140665. * An event triggered when the mesh is rendered into the effect render target.
  140666. */
  140667. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  140668. /**
  140669. * An event triggered after the mesh has been rendered into the effect render target.
  140670. */
  140671. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  140672. /**
  140673. * An event triggered when the generated texture has been merged in the scene.
  140674. */
  140675. onAfterComposeObservable: Observable<EffectLayer>;
  140676. /**
  140677. * An event triggered when the efffect layer changes its size.
  140678. */
  140679. onSizeChangedObservable: Observable<EffectLayer>;
  140680. /** @hidden */
  140681. static _SceneComponentInitialization: (scene: Scene) => void;
  140682. /**
  140683. * Instantiates a new effect Layer and references it in the scene.
  140684. * @param name The name of the layer
  140685. * @param scene The scene to use the layer in
  140686. */
  140687. constructor(
  140688. /** The Friendly of the effect in the scene */
  140689. name: string, scene: Scene);
  140690. /**
  140691. * Get the effect name of the layer.
  140692. * @return The effect name
  140693. */
  140694. abstract getEffectName(): string;
  140695. /**
  140696. * Checks for the readiness of the element composing the layer.
  140697. * @param subMesh the mesh to check for
  140698. * @param useInstances specify whether or not to use instances to render the mesh
  140699. * @return true if ready otherwise, false
  140700. */
  140701. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140702. /**
  140703. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140704. * @returns true if the effect requires stencil during the main canvas render pass.
  140705. */
  140706. abstract needStencil(): boolean;
  140707. /**
  140708. * Create the merge effect. This is the shader use to blit the information back
  140709. * to the main canvas at the end of the scene rendering.
  140710. * @returns The effect containing the shader used to merge the effect on the main canvas
  140711. */
  140712. protected abstract _createMergeEffect(): Effect;
  140713. /**
  140714. * Creates the render target textures and post processes used in the effect layer.
  140715. */
  140716. protected abstract _createTextureAndPostProcesses(): void;
  140717. /**
  140718. * Implementation specific of rendering the generating effect on the main canvas.
  140719. * @param effect The effect used to render through
  140720. */
  140721. protected abstract _internalRender(effect: Effect): void;
  140722. /**
  140723. * Sets the required values for both the emissive texture and and the main color.
  140724. */
  140725. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140726. /**
  140727. * Free any resources and references associated to a mesh.
  140728. * Internal use
  140729. * @param mesh The mesh to free.
  140730. */
  140731. abstract _disposeMesh(mesh: Mesh): void;
  140732. /**
  140733. * Serializes this layer (Glow or Highlight for example)
  140734. * @returns a serialized layer object
  140735. */
  140736. abstract serialize?(): any;
  140737. /**
  140738. * Initializes the effect layer with the required options.
  140739. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  140740. */
  140741. protected _init(options: Partial<IEffectLayerOptions>): void;
  140742. /**
  140743. * Generates the index buffer of the full screen quad blending to the main canvas.
  140744. */
  140745. private _generateIndexBuffer;
  140746. /**
  140747. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  140748. */
  140749. private _generateVertexBuffer;
  140750. /**
  140751. * Sets the main texture desired size which is the closest power of two
  140752. * of the engine canvas size.
  140753. */
  140754. private _setMainTextureSize;
  140755. /**
  140756. * Creates the main texture for the effect layer.
  140757. */
  140758. protected _createMainTexture(): void;
  140759. /**
  140760. * Adds specific effects defines.
  140761. * @param defines The defines to add specifics to.
  140762. */
  140763. protected _addCustomEffectDefines(defines: string[]): void;
  140764. /**
  140765. * Checks for the readiness of the element composing the layer.
  140766. * @param subMesh the mesh to check for
  140767. * @param useInstances specify whether or not to use instances to render the mesh
  140768. * @param emissiveTexture the associated emissive texture used to generate the glow
  140769. * @return true if ready otherwise, false
  140770. */
  140771. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  140772. /**
  140773. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  140774. */
  140775. render(): void;
  140776. /**
  140777. * Determine if a given mesh will be used in the current effect.
  140778. * @param mesh mesh to test
  140779. * @returns true if the mesh will be used
  140780. */
  140781. hasMesh(mesh: AbstractMesh): boolean;
  140782. /**
  140783. * Returns true if the layer contains information to display, otherwise false.
  140784. * @returns true if the glow layer should be rendered
  140785. */
  140786. shouldRender(): boolean;
  140787. /**
  140788. * Returns true if the mesh should render, otherwise false.
  140789. * @param mesh The mesh to render
  140790. * @returns true if it should render otherwise false
  140791. */
  140792. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  140793. /**
  140794. * Returns true if the mesh can be rendered, otherwise false.
  140795. * @param mesh The mesh to render
  140796. * @param material The material used on the mesh
  140797. * @returns true if it can be rendered otherwise false
  140798. */
  140799. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140800. /**
  140801. * Returns true if the mesh should render, otherwise false.
  140802. * @param mesh The mesh to render
  140803. * @returns true if it should render otherwise false
  140804. */
  140805. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  140806. /**
  140807. * Renders the submesh passed in parameter to the generation map.
  140808. */
  140809. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  140810. /**
  140811. * Defines whether the current material of the mesh should be use to render the effect.
  140812. * @param mesh defines the current mesh to render
  140813. */
  140814. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140815. /**
  140816. * Rebuild the required buffers.
  140817. * @hidden Internal use only.
  140818. */
  140819. _rebuild(): void;
  140820. /**
  140821. * Dispose only the render target textures and post process.
  140822. */
  140823. private _disposeTextureAndPostProcesses;
  140824. /**
  140825. * Dispose the highlight layer and free resources.
  140826. */
  140827. dispose(): void;
  140828. /**
  140829. * Gets the class name of the effect layer
  140830. * @returns the string with the class name of the effect layer
  140831. */
  140832. getClassName(): string;
  140833. /**
  140834. * Creates an effect layer from parsed effect layer data
  140835. * @param parsedEffectLayer defines effect layer data
  140836. * @param scene defines the current scene
  140837. * @param rootUrl defines the root URL containing the effect layer information
  140838. * @returns a parsed effect Layer
  140839. */
  140840. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140841. }
  140842. }
  140843. declare module BABYLON {
  140844. interface AbstractScene {
  140845. /**
  140846. * The list of effect layers (highlights/glow) added to the scene
  140847. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140848. * @see https://doc.babylonjs.com/how_to/glow_layer
  140849. */
  140850. effectLayers: Array<EffectLayer>;
  140851. /**
  140852. * Removes the given effect layer from this scene.
  140853. * @param toRemove defines the effect layer to remove
  140854. * @returns the index of the removed effect layer
  140855. */
  140856. removeEffectLayer(toRemove: EffectLayer): number;
  140857. /**
  140858. * Adds the given effect layer to this scene
  140859. * @param newEffectLayer defines the effect layer to add
  140860. */
  140861. addEffectLayer(newEffectLayer: EffectLayer): void;
  140862. }
  140863. /**
  140864. * Defines the layer scene component responsible to manage any effect layers
  140865. * in a given scene.
  140866. */
  140867. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140868. /**
  140869. * The component name helpfull to identify the component in the list of scene components.
  140870. */
  140871. readonly name: string;
  140872. /**
  140873. * The scene the component belongs to.
  140874. */
  140875. scene: Scene;
  140876. private _engine;
  140877. private _renderEffects;
  140878. private _needStencil;
  140879. private _previousStencilState;
  140880. /**
  140881. * Creates a new instance of the component for the given scene
  140882. * @param scene Defines the scene to register the component in
  140883. */
  140884. constructor(scene: Scene);
  140885. /**
  140886. * Registers the component in a given scene
  140887. */
  140888. register(): void;
  140889. /**
  140890. * Rebuilds the elements related to this component in case of
  140891. * context lost for instance.
  140892. */
  140893. rebuild(): void;
  140894. /**
  140895. * Serializes the component data to the specified json object
  140896. * @param serializationObject The object to serialize to
  140897. */
  140898. serialize(serializationObject: any): void;
  140899. /**
  140900. * Adds all the elements from the container to the scene
  140901. * @param container the container holding the elements
  140902. */
  140903. addFromContainer(container: AbstractScene): void;
  140904. /**
  140905. * Removes all the elements in the container from the scene
  140906. * @param container contains the elements to remove
  140907. * @param dispose if the removed element should be disposed (default: false)
  140908. */
  140909. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140910. /**
  140911. * Disposes the component and the associated ressources.
  140912. */
  140913. dispose(): void;
  140914. private _isReadyForMesh;
  140915. private _renderMainTexture;
  140916. private _setStencil;
  140917. private _setStencilBack;
  140918. private _draw;
  140919. private _drawCamera;
  140920. private _drawRenderingGroup;
  140921. }
  140922. }
  140923. declare module BABYLON {
  140924. /** @hidden */
  140925. export var glowMapMergePixelShader: {
  140926. name: string;
  140927. shader: string;
  140928. };
  140929. }
  140930. declare module BABYLON {
  140931. /** @hidden */
  140932. export var glowMapMergeVertexShader: {
  140933. name: string;
  140934. shader: string;
  140935. };
  140936. }
  140937. declare module BABYLON {
  140938. interface AbstractScene {
  140939. /**
  140940. * Return a the first highlight layer of the scene with a given name.
  140941. * @param name The name of the highlight layer to look for.
  140942. * @return The highlight layer if found otherwise null.
  140943. */
  140944. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140945. }
  140946. /**
  140947. * Glow layer options. This helps customizing the behaviour
  140948. * of the glow layer.
  140949. */
  140950. export interface IGlowLayerOptions {
  140951. /**
  140952. * Multiplication factor apply to the canvas size to compute the render target size
  140953. * used to generated the glowing objects (the smaller the faster).
  140954. */
  140955. mainTextureRatio: number;
  140956. /**
  140957. * Enforces a fixed size texture to ensure resize independant blur.
  140958. */
  140959. mainTextureFixedSize?: number;
  140960. /**
  140961. * How big is the kernel of the blur texture.
  140962. */
  140963. blurKernelSize: number;
  140964. /**
  140965. * The camera attached to the layer.
  140966. */
  140967. camera: Nullable<Camera>;
  140968. /**
  140969. * Enable MSAA by chosing the number of samples.
  140970. */
  140971. mainTextureSamples?: number;
  140972. /**
  140973. * The rendering group to draw the layer in.
  140974. */
  140975. renderingGroupId: number;
  140976. }
  140977. /**
  140978. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140979. *
  140980. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140981. *
  140982. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140983. */
  140984. export class GlowLayer extends EffectLayer {
  140985. /**
  140986. * Effect Name of the layer.
  140987. */
  140988. static readonly EffectName: string;
  140989. /**
  140990. * The default blur kernel size used for the glow.
  140991. */
  140992. static DefaultBlurKernelSize: number;
  140993. /**
  140994. * The default texture size ratio used for the glow.
  140995. */
  140996. static DefaultTextureRatio: number;
  140997. /**
  140998. * Sets the kernel size of the blur.
  140999. */
  141000. set blurKernelSize(value: number);
  141001. /**
  141002. * Gets the kernel size of the blur.
  141003. */
  141004. get blurKernelSize(): number;
  141005. /**
  141006. * Sets the glow intensity.
  141007. */
  141008. set intensity(value: number);
  141009. /**
  141010. * Gets the glow intensity.
  141011. */
  141012. get intensity(): number;
  141013. private _options;
  141014. private _intensity;
  141015. private _horizontalBlurPostprocess1;
  141016. private _verticalBlurPostprocess1;
  141017. private _horizontalBlurPostprocess2;
  141018. private _verticalBlurPostprocess2;
  141019. private _blurTexture1;
  141020. private _blurTexture2;
  141021. private _postProcesses1;
  141022. private _postProcesses2;
  141023. private _includedOnlyMeshes;
  141024. private _excludedMeshes;
  141025. private _meshesUsingTheirOwnMaterials;
  141026. /**
  141027. * Callback used to let the user override the color selection on a per mesh basis
  141028. */
  141029. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141030. /**
  141031. * Callback used to let the user override the texture selection on a per mesh basis
  141032. */
  141033. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141034. /**
  141035. * Instantiates a new glow Layer and references it to the scene.
  141036. * @param name The name of the layer
  141037. * @param scene The scene to use the layer in
  141038. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141039. */
  141040. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141041. /**
  141042. * Get the effect name of the layer.
  141043. * @return The effect name
  141044. */
  141045. getEffectName(): string;
  141046. /**
  141047. * Create the merge effect. This is the shader use to blit the information back
  141048. * to the main canvas at the end of the scene rendering.
  141049. */
  141050. protected _createMergeEffect(): Effect;
  141051. /**
  141052. * Creates the render target textures and post processes used in the glow layer.
  141053. */
  141054. protected _createTextureAndPostProcesses(): void;
  141055. /**
  141056. * Checks for the readiness of the element composing the layer.
  141057. * @param subMesh the mesh to check for
  141058. * @param useInstances specify wether or not to use instances to render the mesh
  141059. * @param emissiveTexture the associated emissive texture used to generate the glow
  141060. * @return true if ready otherwise, false
  141061. */
  141062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141063. /**
  141064. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141065. */
  141066. needStencil(): boolean;
  141067. /**
  141068. * Returns true if the mesh can be rendered, otherwise false.
  141069. * @param mesh The mesh to render
  141070. * @param material The material used on the mesh
  141071. * @returns true if it can be rendered otherwise false
  141072. */
  141073. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141074. /**
  141075. * Implementation specific of rendering the generating effect on the main canvas.
  141076. * @param effect The effect used to render through
  141077. */
  141078. protected _internalRender(effect: Effect): void;
  141079. /**
  141080. * Sets the required values for both the emissive texture and and the main color.
  141081. */
  141082. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141083. /**
  141084. * Returns true if the mesh should render, otherwise false.
  141085. * @param mesh The mesh to render
  141086. * @returns true if it should render otherwise false
  141087. */
  141088. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141089. /**
  141090. * Adds specific effects defines.
  141091. * @param defines The defines to add specifics to.
  141092. */
  141093. protected _addCustomEffectDefines(defines: string[]): void;
  141094. /**
  141095. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  141096. * @param mesh The mesh to exclude from the glow layer
  141097. */
  141098. addExcludedMesh(mesh: Mesh): void;
  141099. /**
  141100. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  141101. * @param mesh The mesh to remove
  141102. */
  141103. removeExcludedMesh(mesh: Mesh): void;
  141104. /**
  141105. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  141106. * @param mesh The mesh to include in the glow layer
  141107. */
  141108. addIncludedOnlyMesh(mesh: Mesh): void;
  141109. /**
  141110. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  141111. * @param mesh The mesh to remove
  141112. */
  141113. removeIncludedOnlyMesh(mesh: Mesh): void;
  141114. /**
  141115. * Determine if a given mesh will be used in the glow layer
  141116. * @param mesh The mesh to test
  141117. * @returns true if the mesh will be highlighted by the current glow layer
  141118. */
  141119. hasMesh(mesh: AbstractMesh): boolean;
  141120. /**
  141121. * Defines whether the current material of the mesh should be use to render the effect.
  141122. * @param mesh defines the current mesh to render
  141123. */
  141124. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141125. /**
  141126. * Add a mesh to be rendered through its own material and not with emissive only.
  141127. * @param mesh The mesh for which we need to use its material
  141128. */
  141129. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141130. /**
  141131. * Remove a mesh from being rendered through its own material and not with emissive only.
  141132. * @param mesh The mesh for which we need to not use its material
  141133. */
  141134. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141135. /**
  141136. * Free any resources and references associated to a mesh.
  141137. * Internal use
  141138. * @param mesh The mesh to free.
  141139. * @hidden
  141140. */
  141141. _disposeMesh(mesh: Mesh): void;
  141142. /**
  141143. * Gets the class name of the effect layer
  141144. * @returns the string with the class name of the effect layer
  141145. */
  141146. getClassName(): string;
  141147. /**
  141148. * Serializes this glow layer
  141149. * @returns a serialized glow layer object
  141150. */
  141151. serialize(): any;
  141152. /**
  141153. * Creates a Glow Layer from parsed glow layer data
  141154. * @param parsedGlowLayer defines glow layer data
  141155. * @param scene defines the current scene
  141156. * @param rootUrl defines the root URL containing the glow layer information
  141157. * @returns a parsed Glow Layer
  141158. */
  141159. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141160. }
  141161. }
  141162. declare module BABYLON {
  141163. /** @hidden */
  141164. export var glowBlurPostProcessPixelShader: {
  141165. name: string;
  141166. shader: string;
  141167. };
  141168. }
  141169. declare module BABYLON {
  141170. interface AbstractScene {
  141171. /**
  141172. * Return a the first highlight layer of the scene with a given name.
  141173. * @param name The name of the highlight layer to look for.
  141174. * @return The highlight layer if found otherwise null.
  141175. */
  141176. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  141177. }
  141178. /**
  141179. * Highlight layer options. This helps customizing the behaviour
  141180. * of the highlight layer.
  141181. */
  141182. export interface IHighlightLayerOptions {
  141183. /**
  141184. * Multiplication factor apply to the canvas size to compute the render target size
  141185. * used to generated the glowing objects (the smaller the faster).
  141186. */
  141187. mainTextureRatio: number;
  141188. /**
  141189. * Enforces a fixed size texture to ensure resize independant blur.
  141190. */
  141191. mainTextureFixedSize?: number;
  141192. /**
  141193. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  141194. * of the picture to blur (the smaller the faster).
  141195. */
  141196. blurTextureSizeRatio: number;
  141197. /**
  141198. * How big in texel of the blur texture is the vertical blur.
  141199. */
  141200. blurVerticalSize: number;
  141201. /**
  141202. * How big in texel of the blur texture is the horizontal blur.
  141203. */
  141204. blurHorizontalSize: number;
  141205. /**
  141206. * Alpha blending mode used to apply the blur. Default is combine.
  141207. */
  141208. alphaBlendingMode: number;
  141209. /**
  141210. * The camera attached to the layer.
  141211. */
  141212. camera: Nullable<Camera>;
  141213. /**
  141214. * Should we display highlight as a solid stroke?
  141215. */
  141216. isStroke?: boolean;
  141217. /**
  141218. * The rendering group to draw the layer in.
  141219. */
  141220. renderingGroupId: number;
  141221. }
  141222. /**
  141223. * The highlight layer Helps adding a glow effect around a mesh.
  141224. *
  141225. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  141226. * glowy meshes to your scene.
  141227. *
  141228. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  141229. */
  141230. export class HighlightLayer extends EffectLayer {
  141231. name: string;
  141232. /**
  141233. * Effect Name of the highlight layer.
  141234. */
  141235. static readonly EffectName: string;
  141236. /**
  141237. * The neutral color used during the preparation of the glow effect.
  141238. * This is black by default as the blend operation is a blend operation.
  141239. */
  141240. static NeutralColor: Color4;
  141241. /**
  141242. * Stencil value used for glowing meshes.
  141243. */
  141244. static GlowingMeshStencilReference: number;
  141245. /**
  141246. * Stencil value used for the other meshes in the scene.
  141247. */
  141248. static NormalMeshStencilReference: number;
  141249. /**
  141250. * Specifies whether or not the inner glow is ACTIVE in the layer.
  141251. */
  141252. innerGlow: boolean;
  141253. /**
  141254. * Specifies whether or not the outer glow is ACTIVE in the layer.
  141255. */
  141256. outerGlow: boolean;
  141257. /**
  141258. * Specifies the horizontal size of the blur.
  141259. */
  141260. set blurHorizontalSize(value: number);
  141261. /**
  141262. * Specifies the vertical size of the blur.
  141263. */
  141264. set blurVerticalSize(value: number);
  141265. /**
  141266. * Gets the horizontal size of the blur.
  141267. */
  141268. get blurHorizontalSize(): number;
  141269. /**
  141270. * Gets the vertical size of the blur.
  141271. */
  141272. get blurVerticalSize(): number;
  141273. /**
  141274. * An event triggered when the highlight layer is being blurred.
  141275. */
  141276. onBeforeBlurObservable: Observable<HighlightLayer>;
  141277. /**
  141278. * An event triggered when the highlight layer has been blurred.
  141279. */
  141280. onAfterBlurObservable: Observable<HighlightLayer>;
  141281. private _instanceGlowingMeshStencilReference;
  141282. private _options;
  141283. private _downSamplePostprocess;
  141284. private _horizontalBlurPostprocess;
  141285. private _verticalBlurPostprocess;
  141286. private _blurTexture;
  141287. private _meshes;
  141288. private _excludedMeshes;
  141289. /**
  141290. * Instantiates a new highlight Layer and references it to the scene..
  141291. * @param name The name of the layer
  141292. * @param scene The scene to use the layer in
  141293. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  141294. */
  141295. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  141296. /**
  141297. * Get the effect name of the layer.
  141298. * @return The effect name
  141299. */
  141300. getEffectName(): string;
  141301. /**
  141302. * Create the merge effect. This is the shader use to blit the information back
  141303. * to the main canvas at the end of the scene rendering.
  141304. */
  141305. protected _createMergeEffect(): Effect;
  141306. /**
  141307. * Creates the render target textures and post processes used in the highlight layer.
  141308. */
  141309. protected _createTextureAndPostProcesses(): void;
  141310. /**
  141311. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  141312. */
  141313. needStencil(): boolean;
  141314. /**
  141315. * Checks for the readiness of the element composing the layer.
  141316. * @param subMesh the mesh to check for
  141317. * @param useInstances specify wether or not to use instances to render the mesh
  141318. * @param emissiveTexture the associated emissive texture used to generate the glow
  141319. * @return true if ready otherwise, false
  141320. */
  141321. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141322. /**
  141323. * Implementation specific of rendering the generating effect on the main canvas.
  141324. * @param effect The effect used to render through
  141325. */
  141326. protected _internalRender(effect: Effect): void;
  141327. /**
  141328. * Returns true if the layer contains information to display, otherwise false.
  141329. */
  141330. shouldRender(): boolean;
  141331. /**
  141332. * Returns true if the mesh should render, otherwise false.
  141333. * @param mesh The mesh to render
  141334. * @returns true if it should render otherwise false
  141335. */
  141336. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141337. /**
  141338. * Returns true if the mesh can be rendered, otherwise false.
  141339. * @param mesh The mesh to render
  141340. * @param material The material used on the mesh
  141341. * @returns true if it can be rendered otherwise false
  141342. */
  141343. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141344. /**
  141345. * Adds specific effects defines.
  141346. * @param defines The defines to add specifics to.
  141347. */
  141348. protected _addCustomEffectDefines(defines: string[]): void;
  141349. /**
  141350. * Sets the required values for both the emissive texture and and the main color.
  141351. */
  141352. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141353. /**
  141354. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  141355. * @param mesh The mesh to exclude from the highlight layer
  141356. */
  141357. addExcludedMesh(mesh: Mesh): void;
  141358. /**
  141359. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  141360. * @param mesh The mesh to highlight
  141361. */
  141362. removeExcludedMesh(mesh: Mesh): void;
  141363. /**
  141364. * Determine if a given mesh will be highlighted by the current HighlightLayer
  141365. * @param mesh mesh to test
  141366. * @returns true if the mesh will be highlighted by the current HighlightLayer
  141367. */
  141368. hasMesh(mesh: AbstractMesh): boolean;
  141369. /**
  141370. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  141371. * @param mesh The mesh to highlight
  141372. * @param color The color of the highlight
  141373. * @param glowEmissiveOnly Extract the glow from the emissive texture
  141374. */
  141375. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  141376. /**
  141377. * Remove a mesh from the highlight layer in order to make it stop glowing.
  141378. * @param mesh The mesh to highlight
  141379. */
  141380. removeMesh(mesh: Mesh): void;
  141381. /**
  141382. * Remove all the meshes currently referenced in the highlight layer
  141383. */
  141384. removeAllMeshes(): void;
  141385. /**
  141386. * Force the stencil to the normal expected value for none glowing parts
  141387. */
  141388. private _defaultStencilReference;
  141389. /**
  141390. * Free any resources and references associated to a mesh.
  141391. * Internal use
  141392. * @param mesh The mesh to free.
  141393. * @hidden
  141394. */
  141395. _disposeMesh(mesh: Mesh): void;
  141396. /**
  141397. * Dispose the highlight layer and free resources.
  141398. */
  141399. dispose(): void;
  141400. /**
  141401. * Gets the class name of the effect layer
  141402. * @returns the string with the class name of the effect layer
  141403. */
  141404. getClassName(): string;
  141405. /**
  141406. * Serializes this Highlight layer
  141407. * @returns a serialized Highlight layer object
  141408. */
  141409. serialize(): any;
  141410. /**
  141411. * Creates a Highlight layer from parsed Highlight layer data
  141412. * @param parsedHightlightLayer defines the Highlight layer data
  141413. * @param scene defines the current scene
  141414. * @param rootUrl defines the root URL containing the Highlight layer information
  141415. * @returns a parsed Highlight layer
  141416. */
  141417. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  141418. }
  141419. }
  141420. declare module BABYLON {
  141421. interface AbstractScene {
  141422. /**
  141423. * The list of layers (background and foreground) of the scene
  141424. */
  141425. layers: Array<Layer>;
  141426. }
  141427. /**
  141428. * Defines the layer scene component responsible to manage any layers
  141429. * in a given scene.
  141430. */
  141431. export class LayerSceneComponent implements ISceneComponent {
  141432. /**
  141433. * The component name helpfull to identify the component in the list of scene components.
  141434. */
  141435. readonly name: string;
  141436. /**
  141437. * The scene the component belongs to.
  141438. */
  141439. scene: Scene;
  141440. private _engine;
  141441. /**
  141442. * Creates a new instance of the component for the given scene
  141443. * @param scene Defines the scene to register the component in
  141444. */
  141445. constructor(scene: Scene);
  141446. /**
  141447. * Registers the component in a given scene
  141448. */
  141449. register(): void;
  141450. /**
  141451. * Rebuilds the elements related to this component in case of
  141452. * context lost for instance.
  141453. */
  141454. rebuild(): void;
  141455. /**
  141456. * Disposes the component and the associated ressources.
  141457. */
  141458. dispose(): void;
  141459. private _draw;
  141460. private _drawCameraPredicate;
  141461. private _drawCameraBackground;
  141462. private _drawCameraForeground;
  141463. private _drawRenderTargetPredicate;
  141464. private _drawRenderTargetBackground;
  141465. private _drawRenderTargetForeground;
  141466. /**
  141467. * Adds all the elements from the container to the scene
  141468. * @param container the container holding the elements
  141469. */
  141470. addFromContainer(container: AbstractScene): void;
  141471. /**
  141472. * Removes all the elements in the container from the scene
  141473. * @param container contains the elements to remove
  141474. * @param dispose if the removed element should be disposed (default: false)
  141475. */
  141476. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141477. }
  141478. }
  141479. declare module BABYLON {
  141480. /** @hidden */
  141481. export var layerPixelShader: {
  141482. name: string;
  141483. shader: string;
  141484. };
  141485. }
  141486. declare module BABYLON {
  141487. /** @hidden */
  141488. export var layerVertexShader: {
  141489. name: string;
  141490. shader: string;
  141491. };
  141492. }
  141493. declare module BABYLON {
  141494. /**
  141495. * This represents a full screen 2d layer.
  141496. * This can be useful to display a picture in the background of your scene for instance.
  141497. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141498. */
  141499. export class Layer {
  141500. /**
  141501. * Define the name of the layer.
  141502. */
  141503. name: string;
  141504. /**
  141505. * Define the texture the layer should display.
  141506. */
  141507. texture: Nullable<Texture>;
  141508. /**
  141509. * Is the layer in background or foreground.
  141510. */
  141511. isBackground: boolean;
  141512. /**
  141513. * Define the color of the layer (instead of texture).
  141514. */
  141515. color: Color4;
  141516. /**
  141517. * Define the scale of the layer in order to zoom in out of the texture.
  141518. */
  141519. scale: Vector2;
  141520. /**
  141521. * Define an offset for the layer in order to shift the texture.
  141522. */
  141523. offset: Vector2;
  141524. /**
  141525. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  141526. */
  141527. alphaBlendingMode: number;
  141528. /**
  141529. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  141530. * Alpha test will not mix with the background color in case of transparency.
  141531. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  141532. */
  141533. alphaTest: boolean;
  141534. /**
  141535. * Define a mask to restrict the layer to only some of the scene cameras.
  141536. */
  141537. layerMask: number;
  141538. /**
  141539. * Define the list of render target the layer is visible into.
  141540. */
  141541. renderTargetTextures: RenderTargetTexture[];
  141542. /**
  141543. * Define if the layer is only used in renderTarget or if it also
  141544. * renders in the main frame buffer of the canvas.
  141545. */
  141546. renderOnlyInRenderTargetTextures: boolean;
  141547. private _scene;
  141548. private _vertexBuffers;
  141549. private _indexBuffer;
  141550. private _effect;
  141551. private _previousDefines;
  141552. /**
  141553. * An event triggered when the layer is disposed.
  141554. */
  141555. onDisposeObservable: Observable<Layer>;
  141556. private _onDisposeObserver;
  141557. /**
  141558. * Back compatibility with callback before the onDisposeObservable existed.
  141559. * The set callback will be triggered when the layer has been disposed.
  141560. */
  141561. set onDispose(callback: () => void);
  141562. /**
  141563. * An event triggered before rendering the scene
  141564. */
  141565. onBeforeRenderObservable: Observable<Layer>;
  141566. private _onBeforeRenderObserver;
  141567. /**
  141568. * Back compatibility with callback before the onBeforeRenderObservable existed.
  141569. * The set callback will be triggered just before rendering the layer.
  141570. */
  141571. set onBeforeRender(callback: () => void);
  141572. /**
  141573. * An event triggered after rendering the scene
  141574. */
  141575. onAfterRenderObservable: Observable<Layer>;
  141576. private _onAfterRenderObserver;
  141577. /**
  141578. * Back compatibility with callback before the onAfterRenderObservable existed.
  141579. * The set callback will be triggered just after rendering the layer.
  141580. */
  141581. set onAfterRender(callback: () => void);
  141582. /**
  141583. * Instantiates a new layer.
  141584. * This represents a full screen 2d layer.
  141585. * This can be useful to display a picture in the background of your scene for instance.
  141586. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141587. * @param name Define the name of the layer in the scene
  141588. * @param imgUrl Define the url of the texture to display in the layer
  141589. * @param scene Define the scene the layer belongs to
  141590. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  141591. * @param color Defines a color for the layer
  141592. */
  141593. constructor(
  141594. /**
  141595. * Define the name of the layer.
  141596. */
  141597. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  141598. private _createIndexBuffer;
  141599. /** @hidden */
  141600. _rebuild(): void;
  141601. /**
  141602. * Renders the layer in the scene.
  141603. */
  141604. render(): void;
  141605. /**
  141606. * Disposes and releases the associated ressources.
  141607. */
  141608. dispose(): void;
  141609. }
  141610. }
  141611. declare module BABYLON {
  141612. /** @hidden */
  141613. export var lensFlarePixelShader: {
  141614. name: string;
  141615. shader: string;
  141616. };
  141617. }
  141618. declare module BABYLON {
  141619. /** @hidden */
  141620. export var lensFlareVertexShader: {
  141621. name: string;
  141622. shader: string;
  141623. };
  141624. }
  141625. declare module BABYLON {
  141626. /**
  141627. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141628. * It is usually composed of several `lensFlare`.
  141629. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141630. */
  141631. export class LensFlareSystem {
  141632. /**
  141633. * Define the name of the lens flare system
  141634. */
  141635. name: string;
  141636. /**
  141637. * List of lens flares used in this system.
  141638. */
  141639. lensFlares: LensFlare[];
  141640. /**
  141641. * Define a limit from the border the lens flare can be visible.
  141642. */
  141643. borderLimit: number;
  141644. /**
  141645. * Define a viewport border we do not want to see the lens flare in.
  141646. */
  141647. viewportBorder: number;
  141648. /**
  141649. * Define a predicate which could limit the list of meshes able to occlude the effect.
  141650. */
  141651. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  141652. /**
  141653. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  141654. */
  141655. layerMask: number;
  141656. /**
  141657. * Define the id of the lens flare system in the scene.
  141658. * (equal to name by default)
  141659. */
  141660. id: string;
  141661. private _scene;
  141662. private _emitter;
  141663. private _vertexBuffers;
  141664. private _indexBuffer;
  141665. private _effect;
  141666. private _positionX;
  141667. private _positionY;
  141668. private _isEnabled;
  141669. /** @hidden */
  141670. static _SceneComponentInitialization: (scene: Scene) => void;
  141671. /**
  141672. * Instantiates a lens flare system.
  141673. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141674. * It is usually composed of several `lensFlare`.
  141675. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141676. * @param name Define the name of the lens flare system in the scene
  141677. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  141678. * @param scene Define the scene the lens flare system belongs to
  141679. */
  141680. constructor(
  141681. /**
  141682. * Define the name of the lens flare system
  141683. */
  141684. name: string, emitter: any, scene: Scene);
  141685. /**
  141686. * Define if the lens flare system is enabled.
  141687. */
  141688. get isEnabled(): boolean;
  141689. set isEnabled(value: boolean);
  141690. /**
  141691. * Get the scene the effects belongs to.
  141692. * @returns the scene holding the lens flare system
  141693. */
  141694. getScene(): Scene;
  141695. /**
  141696. * Get the emitter of the lens flare system.
  141697. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141698. * @returns the emitter of the lens flare system
  141699. */
  141700. getEmitter(): any;
  141701. /**
  141702. * Set the emitter of the lens flare system.
  141703. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141704. * @param newEmitter Define the new emitter of the system
  141705. */
  141706. setEmitter(newEmitter: any): void;
  141707. /**
  141708. * Get the lens flare system emitter position.
  141709. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  141710. * @returns the position
  141711. */
  141712. getEmitterPosition(): Vector3;
  141713. /**
  141714. * @hidden
  141715. */
  141716. computeEffectivePosition(globalViewport: Viewport): boolean;
  141717. /** @hidden */
  141718. _isVisible(): boolean;
  141719. /**
  141720. * @hidden
  141721. */
  141722. render(): boolean;
  141723. /**
  141724. * Dispose and release the lens flare with its associated resources.
  141725. */
  141726. dispose(): void;
  141727. /**
  141728. * Parse a lens flare system from a JSON repressentation
  141729. * @param parsedLensFlareSystem Define the JSON to parse
  141730. * @param scene Define the scene the parsed system should be instantiated in
  141731. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  141732. * @returns the parsed system
  141733. */
  141734. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  141735. /**
  141736. * Serialize the current Lens Flare System into a JSON representation.
  141737. * @returns the serialized JSON
  141738. */
  141739. serialize(): any;
  141740. }
  141741. }
  141742. declare module BABYLON {
  141743. /**
  141744. * This represents one of the lens effect in a `lensFlareSystem`.
  141745. * It controls one of the indiviual texture used in the effect.
  141746. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141747. */
  141748. export class LensFlare {
  141749. /**
  141750. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141751. */
  141752. size: number;
  141753. /**
  141754. * 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.
  141755. */
  141756. position: number;
  141757. /**
  141758. * Define the lens color.
  141759. */
  141760. color: Color3;
  141761. /**
  141762. * Define the lens texture.
  141763. */
  141764. texture: Nullable<Texture>;
  141765. /**
  141766. * Define the alpha mode to render this particular lens.
  141767. */
  141768. alphaMode: number;
  141769. private _system;
  141770. /**
  141771. * Creates a new Lens Flare.
  141772. * This represents one of the lens effect in a `lensFlareSystem`.
  141773. * It controls one of the indiviual texture used in the effect.
  141774. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141775. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  141776. * @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.
  141777. * @param color Define the lens color
  141778. * @param imgUrl Define the lens texture url
  141779. * @param system Define the `lensFlareSystem` this flare is part of
  141780. * @returns The newly created Lens Flare
  141781. */
  141782. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  141783. /**
  141784. * Instantiates a new Lens Flare.
  141785. * This represents one of the lens effect in a `lensFlareSystem`.
  141786. * It controls one of the indiviual texture used in the effect.
  141787. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141788. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  141789. * @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.
  141790. * @param color Define the lens color
  141791. * @param imgUrl Define the lens texture url
  141792. * @param system Define the `lensFlareSystem` this flare is part of
  141793. */
  141794. constructor(
  141795. /**
  141796. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141797. */
  141798. size: number,
  141799. /**
  141800. * 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.
  141801. */
  141802. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  141803. /**
  141804. * Dispose and release the lens flare with its associated resources.
  141805. */
  141806. dispose(): void;
  141807. }
  141808. }
  141809. declare module BABYLON {
  141810. interface AbstractScene {
  141811. /**
  141812. * The list of lens flare system added to the scene
  141813. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141814. */
  141815. lensFlareSystems: Array<LensFlareSystem>;
  141816. /**
  141817. * Removes the given lens flare system from this scene.
  141818. * @param toRemove The lens flare system to remove
  141819. * @returns The index of the removed lens flare system
  141820. */
  141821. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141822. /**
  141823. * Adds the given lens flare system to this scene
  141824. * @param newLensFlareSystem The lens flare system to add
  141825. */
  141826. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141827. /**
  141828. * Gets a lens flare system using its name
  141829. * @param name defines the name to look for
  141830. * @returns the lens flare system or null if not found
  141831. */
  141832. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141833. /**
  141834. * Gets a lens flare system using its id
  141835. * @param id defines the id to look for
  141836. * @returns the lens flare system or null if not found
  141837. */
  141838. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141839. }
  141840. /**
  141841. * Defines the lens flare scene component responsible to manage any lens flares
  141842. * in a given scene.
  141843. */
  141844. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141845. /**
  141846. * The component name helpfull to identify the component in the list of scene components.
  141847. */
  141848. readonly name: string;
  141849. /**
  141850. * The scene the component belongs to.
  141851. */
  141852. scene: Scene;
  141853. /**
  141854. * Creates a new instance of the component for the given scene
  141855. * @param scene Defines the scene to register the component in
  141856. */
  141857. constructor(scene: Scene);
  141858. /**
  141859. * Registers the component in a given scene
  141860. */
  141861. register(): void;
  141862. /**
  141863. * Rebuilds the elements related to this component in case of
  141864. * context lost for instance.
  141865. */
  141866. rebuild(): void;
  141867. /**
  141868. * Adds all the elements from the container to the scene
  141869. * @param container the container holding the elements
  141870. */
  141871. addFromContainer(container: AbstractScene): void;
  141872. /**
  141873. * Removes all the elements in the container from the scene
  141874. * @param container contains the elements to remove
  141875. * @param dispose if the removed element should be disposed (default: false)
  141876. */
  141877. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141878. /**
  141879. * Serializes the component data to the specified json object
  141880. * @param serializationObject The object to serialize to
  141881. */
  141882. serialize(serializationObject: any): void;
  141883. /**
  141884. * Disposes the component and the associated ressources.
  141885. */
  141886. dispose(): void;
  141887. private _draw;
  141888. }
  141889. }
  141890. declare module BABYLON {
  141891. /** @hidden */
  141892. export var depthPixelShader: {
  141893. name: string;
  141894. shader: string;
  141895. };
  141896. }
  141897. declare module BABYLON {
  141898. /** @hidden */
  141899. export var depthVertexShader: {
  141900. name: string;
  141901. shader: string;
  141902. };
  141903. }
  141904. declare module BABYLON {
  141905. /**
  141906. * This represents a depth renderer in Babylon.
  141907. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141908. */
  141909. export class DepthRenderer {
  141910. private _scene;
  141911. private _depthMap;
  141912. private _effect;
  141913. private readonly _storeNonLinearDepth;
  141914. private readonly _clearColor;
  141915. /** Get if the depth renderer is using packed depth or not */
  141916. readonly isPacked: boolean;
  141917. private _cachedDefines;
  141918. private _camera;
  141919. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141920. enabled: boolean;
  141921. /**
  141922. * Specifiess that the depth renderer will only be used within
  141923. * the camera it is created for.
  141924. * This can help forcing its rendering during the camera processing.
  141925. */
  141926. useOnlyInActiveCamera: boolean;
  141927. /** @hidden */
  141928. static _SceneComponentInitialization: (scene: Scene) => void;
  141929. /**
  141930. * Instantiates a depth renderer
  141931. * @param scene The scene the renderer belongs to
  141932. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141933. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141934. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141935. */
  141936. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141937. /**
  141938. * Creates the depth rendering effect and checks if the effect is ready.
  141939. * @param subMesh The submesh to be used to render the depth map of
  141940. * @param useInstances If multiple world instances should be used
  141941. * @returns if the depth renderer is ready to render the depth map
  141942. */
  141943. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141944. /**
  141945. * Gets the texture which the depth map will be written to.
  141946. * @returns The depth map texture
  141947. */
  141948. getDepthMap(): RenderTargetTexture;
  141949. /**
  141950. * Disposes of the depth renderer.
  141951. */
  141952. dispose(): void;
  141953. }
  141954. }
  141955. declare module BABYLON {
  141956. /** @hidden */
  141957. export var minmaxReduxPixelShader: {
  141958. name: string;
  141959. shader: string;
  141960. };
  141961. }
  141962. declare module BABYLON {
  141963. /**
  141964. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141965. * and maximum values from all values of the texture.
  141966. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141967. * The source values are read from the red channel of the texture.
  141968. */
  141969. export class MinMaxReducer {
  141970. /**
  141971. * Observable triggered when the computation has been performed
  141972. */
  141973. onAfterReductionPerformed: Observable<{
  141974. min: number;
  141975. max: number;
  141976. }>;
  141977. protected _camera: Camera;
  141978. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141979. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141980. protected _postProcessManager: PostProcessManager;
  141981. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141982. protected _forceFullscreenViewport: boolean;
  141983. /**
  141984. * Creates a min/max reducer
  141985. * @param camera The camera to use for the post processes
  141986. */
  141987. constructor(camera: Camera);
  141988. /**
  141989. * Gets the texture used to read the values from.
  141990. */
  141991. get sourceTexture(): Nullable<RenderTargetTexture>;
  141992. /**
  141993. * Sets the source texture to read the values from.
  141994. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141995. * because in such textures '1' value must not be taken into account to compute the maximum
  141996. * as this value is used to clear the texture.
  141997. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141998. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141999. * @param depthRedux Indicates if the texture is a depth texture or not
  142000. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  142001. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142002. */
  142003. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142004. /**
  142005. * Defines the refresh rate of the computation.
  142006. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142007. */
  142008. get refreshRate(): number;
  142009. set refreshRate(value: number);
  142010. protected _activated: boolean;
  142011. /**
  142012. * Gets the activation status of the reducer
  142013. */
  142014. get activated(): boolean;
  142015. /**
  142016. * Activates the reduction computation.
  142017. * When activated, the observers registered in onAfterReductionPerformed are
  142018. * called after the compuation is performed
  142019. */
  142020. activate(): void;
  142021. /**
  142022. * Deactivates the reduction computation.
  142023. */
  142024. deactivate(): void;
  142025. /**
  142026. * Disposes the min/max reducer
  142027. * @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.
  142028. */
  142029. dispose(disposeAll?: boolean): void;
  142030. }
  142031. }
  142032. declare module BABYLON {
  142033. /**
  142034. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142035. */
  142036. export class DepthReducer extends MinMaxReducer {
  142037. private _depthRenderer;
  142038. private _depthRendererId;
  142039. /**
  142040. * Gets the depth renderer used for the computation.
  142041. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142042. */
  142043. get depthRenderer(): Nullable<DepthRenderer>;
  142044. /**
  142045. * Creates a depth reducer
  142046. * @param camera The camera used to render the depth texture
  142047. */
  142048. constructor(camera: Camera);
  142049. /**
  142050. * Sets the depth renderer to use to generate the depth map
  142051. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142052. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142053. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142054. */
  142055. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142056. /** @hidden */
  142057. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142058. /**
  142059. * Activates the reduction computation.
  142060. * When activated, the observers registered in onAfterReductionPerformed are
  142061. * called after the compuation is performed
  142062. */
  142063. activate(): void;
  142064. /**
  142065. * Deactivates the reduction computation.
  142066. */
  142067. deactivate(): void;
  142068. /**
  142069. * Disposes the depth reducer
  142070. * @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.
  142071. */
  142072. dispose(disposeAll?: boolean): void;
  142073. }
  142074. }
  142075. declare module BABYLON {
  142076. /**
  142077. * A CSM implementation allowing casting shadows on large scenes.
  142078. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142079. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  142080. */
  142081. export class CascadedShadowGenerator extends ShadowGenerator {
  142082. private static readonly frustumCornersNDCSpace;
  142083. /**
  142084. * Name of the CSM class
  142085. */
  142086. static CLASSNAME: string;
  142087. /**
  142088. * Defines the default number of cascades used by the CSM.
  142089. */
  142090. static readonly DEFAULT_CASCADES_COUNT: number;
  142091. /**
  142092. * Defines the minimum number of cascades used by the CSM.
  142093. */
  142094. static readonly MIN_CASCADES_COUNT: number;
  142095. /**
  142096. * Defines the maximum number of cascades used by the CSM.
  142097. */
  142098. static readonly MAX_CASCADES_COUNT: number;
  142099. protected _validateFilter(filter: number): number;
  142100. /**
  142101. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  142102. */
  142103. penumbraDarkness: number;
  142104. private _numCascades;
  142105. /**
  142106. * Gets or set the number of cascades used by the CSM.
  142107. */
  142108. get numCascades(): number;
  142109. set numCascades(value: number);
  142110. /**
  142111. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  142112. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  142113. */
  142114. stabilizeCascades: boolean;
  142115. private _freezeShadowCastersBoundingInfo;
  142116. private _freezeShadowCastersBoundingInfoObservable;
  142117. /**
  142118. * Enables or disables the shadow casters bounding info computation.
  142119. * If your shadow casters don't move, you can disable this feature.
  142120. * If it is enabled, the bounding box computation is done every frame.
  142121. */
  142122. get freezeShadowCastersBoundingInfo(): boolean;
  142123. set freezeShadowCastersBoundingInfo(freeze: boolean);
  142124. private _scbiMin;
  142125. private _scbiMax;
  142126. protected _computeShadowCastersBoundingInfo(): void;
  142127. protected _shadowCastersBoundingInfo: BoundingInfo;
  142128. /**
  142129. * Gets or sets the shadow casters bounding info.
  142130. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142131. * so that the system won't overwrite the bounds you provide
  142132. */
  142133. get shadowCastersBoundingInfo(): BoundingInfo;
  142134. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142135. protected _breaksAreDirty: boolean;
  142136. protected _minDistance: number;
  142137. protected _maxDistance: number;
  142138. /**
  142139. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142140. *
  142141. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142142. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142143. * @param min minimal distance for the breaks (default to 0.)
  142144. * @param max maximal distance for the breaks (default to 1.)
  142145. */
  142146. setMinMaxDistance(min: number, max: number): void;
  142147. /** Gets the minimal distance used in the cascade break computation */
  142148. get minDistance(): number;
  142149. /** Gets the maximal distance used in the cascade break computation */
  142150. get maxDistance(): number;
  142151. /**
  142152. * Gets the class name of that object
  142153. * @returns "CascadedShadowGenerator"
  142154. */
  142155. getClassName(): string;
  142156. private _cascadeMinExtents;
  142157. private _cascadeMaxExtents;
  142158. /**
  142159. * Gets a cascade minimum extents
  142160. * @param cascadeIndex index of the cascade
  142161. * @returns the minimum cascade extents
  142162. */
  142163. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142164. /**
  142165. * Gets a cascade maximum extents
  142166. * @param cascadeIndex index of the cascade
  142167. * @returns the maximum cascade extents
  142168. */
  142169. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  142170. private _cascades;
  142171. private _currentLayer;
  142172. private _viewSpaceFrustumsZ;
  142173. private _viewMatrices;
  142174. private _projectionMatrices;
  142175. private _transformMatrices;
  142176. private _transformMatricesAsArray;
  142177. private _frustumLengths;
  142178. private _lightSizeUVCorrection;
  142179. private _depthCorrection;
  142180. private _frustumCornersWorldSpace;
  142181. private _frustumCenter;
  142182. private _shadowCameraPos;
  142183. private _shadowMaxZ;
  142184. /**
  142185. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  142186. * It defaults to camera.maxZ
  142187. */
  142188. get shadowMaxZ(): number;
  142189. /**
  142190. * Sets the shadow max z distance.
  142191. */
  142192. set shadowMaxZ(value: number);
  142193. protected _debug: boolean;
  142194. /**
  142195. * Gets or sets the debug flag.
  142196. * When enabled, the cascades are materialized by different colors on the screen.
  142197. */
  142198. get debug(): boolean;
  142199. set debug(dbg: boolean);
  142200. private _depthClamp;
  142201. /**
  142202. * Gets or sets the depth clamping value.
  142203. *
  142204. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  142205. * to account for the shadow casters far away.
  142206. *
  142207. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  142208. */
  142209. get depthClamp(): boolean;
  142210. set depthClamp(value: boolean);
  142211. private _cascadeBlendPercentage;
  142212. /**
  142213. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  142214. * It defaults to 0.1 (10% blending).
  142215. */
  142216. get cascadeBlendPercentage(): number;
  142217. set cascadeBlendPercentage(value: number);
  142218. private _lambda;
  142219. /**
  142220. * Gets or set the lambda parameter.
  142221. * This parameter is used to split the camera frustum and create the cascades.
  142222. * 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.
  142223. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  142224. */
  142225. get lambda(): number;
  142226. set lambda(value: number);
  142227. /**
  142228. * Gets the view matrix corresponding to a given cascade
  142229. * @param cascadeNum cascade to retrieve the view matrix from
  142230. * @returns the cascade view matrix
  142231. */
  142232. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  142233. /**
  142234. * Gets the projection matrix corresponding to a given cascade
  142235. * @param cascadeNum cascade to retrieve the projection matrix from
  142236. * @returns the cascade projection matrix
  142237. */
  142238. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  142239. /**
  142240. * Gets the transformation matrix corresponding to a given cascade
  142241. * @param cascadeNum cascade to retrieve the transformation matrix from
  142242. * @returns the cascade transformation matrix
  142243. */
  142244. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  142245. private _depthRenderer;
  142246. /**
  142247. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  142248. *
  142249. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  142250. *
  142251. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  142252. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  142253. * @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
  142254. */
  142255. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  142256. private _depthReducer;
  142257. private _autoCalcDepthBounds;
  142258. /**
  142259. * Gets or sets the autoCalcDepthBounds property.
  142260. *
  142261. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  142262. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  142263. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  142264. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  142265. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  142266. */
  142267. get autoCalcDepthBounds(): boolean;
  142268. set autoCalcDepthBounds(value: boolean);
  142269. /**
  142270. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  142271. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142272. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  142273. * for setting the refresh rate on the renderer yourself!
  142274. */
  142275. get autoCalcDepthBoundsRefreshRate(): number;
  142276. set autoCalcDepthBoundsRefreshRate(value: number);
  142277. /**
  142278. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  142279. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  142280. * you change the camera near/far planes!
  142281. */
  142282. splitFrustum(): void;
  142283. private _splitFrustum;
  142284. private _computeMatrices;
  142285. private _computeFrustumInWorldSpace;
  142286. private _computeCascadeFrustum;
  142287. /**
  142288. * Support test.
  142289. */
  142290. static get IsSupported(): boolean;
  142291. /** @hidden */
  142292. static _SceneComponentInitialization: (scene: Scene) => void;
  142293. /**
  142294. * Creates a Cascaded Shadow Generator object.
  142295. * A ShadowGenerator is the required tool to use the shadows.
  142296. * Each directional light casting shadows needs to use its own ShadowGenerator.
  142297. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142298. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  142299. * @param light The directional light object generating the shadows.
  142300. * @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.
  142301. */
  142302. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  142303. protected _initializeGenerator(): void;
  142304. protected _createTargetRenderTexture(): void;
  142305. protected _initializeShadowMap(): void;
  142306. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  142307. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  142308. /**
  142309. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  142310. * @param defines Defines of the material we want to update
  142311. * @param lightIndex Index of the light in the enabled light list of the material
  142312. */
  142313. prepareDefines(defines: any, lightIndex: number): void;
  142314. /**
  142315. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  142316. * defined in the generator but impacting the effect).
  142317. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  142318. * @param effect The effect we are binfing the information for
  142319. */
  142320. bindShadowLight(lightIndex: string, effect: Effect): void;
  142321. /**
  142322. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  142323. * (eq to view projection * shadow projection matrices)
  142324. * @returns The transform matrix used to create the shadow map
  142325. */
  142326. getTransformMatrix(): Matrix;
  142327. /**
  142328. * Disposes the ShadowGenerator.
  142329. * Returns nothing.
  142330. */
  142331. dispose(): void;
  142332. /**
  142333. * Serializes the shadow generator setup to a json object.
  142334. * @returns The serialized JSON object
  142335. */
  142336. serialize(): any;
  142337. /**
  142338. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  142339. * @param parsedShadowGenerator The JSON object to parse
  142340. * @param scene The scene to create the shadow map for
  142341. * @returns The parsed shadow generator
  142342. */
  142343. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  142344. }
  142345. }
  142346. declare module BABYLON {
  142347. /**
  142348. * Defines the shadow generator component responsible to manage any shadow generators
  142349. * in a given scene.
  142350. */
  142351. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  142352. /**
  142353. * The component name helpfull to identify the component in the list of scene components.
  142354. */
  142355. readonly name: string;
  142356. /**
  142357. * The scene the component belongs to.
  142358. */
  142359. scene: Scene;
  142360. /**
  142361. * Creates a new instance of the component for the given scene
  142362. * @param scene Defines the scene to register the component in
  142363. */
  142364. constructor(scene: Scene);
  142365. /**
  142366. * Registers the component in a given scene
  142367. */
  142368. register(): void;
  142369. /**
  142370. * Rebuilds the elements related to this component in case of
  142371. * context lost for instance.
  142372. */
  142373. rebuild(): void;
  142374. /**
  142375. * Serializes the component data to the specified json object
  142376. * @param serializationObject The object to serialize to
  142377. */
  142378. serialize(serializationObject: any): void;
  142379. /**
  142380. * Adds all the elements from the container to the scene
  142381. * @param container the container holding the elements
  142382. */
  142383. addFromContainer(container: AbstractScene): void;
  142384. /**
  142385. * Removes all the elements in the container from the scene
  142386. * @param container contains the elements to remove
  142387. * @param dispose if the removed element should be disposed (default: false)
  142388. */
  142389. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142390. /**
  142391. * Rebuilds the elements related to this component in case of
  142392. * context lost for instance.
  142393. */
  142394. dispose(): void;
  142395. private _gatherRenderTargets;
  142396. }
  142397. }
  142398. declare module BABYLON {
  142399. /**
  142400. * A point light is a light defined by an unique point in world space.
  142401. * The light is emitted in every direction from this point.
  142402. * A good example of a point light is a standard light bulb.
  142403. * Documentation: https://doc.babylonjs.com/babylon101/lights
  142404. */
  142405. export class PointLight extends ShadowLight {
  142406. private _shadowAngle;
  142407. /**
  142408. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142409. * This specifies what angle the shadow will use to be created.
  142410. *
  142411. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142412. */
  142413. get shadowAngle(): number;
  142414. /**
  142415. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142416. * This specifies what angle the shadow will use to be created.
  142417. *
  142418. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142419. */
  142420. set shadowAngle(value: number);
  142421. /**
  142422. * Gets the direction if it has been set.
  142423. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142424. */
  142425. get direction(): Vector3;
  142426. /**
  142427. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142428. */
  142429. set direction(value: Vector3);
  142430. /**
  142431. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  142432. * A PointLight emits the light in every direction.
  142433. * It can cast shadows.
  142434. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  142435. * ```javascript
  142436. * var pointLight = new PointLight("pl", camera.position, scene);
  142437. * ```
  142438. * Documentation : https://doc.babylonjs.com/babylon101/lights
  142439. * @param name The light friendly name
  142440. * @param position The position of the point light in the scene
  142441. * @param scene The scene the lights belongs to
  142442. */
  142443. constructor(name: string, position: Vector3, scene: Scene);
  142444. /**
  142445. * Returns the string "PointLight"
  142446. * @returns the class name
  142447. */
  142448. getClassName(): string;
  142449. /**
  142450. * Returns the integer 0.
  142451. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  142452. */
  142453. getTypeID(): number;
  142454. /**
  142455. * Specifies wether or not the shadowmap should be a cube texture.
  142456. * @returns true if the shadowmap needs to be a cube texture.
  142457. */
  142458. needCube(): boolean;
  142459. /**
  142460. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  142461. * @param faceIndex The index of the face we are computed the direction to generate shadow
  142462. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  142463. */
  142464. getShadowDirection(faceIndex?: number): Vector3;
  142465. /**
  142466. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  142467. * - fov = PI / 2
  142468. * - aspect ratio : 1.0
  142469. * - z-near and far equal to the active camera minZ and maxZ.
  142470. * Returns the PointLight.
  142471. */
  142472. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  142473. protected _buildUniformLayout(): void;
  142474. /**
  142475. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  142476. * @param effect The effect to update
  142477. * @param lightIndex The index of the light in the effect to update
  142478. * @returns The point light
  142479. */
  142480. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  142481. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  142482. /**
  142483. * Prepares the list of defines specific to the light type.
  142484. * @param defines the list of defines
  142485. * @param lightIndex defines the index of the light for the effect
  142486. */
  142487. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  142488. }
  142489. }
  142490. declare module BABYLON {
  142491. /**
  142492. * Header information of HDR texture files.
  142493. */
  142494. export interface HDRInfo {
  142495. /**
  142496. * The height of the texture in pixels.
  142497. */
  142498. height: number;
  142499. /**
  142500. * The width of the texture in pixels.
  142501. */
  142502. width: number;
  142503. /**
  142504. * The index of the beginning of the data in the binary file.
  142505. */
  142506. dataPosition: number;
  142507. }
  142508. /**
  142509. * This groups tools to convert HDR texture to native colors array.
  142510. */
  142511. export class HDRTools {
  142512. private static Ldexp;
  142513. private static Rgbe2float;
  142514. private static readStringLine;
  142515. /**
  142516. * Reads header information from an RGBE texture stored in a native array.
  142517. * More information on this format are available here:
  142518. * https://en.wikipedia.org/wiki/RGBE_image_format
  142519. *
  142520. * @param uint8array The binary file stored in native array.
  142521. * @return The header information.
  142522. */
  142523. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  142524. /**
  142525. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  142526. * This RGBE texture needs to store the information as a panorama.
  142527. *
  142528. * More information on this format are available here:
  142529. * https://en.wikipedia.org/wiki/RGBE_image_format
  142530. *
  142531. * @param buffer The binary file stored in an array buffer.
  142532. * @param size The expected size of the extracted cubemap.
  142533. * @return The Cube Map information.
  142534. */
  142535. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  142536. /**
  142537. * Returns the pixels data extracted from an RGBE texture.
  142538. * This pixels will be stored left to right up to down in the R G B order in one array.
  142539. *
  142540. * More information on this format are available here:
  142541. * https://en.wikipedia.org/wiki/RGBE_image_format
  142542. *
  142543. * @param uint8array The binary file stored in an array buffer.
  142544. * @param hdrInfo The header information of the file.
  142545. * @return The pixels data in RGB right to left up to down order.
  142546. */
  142547. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  142548. private static RGBE_ReadPixels_RLE;
  142549. private static RGBE_ReadPixels_NOT_RLE;
  142550. }
  142551. }
  142552. declare module BABYLON {
  142553. /**
  142554. * Effect Render Options
  142555. */
  142556. export interface IEffectRendererOptions {
  142557. /**
  142558. * Defines the vertices positions.
  142559. */
  142560. positions?: number[];
  142561. /**
  142562. * Defines the indices.
  142563. */
  142564. indices?: number[];
  142565. }
  142566. /**
  142567. * Helper class to render one or more effects.
  142568. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  142569. */
  142570. export class EffectRenderer {
  142571. private engine;
  142572. private static _DefaultOptions;
  142573. private _vertexBuffers;
  142574. private _indexBuffer;
  142575. private _fullscreenViewport;
  142576. /**
  142577. * Creates an effect renderer
  142578. * @param engine the engine to use for rendering
  142579. * @param options defines the options of the effect renderer
  142580. */
  142581. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  142582. /**
  142583. * Sets the current viewport in normalized coordinates 0-1
  142584. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  142585. */
  142586. setViewport(viewport?: Viewport): void;
  142587. /**
  142588. * Binds the embedded attributes buffer to the effect.
  142589. * @param effect Defines the effect to bind the attributes for
  142590. */
  142591. bindBuffers(effect: Effect): void;
  142592. /**
  142593. * Sets the current effect wrapper to use during draw.
  142594. * The effect needs to be ready before calling this api.
  142595. * This also sets the default full screen position attribute.
  142596. * @param effectWrapper Defines the effect to draw with
  142597. */
  142598. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  142599. /**
  142600. * Restores engine states
  142601. */
  142602. restoreStates(): void;
  142603. /**
  142604. * Draws a full screen quad.
  142605. */
  142606. draw(): void;
  142607. private isRenderTargetTexture;
  142608. /**
  142609. * renders one or more effects to a specified texture
  142610. * @param effectWrapper the effect to renderer
  142611. * @param outputTexture texture to draw to, if null it will render to the screen.
  142612. */
  142613. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  142614. /**
  142615. * Disposes of the effect renderer
  142616. */
  142617. dispose(): void;
  142618. }
  142619. /**
  142620. * Options to create an EffectWrapper
  142621. */
  142622. interface EffectWrapperCreationOptions {
  142623. /**
  142624. * Engine to use to create the effect
  142625. */
  142626. engine: ThinEngine;
  142627. /**
  142628. * Fragment shader for the effect
  142629. */
  142630. fragmentShader: string;
  142631. /**
  142632. * Use the shader store instead of direct source code
  142633. */
  142634. useShaderStore?: boolean;
  142635. /**
  142636. * Vertex shader for the effect
  142637. */
  142638. vertexShader?: string;
  142639. /**
  142640. * Attributes to use in the shader
  142641. */
  142642. attributeNames?: Array<string>;
  142643. /**
  142644. * Uniforms to use in the shader
  142645. */
  142646. uniformNames?: Array<string>;
  142647. /**
  142648. * Texture sampler names to use in the shader
  142649. */
  142650. samplerNames?: Array<string>;
  142651. /**
  142652. * Defines to use in the shader
  142653. */
  142654. defines?: Array<string>;
  142655. /**
  142656. * Callback when effect is compiled
  142657. */
  142658. onCompiled?: Nullable<(effect: Effect) => void>;
  142659. /**
  142660. * The friendly name of the effect displayed in Spector.
  142661. */
  142662. name?: string;
  142663. }
  142664. /**
  142665. * Wraps an effect to be used for rendering
  142666. */
  142667. export class EffectWrapper {
  142668. /**
  142669. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  142670. */
  142671. onApplyObservable: Observable<{}>;
  142672. /**
  142673. * The underlying effect
  142674. */
  142675. effect: Effect;
  142676. /**
  142677. * Creates an effect to be renderer
  142678. * @param creationOptions options to create the effect
  142679. */
  142680. constructor(creationOptions: EffectWrapperCreationOptions);
  142681. /**
  142682. * Disposes of the effect wrapper
  142683. */
  142684. dispose(): void;
  142685. }
  142686. }
  142687. declare module BABYLON {
  142688. /** @hidden */
  142689. export var hdrFilteringVertexShader: {
  142690. name: string;
  142691. shader: string;
  142692. };
  142693. }
  142694. declare module BABYLON {
  142695. /** @hidden */
  142696. export var hdrFilteringPixelShader: {
  142697. name: string;
  142698. shader: string;
  142699. };
  142700. }
  142701. declare module BABYLON {
  142702. /**
  142703. * Options for texture filtering
  142704. */
  142705. interface IHDRFilteringOptions {
  142706. /**
  142707. * Scales pixel intensity for the input HDR map.
  142708. */
  142709. hdrScale?: number;
  142710. /**
  142711. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  142712. */
  142713. quality?: number;
  142714. }
  142715. /**
  142716. * Filters HDR maps to get correct renderings of PBR reflections
  142717. */
  142718. export class HDRFiltering {
  142719. private _engine;
  142720. private _effectRenderer;
  142721. private _effectWrapper;
  142722. private _lodGenerationOffset;
  142723. private _lodGenerationScale;
  142724. /**
  142725. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  142726. * you care about baking speed.
  142727. */
  142728. quality: number;
  142729. /**
  142730. * Scales pixel intensity for the input HDR map.
  142731. */
  142732. hdrScale: number;
  142733. /**
  142734. * Instantiates HDR filter for reflection maps
  142735. *
  142736. * @param engine Thin engine
  142737. * @param options Options
  142738. */
  142739. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  142740. private _createRenderTarget;
  142741. private _prefilterInternal;
  142742. private _createEffect;
  142743. /**
  142744. * Get a value indicating if the filter is ready to be used
  142745. * @param texture Texture to filter
  142746. * @returns true if the filter is ready
  142747. */
  142748. isReady(texture: BaseTexture): boolean;
  142749. /**
  142750. * Prefilters a cube texture to have mipmap levels representing roughness values.
  142751. * Prefiltering will be invoked at the end of next rendering pass.
  142752. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  142753. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  142754. * @param texture Texture to filter
  142755. * @param onFinished Callback when filtering is done
  142756. * @return Promise called when prefiltering is done
  142757. */
  142758. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  142759. }
  142760. }
  142761. declare module BABYLON {
  142762. /**
  142763. * This represents a texture coming from an HDR input.
  142764. *
  142765. * The only supported format is currently panorama picture stored in RGBE format.
  142766. * Example of such files can be found on HDRLib: http://hdrlib.com/
  142767. */
  142768. export class HDRCubeTexture extends BaseTexture {
  142769. private static _facesMapping;
  142770. private _generateHarmonics;
  142771. private _noMipmap;
  142772. private _prefilterOnLoad;
  142773. private _textureMatrix;
  142774. private _size;
  142775. private _onLoad;
  142776. private _onError;
  142777. /**
  142778. * The texture URL.
  142779. */
  142780. url: string;
  142781. protected _isBlocking: boolean;
  142782. /**
  142783. * Sets wether or not the texture is blocking during loading.
  142784. */
  142785. set isBlocking(value: boolean);
  142786. /**
  142787. * Gets wether or not the texture is blocking during loading.
  142788. */
  142789. get isBlocking(): boolean;
  142790. protected _rotationY: number;
  142791. /**
  142792. * Sets texture matrix rotation angle around Y axis in radians.
  142793. */
  142794. set rotationY(value: number);
  142795. /**
  142796. * Gets texture matrix rotation angle around Y axis radians.
  142797. */
  142798. get rotationY(): number;
  142799. /**
  142800. * Gets or sets the center of the bounding box associated with the cube texture
  142801. * It must define where the camera used to render the texture was set
  142802. */
  142803. boundingBoxPosition: Vector3;
  142804. private _boundingBoxSize;
  142805. /**
  142806. * Gets or sets the size of the bounding box associated with the cube texture
  142807. * When defined, the cubemap will switch to local mode
  142808. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  142809. * @example https://www.babylonjs-playground.com/#RNASML
  142810. */
  142811. set boundingBoxSize(value: Vector3);
  142812. get boundingBoxSize(): Vector3;
  142813. /**
  142814. * Instantiates an HDRTexture from the following parameters.
  142815. *
  142816. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  142817. * @param sceneOrEngine The scene or engine the texture will be used in
  142818. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142819. * @param noMipmap Forces to not generate the mipmap if true
  142820. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142821. * @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)
  142822. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142823. */
  142824. 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>);
  142825. /**
  142826. * Get the current class name of the texture useful for serialization or dynamic coding.
  142827. * @returns "HDRCubeTexture"
  142828. */
  142829. getClassName(): string;
  142830. /**
  142831. * Occurs when the file is raw .hdr file.
  142832. */
  142833. private loadTexture;
  142834. clone(): HDRCubeTexture;
  142835. delayLoad(): void;
  142836. /**
  142837. * Get the texture reflection matrix used to rotate/transform the reflection.
  142838. * @returns the reflection matrix
  142839. */
  142840. getReflectionTextureMatrix(): Matrix;
  142841. /**
  142842. * Set the texture reflection matrix used to rotate/transform the reflection.
  142843. * @param value Define the reflection matrix to set
  142844. */
  142845. setReflectionTextureMatrix(value: Matrix): void;
  142846. /**
  142847. * Parses a JSON representation of an HDR Texture in order to create the texture
  142848. * @param parsedTexture Define the JSON representation
  142849. * @param scene Define the scene the texture should be created in
  142850. * @param rootUrl Define the root url in case we need to load relative dependencies
  142851. * @returns the newly created texture after parsing
  142852. */
  142853. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142854. serialize(): any;
  142855. }
  142856. }
  142857. declare module BABYLON {
  142858. /**
  142859. * Class used to control physics engine
  142860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142861. */
  142862. export class PhysicsEngine implements IPhysicsEngine {
  142863. private _physicsPlugin;
  142864. /**
  142865. * Global value used to control the smallest number supported by the simulation
  142866. */
  142867. static Epsilon: number;
  142868. private _impostors;
  142869. private _joints;
  142870. private _subTimeStep;
  142871. /**
  142872. * Gets the gravity vector used by the simulation
  142873. */
  142874. gravity: Vector3;
  142875. /**
  142876. * Factory used to create the default physics plugin.
  142877. * @returns The default physics plugin
  142878. */
  142879. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142880. /**
  142881. * Creates a new Physics Engine
  142882. * @param gravity defines the gravity vector used by the simulation
  142883. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142884. */
  142885. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142886. /**
  142887. * Sets the gravity vector used by the simulation
  142888. * @param gravity defines the gravity vector to use
  142889. */
  142890. setGravity(gravity: Vector3): void;
  142891. /**
  142892. * Set the time step of the physics engine.
  142893. * Default is 1/60.
  142894. * To slow it down, enter 1/600 for example.
  142895. * To speed it up, 1/30
  142896. * @param newTimeStep defines the new timestep to apply to this world.
  142897. */
  142898. setTimeStep(newTimeStep?: number): void;
  142899. /**
  142900. * Get the time step of the physics engine.
  142901. * @returns the current time step
  142902. */
  142903. getTimeStep(): number;
  142904. /**
  142905. * Set the sub time step of the physics engine.
  142906. * Default is 0 meaning there is no sub steps
  142907. * To increase physics resolution precision, set a small value (like 1 ms)
  142908. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142909. */
  142910. setSubTimeStep(subTimeStep?: number): void;
  142911. /**
  142912. * Get the sub time step of the physics engine.
  142913. * @returns the current sub time step
  142914. */
  142915. getSubTimeStep(): number;
  142916. /**
  142917. * Release all resources
  142918. */
  142919. dispose(): void;
  142920. /**
  142921. * Gets the name of the current physics plugin
  142922. * @returns the name of the plugin
  142923. */
  142924. getPhysicsPluginName(): string;
  142925. /**
  142926. * Adding a new impostor for the impostor tracking.
  142927. * This will be done by the impostor itself.
  142928. * @param impostor the impostor to add
  142929. */
  142930. addImpostor(impostor: PhysicsImpostor): void;
  142931. /**
  142932. * Remove an impostor from the engine.
  142933. * This impostor and its mesh will not longer be updated by the physics engine.
  142934. * @param impostor the impostor to remove
  142935. */
  142936. removeImpostor(impostor: PhysicsImpostor): void;
  142937. /**
  142938. * Add a joint to the physics engine
  142939. * @param mainImpostor defines the main impostor to which the joint is added.
  142940. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142941. * @param joint defines the joint that will connect both impostors.
  142942. */
  142943. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142944. /**
  142945. * Removes a joint from the simulation
  142946. * @param mainImpostor defines the impostor used with the joint
  142947. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142948. * @param joint defines the joint to remove
  142949. */
  142950. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142951. /**
  142952. * Called by the scene. No need to call it.
  142953. * @param delta defines the timespam between frames
  142954. */
  142955. _step(delta: number): void;
  142956. /**
  142957. * Gets the current plugin used to run the simulation
  142958. * @returns current plugin
  142959. */
  142960. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142961. /**
  142962. * Gets the list of physic impostors
  142963. * @returns an array of PhysicsImpostor
  142964. */
  142965. getImpostors(): Array<PhysicsImpostor>;
  142966. /**
  142967. * Gets the impostor for a physics enabled object
  142968. * @param object defines the object impersonated by the impostor
  142969. * @returns the PhysicsImpostor or null if not found
  142970. */
  142971. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142972. /**
  142973. * Gets the impostor for a physics body object
  142974. * @param body defines physics body used by the impostor
  142975. * @returns the PhysicsImpostor or null if not found
  142976. */
  142977. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142978. /**
  142979. * Does a raycast in the physics world
  142980. * @param from when should the ray start?
  142981. * @param to when should the ray end?
  142982. * @returns PhysicsRaycastResult
  142983. */
  142984. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142985. }
  142986. }
  142987. declare module BABYLON {
  142988. /** @hidden */
  142989. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142990. private _useDeltaForWorldStep;
  142991. world: any;
  142992. name: string;
  142993. private _physicsMaterials;
  142994. private _fixedTimeStep;
  142995. private _cannonRaycastResult;
  142996. private _raycastResult;
  142997. private _physicsBodysToRemoveAfterStep;
  142998. private _firstFrame;
  142999. BJSCANNON: any;
  143000. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  143001. setGravity(gravity: Vector3): void;
  143002. setTimeStep(timeStep: number): void;
  143003. getTimeStep(): number;
  143004. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143005. private _removeMarkedPhysicsBodiesFromWorld;
  143006. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143007. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143008. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143009. private _processChildMeshes;
  143010. removePhysicsBody(impostor: PhysicsImpostor): void;
  143011. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143012. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143013. private _addMaterial;
  143014. private _checkWithEpsilon;
  143015. private _createShape;
  143016. private _createHeightmap;
  143017. private _minus90X;
  143018. private _plus90X;
  143019. private _tmpPosition;
  143020. private _tmpDeltaPosition;
  143021. private _tmpUnityRotation;
  143022. private _updatePhysicsBodyTransformation;
  143023. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143024. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143025. isSupported(): boolean;
  143026. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143027. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143028. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143029. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143030. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143031. getBodyMass(impostor: PhysicsImpostor): number;
  143032. getBodyFriction(impostor: PhysicsImpostor): number;
  143033. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143034. getBodyRestitution(impostor: PhysicsImpostor): number;
  143035. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143036. sleepBody(impostor: PhysicsImpostor): void;
  143037. wakeUpBody(impostor: PhysicsImpostor): void;
  143038. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143039. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143040. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143041. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143042. getRadius(impostor: PhysicsImpostor): number;
  143043. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143044. dispose(): void;
  143045. private _extendNamespace;
  143046. /**
  143047. * Does a raycast in the physics world
  143048. * @param from when should the ray start?
  143049. * @param to when should the ray end?
  143050. * @returns PhysicsRaycastResult
  143051. */
  143052. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143053. }
  143054. }
  143055. declare module BABYLON {
  143056. /** @hidden */
  143057. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143058. private _useDeltaForWorldStep;
  143059. world: any;
  143060. name: string;
  143061. BJSOIMO: any;
  143062. private _raycastResult;
  143063. private _fixedTimeStep;
  143064. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143065. setGravity(gravity: Vector3): void;
  143066. setTimeStep(timeStep: number): void;
  143067. getTimeStep(): number;
  143068. private _tmpImpostorsArray;
  143069. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143070. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143071. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143072. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143073. private _tmpPositionVector;
  143074. removePhysicsBody(impostor: PhysicsImpostor): void;
  143075. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143076. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143077. isSupported(): boolean;
  143078. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143079. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143080. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143081. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143082. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143083. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143084. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143085. getBodyMass(impostor: PhysicsImpostor): number;
  143086. getBodyFriction(impostor: PhysicsImpostor): number;
  143087. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143088. getBodyRestitution(impostor: PhysicsImpostor): number;
  143089. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143090. sleepBody(impostor: PhysicsImpostor): void;
  143091. wakeUpBody(impostor: PhysicsImpostor): void;
  143092. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143093. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  143094. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  143095. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143096. getRadius(impostor: PhysicsImpostor): number;
  143097. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143098. dispose(): void;
  143099. /**
  143100. * Does a raycast in the physics world
  143101. * @param from when should the ray start?
  143102. * @param to when should the ray end?
  143103. * @returns PhysicsRaycastResult
  143104. */
  143105. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143106. }
  143107. }
  143108. declare module BABYLON {
  143109. /**
  143110. * AmmoJS Physics plugin
  143111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143112. * @see https://github.com/kripken/ammo.js/
  143113. */
  143114. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  143115. private _useDeltaForWorldStep;
  143116. /**
  143117. * Reference to the Ammo library
  143118. */
  143119. bjsAMMO: any;
  143120. /**
  143121. * Created ammoJS world which physics bodies are added to
  143122. */
  143123. world: any;
  143124. /**
  143125. * Name of the plugin
  143126. */
  143127. name: string;
  143128. private _timeStep;
  143129. private _fixedTimeStep;
  143130. private _maxSteps;
  143131. private _tmpQuaternion;
  143132. private _tmpAmmoTransform;
  143133. private _tmpAmmoQuaternion;
  143134. private _tmpAmmoConcreteContactResultCallback;
  143135. private _collisionConfiguration;
  143136. private _dispatcher;
  143137. private _overlappingPairCache;
  143138. private _solver;
  143139. private _softBodySolver;
  143140. private _tmpAmmoVectorA;
  143141. private _tmpAmmoVectorB;
  143142. private _tmpAmmoVectorC;
  143143. private _tmpAmmoVectorD;
  143144. private _tmpContactCallbackResult;
  143145. private _tmpAmmoVectorRCA;
  143146. private _tmpAmmoVectorRCB;
  143147. private _raycastResult;
  143148. private _tmpContactPoint;
  143149. private static readonly DISABLE_COLLISION_FLAG;
  143150. private static readonly KINEMATIC_FLAG;
  143151. private static readonly DISABLE_DEACTIVATION_FLAG;
  143152. /**
  143153. * Initializes the ammoJS plugin
  143154. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143155. * @param ammoInjection can be used to inject your own ammo reference
  143156. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143157. */
  143158. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143159. /**
  143160. * Sets the gravity of the physics world (m/(s^2))
  143161. * @param gravity Gravity to set
  143162. */
  143163. setGravity(gravity: Vector3): void;
  143164. /**
  143165. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143166. * @param timeStep timestep to use in seconds
  143167. */
  143168. setTimeStep(timeStep: number): void;
  143169. /**
  143170. * 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)
  143171. * @param fixedTimeStep fixedTimeStep to use in seconds
  143172. */
  143173. setFixedTimeStep(fixedTimeStep: number): void;
  143174. /**
  143175. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  143176. * @param maxSteps the maximum number of steps by the physics engine per frame
  143177. */
  143178. setMaxSteps(maxSteps: number): void;
  143179. /**
  143180. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  143181. * @returns the current timestep in seconds
  143182. */
  143183. getTimeStep(): number;
  143184. /**
  143185. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  143186. */
  143187. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  143188. private _isImpostorInContact;
  143189. private _isImpostorPairInContact;
  143190. private _stepSimulation;
  143191. /**
  143192. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  143193. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  143194. * After the step the babylon meshes are set to the position of the physics imposters
  143195. * @param delta amount of time to step forward
  143196. * @param impostors array of imposters to update before/after the step
  143197. */
  143198. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143199. /**
  143200. * Update babylon mesh to match physics world object
  143201. * @param impostor imposter to match
  143202. */
  143203. private _afterSoftStep;
  143204. /**
  143205. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143206. * @param impostor imposter to match
  143207. */
  143208. private _ropeStep;
  143209. /**
  143210. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143211. * @param impostor imposter to match
  143212. */
  143213. private _softbodyOrClothStep;
  143214. private _tmpMatrix;
  143215. /**
  143216. * Applies an impulse on the imposter
  143217. * @param impostor imposter to apply impulse to
  143218. * @param force amount of force to be applied to the imposter
  143219. * @param contactPoint the location to apply the impulse on the imposter
  143220. */
  143221. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143222. /**
  143223. * Applies a force on the imposter
  143224. * @param impostor imposter to apply force
  143225. * @param force amount of force to be applied to the imposter
  143226. * @param contactPoint the location to apply the force on the imposter
  143227. */
  143228. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143229. /**
  143230. * Creates a physics body using the plugin
  143231. * @param impostor the imposter to create the physics body on
  143232. */
  143233. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143234. /**
  143235. * Removes the physics body from the imposter and disposes of the body's memory
  143236. * @param impostor imposter to remove the physics body from
  143237. */
  143238. removePhysicsBody(impostor: PhysicsImpostor): void;
  143239. /**
  143240. * Generates a joint
  143241. * @param impostorJoint the imposter joint to create the joint with
  143242. */
  143243. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143244. /**
  143245. * Removes a joint
  143246. * @param impostorJoint the imposter joint to remove the joint from
  143247. */
  143248. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143249. private _addMeshVerts;
  143250. /**
  143251. * Initialise the soft body vertices to match its object's (mesh) vertices
  143252. * Softbody vertices (nodes) are in world space and to match this
  143253. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  143254. * @param impostor to create the softbody for
  143255. */
  143256. private _softVertexData;
  143257. /**
  143258. * Create an impostor's soft body
  143259. * @param impostor to create the softbody for
  143260. */
  143261. private _createSoftbody;
  143262. /**
  143263. * Create cloth for an impostor
  143264. * @param impostor to create the softbody for
  143265. */
  143266. private _createCloth;
  143267. /**
  143268. * Create rope for an impostor
  143269. * @param impostor to create the softbody for
  143270. */
  143271. private _createRope;
  143272. /**
  143273. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  143274. * @param impostor to create the custom physics shape for
  143275. */
  143276. private _createCustom;
  143277. private _addHullVerts;
  143278. private _createShape;
  143279. /**
  143280. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  143281. * @param impostor imposter containing the physics body and babylon object
  143282. */
  143283. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143284. /**
  143285. * Sets the babylon object's position/rotation from the physics body's position/rotation
  143286. * @param impostor imposter containing the physics body and babylon object
  143287. * @param newPosition new position
  143288. * @param newRotation new rotation
  143289. */
  143290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143291. /**
  143292. * If this plugin is supported
  143293. * @returns true if its supported
  143294. */
  143295. isSupported(): boolean;
  143296. /**
  143297. * Sets the linear velocity of the physics body
  143298. * @param impostor imposter to set the velocity on
  143299. * @param velocity velocity to set
  143300. */
  143301. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143302. /**
  143303. * Sets the angular velocity of the physics body
  143304. * @param impostor imposter to set the velocity on
  143305. * @param velocity velocity to set
  143306. */
  143307. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143308. /**
  143309. * gets the linear velocity
  143310. * @param impostor imposter to get linear velocity from
  143311. * @returns linear velocity
  143312. */
  143313. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143314. /**
  143315. * gets the angular velocity
  143316. * @param impostor imposter to get angular velocity from
  143317. * @returns angular velocity
  143318. */
  143319. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143320. /**
  143321. * Sets the mass of physics body
  143322. * @param impostor imposter to set the mass on
  143323. * @param mass mass to set
  143324. */
  143325. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143326. /**
  143327. * Gets the mass of the physics body
  143328. * @param impostor imposter to get the mass from
  143329. * @returns mass
  143330. */
  143331. getBodyMass(impostor: PhysicsImpostor): number;
  143332. /**
  143333. * Gets friction of the impostor
  143334. * @param impostor impostor to get friction from
  143335. * @returns friction value
  143336. */
  143337. getBodyFriction(impostor: PhysicsImpostor): number;
  143338. /**
  143339. * Sets friction of the impostor
  143340. * @param impostor impostor to set friction on
  143341. * @param friction friction value
  143342. */
  143343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143344. /**
  143345. * Gets restitution of the impostor
  143346. * @param impostor impostor to get restitution from
  143347. * @returns restitution value
  143348. */
  143349. getBodyRestitution(impostor: PhysicsImpostor): number;
  143350. /**
  143351. * Sets resitution of the impostor
  143352. * @param impostor impostor to set resitution on
  143353. * @param restitution resitution value
  143354. */
  143355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143356. /**
  143357. * Gets pressure inside the impostor
  143358. * @param impostor impostor to get pressure from
  143359. * @returns pressure value
  143360. */
  143361. getBodyPressure(impostor: PhysicsImpostor): number;
  143362. /**
  143363. * Sets pressure inside a soft body impostor
  143364. * Cloth and rope must remain 0 pressure
  143365. * @param impostor impostor to set pressure on
  143366. * @param pressure pressure value
  143367. */
  143368. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  143369. /**
  143370. * Gets stiffness of the impostor
  143371. * @param impostor impostor to get stiffness from
  143372. * @returns pressure value
  143373. */
  143374. getBodyStiffness(impostor: PhysicsImpostor): number;
  143375. /**
  143376. * Sets stiffness of the impostor
  143377. * @param impostor impostor to set stiffness on
  143378. * @param stiffness stiffness value from 0 to 1
  143379. */
  143380. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  143381. /**
  143382. * Gets velocityIterations of the impostor
  143383. * @param impostor impostor to get velocity iterations from
  143384. * @returns velocityIterations value
  143385. */
  143386. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  143387. /**
  143388. * Sets velocityIterations of the impostor
  143389. * @param impostor impostor to set velocity iterations on
  143390. * @param velocityIterations velocityIterations value
  143391. */
  143392. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  143393. /**
  143394. * Gets positionIterations of the impostor
  143395. * @param impostor impostor to get position iterations from
  143396. * @returns positionIterations value
  143397. */
  143398. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  143399. /**
  143400. * Sets positionIterations of the impostor
  143401. * @param impostor impostor to set position on
  143402. * @param positionIterations positionIterations value
  143403. */
  143404. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  143405. /**
  143406. * Append an anchor to a cloth object
  143407. * @param impostor is the cloth impostor to add anchor to
  143408. * @param otherImpostor is the rigid impostor to anchor to
  143409. * @param width ratio across width from 0 to 1
  143410. * @param height ratio up height from 0 to 1
  143411. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  143412. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143413. */
  143414. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143415. /**
  143416. * Append an hook to a rope object
  143417. * @param impostor is the rope impostor to add hook to
  143418. * @param otherImpostor is the rigid impostor to hook to
  143419. * @param length ratio along the rope from 0 to 1
  143420. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  143421. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143422. */
  143423. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143424. /**
  143425. * Sleeps the physics body and stops it from being active
  143426. * @param impostor impostor to sleep
  143427. */
  143428. sleepBody(impostor: PhysicsImpostor): void;
  143429. /**
  143430. * Activates the physics body
  143431. * @param impostor impostor to activate
  143432. */
  143433. wakeUpBody(impostor: PhysicsImpostor): void;
  143434. /**
  143435. * Updates the distance parameters of the joint
  143436. * @param joint joint to update
  143437. * @param maxDistance maximum distance of the joint
  143438. * @param minDistance minimum distance of the joint
  143439. */
  143440. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143441. /**
  143442. * Sets a motor on the joint
  143443. * @param joint joint to set motor on
  143444. * @param speed speed of the motor
  143445. * @param maxForce maximum force of the motor
  143446. * @param motorIndex index of the motor
  143447. */
  143448. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143449. /**
  143450. * Sets the motors limit
  143451. * @param joint joint to set limit on
  143452. * @param upperLimit upper limit
  143453. * @param lowerLimit lower limit
  143454. */
  143455. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143456. /**
  143457. * Syncs the position and rotation of a mesh with the impostor
  143458. * @param mesh mesh to sync
  143459. * @param impostor impostor to update the mesh with
  143460. */
  143461. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143462. /**
  143463. * Gets the radius of the impostor
  143464. * @param impostor impostor to get radius from
  143465. * @returns the radius
  143466. */
  143467. getRadius(impostor: PhysicsImpostor): number;
  143468. /**
  143469. * Gets the box size of the impostor
  143470. * @param impostor impostor to get box size from
  143471. * @param result the resulting box size
  143472. */
  143473. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143474. /**
  143475. * Disposes of the impostor
  143476. */
  143477. dispose(): void;
  143478. /**
  143479. * Does a raycast in the physics world
  143480. * @param from when should the ray start?
  143481. * @param to when should the ray end?
  143482. * @returns PhysicsRaycastResult
  143483. */
  143484. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143485. }
  143486. }
  143487. declare module BABYLON {
  143488. interface AbstractScene {
  143489. /**
  143490. * The list of reflection probes added to the scene
  143491. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143492. */
  143493. reflectionProbes: Array<ReflectionProbe>;
  143494. /**
  143495. * Removes the given reflection probe from this scene.
  143496. * @param toRemove The reflection probe to remove
  143497. * @returns The index of the removed reflection probe
  143498. */
  143499. removeReflectionProbe(toRemove: ReflectionProbe): number;
  143500. /**
  143501. * Adds the given reflection probe to this scene.
  143502. * @param newReflectionProbe The reflection probe to add
  143503. */
  143504. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  143505. }
  143506. /**
  143507. * Class used to generate realtime reflection / refraction cube textures
  143508. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143509. */
  143510. export class ReflectionProbe {
  143511. /** defines the name of the probe */
  143512. name: string;
  143513. private _scene;
  143514. private _renderTargetTexture;
  143515. private _projectionMatrix;
  143516. private _viewMatrix;
  143517. private _target;
  143518. private _add;
  143519. private _attachedMesh;
  143520. private _invertYAxis;
  143521. /** Gets or sets probe position (center of the cube map) */
  143522. position: Vector3;
  143523. /**
  143524. * Creates a new reflection probe
  143525. * @param name defines the name of the probe
  143526. * @param size defines the texture resolution (for each face)
  143527. * @param scene defines the hosting scene
  143528. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  143529. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  143530. */
  143531. constructor(
  143532. /** defines the name of the probe */
  143533. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  143534. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  143535. get samples(): number;
  143536. set samples(value: number);
  143537. /** Gets or sets the refresh rate to use (on every frame by default) */
  143538. get refreshRate(): number;
  143539. set refreshRate(value: number);
  143540. /**
  143541. * Gets the hosting scene
  143542. * @returns a Scene
  143543. */
  143544. getScene(): Scene;
  143545. /** Gets the internal CubeTexture used to render to */
  143546. get cubeTexture(): RenderTargetTexture;
  143547. /** Gets the list of meshes to render */
  143548. get renderList(): Nullable<AbstractMesh[]>;
  143549. /**
  143550. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  143551. * @param mesh defines the mesh to attach to
  143552. */
  143553. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  143554. /**
  143555. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  143556. * @param renderingGroupId The rendering group id corresponding to its index
  143557. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  143558. */
  143559. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  143560. /**
  143561. * Clean all associated resources
  143562. */
  143563. dispose(): void;
  143564. /**
  143565. * Converts the reflection probe information to a readable string for debug purpose.
  143566. * @param fullDetails Supports for multiple levels of logging within scene loading
  143567. * @returns the human readable reflection probe info
  143568. */
  143569. toString(fullDetails?: boolean): string;
  143570. /**
  143571. * Get the class name of the relfection probe.
  143572. * @returns "ReflectionProbe"
  143573. */
  143574. getClassName(): string;
  143575. /**
  143576. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  143577. * @returns The JSON representation of the texture
  143578. */
  143579. serialize(): any;
  143580. /**
  143581. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  143582. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  143583. * @param scene Define the scene the parsed reflection probe should be instantiated in
  143584. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  143585. * @returns The parsed reflection probe if successful
  143586. */
  143587. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  143588. }
  143589. }
  143590. declare module BABYLON {
  143591. /** @hidden */
  143592. export var _BabylonLoaderRegistered: boolean;
  143593. /**
  143594. * Helps setting up some configuration for the babylon file loader.
  143595. */
  143596. export class BabylonFileLoaderConfiguration {
  143597. /**
  143598. * The loader does not allow injecting custom physix engine into the plugins.
  143599. * Unfortunately in ES6, we need to manually inject them into the plugin.
  143600. * So you could set this variable to your engine import to make it work.
  143601. */
  143602. static LoaderInjectedPhysicsEngine: any;
  143603. }
  143604. }
  143605. declare module BABYLON {
  143606. /**
  143607. * The Physically based simple base material of BJS.
  143608. *
  143609. * This enables better naming and convention enforcements on top of the pbrMaterial.
  143610. * It is used as the base class for both the specGloss and metalRough conventions.
  143611. */
  143612. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  143613. /**
  143614. * Number of Simultaneous lights allowed on the material.
  143615. */
  143616. maxSimultaneousLights: number;
  143617. /**
  143618. * If sets to true, disables all the lights affecting the material.
  143619. */
  143620. disableLighting: boolean;
  143621. /**
  143622. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  143623. */
  143624. environmentTexture: BaseTexture;
  143625. /**
  143626. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  143627. */
  143628. invertNormalMapX: boolean;
  143629. /**
  143630. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  143631. */
  143632. invertNormalMapY: boolean;
  143633. /**
  143634. * Normal map used in the model.
  143635. */
  143636. normalTexture: BaseTexture;
  143637. /**
  143638. * Emissivie color used to self-illuminate the model.
  143639. */
  143640. emissiveColor: Color3;
  143641. /**
  143642. * Emissivie texture used to self-illuminate the model.
  143643. */
  143644. emissiveTexture: BaseTexture;
  143645. /**
  143646. * Occlusion Channel Strenght.
  143647. */
  143648. occlusionStrength: number;
  143649. /**
  143650. * Occlusion Texture of the material (adding extra occlusion effects).
  143651. */
  143652. occlusionTexture: BaseTexture;
  143653. /**
  143654. * Defines the alpha limits in alpha test mode.
  143655. */
  143656. alphaCutOff: number;
  143657. /**
  143658. * Gets the current double sided mode.
  143659. */
  143660. get doubleSided(): boolean;
  143661. /**
  143662. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  143663. */
  143664. set doubleSided(value: boolean);
  143665. /**
  143666. * Stores the pre-calculated light information of a mesh in a texture.
  143667. */
  143668. lightmapTexture: BaseTexture;
  143669. /**
  143670. * If true, the light map contains occlusion information instead of lighting info.
  143671. */
  143672. useLightmapAsShadowmap: boolean;
  143673. /**
  143674. * Instantiates a new PBRMaterial instance.
  143675. *
  143676. * @param name The material name
  143677. * @param scene The scene the material will be use in.
  143678. */
  143679. constructor(name: string, scene: Scene);
  143680. getClassName(): string;
  143681. }
  143682. }
  143683. declare module BABYLON {
  143684. /**
  143685. * The PBR material of BJS following the metal roughness convention.
  143686. *
  143687. * This fits to the PBR convention in the GLTF definition:
  143688. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  143689. */
  143690. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  143691. /**
  143692. * The base color has two different interpretations depending on the value of metalness.
  143693. * When the material is a metal, the base color is the specific measured reflectance value
  143694. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  143695. * of the material.
  143696. */
  143697. baseColor: Color3;
  143698. /**
  143699. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  143700. * well as opacity information in the alpha channel.
  143701. */
  143702. baseTexture: BaseTexture;
  143703. /**
  143704. * Specifies the metallic scalar value of the material.
  143705. * Can also be used to scale the metalness values of the metallic texture.
  143706. */
  143707. metallic: number;
  143708. /**
  143709. * Specifies the roughness scalar value of the material.
  143710. * Can also be used to scale the roughness values of the metallic texture.
  143711. */
  143712. roughness: number;
  143713. /**
  143714. * Texture containing both the metallic value in the B channel and the
  143715. * roughness value in the G channel to keep better precision.
  143716. */
  143717. metallicRoughnessTexture: BaseTexture;
  143718. /**
  143719. * Instantiates a new PBRMetalRoughnessMaterial instance.
  143720. *
  143721. * @param name The material name
  143722. * @param scene The scene the material will be use in.
  143723. */
  143724. constructor(name: string, scene: Scene);
  143725. /**
  143726. * Return the currrent class name of the material.
  143727. */
  143728. getClassName(): string;
  143729. /**
  143730. * Makes a duplicate of the current material.
  143731. * @param name - name to use for the new material.
  143732. */
  143733. clone(name: string): PBRMetallicRoughnessMaterial;
  143734. /**
  143735. * Serialize the material to a parsable JSON object.
  143736. */
  143737. serialize(): any;
  143738. /**
  143739. * Parses a JSON object correponding to the serialize function.
  143740. */
  143741. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  143742. }
  143743. }
  143744. declare module BABYLON {
  143745. /**
  143746. * The PBR material of BJS following the specular glossiness convention.
  143747. *
  143748. * This fits to the PBR convention in the GLTF definition:
  143749. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  143750. */
  143751. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  143752. /**
  143753. * Specifies the diffuse color of the material.
  143754. */
  143755. diffuseColor: Color3;
  143756. /**
  143757. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  143758. * channel.
  143759. */
  143760. diffuseTexture: BaseTexture;
  143761. /**
  143762. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  143763. */
  143764. specularColor: Color3;
  143765. /**
  143766. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  143767. */
  143768. glossiness: number;
  143769. /**
  143770. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  143771. */
  143772. specularGlossinessTexture: BaseTexture;
  143773. /**
  143774. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  143775. *
  143776. * @param name The material name
  143777. * @param scene The scene the material will be use in.
  143778. */
  143779. constructor(name: string, scene: Scene);
  143780. /**
  143781. * Return the currrent class name of the material.
  143782. */
  143783. getClassName(): string;
  143784. /**
  143785. * Makes a duplicate of the current material.
  143786. * @param name - name to use for the new material.
  143787. */
  143788. clone(name: string): PBRSpecularGlossinessMaterial;
  143789. /**
  143790. * Serialize the material to a parsable JSON object.
  143791. */
  143792. serialize(): any;
  143793. /**
  143794. * Parses a JSON object correponding to the serialize function.
  143795. */
  143796. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  143797. }
  143798. }
  143799. declare module BABYLON {
  143800. /**
  143801. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  143802. * It can help converting any input color in a desired output one. This can then be used to create effects
  143803. * from sepia, black and white to sixties or futuristic rendering...
  143804. *
  143805. * The only supported format is currently 3dl.
  143806. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  143807. */
  143808. export class ColorGradingTexture extends BaseTexture {
  143809. /**
  143810. * The texture URL.
  143811. */
  143812. url: string;
  143813. /**
  143814. * Empty line regex stored for GC.
  143815. */
  143816. private static _noneEmptyLineRegex;
  143817. private _textureMatrix;
  143818. private _onLoad;
  143819. /**
  143820. * Instantiates a ColorGradingTexture from the following parameters.
  143821. *
  143822. * @param url The location of the color gradind data (currently only supporting 3dl)
  143823. * @param sceneOrEngine The scene or engine the texture will be used in
  143824. * @param onLoad defines a callback triggered when the texture has been loaded
  143825. */
  143826. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143827. /**
  143828. * Fires the onload event from the constructor if requested.
  143829. */
  143830. private _triggerOnLoad;
  143831. /**
  143832. * Returns the texture matrix used in most of the material.
  143833. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143834. */
  143835. getTextureMatrix(): Matrix;
  143836. /**
  143837. * Occurs when the file being loaded is a .3dl LUT file.
  143838. */
  143839. private load3dlTexture;
  143840. /**
  143841. * Starts the loading process of the texture.
  143842. */
  143843. private loadTexture;
  143844. /**
  143845. * Clones the color gradind texture.
  143846. */
  143847. clone(): ColorGradingTexture;
  143848. /**
  143849. * Called during delayed load for textures.
  143850. */
  143851. delayLoad(): void;
  143852. /**
  143853. * Parses a color grading texture serialized by Babylon.
  143854. * @param parsedTexture The texture information being parsedTexture
  143855. * @param scene The scene to load the texture in
  143856. * @param rootUrl The root url of the data assets to load
  143857. * @return A color gradind texture
  143858. */
  143859. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143860. /**
  143861. * Serializes the LUT texture to json format.
  143862. */
  143863. serialize(): any;
  143864. }
  143865. }
  143866. declare module BABYLON {
  143867. /**
  143868. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143869. */
  143870. export class EquiRectangularCubeTexture extends BaseTexture {
  143871. /** The six faces of the cube. */
  143872. private static _FacesMapping;
  143873. private _noMipmap;
  143874. private _onLoad;
  143875. private _onError;
  143876. /** The size of the cubemap. */
  143877. private _size;
  143878. /** The buffer of the image. */
  143879. private _buffer;
  143880. /** The width of the input image. */
  143881. private _width;
  143882. /** The height of the input image. */
  143883. private _height;
  143884. /** The URL to the image. */
  143885. url: string;
  143886. /**
  143887. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143888. * @param url The location of the image
  143889. * @param scene The scene the texture will be used in
  143890. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143891. * @param noMipmap Forces to not generate the mipmap if true
  143892. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143893. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143894. * @param onLoad — defines a callback called when texture is loaded
  143895. * @param onError — defines a callback called if there is an error
  143896. */
  143897. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143898. /**
  143899. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143900. */
  143901. private loadImage;
  143902. /**
  143903. * Convert the image buffer into a cubemap and create a CubeTexture.
  143904. */
  143905. private loadTexture;
  143906. /**
  143907. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143908. * @param buffer The ArrayBuffer that should be converted.
  143909. * @returns The buffer as Float32Array.
  143910. */
  143911. private getFloat32ArrayFromArrayBuffer;
  143912. /**
  143913. * Get the current class name of the texture useful for serialization or dynamic coding.
  143914. * @returns "EquiRectangularCubeTexture"
  143915. */
  143916. getClassName(): string;
  143917. /**
  143918. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143919. * @returns A clone of the current EquiRectangularCubeTexture.
  143920. */
  143921. clone(): EquiRectangularCubeTexture;
  143922. }
  143923. }
  143924. declare module BABYLON {
  143925. /**
  143926. * Defines the options related to the creation of an HtmlElementTexture
  143927. */
  143928. export interface IHtmlElementTextureOptions {
  143929. /**
  143930. * Defines wether mip maps should be created or not.
  143931. */
  143932. generateMipMaps?: boolean;
  143933. /**
  143934. * Defines the sampling mode of the texture.
  143935. */
  143936. samplingMode?: number;
  143937. /**
  143938. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143939. */
  143940. engine: Nullable<ThinEngine>;
  143941. /**
  143942. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143943. */
  143944. scene: Nullable<Scene>;
  143945. }
  143946. /**
  143947. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143948. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143949. * is automatically managed.
  143950. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143951. * in your application.
  143952. *
  143953. * As the update is not automatic, you need to call them manually.
  143954. */
  143955. export class HtmlElementTexture extends BaseTexture {
  143956. /**
  143957. * The texture URL.
  143958. */
  143959. element: HTMLVideoElement | HTMLCanvasElement;
  143960. private static readonly DefaultOptions;
  143961. private _textureMatrix;
  143962. private _isVideo;
  143963. private _generateMipMaps;
  143964. private _samplingMode;
  143965. /**
  143966. * Instantiates a HtmlElementTexture from the following parameters.
  143967. *
  143968. * @param name Defines the name of the texture
  143969. * @param element Defines the video or canvas the texture is filled with
  143970. * @param options Defines the other none mandatory texture creation options
  143971. */
  143972. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143973. private _createInternalTexture;
  143974. /**
  143975. * Returns the texture matrix used in most of the material.
  143976. */
  143977. getTextureMatrix(): Matrix;
  143978. /**
  143979. * Updates the content of the texture.
  143980. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143981. */
  143982. update(invertY?: Nullable<boolean>): void;
  143983. }
  143984. }
  143985. declare module BABYLON {
  143986. /**
  143987. * Based on jsTGALoader - Javascript loader for TGA file
  143988. * By Vincent Thibault
  143989. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143990. */
  143991. export class TGATools {
  143992. private static _TYPE_INDEXED;
  143993. private static _TYPE_RGB;
  143994. private static _TYPE_GREY;
  143995. private static _TYPE_RLE_INDEXED;
  143996. private static _TYPE_RLE_RGB;
  143997. private static _TYPE_RLE_GREY;
  143998. private static _ORIGIN_MASK;
  143999. private static _ORIGIN_SHIFT;
  144000. private static _ORIGIN_BL;
  144001. private static _ORIGIN_BR;
  144002. private static _ORIGIN_UL;
  144003. private static _ORIGIN_UR;
  144004. /**
  144005. * Gets the header of a TGA file
  144006. * @param data defines the TGA data
  144007. * @returns the header
  144008. */
  144009. static GetTGAHeader(data: Uint8Array): any;
  144010. /**
  144011. * Uploads TGA content to a Babylon Texture
  144012. * @hidden
  144013. */
  144014. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144015. /** @hidden */
  144016. 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;
  144017. /** @hidden */
  144018. 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;
  144019. /** @hidden */
  144020. 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;
  144021. /** @hidden */
  144022. 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;
  144023. /** @hidden */
  144024. 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;
  144025. /** @hidden */
  144026. 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;
  144027. }
  144028. }
  144029. declare module BABYLON {
  144030. /**
  144031. * Implementation of the TGA Texture Loader.
  144032. * @hidden
  144033. */
  144034. export class _TGATextureLoader implements IInternalTextureLoader {
  144035. /**
  144036. * Defines wether the loader supports cascade loading the different faces.
  144037. */
  144038. readonly supportCascades: boolean;
  144039. /**
  144040. * This returns if the loader support the current file information.
  144041. * @param extension defines the file extension of the file being loaded
  144042. * @returns true if the loader can load the specified file
  144043. */
  144044. canLoad(extension: string): boolean;
  144045. /**
  144046. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144047. * @param data contains the texture data
  144048. * @param texture defines the BabylonJS internal texture
  144049. * @param createPolynomials will be true if polynomials have been requested
  144050. * @param onLoad defines the callback to trigger once the texture is ready
  144051. * @param onError defines the callback to trigger in case of error
  144052. */
  144053. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144054. /**
  144055. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144056. * @param data contains the texture data
  144057. * @param texture defines the BabylonJS internal texture
  144058. * @param callback defines the method to call once ready to upload
  144059. */
  144060. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144061. }
  144062. }
  144063. declare module BABYLON {
  144064. /**
  144065. * Info about the .basis files
  144066. */
  144067. class BasisFileInfo {
  144068. /**
  144069. * If the file has alpha
  144070. */
  144071. hasAlpha: boolean;
  144072. /**
  144073. * Info about each image of the basis file
  144074. */
  144075. images: Array<{
  144076. levels: Array<{
  144077. width: number;
  144078. height: number;
  144079. transcodedPixels: ArrayBufferView;
  144080. }>;
  144081. }>;
  144082. }
  144083. /**
  144084. * Result of transcoding a basis file
  144085. */
  144086. class TranscodeResult {
  144087. /**
  144088. * Info about the .basis file
  144089. */
  144090. fileInfo: BasisFileInfo;
  144091. /**
  144092. * Format to use when loading the file
  144093. */
  144094. format: number;
  144095. }
  144096. /**
  144097. * Configuration options for the Basis transcoder
  144098. */
  144099. export class BasisTranscodeConfiguration {
  144100. /**
  144101. * Supported compression formats used to determine the supported output format of the transcoder
  144102. */
  144103. supportedCompressionFormats?: {
  144104. /**
  144105. * etc1 compression format
  144106. */
  144107. etc1?: boolean;
  144108. /**
  144109. * s3tc compression format
  144110. */
  144111. s3tc?: boolean;
  144112. /**
  144113. * pvrtc compression format
  144114. */
  144115. pvrtc?: boolean;
  144116. /**
  144117. * etc2 compression format
  144118. */
  144119. etc2?: boolean;
  144120. };
  144121. /**
  144122. * If mipmap levels should be loaded for transcoded images (Default: true)
  144123. */
  144124. loadMipmapLevels?: boolean;
  144125. /**
  144126. * Index of a single image to load (Default: all images)
  144127. */
  144128. loadSingleImage?: number;
  144129. }
  144130. /**
  144131. * Used to load .Basis files
  144132. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144133. */
  144134. export class BasisTools {
  144135. private static _IgnoreSupportedFormats;
  144136. /**
  144137. * URL to use when loading the basis transcoder
  144138. */
  144139. static JSModuleURL: string;
  144140. /**
  144141. * URL to use when loading the wasm module for the transcoder
  144142. */
  144143. static WasmModuleURL: string;
  144144. /**
  144145. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144146. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144147. * @returns internal format corresponding to the Basis format
  144148. */
  144149. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144150. private static _WorkerPromise;
  144151. private static _Worker;
  144152. private static _actionId;
  144153. private static _CreateWorkerAsync;
  144154. /**
  144155. * Transcodes a loaded image file to compressed pixel data
  144156. * @param data image data to transcode
  144157. * @param config configuration options for the transcoding
  144158. * @returns a promise resulting in the transcoded image
  144159. */
  144160. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144161. /**
  144162. * Loads a texture from the transcode result
  144163. * @param texture texture load to
  144164. * @param transcodeResult the result of transcoding the basis file to load from
  144165. */
  144166. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  144167. }
  144168. }
  144169. declare module BABYLON {
  144170. /**
  144171. * Loader for .basis file format
  144172. */
  144173. export class _BasisTextureLoader implements IInternalTextureLoader {
  144174. /**
  144175. * Defines whether the loader supports cascade loading the different faces.
  144176. */
  144177. readonly supportCascades: boolean;
  144178. /**
  144179. * This returns if the loader support the current file information.
  144180. * @param extension defines the file extension of the file being loaded
  144181. * @returns true if the loader can load the specified file
  144182. */
  144183. canLoad(extension: string): boolean;
  144184. /**
  144185. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144186. * @param data contains the texture data
  144187. * @param texture defines the BabylonJS internal texture
  144188. * @param createPolynomials will be true if polynomials have been requested
  144189. * @param onLoad defines the callback to trigger once the texture is ready
  144190. * @param onError defines the callback to trigger in case of error
  144191. */
  144192. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144193. /**
  144194. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144195. * @param data contains the texture data
  144196. * @param texture defines the BabylonJS internal texture
  144197. * @param callback defines the method to call once ready to upload
  144198. */
  144199. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144200. }
  144201. }
  144202. declare module BABYLON {
  144203. /**
  144204. * Defines the basic options interface of a TexturePacker Frame
  144205. */
  144206. export interface ITexturePackerFrame {
  144207. /**
  144208. * The frame ID
  144209. */
  144210. id: number;
  144211. /**
  144212. * The frames Scale
  144213. */
  144214. scale: Vector2;
  144215. /**
  144216. * The Frames offset
  144217. */
  144218. offset: Vector2;
  144219. }
  144220. /**
  144221. * This is a support class for frame Data on texture packer sets.
  144222. */
  144223. export class TexturePackerFrame implements ITexturePackerFrame {
  144224. /**
  144225. * The frame ID
  144226. */
  144227. id: number;
  144228. /**
  144229. * The frames Scale
  144230. */
  144231. scale: Vector2;
  144232. /**
  144233. * The Frames offset
  144234. */
  144235. offset: Vector2;
  144236. /**
  144237. * Initializes a texture package frame.
  144238. * @param id The numerical frame identifier
  144239. * @param scale Scalar Vector2 for UV frame
  144240. * @param offset Vector2 for the frame position in UV units.
  144241. * @returns TexturePackerFrame
  144242. */
  144243. constructor(id: number, scale: Vector2, offset: Vector2);
  144244. }
  144245. }
  144246. declare module BABYLON {
  144247. /**
  144248. * Defines the basic options interface of a TexturePacker
  144249. */
  144250. export interface ITexturePackerOptions {
  144251. /**
  144252. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  144253. */
  144254. map?: string[];
  144255. /**
  144256. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144257. */
  144258. uvsIn?: string;
  144259. /**
  144260. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144261. */
  144262. uvsOut?: string;
  144263. /**
  144264. * number representing the layout style. Defaults to LAYOUT_STRIP
  144265. */
  144266. layout?: number;
  144267. /**
  144268. * number of columns if using custom column count layout(2). This defaults to 4.
  144269. */
  144270. colnum?: number;
  144271. /**
  144272. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  144273. */
  144274. updateInputMeshes?: boolean;
  144275. /**
  144276. * boolean flag to dispose all the source textures. Defaults to true.
  144277. */
  144278. disposeSources?: boolean;
  144279. /**
  144280. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  144281. */
  144282. fillBlanks?: boolean;
  144283. /**
  144284. * string value representing the context fill style color. Defaults to 'black'.
  144285. */
  144286. customFillColor?: string;
  144287. /**
  144288. * Width and Height Value of each Frame in the TexturePacker Sets
  144289. */
  144290. frameSize?: number;
  144291. /**
  144292. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  144293. */
  144294. paddingRatio?: number;
  144295. /**
  144296. * Number that declares the fill method for the padding gutter.
  144297. */
  144298. paddingMode?: number;
  144299. /**
  144300. * If in SUBUV_COLOR padding mode what color to use.
  144301. */
  144302. paddingColor?: Color3 | Color4;
  144303. }
  144304. /**
  144305. * Defines the basic interface of a TexturePacker JSON File
  144306. */
  144307. export interface ITexturePackerJSON {
  144308. /**
  144309. * The frame ID
  144310. */
  144311. name: string;
  144312. /**
  144313. * The base64 channel data
  144314. */
  144315. sets: any;
  144316. /**
  144317. * The options of the Packer
  144318. */
  144319. options: ITexturePackerOptions;
  144320. /**
  144321. * The frame data of the Packer
  144322. */
  144323. frames: Array<number>;
  144324. }
  144325. /**
  144326. * This is a support class that generates a series of packed texture sets.
  144327. * @see https://doc.babylonjs.com/babylon101/materials
  144328. */
  144329. export class TexturePacker {
  144330. /** Packer Layout Constant 0 */
  144331. static readonly LAYOUT_STRIP: number;
  144332. /** Packer Layout Constant 1 */
  144333. static readonly LAYOUT_POWER2: number;
  144334. /** Packer Layout Constant 2 */
  144335. static readonly LAYOUT_COLNUM: number;
  144336. /** Packer Layout Constant 0 */
  144337. static readonly SUBUV_WRAP: number;
  144338. /** Packer Layout Constant 1 */
  144339. static readonly SUBUV_EXTEND: number;
  144340. /** Packer Layout Constant 2 */
  144341. static readonly SUBUV_COLOR: number;
  144342. /** The Name of the Texture Package */
  144343. name: string;
  144344. /** The scene scope of the TexturePacker */
  144345. scene: Scene;
  144346. /** The Meshes to target */
  144347. meshes: AbstractMesh[];
  144348. /** Arguments passed with the Constructor */
  144349. options: ITexturePackerOptions;
  144350. /** The promise that is started upon initialization */
  144351. promise: Nullable<Promise<TexturePacker | string>>;
  144352. /** The Container object for the channel sets that are generated */
  144353. sets: object;
  144354. /** The Container array for the frames that are generated */
  144355. frames: TexturePackerFrame[];
  144356. /** The expected number of textures the system is parsing. */
  144357. private _expecting;
  144358. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  144359. private _paddingValue;
  144360. /**
  144361. * Initializes a texture package series from an array of meshes or a single mesh.
  144362. * @param name The name of the package
  144363. * @param meshes The target meshes to compose the package from
  144364. * @param options The arguments that texture packer should follow while building.
  144365. * @param scene The scene which the textures are scoped to.
  144366. * @returns TexturePacker
  144367. */
  144368. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  144369. /**
  144370. * Starts the package process
  144371. * @param resolve The promises resolution function
  144372. * @returns TexturePacker
  144373. */
  144374. private _createFrames;
  144375. /**
  144376. * Calculates the Size of the Channel Sets
  144377. * @returns Vector2
  144378. */
  144379. private _calculateSize;
  144380. /**
  144381. * Calculates the UV data for the frames.
  144382. * @param baseSize the base frameSize
  144383. * @param padding the base frame padding
  144384. * @param dtSize size of the Dynamic Texture for that channel
  144385. * @param dtUnits is 1/dtSize
  144386. * @param update flag to update the input meshes
  144387. */
  144388. private _calculateMeshUVFrames;
  144389. /**
  144390. * Calculates the frames Offset.
  144391. * @param index of the frame
  144392. * @returns Vector2
  144393. */
  144394. private _getFrameOffset;
  144395. /**
  144396. * Updates a Mesh to the frame data
  144397. * @param mesh that is the target
  144398. * @param frameID or the frame index
  144399. */
  144400. private _updateMeshUV;
  144401. /**
  144402. * Updates a Meshes materials to use the texture packer channels
  144403. * @param m is the mesh to target
  144404. * @param force all channels on the packer to be set.
  144405. */
  144406. private _updateTextureReferences;
  144407. /**
  144408. * Public method to set a Mesh to a frame
  144409. * @param m that is the target
  144410. * @param frameID or the frame index
  144411. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  144412. */
  144413. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  144414. /**
  144415. * Starts the async promise to compile the texture packer.
  144416. * @returns Promise<void>
  144417. */
  144418. processAsync(): Promise<void>;
  144419. /**
  144420. * Disposes all textures associated with this packer
  144421. */
  144422. dispose(): void;
  144423. /**
  144424. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  144425. * @param imageType is the image type to use.
  144426. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  144427. */
  144428. download(imageType?: string, quality?: number): void;
  144429. /**
  144430. * Public method to load a texturePacker JSON file.
  144431. * @param data of the JSON file in string format.
  144432. */
  144433. updateFromJSON(data: string): void;
  144434. }
  144435. }
  144436. declare module BABYLON {
  144437. /**
  144438. * 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.
  144439. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144440. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144441. */
  144442. export class CustomProceduralTexture extends ProceduralTexture {
  144443. private _animate;
  144444. private _time;
  144445. private _config;
  144446. private _texturePath;
  144447. /**
  144448. * Instantiates a new Custom Procedural Texture.
  144449. * 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.
  144450. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144451. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144452. * @param name Define the name of the texture
  144453. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  144454. * @param size Define the size of the texture to create
  144455. * @param scene Define the scene the texture belongs to
  144456. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  144457. * @param generateMipMaps Define if the texture should creates mip maps or not
  144458. */
  144459. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144460. private _loadJson;
  144461. /**
  144462. * Is the texture ready to be used ? (rendered at least once)
  144463. * @returns true if ready, otherwise, false.
  144464. */
  144465. isReady(): boolean;
  144466. /**
  144467. * Render the texture to its associated render target.
  144468. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  144469. */
  144470. render(useCameraPostProcess?: boolean): void;
  144471. /**
  144472. * Update the list of dependant textures samplers in the shader.
  144473. */
  144474. updateTextures(): void;
  144475. /**
  144476. * Update the uniform values of the procedural texture in the shader.
  144477. */
  144478. updateShaderUniforms(): void;
  144479. /**
  144480. * Define if the texture animates or not.
  144481. */
  144482. get animate(): boolean;
  144483. set animate(value: boolean);
  144484. }
  144485. }
  144486. declare module BABYLON {
  144487. /** @hidden */
  144488. export var noisePixelShader: {
  144489. name: string;
  144490. shader: string;
  144491. };
  144492. }
  144493. declare module BABYLON {
  144494. /**
  144495. * Class used to generate noise procedural textures
  144496. */
  144497. export class NoiseProceduralTexture extends ProceduralTexture {
  144498. /** Gets or sets the start time (default is 0) */
  144499. time: number;
  144500. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  144501. brightness: number;
  144502. /** Defines the number of octaves to process */
  144503. octaves: number;
  144504. /** Defines the level of persistence (0.8 by default) */
  144505. persistence: number;
  144506. /** Gets or sets animation speed factor (default is 1) */
  144507. animationSpeedFactor: number;
  144508. /**
  144509. * Creates a new NoiseProceduralTexture
  144510. * @param name defines the name fo the texture
  144511. * @param size defines the size of the texture (default is 256)
  144512. * @param scene defines the hosting scene
  144513. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  144514. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  144515. */
  144516. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144517. private _updateShaderUniforms;
  144518. protected _getDefines(): string;
  144519. /** Generate the current state of the procedural texture */
  144520. render(useCameraPostProcess?: boolean): void;
  144521. /**
  144522. * Serializes this noise procedural texture
  144523. * @returns a serialized noise procedural texture object
  144524. */
  144525. serialize(): any;
  144526. /**
  144527. * Clone the texture.
  144528. * @returns the cloned texture
  144529. */
  144530. clone(): NoiseProceduralTexture;
  144531. /**
  144532. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  144533. * @param parsedTexture defines parsed texture data
  144534. * @param scene defines the current scene
  144535. * @param rootUrl defines the root URL containing noise procedural texture information
  144536. * @returns a parsed NoiseProceduralTexture
  144537. */
  144538. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  144539. }
  144540. }
  144541. declare module BABYLON {
  144542. /**
  144543. * Raw cube texture where the raw buffers are passed in
  144544. */
  144545. export class RawCubeTexture extends CubeTexture {
  144546. /**
  144547. * Creates a cube texture where the raw buffers are passed in.
  144548. * @param scene defines the scene the texture is attached to
  144549. * @param data defines the array of data to use to create each face
  144550. * @param size defines the size of the textures
  144551. * @param format defines the format of the data
  144552. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  144553. * @param generateMipMaps defines if the engine should generate the mip levels
  144554. * @param invertY defines if data must be stored with Y axis inverted
  144555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  144556. * @param compression defines the compression used (null by default)
  144557. */
  144558. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  144559. /**
  144560. * Updates the raw cube texture.
  144561. * @param data defines the data to store
  144562. * @param format defines the data format
  144563. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144564. * @param invertY defines if data must be stored with Y axis inverted
  144565. * @param compression defines the compression used (null by default)
  144566. * @param level defines which level of the texture to update
  144567. */
  144568. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  144569. /**
  144570. * Updates a raw cube texture with RGBD encoded data.
  144571. * @param data defines the array of data [mipmap][face] to use to create each face
  144572. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  144573. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  144574. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  144575. * @returns a promsie that resolves when the operation is complete
  144576. */
  144577. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  144578. /**
  144579. * Clones the raw cube texture.
  144580. * @return a new cube texture
  144581. */
  144582. clone(): CubeTexture;
  144583. /** @hidden */
  144584. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144585. }
  144586. }
  144587. declare module BABYLON {
  144588. /**
  144589. * Class used to store 2D array textures containing user data
  144590. */
  144591. export class RawTexture2DArray extends Texture {
  144592. /** Gets or sets the texture format to use */
  144593. format: number;
  144594. /**
  144595. * Create a new RawTexture2DArray
  144596. * @param data defines the data of the texture
  144597. * @param width defines the width of the texture
  144598. * @param height defines the height of the texture
  144599. * @param depth defines the number of layers of the texture
  144600. * @param format defines the texture format to use
  144601. * @param scene defines the hosting scene
  144602. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144603. * @param invertY defines if texture must be stored with Y axis inverted
  144604. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144605. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144606. */
  144607. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144608. /** Gets or sets the texture format to use */
  144609. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144610. /**
  144611. * Update the texture with new data
  144612. * @param data defines the data to store in the texture
  144613. */
  144614. update(data: ArrayBufferView): void;
  144615. }
  144616. }
  144617. declare module BABYLON {
  144618. /**
  144619. * Class used to store 3D textures containing user data
  144620. */
  144621. export class RawTexture3D extends Texture {
  144622. /** Gets or sets the texture format to use */
  144623. format: number;
  144624. /**
  144625. * Create a new RawTexture3D
  144626. * @param data defines the data of the texture
  144627. * @param width defines the width of the texture
  144628. * @param height defines the height of the texture
  144629. * @param depth defines the depth of the texture
  144630. * @param format defines the texture format to use
  144631. * @param scene defines the hosting scene
  144632. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144633. * @param invertY defines if texture must be stored with Y axis inverted
  144634. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144635. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144636. */
  144637. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144638. /** Gets or sets the texture format to use */
  144639. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144640. /**
  144641. * Update the texture with new data
  144642. * @param data defines the data to store in the texture
  144643. */
  144644. update(data: ArrayBufferView): void;
  144645. }
  144646. }
  144647. declare module BABYLON {
  144648. /**
  144649. * Creates a refraction texture used by refraction channel of the standard material.
  144650. * It is like a mirror but to see through a material.
  144651. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144652. */
  144653. export class RefractionTexture extends RenderTargetTexture {
  144654. /**
  144655. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  144656. * 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.
  144657. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144658. */
  144659. refractionPlane: Plane;
  144660. /**
  144661. * Define how deep under the surface we should see.
  144662. */
  144663. depth: number;
  144664. /**
  144665. * Creates a refraction texture used by refraction channel of the standard material.
  144666. * It is like a mirror but to see through a material.
  144667. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144668. * @param name Define the texture name
  144669. * @param size Define the size of the underlying texture
  144670. * @param scene Define the scene the refraction belongs to
  144671. * @param generateMipMaps Define if we need to generate mips level for the refraction
  144672. */
  144673. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  144674. /**
  144675. * Clone the refraction texture.
  144676. * @returns the cloned texture
  144677. */
  144678. clone(): RefractionTexture;
  144679. /**
  144680. * Serialize the texture to a JSON representation you could use in Parse later on
  144681. * @returns the serialized JSON representation
  144682. */
  144683. serialize(): any;
  144684. }
  144685. }
  144686. declare module BABYLON {
  144687. /**
  144688. * Block used to add support for vertex skinning (bones)
  144689. */
  144690. export class BonesBlock extends NodeMaterialBlock {
  144691. /**
  144692. * Creates a new BonesBlock
  144693. * @param name defines the block name
  144694. */
  144695. constructor(name: string);
  144696. /**
  144697. * Initialize the block and prepare the context for build
  144698. * @param state defines the state that will be used for the build
  144699. */
  144700. initialize(state: NodeMaterialBuildState): void;
  144701. /**
  144702. * Gets the current class name
  144703. * @returns the class name
  144704. */
  144705. getClassName(): string;
  144706. /**
  144707. * Gets the matrix indices input component
  144708. */
  144709. get matricesIndices(): NodeMaterialConnectionPoint;
  144710. /**
  144711. * Gets the matrix weights input component
  144712. */
  144713. get matricesWeights(): NodeMaterialConnectionPoint;
  144714. /**
  144715. * Gets the extra matrix indices input component
  144716. */
  144717. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  144718. /**
  144719. * Gets the extra matrix weights input component
  144720. */
  144721. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  144722. /**
  144723. * Gets the world input component
  144724. */
  144725. get world(): NodeMaterialConnectionPoint;
  144726. /**
  144727. * Gets the output component
  144728. */
  144729. get output(): NodeMaterialConnectionPoint;
  144730. autoConfigure(material: NodeMaterial): void;
  144731. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  144732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144734. protected _buildBlock(state: NodeMaterialBuildState): this;
  144735. }
  144736. }
  144737. declare module BABYLON {
  144738. /**
  144739. * Block used to add support for instances
  144740. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  144741. */
  144742. export class InstancesBlock extends NodeMaterialBlock {
  144743. /**
  144744. * Creates a new InstancesBlock
  144745. * @param name defines the block name
  144746. */
  144747. constructor(name: string);
  144748. /**
  144749. * Gets the current class name
  144750. * @returns the class name
  144751. */
  144752. getClassName(): string;
  144753. /**
  144754. * Gets the first world row input component
  144755. */
  144756. get world0(): NodeMaterialConnectionPoint;
  144757. /**
  144758. * Gets the second world row input component
  144759. */
  144760. get world1(): NodeMaterialConnectionPoint;
  144761. /**
  144762. * Gets the third world row input component
  144763. */
  144764. get world2(): NodeMaterialConnectionPoint;
  144765. /**
  144766. * Gets the forth world row input component
  144767. */
  144768. get world3(): NodeMaterialConnectionPoint;
  144769. /**
  144770. * Gets the world input component
  144771. */
  144772. get world(): NodeMaterialConnectionPoint;
  144773. /**
  144774. * Gets the output component
  144775. */
  144776. get output(): NodeMaterialConnectionPoint;
  144777. /**
  144778. * Gets the isntanceID component
  144779. */
  144780. get instanceID(): NodeMaterialConnectionPoint;
  144781. autoConfigure(material: NodeMaterial): void;
  144782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  144783. protected _buildBlock(state: NodeMaterialBuildState): this;
  144784. }
  144785. }
  144786. declare module BABYLON {
  144787. /**
  144788. * Block used to add morph targets support to vertex shader
  144789. */
  144790. export class MorphTargetsBlock extends NodeMaterialBlock {
  144791. private _repeatableContentAnchor;
  144792. /**
  144793. * Create a new MorphTargetsBlock
  144794. * @param name defines the block name
  144795. */
  144796. constructor(name: string);
  144797. /**
  144798. * Gets the current class name
  144799. * @returns the class name
  144800. */
  144801. getClassName(): string;
  144802. /**
  144803. * Gets the position input component
  144804. */
  144805. get position(): NodeMaterialConnectionPoint;
  144806. /**
  144807. * Gets the normal input component
  144808. */
  144809. get normal(): NodeMaterialConnectionPoint;
  144810. /**
  144811. * Gets the tangent input component
  144812. */
  144813. get tangent(): NodeMaterialConnectionPoint;
  144814. /**
  144815. * Gets the tangent input component
  144816. */
  144817. get uv(): NodeMaterialConnectionPoint;
  144818. /**
  144819. * Gets the position output component
  144820. */
  144821. get positionOutput(): NodeMaterialConnectionPoint;
  144822. /**
  144823. * Gets the normal output component
  144824. */
  144825. get normalOutput(): NodeMaterialConnectionPoint;
  144826. /**
  144827. * Gets the tangent output component
  144828. */
  144829. get tangentOutput(): NodeMaterialConnectionPoint;
  144830. /**
  144831. * Gets the tangent output component
  144832. */
  144833. get uvOutput(): NodeMaterialConnectionPoint;
  144834. initialize(state: NodeMaterialBuildState): void;
  144835. autoConfigure(material: NodeMaterial): void;
  144836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144838. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144839. protected _buildBlock(state: NodeMaterialBuildState): this;
  144840. }
  144841. }
  144842. declare module BABYLON {
  144843. /**
  144844. * Block used to get data information from a light
  144845. */
  144846. export class LightInformationBlock extends NodeMaterialBlock {
  144847. private _lightDataUniformName;
  144848. private _lightColorUniformName;
  144849. private _lightTypeDefineName;
  144850. /**
  144851. * Gets or sets the light associated with this block
  144852. */
  144853. light: Nullable<Light>;
  144854. /**
  144855. * Creates a new LightInformationBlock
  144856. * @param name defines the block name
  144857. */
  144858. constructor(name: string);
  144859. /**
  144860. * Gets the current class name
  144861. * @returns the class name
  144862. */
  144863. getClassName(): string;
  144864. /**
  144865. * Gets the world position input component
  144866. */
  144867. get worldPosition(): NodeMaterialConnectionPoint;
  144868. /**
  144869. * Gets the direction output component
  144870. */
  144871. get direction(): NodeMaterialConnectionPoint;
  144872. /**
  144873. * Gets the direction output component
  144874. */
  144875. get color(): NodeMaterialConnectionPoint;
  144876. /**
  144877. * Gets the direction output component
  144878. */
  144879. get intensity(): NodeMaterialConnectionPoint;
  144880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144882. protected _buildBlock(state: NodeMaterialBuildState): this;
  144883. serialize(): any;
  144884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144885. }
  144886. }
  144887. declare module BABYLON {
  144888. /**
  144889. * Block used to add image processing support to fragment shader
  144890. */
  144891. export class ImageProcessingBlock extends NodeMaterialBlock {
  144892. /**
  144893. * Create a new ImageProcessingBlock
  144894. * @param name defines the block name
  144895. */
  144896. constructor(name: string);
  144897. /**
  144898. * Gets the current class name
  144899. * @returns the class name
  144900. */
  144901. getClassName(): string;
  144902. /**
  144903. * Gets the color input component
  144904. */
  144905. get color(): NodeMaterialConnectionPoint;
  144906. /**
  144907. * Gets the output component
  144908. */
  144909. get output(): NodeMaterialConnectionPoint;
  144910. /**
  144911. * Initialize the block and prepare the context for build
  144912. * @param state defines the state that will be used for the build
  144913. */
  144914. initialize(state: NodeMaterialBuildState): void;
  144915. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144917. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144918. protected _buildBlock(state: NodeMaterialBuildState): this;
  144919. }
  144920. }
  144921. declare module BABYLON {
  144922. /**
  144923. * Block used to pertub normals based on a normal map
  144924. */
  144925. export class PerturbNormalBlock extends NodeMaterialBlock {
  144926. private _tangentSpaceParameterName;
  144927. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144928. invertX: boolean;
  144929. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144930. invertY: boolean;
  144931. /**
  144932. * Create a new PerturbNormalBlock
  144933. * @param name defines the block name
  144934. */
  144935. constructor(name: string);
  144936. /**
  144937. * Gets the current class name
  144938. * @returns the class name
  144939. */
  144940. getClassName(): string;
  144941. /**
  144942. * Gets the world position input component
  144943. */
  144944. get worldPosition(): NodeMaterialConnectionPoint;
  144945. /**
  144946. * Gets the world normal input component
  144947. */
  144948. get worldNormal(): NodeMaterialConnectionPoint;
  144949. /**
  144950. * Gets the world tangent input component
  144951. */
  144952. get worldTangent(): NodeMaterialConnectionPoint;
  144953. /**
  144954. * Gets the uv input component
  144955. */
  144956. get uv(): NodeMaterialConnectionPoint;
  144957. /**
  144958. * Gets the normal map color input component
  144959. */
  144960. get normalMapColor(): NodeMaterialConnectionPoint;
  144961. /**
  144962. * Gets the strength input component
  144963. */
  144964. get strength(): NodeMaterialConnectionPoint;
  144965. /**
  144966. * Gets the output component
  144967. */
  144968. get output(): NodeMaterialConnectionPoint;
  144969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144970. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144971. autoConfigure(material: NodeMaterial): void;
  144972. protected _buildBlock(state: NodeMaterialBuildState): this;
  144973. protected _dumpPropertiesCode(): string;
  144974. serialize(): any;
  144975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144976. }
  144977. }
  144978. declare module BABYLON {
  144979. /**
  144980. * Block used to discard a pixel if a value is smaller than a cutoff
  144981. */
  144982. export class DiscardBlock extends NodeMaterialBlock {
  144983. /**
  144984. * Create a new DiscardBlock
  144985. * @param name defines the block name
  144986. */
  144987. constructor(name: string);
  144988. /**
  144989. * Gets the current class name
  144990. * @returns the class name
  144991. */
  144992. getClassName(): string;
  144993. /**
  144994. * Gets the color input component
  144995. */
  144996. get value(): NodeMaterialConnectionPoint;
  144997. /**
  144998. * Gets the cutoff input component
  144999. */
  145000. get cutoff(): NodeMaterialConnectionPoint;
  145001. protected _buildBlock(state: NodeMaterialBuildState): this;
  145002. }
  145003. }
  145004. declare module BABYLON {
  145005. /**
  145006. * Block used to test if the fragment shader is front facing
  145007. */
  145008. export class FrontFacingBlock extends NodeMaterialBlock {
  145009. /**
  145010. * Creates a new FrontFacingBlock
  145011. * @param name defines the block name
  145012. */
  145013. constructor(name: string);
  145014. /**
  145015. * Gets the current class name
  145016. * @returns the class name
  145017. */
  145018. getClassName(): string;
  145019. /**
  145020. * Gets the output component
  145021. */
  145022. get output(): NodeMaterialConnectionPoint;
  145023. protected _buildBlock(state: NodeMaterialBuildState): this;
  145024. }
  145025. }
  145026. declare module BABYLON {
  145027. /**
  145028. * Block used to get the derivative value on x and y of a given input
  145029. */
  145030. export class DerivativeBlock extends NodeMaterialBlock {
  145031. /**
  145032. * Create a new DerivativeBlock
  145033. * @param name defines the block name
  145034. */
  145035. constructor(name: string);
  145036. /**
  145037. * Gets the current class name
  145038. * @returns the class name
  145039. */
  145040. getClassName(): string;
  145041. /**
  145042. * Gets the input component
  145043. */
  145044. get input(): NodeMaterialConnectionPoint;
  145045. /**
  145046. * Gets the derivative output on x
  145047. */
  145048. get dx(): NodeMaterialConnectionPoint;
  145049. /**
  145050. * Gets the derivative output on y
  145051. */
  145052. get dy(): NodeMaterialConnectionPoint;
  145053. protected _buildBlock(state: NodeMaterialBuildState): this;
  145054. }
  145055. }
  145056. declare module BABYLON {
  145057. /**
  145058. * Block used to make gl_FragCoord available
  145059. */
  145060. export class FragCoordBlock extends NodeMaterialBlock {
  145061. /**
  145062. * Creates a new FragCoordBlock
  145063. * @param name defines the block name
  145064. */
  145065. constructor(name: string);
  145066. /**
  145067. * Gets the current class name
  145068. * @returns the class name
  145069. */
  145070. getClassName(): string;
  145071. /**
  145072. * Gets the xy component
  145073. */
  145074. get xy(): NodeMaterialConnectionPoint;
  145075. /**
  145076. * Gets the xyz component
  145077. */
  145078. get xyz(): NodeMaterialConnectionPoint;
  145079. /**
  145080. * Gets the xyzw component
  145081. */
  145082. get xyzw(): NodeMaterialConnectionPoint;
  145083. /**
  145084. * Gets the x component
  145085. */
  145086. get x(): NodeMaterialConnectionPoint;
  145087. /**
  145088. * Gets the y component
  145089. */
  145090. get y(): NodeMaterialConnectionPoint;
  145091. /**
  145092. * Gets the z component
  145093. */
  145094. get z(): NodeMaterialConnectionPoint;
  145095. /**
  145096. * Gets the w component
  145097. */
  145098. get output(): NodeMaterialConnectionPoint;
  145099. protected writeOutputs(state: NodeMaterialBuildState): string;
  145100. protected _buildBlock(state: NodeMaterialBuildState): this;
  145101. }
  145102. }
  145103. declare module BABYLON {
  145104. /**
  145105. * Block used to get the screen sizes
  145106. */
  145107. export class ScreenSizeBlock extends NodeMaterialBlock {
  145108. private _varName;
  145109. private _scene;
  145110. /**
  145111. * Creates a new ScreenSizeBlock
  145112. * @param name defines the block name
  145113. */
  145114. constructor(name: string);
  145115. /**
  145116. * Gets the current class name
  145117. * @returns the class name
  145118. */
  145119. getClassName(): string;
  145120. /**
  145121. * Gets the xy component
  145122. */
  145123. get xy(): NodeMaterialConnectionPoint;
  145124. /**
  145125. * Gets the x component
  145126. */
  145127. get x(): NodeMaterialConnectionPoint;
  145128. /**
  145129. * Gets the y component
  145130. */
  145131. get y(): NodeMaterialConnectionPoint;
  145132. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145133. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145134. protected _buildBlock(state: NodeMaterialBuildState): this;
  145135. }
  145136. }
  145137. declare module BABYLON {
  145138. /**
  145139. * Block used to add support for scene fog
  145140. */
  145141. export class FogBlock extends NodeMaterialBlock {
  145142. private _fogDistanceName;
  145143. private _fogParameters;
  145144. /**
  145145. * Create a new FogBlock
  145146. * @param name defines the block name
  145147. */
  145148. constructor(name: string);
  145149. /**
  145150. * Gets the current class name
  145151. * @returns the class name
  145152. */
  145153. getClassName(): string;
  145154. /**
  145155. * Gets the world position input component
  145156. */
  145157. get worldPosition(): NodeMaterialConnectionPoint;
  145158. /**
  145159. * Gets the view input component
  145160. */
  145161. get view(): NodeMaterialConnectionPoint;
  145162. /**
  145163. * Gets the color input component
  145164. */
  145165. get input(): NodeMaterialConnectionPoint;
  145166. /**
  145167. * Gets the fog color input component
  145168. */
  145169. get fogColor(): NodeMaterialConnectionPoint;
  145170. /**
  145171. * Gets the output component
  145172. */
  145173. get output(): NodeMaterialConnectionPoint;
  145174. autoConfigure(material: NodeMaterial): void;
  145175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145176. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145177. protected _buildBlock(state: NodeMaterialBuildState): this;
  145178. }
  145179. }
  145180. declare module BABYLON {
  145181. /**
  145182. * Block used to add light in the fragment shader
  145183. */
  145184. export class LightBlock extends NodeMaterialBlock {
  145185. private _lightId;
  145186. /**
  145187. * Gets or sets the light associated with this block
  145188. */
  145189. light: Nullable<Light>;
  145190. /**
  145191. * Create a new LightBlock
  145192. * @param name defines the block name
  145193. */
  145194. constructor(name: string);
  145195. /**
  145196. * Gets the current class name
  145197. * @returns the class name
  145198. */
  145199. getClassName(): string;
  145200. /**
  145201. * Gets the world position input component
  145202. */
  145203. get worldPosition(): NodeMaterialConnectionPoint;
  145204. /**
  145205. * Gets the world normal input component
  145206. */
  145207. get worldNormal(): NodeMaterialConnectionPoint;
  145208. /**
  145209. * Gets the camera (or eye) position component
  145210. */
  145211. get cameraPosition(): NodeMaterialConnectionPoint;
  145212. /**
  145213. * Gets the glossiness component
  145214. */
  145215. get glossiness(): NodeMaterialConnectionPoint;
  145216. /**
  145217. * Gets the glossinness power component
  145218. */
  145219. get glossPower(): NodeMaterialConnectionPoint;
  145220. /**
  145221. * Gets the diffuse color component
  145222. */
  145223. get diffuseColor(): NodeMaterialConnectionPoint;
  145224. /**
  145225. * Gets the specular color component
  145226. */
  145227. get specularColor(): NodeMaterialConnectionPoint;
  145228. /**
  145229. * Gets the view matrix component
  145230. */
  145231. get view(): NodeMaterialConnectionPoint;
  145232. /**
  145233. * Gets the diffuse output component
  145234. */
  145235. get diffuseOutput(): NodeMaterialConnectionPoint;
  145236. /**
  145237. * Gets the specular output component
  145238. */
  145239. get specularOutput(): NodeMaterialConnectionPoint;
  145240. /**
  145241. * Gets the shadow output component
  145242. */
  145243. get shadow(): NodeMaterialConnectionPoint;
  145244. autoConfigure(material: NodeMaterial): void;
  145245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145246. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145247. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145248. private _injectVertexCode;
  145249. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145250. serialize(): any;
  145251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145252. }
  145253. }
  145254. declare module BABYLON {
  145255. /**
  145256. * Block used to read a reflection texture from a sampler
  145257. */
  145258. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  145259. /**
  145260. * Create a new ReflectionTextureBlock
  145261. * @param name defines the block name
  145262. */
  145263. constructor(name: string);
  145264. /**
  145265. * Gets the current class name
  145266. * @returns the class name
  145267. */
  145268. getClassName(): string;
  145269. /**
  145270. * Gets the world position input component
  145271. */
  145272. get position(): NodeMaterialConnectionPoint;
  145273. /**
  145274. * Gets the world position input component
  145275. */
  145276. get worldPosition(): NodeMaterialConnectionPoint;
  145277. /**
  145278. * Gets the world normal input component
  145279. */
  145280. get worldNormal(): NodeMaterialConnectionPoint;
  145281. /**
  145282. * Gets the world input component
  145283. */
  145284. get world(): NodeMaterialConnectionPoint;
  145285. /**
  145286. * Gets the camera (or eye) position component
  145287. */
  145288. get cameraPosition(): NodeMaterialConnectionPoint;
  145289. /**
  145290. * Gets the view input component
  145291. */
  145292. get view(): NodeMaterialConnectionPoint;
  145293. /**
  145294. * Gets the rgb output component
  145295. */
  145296. get rgb(): NodeMaterialConnectionPoint;
  145297. /**
  145298. * Gets the rgba output component
  145299. */
  145300. get rgba(): NodeMaterialConnectionPoint;
  145301. /**
  145302. * Gets the r output component
  145303. */
  145304. get r(): NodeMaterialConnectionPoint;
  145305. /**
  145306. * Gets the g output component
  145307. */
  145308. get g(): NodeMaterialConnectionPoint;
  145309. /**
  145310. * Gets the b output component
  145311. */
  145312. get b(): NodeMaterialConnectionPoint;
  145313. /**
  145314. * Gets the a output component
  145315. */
  145316. get a(): NodeMaterialConnectionPoint;
  145317. autoConfigure(material: NodeMaterial): void;
  145318. protected _buildBlock(state: NodeMaterialBuildState): this;
  145319. }
  145320. }
  145321. declare module BABYLON {
  145322. /**
  145323. * Block used to add 2 vectors
  145324. */
  145325. export class AddBlock extends NodeMaterialBlock {
  145326. /**
  145327. * Creates a new AddBlock
  145328. * @param name defines the block name
  145329. */
  145330. constructor(name: string);
  145331. /**
  145332. * Gets the current class name
  145333. * @returns the class name
  145334. */
  145335. getClassName(): string;
  145336. /**
  145337. * Gets the left operand input component
  145338. */
  145339. get left(): NodeMaterialConnectionPoint;
  145340. /**
  145341. * Gets the right operand input component
  145342. */
  145343. get right(): NodeMaterialConnectionPoint;
  145344. /**
  145345. * Gets the output component
  145346. */
  145347. get output(): NodeMaterialConnectionPoint;
  145348. protected _buildBlock(state: NodeMaterialBuildState): this;
  145349. }
  145350. }
  145351. declare module BABYLON {
  145352. /**
  145353. * Block used to scale a vector by a float
  145354. */
  145355. export class ScaleBlock extends NodeMaterialBlock {
  145356. /**
  145357. * Creates a new ScaleBlock
  145358. * @param name defines the block name
  145359. */
  145360. constructor(name: string);
  145361. /**
  145362. * Gets the current class name
  145363. * @returns the class name
  145364. */
  145365. getClassName(): string;
  145366. /**
  145367. * Gets the input component
  145368. */
  145369. get input(): NodeMaterialConnectionPoint;
  145370. /**
  145371. * Gets the factor input component
  145372. */
  145373. get factor(): NodeMaterialConnectionPoint;
  145374. /**
  145375. * Gets the output component
  145376. */
  145377. get output(): NodeMaterialConnectionPoint;
  145378. protected _buildBlock(state: NodeMaterialBuildState): this;
  145379. }
  145380. }
  145381. declare module BABYLON {
  145382. /**
  145383. * Block used to clamp a float
  145384. */
  145385. export class ClampBlock extends NodeMaterialBlock {
  145386. /** Gets or sets the minimum range */
  145387. minimum: number;
  145388. /** Gets or sets the maximum range */
  145389. maximum: number;
  145390. /**
  145391. * Creates a new ClampBlock
  145392. * @param name defines the block name
  145393. */
  145394. constructor(name: string);
  145395. /**
  145396. * Gets the current class name
  145397. * @returns the class name
  145398. */
  145399. getClassName(): string;
  145400. /**
  145401. * Gets the value input component
  145402. */
  145403. get value(): NodeMaterialConnectionPoint;
  145404. /**
  145405. * Gets the output component
  145406. */
  145407. get output(): NodeMaterialConnectionPoint;
  145408. protected _buildBlock(state: NodeMaterialBuildState): this;
  145409. protected _dumpPropertiesCode(): string;
  145410. serialize(): any;
  145411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145412. }
  145413. }
  145414. declare module BABYLON {
  145415. /**
  145416. * Block used to apply a cross product between 2 vectors
  145417. */
  145418. export class CrossBlock extends NodeMaterialBlock {
  145419. /**
  145420. * Creates a new CrossBlock
  145421. * @param name defines the block name
  145422. */
  145423. constructor(name: string);
  145424. /**
  145425. * Gets the current class name
  145426. * @returns the class name
  145427. */
  145428. getClassName(): string;
  145429. /**
  145430. * Gets the left operand input component
  145431. */
  145432. get left(): NodeMaterialConnectionPoint;
  145433. /**
  145434. * Gets the right operand input component
  145435. */
  145436. get right(): NodeMaterialConnectionPoint;
  145437. /**
  145438. * Gets the output component
  145439. */
  145440. get output(): NodeMaterialConnectionPoint;
  145441. protected _buildBlock(state: NodeMaterialBuildState): this;
  145442. }
  145443. }
  145444. declare module BABYLON {
  145445. /**
  145446. * Block used to apply a dot product between 2 vectors
  145447. */
  145448. export class DotBlock extends NodeMaterialBlock {
  145449. /**
  145450. * Creates a new DotBlock
  145451. * @param name defines the block name
  145452. */
  145453. constructor(name: string);
  145454. /**
  145455. * Gets the current class name
  145456. * @returns the class name
  145457. */
  145458. getClassName(): string;
  145459. /**
  145460. * Gets the left operand input component
  145461. */
  145462. get left(): NodeMaterialConnectionPoint;
  145463. /**
  145464. * Gets the right operand input component
  145465. */
  145466. get right(): NodeMaterialConnectionPoint;
  145467. /**
  145468. * Gets the output component
  145469. */
  145470. get output(): NodeMaterialConnectionPoint;
  145471. protected _buildBlock(state: NodeMaterialBuildState): this;
  145472. }
  145473. }
  145474. declare module BABYLON {
  145475. /**
  145476. * Block used to normalize a vector
  145477. */
  145478. export class NormalizeBlock extends NodeMaterialBlock {
  145479. /**
  145480. * Creates a new NormalizeBlock
  145481. * @param name defines the block name
  145482. */
  145483. constructor(name: string);
  145484. /**
  145485. * Gets the current class name
  145486. * @returns the class name
  145487. */
  145488. getClassName(): string;
  145489. /**
  145490. * Gets the input component
  145491. */
  145492. get input(): NodeMaterialConnectionPoint;
  145493. /**
  145494. * Gets the output component
  145495. */
  145496. get output(): NodeMaterialConnectionPoint;
  145497. protected _buildBlock(state: NodeMaterialBuildState): this;
  145498. }
  145499. }
  145500. declare module BABYLON {
  145501. /**
  145502. * Block used to create a Color3/4 out of individual inputs (one for each component)
  145503. */
  145504. export class ColorMergerBlock extends NodeMaterialBlock {
  145505. /**
  145506. * Create a new ColorMergerBlock
  145507. * @param name defines the block name
  145508. */
  145509. constructor(name: string);
  145510. /**
  145511. * Gets the current class name
  145512. * @returns the class name
  145513. */
  145514. getClassName(): string;
  145515. /**
  145516. * Gets the rgb component (input)
  145517. */
  145518. get rgbIn(): NodeMaterialConnectionPoint;
  145519. /**
  145520. * Gets the r component (input)
  145521. */
  145522. get r(): NodeMaterialConnectionPoint;
  145523. /**
  145524. * Gets the g component (input)
  145525. */
  145526. get g(): NodeMaterialConnectionPoint;
  145527. /**
  145528. * Gets the b component (input)
  145529. */
  145530. get b(): NodeMaterialConnectionPoint;
  145531. /**
  145532. * Gets the a component (input)
  145533. */
  145534. get a(): NodeMaterialConnectionPoint;
  145535. /**
  145536. * Gets the rgba component (output)
  145537. */
  145538. get rgba(): NodeMaterialConnectionPoint;
  145539. /**
  145540. * Gets the rgb component (output)
  145541. */
  145542. get rgbOut(): NodeMaterialConnectionPoint;
  145543. /**
  145544. * Gets the rgb component (output)
  145545. * @deprecated Please use rgbOut instead.
  145546. */
  145547. get rgb(): NodeMaterialConnectionPoint;
  145548. protected _buildBlock(state: NodeMaterialBuildState): this;
  145549. }
  145550. }
  145551. declare module BABYLON {
  145552. /**
  145553. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  145554. */
  145555. export class VectorSplitterBlock extends NodeMaterialBlock {
  145556. /**
  145557. * Create a new VectorSplitterBlock
  145558. * @param name defines the block name
  145559. */
  145560. constructor(name: string);
  145561. /**
  145562. * Gets the current class name
  145563. * @returns the class name
  145564. */
  145565. getClassName(): string;
  145566. /**
  145567. * Gets the xyzw component (input)
  145568. */
  145569. get xyzw(): NodeMaterialConnectionPoint;
  145570. /**
  145571. * Gets the xyz component (input)
  145572. */
  145573. get xyzIn(): NodeMaterialConnectionPoint;
  145574. /**
  145575. * Gets the xy component (input)
  145576. */
  145577. get xyIn(): NodeMaterialConnectionPoint;
  145578. /**
  145579. * Gets the xyz component (output)
  145580. */
  145581. get xyzOut(): NodeMaterialConnectionPoint;
  145582. /**
  145583. * Gets the xy component (output)
  145584. */
  145585. get xyOut(): NodeMaterialConnectionPoint;
  145586. /**
  145587. * Gets the x component (output)
  145588. */
  145589. get x(): NodeMaterialConnectionPoint;
  145590. /**
  145591. * Gets the y component (output)
  145592. */
  145593. get y(): NodeMaterialConnectionPoint;
  145594. /**
  145595. * Gets the z component (output)
  145596. */
  145597. get z(): NodeMaterialConnectionPoint;
  145598. /**
  145599. * Gets the w component (output)
  145600. */
  145601. get w(): NodeMaterialConnectionPoint;
  145602. protected _inputRename(name: string): string;
  145603. protected _outputRename(name: string): string;
  145604. protected _buildBlock(state: NodeMaterialBuildState): this;
  145605. }
  145606. }
  145607. declare module BABYLON {
  145608. /**
  145609. * Block used to lerp between 2 values
  145610. */
  145611. export class LerpBlock extends NodeMaterialBlock {
  145612. /**
  145613. * Creates a new LerpBlock
  145614. * @param name defines the block name
  145615. */
  145616. constructor(name: string);
  145617. /**
  145618. * Gets the current class name
  145619. * @returns the class name
  145620. */
  145621. getClassName(): string;
  145622. /**
  145623. * Gets the left operand input component
  145624. */
  145625. get left(): NodeMaterialConnectionPoint;
  145626. /**
  145627. * Gets the right operand input component
  145628. */
  145629. get right(): NodeMaterialConnectionPoint;
  145630. /**
  145631. * Gets the gradient operand input component
  145632. */
  145633. get gradient(): NodeMaterialConnectionPoint;
  145634. /**
  145635. * Gets the output component
  145636. */
  145637. get output(): NodeMaterialConnectionPoint;
  145638. protected _buildBlock(state: NodeMaterialBuildState): this;
  145639. }
  145640. }
  145641. declare module BABYLON {
  145642. /**
  145643. * Block used to divide 2 vectors
  145644. */
  145645. export class DivideBlock extends NodeMaterialBlock {
  145646. /**
  145647. * Creates a new DivideBlock
  145648. * @param name defines the block name
  145649. */
  145650. constructor(name: string);
  145651. /**
  145652. * Gets the current class name
  145653. * @returns the class name
  145654. */
  145655. getClassName(): string;
  145656. /**
  145657. * Gets the left operand input component
  145658. */
  145659. get left(): NodeMaterialConnectionPoint;
  145660. /**
  145661. * Gets the right operand input component
  145662. */
  145663. get right(): NodeMaterialConnectionPoint;
  145664. /**
  145665. * Gets the output component
  145666. */
  145667. get output(): NodeMaterialConnectionPoint;
  145668. protected _buildBlock(state: NodeMaterialBuildState): this;
  145669. }
  145670. }
  145671. declare module BABYLON {
  145672. /**
  145673. * Block used to subtract 2 vectors
  145674. */
  145675. export class SubtractBlock extends NodeMaterialBlock {
  145676. /**
  145677. * Creates a new SubtractBlock
  145678. * @param name defines the block name
  145679. */
  145680. constructor(name: string);
  145681. /**
  145682. * Gets the current class name
  145683. * @returns the class name
  145684. */
  145685. getClassName(): string;
  145686. /**
  145687. * Gets the left operand input component
  145688. */
  145689. get left(): NodeMaterialConnectionPoint;
  145690. /**
  145691. * Gets the right operand input component
  145692. */
  145693. get right(): NodeMaterialConnectionPoint;
  145694. /**
  145695. * Gets the output component
  145696. */
  145697. get output(): NodeMaterialConnectionPoint;
  145698. protected _buildBlock(state: NodeMaterialBuildState): this;
  145699. }
  145700. }
  145701. declare module BABYLON {
  145702. /**
  145703. * Block used to step a value
  145704. */
  145705. export class StepBlock extends NodeMaterialBlock {
  145706. /**
  145707. * Creates a new StepBlock
  145708. * @param name defines the block name
  145709. */
  145710. constructor(name: string);
  145711. /**
  145712. * Gets the current class name
  145713. * @returns the class name
  145714. */
  145715. getClassName(): string;
  145716. /**
  145717. * Gets the value operand input component
  145718. */
  145719. get value(): NodeMaterialConnectionPoint;
  145720. /**
  145721. * Gets the edge operand input component
  145722. */
  145723. get edge(): NodeMaterialConnectionPoint;
  145724. /**
  145725. * Gets the output component
  145726. */
  145727. get output(): NodeMaterialConnectionPoint;
  145728. protected _buildBlock(state: NodeMaterialBuildState): this;
  145729. }
  145730. }
  145731. declare module BABYLON {
  145732. /**
  145733. * Block used to get the opposite (1 - x) of a value
  145734. */
  145735. export class OneMinusBlock extends NodeMaterialBlock {
  145736. /**
  145737. * Creates a new OneMinusBlock
  145738. * @param name defines the block name
  145739. */
  145740. constructor(name: string);
  145741. /**
  145742. * Gets the current class name
  145743. * @returns the class name
  145744. */
  145745. getClassName(): string;
  145746. /**
  145747. * Gets the input component
  145748. */
  145749. get input(): NodeMaterialConnectionPoint;
  145750. /**
  145751. * Gets the output component
  145752. */
  145753. get output(): NodeMaterialConnectionPoint;
  145754. protected _buildBlock(state: NodeMaterialBuildState): this;
  145755. }
  145756. }
  145757. declare module BABYLON {
  145758. /**
  145759. * Block used to get the view direction
  145760. */
  145761. export class ViewDirectionBlock extends NodeMaterialBlock {
  145762. /**
  145763. * Creates a new ViewDirectionBlock
  145764. * @param name defines the block name
  145765. */
  145766. constructor(name: string);
  145767. /**
  145768. * Gets the current class name
  145769. * @returns the class name
  145770. */
  145771. getClassName(): string;
  145772. /**
  145773. * Gets the world position component
  145774. */
  145775. get worldPosition(): NodeMaterialConnectionPoint;
  145776. /**
  145777. * Gets the camera position component
  145778. */
  145779. get cameraPosition(): NodeMaterialConnectionPoint;
  145780. /**
  145781. * Gets the output component
  145782. */
  145783. get output(): NodeMaterialConnectionPoint;
  145784. autoConfigure(material: NodeMaterial): void;
  145785. protected _buildBlock(state: NodeMaterialBuildState): this;
  145786. }
  145787. }
  145788. declare module BABYLON {
  145789. /**
  145790. * Block used to compute fresnel value
  145791. */
  145792. export class FresnelBlock extends NodeMaterialBlock {
  145793. /**
  145794. * Create a new FresnelBlock
  145795. * @param name defines the block name
  145796. */
  145797. constructor(name: string);
  145798. /**
  145799. * Gets the current class name
  145800. * @returns the class name
  145801. */
  145802. getClassName(): string;
  145803. /**
  145804. * Gets the world normal input component
  145805. */
  145806. get worldNormal(): NodeMaterialConnectionPoint;
  145807. /**
  145808. * Gets the view direction input component
  145809. */
  145810. get viewDirection(): NodeMaterialConnectionPoint;
  145811. /**
  145812. * Gets the bias input component
  145813. */
  145814. get bias(): NodeMaterialConnectionPoint;
  145815. /**
  145816. * Gets the camera (or eye) position component
  145817. */
  145818. get power(): NodeMaterialConnectionPoint;
  145819. /**
  145820. * Gets the fresnel output component
  145821. */
  145822. get fresnel(): NodeMaterialConnectionPoint;
  145823. autoConfigure(material: NodeMaterial): void;
  145824. protected _buildBlock(state: NodeMaterialBuildState): this;
  145825. }
  145826. }
  145827. declare module BABYLON {
  145828. /**
  145829. * Block used to get the max of 2 values
  145830. */
  145831. export class MaxBlock extends NodeMaterialBlock {
  145832. /**
  145833. * Creates a new MaxBlock
  145834. * @param name defines the block name
  145835. */
  145836. constructor(name: string);
  145837. /**
  145838. * Gets the current class name
  145839. * @returns the class name
  145840. */
  145841. getClassName(): string;
  145842. /**
  145843. * Gets the left operand input component
  145844. */
  145845. get left(): NodeMaterialConnectionPoint;
  145846. /**
  145847. * Gets the right operand input component
  145848. */
  145849. get right(): NodeMaterialConnectionPoint;
  145850. /**
  145851. * Gets the output component
  145852. */
  145853. get output(): NodeMaterialConnectionPoint;
  145854. protected _buildBlock(state: NodeMaterialBuildState): this;
  145855. }
  145856. }
  145857. declare module BABYLON {
  145858. /**
  145859. * Block used to get the min of 2 values
  145860. */
  145861. export class MinBlock extends NodeMaterialBlock {
  145862. /**
  145863. * Creates a new MinBlock
  145864. * @param name defines the block name
  145865. */
  145866. constructor(name: string);
  145867. /**
  145868. * Gets the current class name
  145869. * @returns the class name
  145870. */
  145871. getClassName(): string;
  145872. /**
  145873. * Gets the left operand input component
  145874. */
  145875. get left(): NodeMaterialConnectionPoint;
  145876. /**
  145877. * Gets the right operand input component
  145878. */
  145879. get right(): NodeMaterialConnectionPoint;
  145880. /**
  145881. * Gets the output component
  145882. */
  145883. get output(): NodeMaterialConnectionPoint;
  145884. protected _buildBlock(state: NodeMaterialBuildState): this;
  145885. }
  145886. }
  145887. declare module BABYLON {
  145888. /**
  145889. * Block used to get the distance between 2 values
  145890. */
  145891. export class DistanceBlock extends NodeMaterialBlock {
  145892. /**
  145893. * Creates a new DistanceBlock
  145894. * @param name defines the block name
  145895. */
  145896. constructor(name: string);
  145897. /**
  145898. * Gets the current class name
  145899. * @returns the class name
  145900. */
  145901. getClassName(): string;
  145902. /**
  145903. * Gets the left operand input component
  145904. */
  145905. get left(): NodeMaterialConnectionPoint;
  145906. /**
  145907. * Gets the right operand input component
  145908. */
  145909. get right(): NodeMaterialConnectionPoint;
  145910. /**
  145911. * Gets the output component
  145912. */
  145913. get output(): NodeMaterialConnectionPoint;
  145914. protected _buildBlock(state: NodeMaterialBuildState): this;
  145915. }
  145916. }
  145917. declare module BABYLON {
  145918. /**
  145919. * Block used to get the length of a vector
  145920. */
  145921. export class LengthBlock extends NodeMaterialBlock {
  145922. /**
  145923. * Creates a new LengthBlock
  145924. * @param name defines the block name
  145925. */
  145926. constructor(name: string);
  145927. /**
  145928. * Gets the current class name
  145929. * @returns the class name
  145930. */
  145931. getClassName(): string;
  145932. /**
  145933. * Gets the value input component
  145934. */
  145935. get value(): NodeMaterialConnectionPoint;
  145936. /**
  145937. * Gets the output component
  145938. */
  145939. get output(): NodeMaterialConnectionPoint;
  145940. protected _buildBlock(state: NodeMaterialBuildState): this;
  145941. }
  145942. }
  145943. declare module BABYLON {
  145944. /**
  145945. * Block used to get negative version of a value (i.e. x * -1)
  145946. */
  145947. export class NegateBlock extends NodeMaterialBlock {
  145948. /**
  145949. * Creates a new NegateBlock
  145950. * @param name defines the block name
  145951. */
  145952. constructor(name: string);
  145953. /**
  145954. * Gets the current class name
  145955. * @returns the class name
  145956. */
  145957. getClassName(): string;
  145958. /**
  145959. * Gets the value input component
  145960. */
  145961. get value(): NodeMaterialConnectionPoint;
  145962. /**
  145963. * Gets the output component
  145964. */
  145965. get output(): NodeMaterialConnectionPoint;
  145966. protected _buildBlock(state: NodeMaterialBuildState): this;
  145967. }
  145968. }
  145969. declare module BABYLON {
  145970. /**
  145971. * Block used to get the value of the first parameter raised to the power of the second
  145972. */
  145973. export class PowBlock extends NodeMaterialBlock {
  145974. /**
  145975. * Creates a new PowBlock
  145976. * @param name defines the block name
  145977. */
  145978. constructor(name: string);
  145979. /**
  145980. * Gets the current class name
  145981. * @returns the class name
  145982. */
  145983. getClassName(): string;
  145984. /**
  145985. * Gets the value operand input component
  145986. */
  145987. get value(): NodeMaterialConnectionPoint;
  145988. /**
  145989. * Gets the power operand input component
  145990. */
  145991. get power(): NodeMaterialConnectionPoint;
  145992. /**
  145993. * Gets the output component
  145994. */
  145995. get output(): NodeMaterialConnectionPoint;
  145996. protected _buildBlock(state: NodeMaterialBuildState): this;
  145997. }
  145998. }
  145999. declare module BABYLON {
  146000. /**
  146001. * Block used to get a random number
  146002. */
  146003. export class RandomNumberBlock extends NodeMaterialBlock {
  146004. /**
  146005. * Creates a new RandomNumberBlock
  146006. * @param name defines the block name
  146007. */
  146008. constructor(name: string);
  146009. /**
  146010. * Gets the current class name
  146011. * @returns the class name
  146012. */
  146013. getClassName(): string;
  146014. /**
  146015. * Gets the seed input component
  146016. */
  146017. get seed(): 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 compute arc tangent of 2 values
  146028. */
  146029. export class ArcTan2Block extends NodeMaterialBlock {
  146030. /**
  146031. * Creates a new ArcTan2Block
  146032. * @param name defines the block name
  146033. */
  146034. constructor(name: string);
  146035. /**
  146036. * Gets the current class name
  146037. * @returns the class name
  146038. */
  146039. getClassName(): string;
  146040. /**
  146041. * Gets the x operand input component
  146042. */
  146043. get x(): NodeMaterialConnectionPoint;
  146044. /**
  146045. * Gets the y operand input component
  146046. */
  146047. get y(): NodeMaterialConnectionPoint;
  146048. /**
  146049. * Gets the output component
  146050. */
  146051. get output(): NodeMaterialConnectionPoint;
  146052. protected _buildBlock(state: NodeMaterialBuildState): this;
  146053. }
  146054. }
  146055. declare module BABYLON {
  146056. /**
  146057. * Block used to smooth step a value
  146058. */
  146059. export class SmoothStepBlock extends NodeMaterialBlock {
  146060. /**
  146061. * Creates a new SmoothStepBlock
  146062. * @param name defines the block name
  146063. */
  146064. constructor(name: string);
  146065. /**
  146066. * Gets the current class name
  146067. * @returns the class name
  146068. */
  146069. getClassName(): string;
  146070. /**
  146071. * Gets the value operand input component
  146072. */
  146073. get value(): NodeMaterialConnectionPoint;
  146074. /**
  146075. * Gets the first edge operand input component
  146076. */
  146077. get edge0(): NodeMaterialConnectionPoint;
  146078. /**
  146079. * Gets the second edge operand input component
  146080. */
  146081. get edge1(): NodeMaterialConnectionPoint;
  146082. /**
  146083. * Gets the output component
  146084. */
  146085. get output(): NodeMaterialConnectionPoint;
  146086. protected _buildBlock(state: NodeMaterialBuildState): this;
  146087. }
  146088. }
  146089. declare module BABYLON {
  146090. /**
  146091. * Block used to get the reciprocal (1 / x) of a value
  146092. */
  146093. export class ReciprocalBlock extends NodeMaterialBlock {
  146094. /**
  146095. * Creates a new ReciprocalBlock
  146096. * @param name defines the block name
  146097. */
  146098. constructor(name: string);
  146099. /**
  146100. * Gets the current class name
  146101. * @returns the class name
  146102. */
  146103. getClassName(): string;
  146104. /**
  146105. * Gets the input component
  146106. */
  146107. get input(): NodeMaterialConnectionPoint;
  146108. /**
  146109. * Gets the output component
  146110. */
  146111. get output(): NodeMaterialConnectionPoint;
  146112. protected _buildBlock(state: NodeMaterialBuildState): this;
  146113. }
  146114. }
  146115. declare module BABYLON {
  146116. /**
  146117. * Block used to replace a color by another one
  146118. */
  146119. export class ReplaceColorBlock extends NodeMaterialBlock {
  146120. /**
  146121. * Creates a new ReplaceColorBlock
  146122. * @param name defines the block name
  146123. */
  146124. constructor(name: string);
  146125. /**
  146126. * Gets the current class name
  146127. * @returns the class name
  146128. */
  146129. getClassName(): string;
  146130. /**
  146131. * Gets the value input component
  146132. */
  146133. get value(): NodeMaterialConnectionPoint;
  146134. /**
  146135. * Gets the reference input component
  146136. */
  146137. get reference(): NodeMaterialConnectionPoint;
  146138. /**
  146139. * Gets the distance input component
  146140. */
  146141. get distance(): NodeMaterialConnectionPoint;
  146142. /**
  146143. * Gets the replacement input component
  146144. */
  146145. get replacement(): NodeMaterialConnectionPoint;
  146146. /**
  146147. * Gets the output component
  146148. */
  146149. get output(): NodeMaterialConnectionPoint;
  146150. protected _buildBlock(state: NodeMaterialBuildState): this;
  146151. }
  146152. }
  146153. declare module BABYLON {
  146154. /**
  146155. * Block used to posterize a value
  146156. * @see https://en.wikipedia.org/wiki/Posterization
  146157. */
  146158. export class PosterizeBlock extends NodeMaterialBlock {
  146159. /**
  146160. * Creates a new PosterizeBlock
  146161. * @param name defines the block name
  146162. */
  146163. constructor(name: string);
  146164. /**
  146165. * Gets the current class name
  146166. * @returns the class name
  146167. */
  146168. getClassName(): string;
  146169. /**
  146170. * Gets the value input component
  146171. */
  146172. get value(): NodeMaterialConnectionPoint;
  146173. /**
  146174. * Gets the steps input component
  146175. */
  146176. get steps(): NodeMaterialConnectionPoint;
  146177. /**
  146178. * Gets the output component
  146179. */
  146180. get output(): NodeMaterialConnectionPoint;
  146181. protected _buildBlock(state: NodeMaterialBuildState): this;
  146182. }
  146183. }
  146184. declare module BABYLON {
  146185. /**
  146186. * Operations supported by the Wave block
  146187. */
  146188. export enum WaveBlockKind {
  146189. /** SawTooth */
  146190. SawTooth = 0,
  146191. /** Square */
  146192. Square = 1,
  146193. /** Triangle */
  146194. Triangle = 2
  146195. }
  146196. /**
  146197. * Block used to apply wave operation to floats
  146198. */
  146199. export class WaveBlock extends NodeMaterialBlock {
  146200. /**
  146201. * Gets or sets the kibnd of wave to be applied by the block
  146202. */
  146203. kind: WaveBlockKind;
  146204. /**
  146205. * Creates a new WaveBlock
  146206. * @param name defines the block name
  146207. */
  146208. constructor(name: string);
  146209. /**
  146210. * Gets the current class name
  146211. * @returns the class name
  146212. */
  146213. getClassName(): string;
  146214. /**
  146215. * Gets the input component
  146216. */
  146217. get input(): NodeMaterialConnectionPoint;
  146218. /**
  146219. * Gets the output component
  146220. */
  146221. get output(): NodeMaterialConnectionPoint;
  146222. protected _buildBlock(state: NodeMaterialBuildState): this;
  146223. serialize(): any;
  146224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146225. }
  146226. }
  146227. declare module BABYLON {
  146228. /**
  146229. * Class used to store a color step for the GradientBlock
  146230. */
  146231. export class GradientBlockColorStep {
  146232. private _step;
  146233. /**
  146234. * Gets value indicating which step this color is associated with (between 0 and 1)
  146235. */
  146236. get step(): number;
  146237. /**
  146238. * Sets a value indicating which step this color is associated with (between 0 and 1)
  146239. */
  146240. set step(val: number);
  146241. private _color;
  146242. /**
  146243. * Gets the color associated with this step
  146244. */
  146245. get color(): Color3;
  146246. /**
  146247. * Sets the color associated with this step
  146248. */
  146249. set color(val: Color3);
  146250. /**
  146251. * Creates a new GradientBlockColorStep
  146252. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  146253. * @param color defines the color associated with this step
  146254. */
  146255. constructor(step: number, color: Color3);
  146256. }
  146257. /**
  146258. * Block used to return a color from a gradient based on an input value between 0 and 1
  146259. */
  146260. export class GradientBlock extends NodeMaterialBlock {
  146261. /**
  146262. * Gets or sets the list of color steps
  146263. */
  146264. colorSteps: GradientBlockColorStep[];
  146265. /** Gets an observable raised when the value is changed */
  146266. onValueChangedObservable: Observable<GradientBlock>;
  146267. /** calls observable when the value is changed*/
  146268. colorStepsUpdated(): void;
  146269. /**
  146270. * Creates a new GradientBlock
  146271. * @param name defines the block name
  146272. */
  146273. constructor(name: string);
  146274. /**
  146275. * Gets the current class name
  146276. * @returns the class name
  146277. */
  146278. getClassName(): string;
  146279. /**
  146280. * Gets the gradient input component
  146281. */
  146282. get gradient(): NodeMaterialConnectionPoint;
  146283. /**
  146284. * Gets the output component
  146285. */
  146286. get output(): NodeMaterialConnectionPoint;
  146287. private _writeColorConstant;
  146288. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146289. serialize(): any;
  146290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146291. protected _dumpPropertiesCode(): string;
  146292. }
  146293. }
  146294. declare module BABYLON {
  146295. /**
  146296. * Block used to normalize lerp between 2 values
  146297. */
  146298. export class NLerpBlock extends NodeMaterialBlock {
  146299. /**
  146300. * Creates a new NLerpBlock
  146301. * @param name defines the block name
  146302. */
  146303. constructor(name: string);
  146304. /**
  146305. * Gets the current class name
  146306. * @returns the class name
  146307. */
  146308. getClassName(): string;
  146309. /**
  146310. * Gets the left operand input component
  146311. */
  146312. get left(): NodeMaterialConnectionPoint;
  146313. /**
  146314. * Gets the right operand input component
  146315. */
  146316. get right(): NodeMaterialConnectionPoint;
  146317. /**
  146318. * Gets the gradient operand input component
  146319. */
  146320. get gradient(): NodeMaterialConnectionPoint;
  146321. /**
  146322. * Gets the output component
  146323. */
  146324. get output(): NodeMaterialConnectionPoint;
  146325. protected _buildBlock(state: NodeMaterialBuildState): this;
  146326. }
  146327. }
  146328. declare module BABYLON {
  146329. /**
  146330. * block used to Generate a Worley Noise 3D Noise Pattern
  146331. */
  146332. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  146333. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  146334. manhattanDistance: boolean;
  146335. /**
  146336. * Creates a new WorleyNoise3DBlock
  146337. * @param name defines the block name
  146338. */
  146339. constructor(name: string);
  146340. /**
  146341. * Gets the current class name
  146342. * @returns the class name
  146343. */
  146344. getClassName(): string;
  146345. /**
  146346. * Gets the seed input component
  146347. */
  146348. get seed(): NodeMaterialConnectionPoint;
  146349. /**
  146350. * Gets the jitter input component
  146351. */
  146352. get jitter(): NodeMaterialConnectionPoint;
  146353. /**
  146354. * Gets the output component
  146355. */
  146356. get output(): NodeMaterialConnectionPoint;
  146357. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146358. /**
  146359. * Exposes the properties to the UI?
  146360. */
  146361. protected _dumpPropertiesCode(): string;
  146362. /**
  146363. * Exposes the properties to the Seralize?
  146364. */
  146365. serialize(): any;
  146366. /**
  146367. * Exposes the properties to the deseralize?
  146368. */
  146369. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146370. }
  146371. }
  146372. declare module BABYLON {
  146373. /**
  146374. * block used to Generate a Simplex Perlin 3d Noise Pattern
  146375. */
  146376. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  146377. /**
  146378. * Creates a new SimplexPerlin3DBlock
  146379. * @param name defines the block name
  146380. */
  146381. constructor(name: string);
  146382. /**
  146383. * Gets the current class name
  146384. * @returns the class name
  146385. */
  146386. getClassName(): string;
  146387. /**
  146388. * Gets the seed operand input component
  146389. */
  146390. get seed(): NodeMaterialConnectionPoint;
  146391. /**
  146392. * Gets the output component
  146393. */
  146394. get output(): NodeMaterialConnectionPoint;
  146395. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146396. }
  146397. }
  146398. declare module BABYLON {
  146399. /**
  146400. * Block used to blend normals
  146401. */
  146402. export class NormalBlendBlock extends NodeMaterialBlock {
  146403. /**
  146404. * Creates a new NormalBlendBlock
  146405. * @param name defines the block name
  146406. */
  146407. constructor(name: string);
  146408. /**
  146409. * Gets the current class name
  146410. * @returns the class name
  146411. */
  146412. getClassName(): string;
  146413. /**
  146414. * Gets the first input component
  146415. */
  146416. get normalMap0(): NodeMaterialConnectionPoint;
  146417. /**
  146418. * Gets the second input component
  146419. */
  146420. get normalMap1(): NodeMaterialConnectionPoint;
  146421. /**
  146422. * Gets the output component
  146423. */
  146424. get output(): NodeMaterialConnectionPoint;
  146425. protected _buildBlock(state: NodeMaterialBuildState): this;
  146426. }
  146427. }
  146428. declare module BABYLON {
  146429. /**
  146430. * Block used to rotate a 2d vector by a given angle
  146431. */
  146432. export class Rotate2dBlock extends NodeMaterialBlock {
  146433. /**
  146434. * Creates a new Rotate2dBlock
  146435. * @param name defines the block name
  146436. */
  146437. constructor(name: string);
  146438. /**
  146439. * Gets the current class name
  146440. * @returns the class name
  146441. */
  146442. getClassName(): string;
  146443. /**
  146444. * Gets the input vector
  146445. */
  146446. get input(): NodeMaterialConnectionPoint;
  146447. /**
  146448. * Gets the input angle
  146449. */
  146450. get angle(): NodeMaterialConnectionPoint;
  146451. /**
  146452. * Gets the output component
  146453. */
  146454. get output(): NodeMaterialConnectionPoint;
  146455. autoConfigure(material: NodeMaterial): void;
  146456. protected _buildBlock(state: NodeMaterialBuildState): this;
  146457. }
  146458. }
  146459. declare module BABYLON {
  146460. /**
  146461. * Block used to get the reflected vector from a direction and a normal
  146462. */
  146463. export class ReflectBlock extends NodeMaterialBlock {
  146464. /**
  146465. * Creates a new ReflectBlock
  146466. * @param name defines the block name
  146467. */
  146468. constructor(name: string);
  146469. /**
  146470. * Gets the current class name
  146471. * @returns the class name
  146472. */
  146473. getClassName(): string;
  146474. /**
  146475. * Gets the incident component
  146476. */
  146477. get incident(): NodeMaterialConnectionPoint;
  146478. /**
  146479. * Gets the normal component
  146480. */
  146481. get normal(): NodeMaterialConnectionPoint;
  146482. /**
  146483. * Gets the output component
  146484. */
  146485. get output(): NodeMaterialConnectionPoint;
  146486. protected _buildBlock(state: NodeMaterialBuildState): this;
  146487. }
  146488. }
  146489. declare module BABYLON {
  146490. /**
  146491. * Block used to get the refracted vector from a direction and a normal
  146492. */
  146493. export class RefractBlock extends NodeMaterialBlock {
  146494. /**
  146495. * Creates a new RefractBlock
  146496. * @param name defines the block name
  146497. */
  146498. constructor(name: string);
  146499. /**
  146500. * Gets the current class name
  146501. * @returns the class name
  146502. */
  146503. getClassName(): string;
  146504. /**
  146505. * Gets the incident component
  146506. */
  146507. get incident(): NodeMaterialConnectionPoint;
  146508. /**
  146509. * Gets the normal component
  146510. */
  146511. get normal(): NodeMaterialConnectionPoint;
  146512. /**
  146513. * Gets the index of refraction component
  146514. */
  146515. get ior(): NodeMaterialConnectionPoint;
  146516. /**
  146517. * Gets the output component
  146518. */
  146519. get output(): NodeMaterialConnectionPoint;
  146520. protected _buildBlock(state: NodeMaterialBuildState): this;
  146521. }
  146522. }
  146523. declare module BABYLON {
  146524. /**
  146525. * Block used to desaturate a color
  146526. */
  146527. export class DesaturateBlock extends NodeMaterialBlock {
  146528. /**
  146529. * Creates a new DesaturateBlock
  146530. * @param name defines the block name
  146531. */
  146532. constructor(name: string);
  146533. /**
  146534. * Gets the current class name
  146535. * @returns the class name
  146536. */
  146537. getClassName(): string;
  146538. /**
  146539. * Gets the color operand input component
  146540. */
  146541. get color(): NodeMaterialConnectionPoint;
  146542. /**
  146543. * Gets the level operand input component
  146544. */
  146545. get level(): NodeMaterialConnectionPoint;
  146546. /**
  146547. * Gets the output component
  146548. */
  146549. get output(): NodeMaterialConnectionPoint;
  146550. protected _buildBlock(state: NodeMaterialBuildState): this;
  146551. }
  146552. }
  146553. declare module BABYLON {
  146554. /**
  146555. * Block used to implement the ambient occlusion module of the PBR material
  146556. */
  146557. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  146558. /**
  146559. * Create a new AmbientOcclusionBlock
  146560. * @param name defines the block name
  146561. */
  146562. constructor(name: string);
  146563. /**
  146564. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  146565. */
  146566. useAmbientInGrayScale: boolean;
  146567. /**
  146568. * Initialize the block and prepare the context for build
  146569. * @param state defines the state that will be used for the build
  146570. */
  146571. initialize(state: NodeMaterialBuildState): void;
  146572. /**
  146573. * Gets the current class name
  146574. * @returns the class name
  146575. */
  146576. getClassName(): string;
  146577. /**
  146578. * Gets the texture input component
  146579. */
  146580. get texture(): NodeMaterialConnectionPoint;
  146581. /**
  146582. * Gets the texture intensity component
  146583. */
  146584. get intensity(): NodeMaterialConnectionPoint;
  146585. /**
  146586. * Gets the direct light intensity input component
  146587. */
  146588. get directLightIntensity(): NodeMaterialConnectionPoint;
  146589. /**
  146590. * Gets the ambient occlusion object output component
  146591. */
  146592. get ambientOcc(): NodeMaterialConnectionPoint;
  146593. /**
  146594. * Gets the main code of the block (fragment side)
  146595. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  146596. * @returns the shader code
  146597. */
  146598. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  146599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146600. protected _buildBlock(state: NodeMaterialBuildState): this;
  146601. protected _dumpPropertiesCode(): string;
  146602. serialize(): any;
  146603. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146604. }
  146605. }
  146606. declare module BABYLON {
  146607. /**
  146608. * Block used to implement the reflection module of the PBR material
  146609. */
  146610. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  146611. /** @hidden */
  146612. _defineLODReflectionAlpha: string;
  146613. /** @hidden */
  146614. _defineLinearSpecularReflection: string;
  146615. private _vEnvironmentIrradianceName;
  146616. /** @hidden */
  146617. _vReflectionMicrosurfaceInfosName: string;
  146618. /** @hidden */
  146619. _vReflectionInfosName: string;
  146620. /** @hidden */
  146621. _vReflectionFilteringInfoName: string;
  146622. private _scene;
  146623. /**
  146624. * The three properties below are set by the main PBR block prior to calling methods of this class.
  146625. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146626. * It's less burden on the user side in the editor part.
  146627. */
  146628. /** @hidden */
  146629. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146630. /** @hidden */
  146631. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146632. /** @hidden */
  146633. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  146634. /**
  146635. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  146636. * diffuse part of the IBL.
  146637. */
  146638. useSphericalHarmonics: boolean;
  146639. /**
  146640. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  146641. */
  146642. forceIrradianceInFragment: boolean;
  146643. /**
  146644. * Create a new ReflectionBlock
  146645. * @param name defines the block name
  146646. */
  146647. constructor(name: string);
  146648. /**
  146649. * Gets the current class name
  146650. * @returns the class name
  146651. */
  146652. getClassName(): string;
  146653. /**
  146654. * Gets the position input component
  146655. */
  146656. get position(): NodeMaterialConnectionPoint;
  146657. /**
  146658. * Gets the world position input component
  146659. */
  146660. get worldPosition(): NodeMaterialConnectionPoint;
  146661. /**
  146662. * Gets the world normal input component
  146663. */
  146664. get worldNormal(): NodeMaterialConnectionPoint;
  146665. /**
  146666. * Gets the world input component
  146667. */
  146668. get world(): NodeMaterialConnectionPoint;
  146669. /**
  146670. * Gets the camera (or eye) position component
  146671. */
  146672. get cameraPosition(): NodeMaterialConnectionPoint;
  146673. /**
  146674. * Gets the view input component
  146675. */
  146676. get view(): NodeMaterialConnectionPoint;
  146677. /**
  146678. * Gets the color input component
  146679. */
  146680. get color(): NodeMaterialConnectionPoint;
  146681. /**
  146682. * Gets the reflection object output component
  146683. */
  146684. get reflection(): NodeMaterialConnectionPoint;
  146685. /**
  146686. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  146687. */
  146688. get hasTexture(): boolean;
  146689. /**
  146690. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  146691. */
  146692. get reflectionColor(): string;
  146693. protected _getTexture(): Nullable<BaseTexture>;
  146694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146696. /**
  146697. * Gets the code to inject in the vertex shader
  146698. * @param state current state of the node material building
  146699. * @returns the shader code
  146700. */
  146701. handleVertexSide(state: NodeMaterialBuildState): string;
  146702. /**
  146703. * Gets the main code of the block (fragment side)
  146704. * @param state current state of the node material building
  146705. * @param normalVarName name of the existing variable corresponding to the normal
  146706. * @returns the shader code
  146707. */
  146708. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  146709. protected _buildBlock(state: NodeMaterialBuildState): this;
  146710. protected _dumpPropertiesCode(): string;
  146711. serialize(): any;
  146712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146713. }
  146714. }
  146715. declare module BABYLON {
  146716. /**
  146717. * Block used to implement the sheen module of the PBR material
  146718. */
  146719. export class SheenBlock extends NodeMaterialBlock {
  146720. /**
  146721. * Create a new SheenBlock
  146722. * @param name defines the block name
  146723. */
  146724. constructor(name: string);
  146725. /**
  146726. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  146727. * It allows the strength of the sheen effect to not depend on the base color of the material,
  146728. * making it easier to setup and tweak the effect
  146729. */
  146730. albedoScaling: boolean;
  146731. /**
  146732. * Defines if the sheen is linked to the sheen color.
  146733. */
  146734. linkSheenWithAlbedo: boolean;
  146735. /**
  146736. * Initialize the block and prepare the context for build
  146737. * @param state defines the state that will be used for the build
  146738. */
  146739. initialize(state: NodeMaterialBuildState): void;
  146740. /**
  146741. * Gets the current class name
  146742. * @returns the class name
  146743. */
  146744. getClassName(): string;
  146745. /**
  146746. * Gets the intensity input component
  146747. */
  146748. get intensity(): NodeMaterialConnectionPoint;
  146749. /**
  146750. * Gets the color input component
  146751. */
  146752. get color(): NodeMaterialConnectionPoint;
  146753. /**
  146754. * Gets the roughness input component
  146755. */
  146756. get roughness(): NodeMaterialConnectionPoint;
  146757. /**
  146758. * Gets the sheen object output component
  146759. */
  146760. get sheen(): NodeMaterialConnectionPoint;
  146761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146762. /**
  146763. * Gets the main code of the block (fragment side)
  146764. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146765. * @returns the shader code
  146766. */
  146767. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  146768. protected _buildBlock(state: NodeMaterialBuildState): this;
  146769. protected _dumpPropertiesCode(): string;
  146770. serialize(): any;
  146771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146772. }
  146773. }
  146774. declare module BABYLON {
  146775. /**
  146776. * Block used to implement the reflectivity module of the PBR material
  146777. */
  146778. export class ReflectivityBlock extends NodeMaterialBlock {
  146779. private _metallicReflectanceColor;
  146780. private _metallicF0Factor;
  146781. /** @hidden */
  146782. _vMetallicReflectanceFactorsName: string;
  146783. /**
  146784. * The property below is set by the main PBR block prior to calling methods of this class.
  146785. */
  146786. /** @hidden */
  146787. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  146788. /**
  146789. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  146790. */
  146791. useAmbientOcclusionFromMetallicTextureRed: boolean;
  146792. /**
  146793. * Specifies if the metallic texture contains the metallness information in its blue channel.
  146794. */
  146795. useMetallnessFromMetallicTextureBlue: boolean;
  146796. /**
  146797. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  146798. */
  146799. useRoughnessFromMetallicTextureAlpha: boolean;
  146800. /**
  146801. * Specifies if the metallic texture contains the roughness information in its green channel.
  146802. */
  146803. useRoughnessFromMetallicTextureGreen: boolean;
  146804. /**
  146805. * Create a new ReflectivityBlock
  146806. * @param name defines the block name
  146807. */
  146808. constructor(name: string);
  146809. /**
  146810. * Initialize the block and prepare the context for build
  146811. * @param state defines the state that will be used for the build
  146812. */
  146813. initialize(state: NodeMaterialBuildState): void;
  146814. /**
  146815. * Gets the current class name
  146816. * @returns the class name
  146817. */
  146818. getClassName(): string;
  146819. /**
  146820. * Gets the metallic input component
  146821. */
  146822. get metallic(): NodeMaterialConnectionPoint;
  146823. /**
  146824. * Gets the roughness input component
  146825. */
  146826. get roughness(): NodeMaterialConnectionPoint;
  146827. /**
  146828. * Gets the texture input component
  146829. */
  146830. get texture(): NodeMaterialConnectionPoint;
  146831. /**
  146832. * Gets the reflectivity object output component
  146833. */
  146834. get reflectivity(): NodeMaterialConnectionPoint;
  146835. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146836. /**
  146837. * Gets the main code of the block (fragment side)
  146838. * @param state current state of the node material building
  146839. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146840. * @returns the shader code
  146841. */
  146842. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146844. protected _buildBlock(state: NodeMaterialBuildState): this;
  146845. protected _dumpPropertiesCode(): string;
  146846. serialize(): any;
  146847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146848. }
  146849. }
  146850. declare module BABYLON {
  146851. /**
  146852. * Block used to implement the anisotropy module of the PBR material
  146853. */
  146854. export class AnisotropyBlock extends NodeMaterialBlock {
  146855. /**
  146856. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146857. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146858. * It's less burden on the user side in the editor part.
  146859. */
  146860. /** @hidden */
  146861. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146862. /** @hidden */
  146863. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146864. /**
  146865. * Create a new AnisotropyBlock
  146866. * @param name defines the block name
  146867. */
  146868. constructor(name: string);
  146869. /**
  146870. * Initialize the block and prepare the context for build
  146871. * @param state defines the state that will be used for the build
  146872. */
  146873. initialize(state: NodeMaterialBuildState): void;
  146874. /**
  146875. * Gets the current class name
  146876. * @returns the class name
  146877. */
  146878. getClassName(): string;
  146879. /**
  146880. * Gets the intensity input component
  146881. */
  146882. get intensity(): NodeMaterialConnectionPoint;
  146883. /**
  146884. * Gets the direction input component
  146885. */
  146886. get direction(): NodeMaterialConnectionPoint;
  146887. /**
  146888. * Gets the texture input component
  146889. */
  146890. get texture(): NodeMaterialConnectionPoint;
  146891. /**
  146892. * Gets the uv input component
  146893. */
  146894. get uv(): NodeMaterialConnectionPoint;
  146895. /**
  146896. * Gets the worldTangent input component
  146897. */
  146898. get worldTangent(): NodeMaterialConnectionPoint;
  146899. /**
  146900. * Gets the anisotropy object output component
  146901. */
  146902. get anisotropy(): NodeMaterialConnectionPoint;
  146903. private _generateTBNSpace;
  146904. /**
  146905. * Gets the main code of the block (fragment side)
  146906. * @param state current state of the node material building
  146907. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146908. * @returns the shader code
  146909. */
  146910. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146912. protected _buildBlock(state: NodeMaterialBuildState): this;
  146913. }
  146914. }
  146915. declare module BABYLON {
  146916. /**
  146917. * Block used to implement the clear coat module of the PBR material
  146918. */
  146919. export class ClearCoatBlock extends NodeMaterialBlock {
  146920. private _scene;
  146921. /**
  146922. * Create a new ClearCoatBlock
  146923. * @param name defines the block name
  146924. */
  146925. constructor(name: string);
  146926. /**
  146927. * Initialize the block and prepare the context for build
  146928. * @param state defines the state that will be used for the build
  146929. */
  146930. initialize(state: NodeMaterialBuildState): void;
  146931. /**
  146932. * Gets the current class name
  146933. * @returns the class name
  146934. */
  146935. getClassName(): string;
  146936. /**
  146937. * Gets the intensity input component
  146938. */
  146939. get intensity(): NodeMaterialConnectionPoint;
  146940. /**
  146941. * Gets the roughness input component
  146942. */
  146943. get roughness(): NodeMaterialConnectionPoint;
  146944. /**
  146945. * Gets the ior input component
  146946. */
  146947. get ior(): NodeMaterialConnectionPoint;
  146948. /**
  146949. * Gets the texture input component
  146950. */
  146951. get texture(): NodeMaterialConnectionPoint;
  146952. /**
  146953. * Gets the bump texture input component
  146954. */
  146955. get bumpTexture(): NodeMaterialConnectionPoint;
  146956. /**
  146957. * Gets the uv input component
  146958. */
  146959. get uv(): NodeMaterialConnectionPoint;
  146960. /**
  146961. * Gets the tint color input component
  146962. */
  146963. get tintColor(): NodeMaterialConnectionPoint;
  146964. /**
  146965. * Gets the tint "at distance" input component
  146966. */
  146967. get tintAtDistance(): NodeMaterialConnectionPoint;
  146968. /**
  146969. * Gets the tint thickness input component
  146970. */
  146971. get tintThickness(): NodeMaterialConnectionPoint;
  146972. /**
  146973. * Gets the world tangent input component
  146974. */
  146975. get worldTangent(): NodeMaterialConnectionPoint;
  146976. /**
  146977. * Gets the clear coat object output component
  146978. */
  146979. get clearcoat(): NodeMaterialConnectionPoint;
  146980. autoConfigure(material: NodeMaterial): void;
  146981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146983. private _generateTBNSpace;
  146984. /**
  146985. * Gets the main code of the block (fragment side)
  146986. * @param state current state of the node material building
  146987. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146988. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146989. * @param worldPosVarName name of the variable holding the world position
  146990. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146991. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146992. * @param worldNormalVarName name of the variable holding the world normal
  146993. * @returns the shader code
  146994. */
  146995. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146996. protected _buildBlock(state: NodeMaterialBuildState): this;
  146997. }
  146998. }
  146999. declare module BABYLON {
  147000. /**
  147001. * Block used to implement the sub surface module of the PBR material
  147002. */
  147003. export class SubSurfaceBlock extends NodeMaterialBlock {
  147004. /**
  147005. * Create a new SubSurfaceBlock
  147006. * @param name defines the block name
  147007. */
  147008. constructor(name: string);
  147009. /**
  147010. * Stores the intensity of the different subsurface effects in the thickness texture.
  147011. * * the green channel is the translucency intensity.
  147012. * * the blue channel is the scattering intensity.
  147013. * * the alpha channel is the refraction intensity.
  147014. */
  147015. useMaskFromThicknessTexture: boolean;
  147016. /**
  147017. * Initialize the block and prepare the context for build
  147018. * @param state defines the state that will be used for the build
  147019. */
  147020. initialize(state: NodeMaterialBuildState): void;
  147021. /**
  147022. * Gets the current class name
  147023. * @returns the class name
  147024. */
  147025. getClassName(): string;
  147026. /**
  147027. * Gets the min thickness input component
  147028. */
  147029. get minThickness(): NodeMaterialConnectionPoint;
  147030. /**
  147031. * Gets the max thickness input component
  147032. */
  147033. get maxThickness(): NodeMaterialConnectionPoint;
  147034. /**
  147035. * Gets the thickness texture component
  147036. */
  147037. get thicknessTexture(): NodeMaterialConnectionPoint;
  147038. /**
  147039. * Gets the tint color input component
  147040. */
  147041. get tintColor(): NodeMaterialConnectionPoint;
  147042. /**
  147043. * Gets the translucency intensity input component
  147044. */
  147045. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147046. /**
  147047. * Gets the translucency diffusion distance input component
  147048. */
  147049. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  147050. /**
  147051. * Gets the refraction object parameters
  147052. */
  147053. get refraction(): NodeMaterialConnectionPoint;
  147054. /**
  147055. * Gets the sub surface object output component
  147056. */
  147057. get subsurface(): NodeMaterialConnectionPoint;
  147058. autoConfigure(material: NodeMaterial): void;
  147059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147060. /**
  147061. * Gets the main code of the block (fragment side)
  147062. * @param state current state of the node material building
  147063. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147064. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147065. * @param worldPosVarName name of the variable holding the world position
  147066. * @returns the shader code
  147067. */
  147068. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147069. protected _buildBlock(state: NodeMaterialBuildState): this;
  147070. }
  147071. }
  147072. declare module BABYLON {
  147073. /**
  147074. * Block used to implement the PBR metallic/roughness model
  147075. */
  147076. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147077. /**
  147078. * Gets or sets the light associated with this block
  147079. */
  147080. light: Nullable<Light>;
  147081. private _lightId;
  147082. private _scene;
  147083. private _environmentBRDFTexture;
  147084. private _environmentBrdfSamplerName;
  147085. private _vNormalWName;
  147086. private _invertNormalName;
  147087. /**
  147088. * Create a new ReflectionBlock
  147089. * @param name defines the block name
  147090. */
  147091. constructor(name: string);
  147092. /**
  147093. * Intensity of the direct lights e.g. the four lights available in your scene.
  147094. * This impacts both the direct diffuse and specular highlights.
  147095. */
  147096. directIntensity: number;
  147097. /**
  147098. * Intensity of the environment e.g. how much the environment will light the object
  147099. * either through harmonics for rough material or through the refelction for shiny ones.
  147100. */
  147101. environmentIntensity: number;
  147102. /**
  147103. * This is a special control allowing the reduction of the specular highlights coming from the
  147104. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147105. */
  147106. specularIntensity: number;
  147107. /**
  147108. * Defines the falloff type used in this material.
  147109. * It by default is Physical.
  147110. */
  147111. lightFalloff: number;
  147112. /**
  147113. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  147114. */
  147115. useAlphaFromAlbedoTexture: boolean;
  147116. /**
  147117. * Specifies that alpha test should be used
  147118. */
  147119. useAlphaTest: boolean;
  147120. /**
  147121. * Defines the alpha limits in alpha test mode.
  147122. */
  147123. alphaTestCutoff: number;
  147124. /**
  147125. * Specifies that alpha blending should be used
  147126. */
  147127. useAlphaBlending: boolean;
  147128. /**
  147129. * Defines if the alpha value should be determined via the rgb values.
  147130. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  147131. */
  147132. opacityRGB: boolean;
  147133. /**
  147134. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147135. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147136. */
  147137. useRadianceOverAlpha: boolean;
  147138. /**
  147139. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147140. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147141. */
  147142. useSpecularOverAlpha: boolean;
  147143. /**
  147144. * Enables specular anti aliasing in the PBR shader.
  147145. * It will both interacts on the Geometry for analytical and IBL lighting.
  147146. * It also prefilter the roughness map based on the bump values.
  147147. */
  147148. enableSpecularAntiAliasing: boolean;
  147149. /**
  147150. * Enables realtime filtering on the texture.
  147151. */
  147152. realTimeFiltering: boolean;
  147153. /**
  147154. * Quality switch for realtime filtering
  147155. */
  147156. realTimeFilteringQuality: number;
  147157. /**
  147158. * Defines if the material uses energy conservation.
  147159. */
  147160. useEnergyConservation: boolean;
  147161. /**
  147162. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147163. * too much the area relying on ambient texture to define their ambient occlusion.
  147164. */
  147165. useRadianceOcclusion: boolean;
  147166. /**
  147167. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147168. * makes the reflect vector face the model (under horizon).
  147169. */
  147170. useHorizonOcclusion: boolean;
  147171. /**
  147172. * If set to true, no lighting calculations will be applied.
  147173. */
  147174. unlit: boolean;
  147175. /**
  147176. * Force normal to face away from face.
  147177. */
  147178. forceNormalForward: boolean;
  147179. /**
  147180. * Defines the material debug mode.
  147181. * It helps seeing only some components of the material while troubleshooting.
  147182. */
  147183. debugMode: number;
  147184. /**
  147185. * Specify from where on screen the debug mode should start.
  147186. * The value goes from -1 (full screen) to 1 (not visible)
  147187. * It helps with side by side comparison against the final render
  147188. * This defaults to 0
  147189. */
  147190. debugLimit: number;
  147191. /**
  147192. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147193. * You can use the factor to better multiply the final value.
  147194. */
  147195. debugFactor: number;
  147196. /**
  147197. * Initialize the block and prepare the context for build
  147198. * @param state defines the state that will be used for the build
  147199. */
  147200. initialize(state: NodeMaterialBuildState): void;
  147201. /**
  147202. * Gets the current class name
  147203. * @returns the class name
  147204. */
  147205. getClassName(): string;
  147206. /**
  147207. * Gets the world position input component
  147208. */
  147209. get worldPosition(): NodeMaterialConnectionPoint;
  147210. /**
  147211. * Gets the world normal input component
  147212. */
  147213. get worldNormal(): NodeMaterialConnectionPoint;
  147214. /**
  147215. * Gets the perturbed normal input component
  147216. */
  147217. get perturbedNormal(): NodeMaterialConnectionPoint;
  147218. /**
  147219. * Gets the camera position input component
  147220. */
  147221. get cameraPosition(): NodeMaterialConnectionPoint;
  147222. /**
  147223. * Gets the base color input component
  147224. */
  147225. get baseColor(): NodeMaterialConnectionPoint;
  147226. /**
  147227. * Gets the opacity texture input component
  147228. */
  147229. get opacityTexture(): NodeMaterialConnectionPoint;
  147230. /**
  147231. * Gets the ambient color input component
  147232. */
  147233. get ambientColor(): NodeMaterialConnectionPoint;
  147234. /**
  147235. * Gets the reflectivity object parameters
  147236. */
  147237. get reflectivity(): NodeMaterialConnectionPoint;
  147238. /**
  147239. * Gets the ambient occlusion object parameters
  147240. */
  147241. get ambientOcc(): NodeMaterialConnectionPoint;
  147242. /**
  147243. * Gets the reflection object parameters
  147244. */
  147245. get reflection(): NodeMaterialConnectionPoint;
  147246. /**
  147247. * Gets the sheen object parameters
  147248. */
  147249. get sheen(): NodeMaterialConnectionPoint;
  147250. /**
  147251. * Gets the clear coat object parameters
  147252. */
  147253. get clearcoat(): NodeMaterialConnectionPoint;
  147254. /**
  147255. * Gets the sub surface object parameters
  147256. */
  147257. get subsurface(): NodeMaterialConnectionPoint;
  147258. /**
  147259. * Gets the anisotropy object parameters
  147260. */
  147261. get anisotropy(): NodeMaterialConnectionPoint;
  147262. /**
  147263. * Gets the view matrix parameter
  147264. */
  147265. get view(): NodeMaterialConnectionPoint;
  147266. /**
  147267. * Gets the ambient output component
  147268. */
  147269. get ambient(): NodeMaterialConnectionPoint;
  147270. /**
  147271. * Gets the diffuse output component
  147272. */
  147273. get diffuse(): NodeMaterialConnectionPoint;
  147274. /**
  147275. * Gets the specular output component
  147276. */
  147277. get specular(): NodeMaterialConnectionPoint;
  147278. /**
  147279. * Gets the sheen output component
  147280. */
  147281. get sheenDir(): NodeMaterialConnectionPoint;
  147282. /**
  147283. * Gets the clear coat output component
  147284. */
  147285. get clearcoatDir(): NodeMaterialConnectionPoint;
  147286. /**
  147287. * Gets the indirect diffuse output component
  147288. */
  147289. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147290. /**
  147291. * Gets the indirect specular output component
  147292. */
  147293. get specularIndirect(): NodeMaterialConnectionPoint;
  147294. /**
  147295. * Gets the indirect sheen output component
  147296. */
  147297. get sheenIndirect(): NodeMaterialConnectionPoint;
  147298. /**
  147299. * Gets the indirect clear coat output component
  147300. */
  147301. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147302. /**
  147303. * Gets the refraction output component
  147304. */
  147305. get refraction(): NodeMaterialConnectionPoint;
  147306. /**
  147307. * Gets the global lighting output component
  147308. */
  147309. get lighting(): NodeMaterialConnectionPoint;
  147310. /**
  147311. * Gets the shadow output component
  147312. */
  147313. get shadow(): NodeMaterialConnectionPoint;
  147314. /**
  147315. * Gets the alpha output component
  147316. */
  147317. get alpha(): NodeMaterialConnectionPoint;
  147318. autoConfigure(material: NodeMaterial): void;
  147319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147320. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  147321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  147322. private _injectVertexCode;
  147323. /**
  147324. * Gets the code corresponding to the albedo/opacity module
  147325. * @returns the shader code
  147326. */
  147327. getAlbedoOpacityCode(): string;
  147328. protected _buildBlock(state: NodeMaterialBuildState): this;
  147329. protected _dumpPropertiesCode(): string;
  147330. serialize(): any;
  147331. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147332. }
  147333. }
  147334. declare module BABYLON {
  147335. /**
  147336. * Block used to compute value of one parameter modulo another
  147337. */
  147338. export class ModBlock extends NodeMaterialBlock {
  147339. /**
  147340. * Creates a new ModBlock
  147341. * @param name defines the block name
  147342. */
  147343. constructor(name: string);
  147344. /**
  147345. * Gets the current class name
  147346. * @returns the class name
  147347. */
  147348. getClassName(): string;
  147349. /**
  147350. * Gets the left operand input component
  147351. */
  147352. get left(): NodeMaterialConnectionPoint;
  147353. /**
  147354. * Gets the right operand input component
  147355. */
  147356. get right(): NodeMaterialConnectionPoint;
  147357. /**
  147358. * Gets the output component
  147359. */
  147360. get output(): NodeMaterialConnectionPoint;
  147361. protected _buildBlock(state: NodeMaterialBuildState): this;
  147362. }
  147363. }
  147364. declare module BABYLON {
  147365. /**
  147366. * Configuration for Draco compression
  147367. */
  147368. export interface IDracoCompressionConfiguration {
  147369. /**
  147370. * Configuration for the decoder.
  147371. */
  147372. decoder: {
  147373. /**
  147374. * The url to the WebAssembly module.
  147375. */
  147376. wasmUrl?: string;
  147377. /**
  147378. * The url to the WebAssembly binary.
  147379. */
  147380. wasmBinaryUrl?: string;
  147381. /**
  147382. * The url to the fallback JavaScript module.
  147383. */
  147384. fallbackUrl?: string;
  147385. };
  147386. }
  147387. /**
  147388. * Draco compression (https://google.github.io/draco/)
  147389. *
  147390. * This class wraps the Draco module.
  147391. *
  147392. * **Encoder**
  147393. *
  147394. * The encoder is not currently implemented.
  147395. *
  147396. * **Decoder**
  147397. *
  147398. * 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.
  147399. *
  147400. * To update the configuration, use the following code:
  147401. * ```javascript
  147402. * DracoCompression.Configuration = {
  147403. * decoder: {
  147404. * wasmUrl: "<url to the WebAssembly library>",
  147405. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  147406. * fallbackUrl: "<url to the fallback JavaScript library>",
  147407. * }
  147408. * };
  147409. * ```
  147410. *
  147411. * 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.
  147412. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  147413. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  147414. *
  147415. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  147416. * ```javascript
  147417. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  147418. * ```
  147419. *
  147420. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  147421. */
  147422. export class DracoCompression implements IDisposable {
  147423. private _workerPoolPromise?;
  147424. private _decoderModulePromise?;
  147425. /**
  147426. * The configuration. Defaults to the following urls:
  147427. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  147428. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  147429. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  147430. */
  147431. static Configuration: IDracoCompressionConfiguration;
  147432. /**
  147433. * Returns true if the decoder configuration is available.
  147434. */
  147435. static get DecoderAvailable(): boolean;
  147436. /**
  147437. * Default number of workers to create when creating the draco compression object.
  147438. */
  147439. static DefaultNumWorkers: number;
  147440. private static GetDefaultNumWorkers;
  147441. private static _Default;
  147442. /**
  147443. * Default instance for the draco compression object.
  147444. */
  147445. static get Default(): DracoCompression;
  147446. /**
  147447. * Constructor
  147448. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147449. */
  147450. constructor(numWorkers?: number);
  147451. /**
  147452. * Stop all async operations and release resources.
  147453. */
  147454. dispose(): void;
  147455. /**
  147456. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  147457. * @returns a promise that resolves when ready
  147458. */
  147459. whenReadyAsync(): Promise<void>;
  147460. /**
  147461. * Decode Draco compressed mesh data to vertex data.
  147462. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  147463. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  147464. * @returns A promise that resolves with the decoded vertex data
  147465. */
  147466. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  147467. [kind: string]: number;
  147468. }): Promise<VertexData>;
  147469. }
  147470. }
  147471. declare module BABYLON {
  147472. /**
  147473. * Class for building Constructive Solid Geometry
  147474. */
  147475. export class CSG {
  147476. private polygons;
  147477. /**
  147478. * The world matrix
  147479. */
  147480. matrix: Matrix;
  147481. /**
  147482. * Stores the position
  147483. */
  147484. position: Vector3;
  147485. /**
  147486. * Stores the rotation
  147487. */
  147488. rotation: Vector3;
  147489. /**
  147490. * Stores the rotation quaternion
  147491. */
  147492. rotationQuaternion: Nullable<Quaternion>;
  147493. /**
  147494. * Stores the scaling vector
  147495. */
  147496. scaling: Vector3;
  147497. /**
  147498. * Convert the Mesh to CSG
  147499. * @param mesh The Mesh to convert to CSG
  147500. * @returns A new CSG from the Mesh
  147501. */
  147502. static FromMesh(mesh: Mesh): CSG;
  147503. /**
  147504. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  147505. * @param polygons Polygons used to construct a CSG solid
  147506. */
  147507. private static FromPolygons;
  147508. /**
  147509. * Clones, or makes a deep copy, of the CSG
  147510. * @returns A new CSG
  147511. */
  147512. clone(): CSG;
  147513. /**
  147514. * Unions this CSG with another CSG
  147515. * @param csg The CSG to union against this CSG
  147516. * @returns The unioned CSG
  147517. */
  147518. union(csg: CSG): CSG;
  147519. /**
  147520. * Unions this CSG with another CSG in place
  147521. * @param csg The CSG to union against this CSG
  147522. */
  147523. unionInPlace(csg: CSG): void;
  147524. /**
  147525. * Subtracts this CSG with another CSG
  147526. * @param csg The CSG to subtract against this CSG
  147527. * @returns A new CSG
  147528. */
  147529. subtract(csg: CSG): CSG;
  147530. /**
  147531. * Subtracts this CSG with another CSG in place
  147532. * @param csg The CSG to subtact against this CSG
  147533. */
  147534. subtractInPlace(csg: CSG): void;
  147535. /**
  147536. * Intersect this CSG with another CSG
  147537. * @param csg The CSG to intersect against this CSG
  147538. * @returns A new CSG
  147539. */
  147540. intersect(csg: CSG): CSG;
  147541. /**
  147542. * Intersects this CSG with another CSG in place
  147543. * @param csg The CSG to intersect against this CSG
  147544. */
  147545. intersectInPlace(csg: CSG): void;
  147546. /**
  147547. * Return a new CSG solid with solid and empty space switched. This solid is
  147548. * not modified.
  147549. * @returns A new CSG solid with solid and empty space switched
  147550. */
  147551. inverse(): CSG;
  147552. /**
  147553. * Inverses the CSG in place
  147554. */
  147555. inverseInPlace(): void;
  147556. /**
  147557. * This is used to keep meshes transformations so they can be restored
  147558. * when we build back a Babylon Mesh
  147559. * NB : All CSG operations are performed in world coordinates
  147560. * @param csg The CSG to copy the transform attributes from
  147561. * @returns This CSG
  147562. */
  147563. copyTransformAttributes(csg: CSG): CSG;
  147564. /**
  147565. * Build Raw mesh from CSG
  147566. * Coordinates here are in world space
  147567. * @param name The name of the mesh geometry
  147568. * @param scene The Scene
  147569. * @param keepSubMeshes Specifies if the submeshes should be kept
  147570. * @returns A new Mesh
  147571. */
  147572. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147573. /**
  147574. * Build Mesh from CSG taking material and transforms into account
  147575. * @param name The name of the Mesh
  147576. * @param material The material of the Mesh
  147577. * @param scene The Scene
  147578. * @param keepSubMeshes Specifies if submeshes should be kept
  147579. * @returns The new Mesh
  147580. */
  147581. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147582. }
  147583. }
  147584. declare module BABYLON {
  147585. /**
  147586. * Class used to create a trail following a mesh
  147587. */
  147588. export class TrailMesh extends Mesh {
  147589. private _generator;
  147590. private _autoStart;
  147591. private _running;
  147592. private _diameter;
  147593. private _length;
  147594. private _sectionPolygonPointsCount;
  147595. private _sectionVectors;
  147596. private _sectionNormalVectors;
  147597. private _beforeRenderObserver;
  147598. /**
  147599. * @constructor
  147600. * @param name The value used by scene.getMeshByName() to do a lookup.
  147601. * @param generator The mesh or transform node to generate a trail.
  147602. * @param scene The scene to add this mesh to.
  147603. * @param diameter Diameter of trailing mesh. Default is 1.
  147604. * @param length Length of trailing mesh. Default is 60.
  147605. * @param autoStart Automatically start trailing mesh. Default true.
  147606. */
  147607. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  147608. /**
  147609. * "TrailMesh"
  147610. * @returns "TrailMesh"
  147611. */
  147612. getClassName(): string;
  147613. private _createMesh;
  147614. /**
  147615. * Start trailing mesh.
  147616. */
  147617. start(): void;
  147618. /**
  147619. * Stop trailing mesh.
  147620. */
  147621. stop(): void;
  147622. /**
  147623. * Update trailing mesh geometry.
  147624. */
  147625. update(): void;
  147626. /**
  147627. * Returns a new TrailMesh object.
  147628. * @param name is a string, the name given to the new mesh
  147629. * @param newGenerator use new generator object for cloned trail mesh
  147630. * @returns a new mesh
  147631. */
  147632. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  147633. /**
  147634. * Serializes this trail mesh
  147635. * @param serializationObject object to write serialization to
  147636. */
  147637. serialize(serializationObject: any): void;
  147638. /**
  147639. * Parses a serialized trail mesh
  147640. * @param parsedMesh the serialized mesh
  147641. * @param scene the scene to create the trail mesh in
  147642. * @returns the created trail mesh
  147643. */
  147644. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  147645. }
  147646. }
  147647. declare module BABYLON {
  147648. /**
  147649. * Class containing static functions to help procedurally build meshes
  147650. */
  147651. export class TiledBoxBuilder {
  147652. /**
  147653. * Creates a box mesh
  147654. * 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)
  147655. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147659. * @param name defines the name of the mesh
  147660. * @param options defines the options used to create the mesh
  147661. * @param scene defines the hosting scene
  147662. * @returns the box mesh
  147663. */
  147664. static CreateTiledBox(name: string, options: {
  147665. pattern?: number;
  147666. width?: number;
  147667. height?: number;
  147668. depth?: number;
  147669. tileSize?: number;
  147670. tileWidth?: number;
  147671. tileHeight?: number;
  147672. alignHorizontal?: number;
  147673. alignVertical?: number;
  147674. faceUV?: Vector4[];
  147675. faceColors?: Color4[];
  147676. sideOrientation?: number;
  147677. updatable?: boolean;
  147678. }, scene?: Nullable<Scene>): Mesh;
  147679. }
  147680. }
  147681. declare module BABYLON {
  147682. /**
  147683. * Class containing static functions to help procedurally build meshes
  147684. */
  147685. export class TorusKnotBuilder {
  147686. /**
  147687. * Creates a torus knot mesh
  147688. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147689. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147690. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147691. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147695. * @param name defines the name of the mesh
  147696. * @param options defines the options used to create the mesh
  147697. * @param scene defines the hosting scene
  147698. * @returns the torus knot mesh
  147699. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147700. */
  147701. static CreateTorusKnot(name: string, options: {
  147702. radius?: number;
  147703. tube?: number;
  147704. radialSegments?: number;
  147705. tubularSegments?: number;
  147706. p?: number;
  147707. q?: number;
  147708. updatable?: boolean;
  147709. sideOrientation?: number;
  147710. frontUVs?: Vector4;
  147711. backUVs?: Vector4;
  147712. }, scene: any): Mesh;
  147713. }
  147714. }
  147715. declare module BABYLON {
  147716. /**
  147717. * Polygon
  147718. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  147719. */
  147720. export class Polygon {
  147721. /**
  147722. * Creates a rectangle
  147723. * @param xmin bottom X coord
  147724. * @param ymin bottom Y coord
  147725. * @param xmax top X coord
  147726. * @param ymax top Y coord
  147727. * @returns points that make the resulting rectation
  147728. */
  147729. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  147730. /**
  147731. * Creates a circle
  147732. * @param radius radius of circle
  147733. * @param cx scale in x
  147734. * @param cy scale in y
  147735. * @param numberOfSides number of sides that make up the circle
  147736. * @returns points that make the resulting circle
  147737. */
  147738. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  147739. /**
  147740. * Creates a polygon from input string
  147741. * @param input Input polygon data
  147742. * @returns the parsed points
  147743. */
  147744. static Parse(input: string): Vector2[];
  147745. /**
  147746. * Starts building a polygon from x and y coordinates
  147747. * @param x x coordinate
  147748. * @param y y coordinate
  147749. * @returns the started path2
  147750. */
  147751. static StartingAt(x: number, y: number): Path2;
  147752. }
  147753. /**
  147754. * Builds a polygon
  147755. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  147756. */
  147757. export class PolygonMeshBuilder {
  147758. private _points;
  147759. private _outlinepoints;
  147760. private _holes;
  147761. private _name;
  147762. private _scene;
  147763. private _epoints;
  147764. private _eholes;
  147765. private _addToepoint;
  147766. /**
  147767. * Babylon reference to the earcut plugin.
  147768. */
  147769. bjsEarcut: any;
  147770. /**
  147771. * Creates a PolygonMeshBuilder
  147772. * @param name name of the builder
  147773. * @param contours Path of the polygon
  147774. * @param scene scene to add to when creating the mesh
  147775. * @param earcutInjection can be used to inject your own earcut reference
  147776. */
  147777. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  147778. /**
  147779. * Adds a whole within the polygon
  147780. * @param hole Array of points defining the hole
  147781. * @returns this
  147782. */
  147783. addHole(hole: Vector2[]): PolygonMeshBuilder;
  147784. /**
  147785. * Creates the polygon
  147786. * @param updatable If the mesh should be updatable
  147787. * @param depth The depth of the mesh created
  147788. * @returns the created mesh
  147789. */
  147790. build(updatable?: boolean, depth?: number): Mesh;
  147791. /**
  147792. * Creates the polygon
  147793. * @param depth The depth of the mesh created
  147794. * @returns the created VertexData
  147795. */
  147796. buildVertexData(depth?: number): VertexData;
  147797. /**
  147798. * Adds a side to the polygon
  147799. * @param positions points that make the polygon
  147800. * @param normals normals of the polygon
  147801. * @param uvs uvs of the polygon
  147802. * @param indices indices of the polygon
  147803. * @param bounds bounds of the polygon
  147804. * @param points points of the polygon
  147805. * @param depth depth of the polygon
  147806. * @param flip flip of the polygon
  147807. */
  147808. private addSide;
  147809. }
  147810. }
  147811. declare module BABYLON {
  147812. /**
  147813. * Class containing static functions to help procedurally build meshes
  147814. */
  147815. export class PolygonBuilder {
  147816. /**
  147817. * Creates a polygon mesh
  147818. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147819. * * 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
  147820. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147823. * * Remember you can only change the shape positions, not their number when updating a polygon
  147824. * @param name defines the name of the mesh
  147825. * @param options defines the options used to create the mesh
  147826. * @param scene defines the hosting scene
  147827. * @param earcutInjection can be used to inject your own earcut reference
  147828. * @returns the polygon mesh
  147829. */
  147830. static CreatePolygon(name: string, options: {
  147831. shape: Vector3[];
  147832. holes?: Vector3[][];
  147833. depth?: number;
  147834. faceUV?: Vector4[];
  147835. faceColors?: Color4[];
  147836. updatable?: boolean;
  147837. sideOrientation?: number;
  147838. frontUVs?: Vector4;
  147839. backUVs?: Vector4;
  147840. wrap?: boolean;
  147841. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147842. /**
  147843. * Creates an extruded polygon mesh, with depth in the Y direction.
  147844. * * 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)
  147845. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147846. * @param name defines the name of the mesh
  147847. * @param options defines the options used to create the mesh
  147848. * @param scene defines the hosting scene
  147849. * @param earcutInjection can be used to inject your own earcut reference
  147850. * @returns the polygon mesh
  147851. */
  147852. static ExtrudePolygon(name: string, options: {
  147853. shape: Vector3[];
  147854. holes?: Vector3[][];
  147855. depth?: number;
  147856. faceUV?: Vector4[];
  147857. faceColors?: Color4[];
  147858. updatable?: boolean;
  147859. sideOrientation?: number;
  147860. frontUVs?: Vector4;
  147861. backUVs?: Vector4;
  147862. wrap?: boolean;
  147863. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147864. }
  147865. }
  147866. declare module BABYLON {
  147867. /**
  147868. * Class containing static functions to help procedurally build meshes
  147869. */
  147870. export class LatheBuilder {
  147871. /**
  147872. * Creates lathe mesh.
  147873. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147874. * * 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
  147875. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147876. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147877. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147878. * * 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
  147879. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147880. * * 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
  147881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147885. * @param name defines the name of the mesh
  147886. * @param options defines the options used to create the mesh
  147887. * @param scene defines the hosting scene
  147888. * @returns the lathe mesh
  147889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147890. */
  147891. static CreateLathe(name: string, options: {
  147892. shape: Vector3[];
  147893. radius?: number;
  147894. tessellation?: number;
  147895. clip?: number;
  147896. arc?: number;
  147897. closed?: boolean;
  147898. updatable?: boolean;
  147899. sideOrientation?: number;
  147900. frontUVs?: Vector4;
  147901. backUVs?: Vector4;
  147902. cap?: number;
  147903. invertUV?: boolean;
  147904. }, scene?: Nullable<Scene>): Mesh;
  147905. }
  147906. }
  147907. declare module BABYLON {
  147908. /**
  147909. * Class containing static functions to help procedurally build meshes
  147910. */
  147911. export class TiledPlaneBuilder {
  147912. /**
  147913. * Creates a tiled plane mesh
  147914. * * The parameter `pattern` will, depending on value, do nothing or
  147915. * * * flip (reflect about central vertical) alternate tiles across and up
  147916. * * * flip every tile on alternate rows
  147917. * * * rotate (180 degs) alternate tiles across and up
  147918. * * * rotate every tile on alternate rows
  147919. * * * flip and rotate alternate tiles across and up
  147920. * * * flip and rotate every tile on alternate rows
  147921. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147922. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147925. * * 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)
  147926. * * 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)
  147927. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147928. * @param name defines the name of the mesh
  147929. * @param options defines the options used to create the mesh
  147930. * @param scene defines the hosting scene
  147931. * @returns the box mesh
  147932. */
  147933. static CreateTiledPlane(name: string, options: {
  147934. pattern?: number;
  147935. tileSize?: number;
  147936. tileWidth?: number;
  147937. tileHeight?: number;
  147938. size?: number;
  147939. width?: number;
  147940. height?: number;
  147941. alignHorizontal?: number;
  147942. alignVertical?: number;
  147943. sideOrientation?: number;
  147944. frontUVs?: Vector4;
  147945. backUVs?: Vector4;
  147946. updatable?: boolean;
  147947. }, scene?: Nullable<Scene>): Mesh;
  147948. }
  147949. }
  147950. declare module BABYLON {
  147951. /**
  147952. * Class containing static functions to help procedurally build meshes
  147953. */
  147954. export class TubeBuilder {
  147955. /**
  147956. * Creates a tube mesh.
  147957. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147958. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147959. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147960. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147961. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147962. * * 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)
  147963. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147964. * * 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
  147965. * * 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
  147966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147970. * @param name defines the name of the mesh
  147971. * @param options defines the options used to create the mesh
  147972. * @param scene defines the hosting scene
  147973. * @returns the tube mesh
  147974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147975. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147976. */
  147977. static CreateTube(name: string, options: {
  147978. path: Vector3[];
  147979. radius?: number;
  147980. tessellation?: number;
  147981. radiusFunction?: {
  147982. (i: number, distance: number): number;
  147983. };
  147984. cap?: number;
  147985. arc?: number;
  147986. updatable?: boolean;
  147987. sideOrientation?: number;
  147988. frontUVs?: Vector4;
  147989. backUVs?: Vector4;
  147990. instance?: Mesh;
  147991. invertUV?: boolean;
  147992. }, scene?: Nullable<Scene>): Mesh;
  147993. }
  147994. }
  147995. declare module BABYLON {
  147996. /**
  147997. * Class containing static functions to help procedurally build meshes
  147998. */
  147999. export class IcoSphereBuilder {
  148000. /**
  148001. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148002. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148003. * * 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`)
  148004. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148005. * * 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
  148006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148009. * @param name defines the name of the mesh
  148010. * @param options defines the options used to create the mesh
  148011. * @param scene defines the hosting scene
  148012. * @returns the icosahedron mesh
  148013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148014. */
  148015. static CreateIcoSphere(name: string, options: {
  148016. radius?: number;
  148017. radiusX?: number;
  148018. radiusY?: number;
  148019. radiusZ?: number;
  148020. flat?: boolean;
  148021. subdivisions?: number;
  148022. sideOrientation?: number;
  148023. frontUVs?: Vector4;
  148024. backUVs?: Vector4;
  148025. updatable?: boolean;
  148026. }, scene?: Nullable<Scene>): Mesh;
  148027. }
  148028. }
  148029. declare module BABYLON {
  148030. /**
  148031. * Class containing static functions to help procedurally build meshes
  148032. */
  148033. export class DecalBuilder {
  148034. /**
  148035. * Creates a decal mesh.
  148036. * 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
  148037. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148038. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148039. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148040. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148041. * @param name defines the name of the mesh
  148042. * @param sourceMesh defines the mesh where the decal must be applied
  148043. * @param options defines the options used to create the mesh
  148044. * @param scene defines the hosting scene
  148045. * @returns the decal mesh
  148046. * @see https://doc.babylonjs.com/how_to/decals
  148047. */
  148048. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148049. position?: Vector3;
  148050. normal?: Vector3;
  148051. size?: Vector3;
  148052. angle?: number;
  148053. }): Mesh;
  148054. }
  148055. }
  148056. declare module BABYLON {
  148057. /**
  148058. * Class containing static functions to help procedurally build meshes
  148059. */
  148060. export class MeshBuilder {
  148061. /**
  148062. * Creates a box mesh
  148063. * * The parameter `size` sets the size (float) of each box side (default 1)
  148064. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148065. * * 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)
  148066. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148070. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148071. * @param name defines the name of the mesh
  148072. * @param options defines the options used to create the mesh
  148073. * @param scene defines the hosting scene
  148074. * @returns the box mesh
  148075. */
  148076. static CreateBox(name: string, options: {
  148077. size?: number;
  148078. width?: number;
  148079. height?: number;
  148080. depth?: number;
  148081. faceUV?: Vector4[];
  148082. faceColors?: Color4[];
  148083. sideOrientation?: number;
  148084. frontUVs?: Vector4;
  148085. backUVs?: Vector4;
  148086. wrap?: boolean;
  148087. topBaseAt?: number;
  148088. bottomBaseAt?: number;
  148089. updatable?: boolean;
  148090. }, scene?: Nullable<Scene>): Mesh;
  148091. /**
  148092. * Creates a tiled box mesh
  148093. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148095. * @param name defines the name of the mesh
  148096. * @param options defines the options used to create the mesh
  148097. * @param scene defines the hosting scene
  148098. * @returns the tiled box mesh
  148099. */
  148100. static CreateTiledBox(name: string, options: {
  148101. pattern?: number;
  148102. size?: number;
  148103. width?: number;
  148104. height?: number;
  148105. depth: number;
  148106. tileSize?: number;
  148107. tileWidth?: number;
  148108. tileHeight?: number;
  148109. faceUV?: Vector4[];
  148110. faceColors?: Color4[];
  148111. alignHorizontal?: number;
  148112. alignVertical?: number;
  148113. sideOrientation?: number;
  148114. updatable?: boolean;
  148115. }, scene?: Nullable<Scene>): Mesh;
  148116. /**
  148117. * Creates a sphere mesh
  148118. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148119. * * 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`)
  148120. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148121. * * 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
  148122. * * 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)
  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 sphere mesh
  148130. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148131. */
  148132. static CreateSphere(name: string, options: {
  148133. segments?: number;
  148134. diameter?: number;
  148135. diameterX?: number;
  148136. diameterY?: number;
  148137. diameterZ?: number;
  148138. arc?: number;
  148139. slice?: number;
  148140. sideOrientation?: number;
  148141. frontUVs?: Vector4;
  148142. backUVs?: Vector4;
  148143. updatable?: boolean;
  148144. }, scene?: Nullable<Scene>): Mesh;
  148145. /**
  148146. * Creates a plane polygonal mesh. By default, this is a disc
  148147. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148148. * * 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
  148149. * * 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
  148150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148153. * @param name defines the name of the mesh
  148154. * @param options defines the options used to create the mesh
  148155. * @param scene defines the hosting scene
  148156. * @returns the plane polygonal mesh
  148157. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148158. */
  148159. static CreateDisc(name: string, options: {
  148160. radius?: number;
  148161. tessellation?: number;
  148162. arc?: number;
  148163. updatable?: boolean;
  148164. sideOrientation?: number;
  148165. frontUVs?: Vector4;
  148166. backUVs?: Vector4;
  148167. }, scene?: Nullable<Scene>): Mesh;
  148168. /**
  148169. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148170. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148171. * * 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`)
  148172. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148173. * * 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
  148174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148177. * @param name defines the name of the mesh
  148178. * @param options defines the options used to create the mesh
  148179. * @param scene defines the hosting scene
  148180. * @returns the icosahedron mesh
  148181. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148182. */
  148183. static CreateIcoSphere(name: string, options: {
  148184. radius?: number;
  148185. radiusX?: number;
  148186. radiusY?: number;
  148187. radiusZ?: number;
  148188. flat?: boolean;
  148189. subdivisions?: number;
  148190. sideOrientation?: number;
  148191. frontUVs?: Vector4;
  148192. backUVs?: Vector4;
  148193. updatable?: boolean;
  148194. }, scene?: Nullable<Scene>): Mesh;
  148195. /**
  148196. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148197. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148198. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148199. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148200. * * 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
  148201. * * 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
  148202. * * 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
  148203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148206. * * 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
  148207. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148208. * * 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
  148209. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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. * @param name defines the name of the mesh
  148212. * @param options defines the options used to create the mesh
  148213. * @param scene defines the hosting scene
  148214. * @returns the ribbon mesh
  148215. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148217. */
  148218. static CreateRibbon(name: string, options: {
  148219. pathArray: Vector3[][];
  148220. closeArray?: boolean;
  148221. closePath?: boolean;
  148222. offset?: number;
  148223. updatable?: boolean;
  148224. sideOrientation?: number;
  148225. frontUVs?: Vector4;
  148226. backUVs?: Vector4;
  148227. instance?: Mesh;
  148228. invertUV?: boolean;
  148229. uvs?: Vector2[];
  148230. colors?: Color4[];
  148231. }, scene?: Nullable<Scene>): Mesh;
  148232. /**
  148233. * Creates a cylinder or a cone mesh
  148234. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148235. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148236. * * 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.
  148237. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148238. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148239. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148240. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148241. * * 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).
  148242. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148243. * * 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).
  148244. * * 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
  148245. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148246. * * 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
  148247. * * 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.
  148248. * * If `enclose` is false, a ring surface is one element.
  148249. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148250. * * 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
  148251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148254. * @param name defines the name of the mesh
  148255. * @param options defines the options used to create the mesh
  148256. * @param scene defines the hosting scene
  148257. * @returns the cylinder mesh
  148258. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148259. */
  148260. static CreateCylinder(name: string, options: {
  148261. height?: number;
  148262. diameterTop?: number;
  148263. diameterBottom?: number;
  148264. diameter?: number;
  148265. tessellation?: number;
  148266. subdivisions?: number;
  148267. arc?: number;
  148268. faceColors?: Color4[];
  148269. faceUV?: Vector4[];
  148270. updatable?: boolean;
  148271. hasRings?: boolean;
  148272. enclose?: boolean;
  148273. cap?: number;
  148274. sideOrientation?: number;
  148275. frontUVs?: Vector4;
  148276. backUVs?: Vector4;
  148277. }, scene?: Nullable<Scene>): Mesh;
  148278. /**
  148279. * Creates a torus mesh
  148280. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148281. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148282. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148286. * @param name defines the name of the mesh
  148287. * @param options defines the options used to create the mesh
  148288. * @param scene defines the hosting scene
  148289. * @returns the torus mesh
  148290. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148291. */
  148292. static CreateTorus(name: string, options: {
  148293. diameter?: number;
  148294. thickness?: number;
  148295. tessellation?: number;
  148296. updatable?: boolean;
  148297. sideOrientation?: number;
  148298. frontUVs?: Vector4;
  148299. backUVs?: Vector4;
  148300. }, scene?: Nullable<Scene>): Mesh;
  148301. /**
  148302. * Creates a torus knot mesh
  148303. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148304. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148305. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148306. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148310. * @param name defines the name of the mesh
  148311. * @param options defines the options used to create the mesh
  148312. * @param scene defines the hosting scene
  148313. * @returns the torus knot mesh
  148314. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148315. */
  148316. static CreateTorusKnot(name: string, options: {
  148317. radius?: number;
  148318. tube?: number;
  148319. radialSegments?: number;
  148320. tubularSegments?: number;
  148321. p?: number;
  148322. q?: number;
  148323. updatable?: boolean;
  148324. sideOrientation?: number;
  148325. frontUVs?: Vector4;
  148326. backUVs?: Vector4;
  148327. }, scene?: Nullable<Scene>): Mesh;
  148328. /**
  148329. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  148330. * * 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
  148331. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  148332. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  148333. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  148334. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  148335. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  148336. * * 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
  148337. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  148338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  148340. * @param name defines the name of the new line system
  148341. * @param options defines the options used to create the line system
  148342. * @param scene defines the hosting scene
  148343. * @returns a new line system mesh
  148344. */
  148345. static CreateLineSystem(name: string, options: {
  148346. lines: Vector3[][];
  148347. updatable?: boolean;
  148348. instance?: Nullable<LinesMesh>;
  148349. colors?: Nullable<Color4[][]>;
  148350. useVertexAlpha?: boolean;
  148351. }, scene: Nullable<Scene>): LinesMesh;
  148352. /**
  148353. * Creates a line mesh
  148354. * 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
  148355. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148356. * * The parameter `points` is an array successive Vector3
  148357. * * 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
  148358. * * The optional parameter `colors` is an array of successive Color4, one per line point
  148359. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  148360. * * When updating an instance, remember that only point positions can change, not the number of points
  148361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  148363. * @param name defines the name of the new line system
  148364. * @param options defines the options used to create the line system
  148365. * @param scene defines the hosting scene
  148366. * @returns a new line mesh
  148367. */
  148368. static CreateLines(name: string, options: {
  148369. points: Vector3[];
  148370. updatable?: boolean;
  148371. instance?: Nullable<LinesMesh>;
  148372. colors?: Color4[];
  148373. useVertexAlpha?: boolean;
  148374. }, scene?: Nullable<Scene>): LinesMesh;
  148375. /**
  148376. * Creates a dashed line mesh
  148377. * * 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
  148378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148379. * * The parameter `points` is an array successive Vector3
  148380. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  148381. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  148382. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  148383. * * 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
  148384. * * When updating an instance, remember that only point positions can change, not the number of points
  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 dashed line mesh
  148390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  148391. */
  148392. static CreateDashedLines(name: string, options: {
  148393. points: Vector3[];
  148394. dashSize?: number;
  148395. gapSize?: number;
  148396. dashNb?: number;
  148397. updatable?: boolean;
  148398. instance?: LinesMesh;
  148399. }, scene?: Nullable<Scene>): LinesMesh;
  148400. /**
  148401. * 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.
  148402. * * 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.
  148403. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148404. * * 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.
  148405. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  148406. * * 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
  148407. * * 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
  148408. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  148409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  148412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148413. * @param name defines the name of the mesh
  148414. * @param options defines the options used to create the mesh
  148415. * @param scene defines the hosting scene
  148416. * @returns the extruded shape mesh
  148417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148419. */
  148420. static ExtrudeShape(name: string, options: {
  148421. shape: Vector3[];
  148422. path: Vector3[];
  148423. scale?: number;
  148424. rotation?: number;
  148425. cap?: number;
  148426. updatable?: boolean;
  148427. sideOrientation?: number;
  148428. frontUVs?: Vector4;
  148429. backUVs?: Vector4;
  148430. instance?: Mesh;
  148431. invertUV?: boolean;
  148432. }, scene?: Nullable<Scene>): Mesh;
  148433. /**
  148434. * Creates an custom extruded shape mesh.
  148435. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  148436. * * 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.
  148437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148438. * * 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
  148439. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  148440. * * 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
  148441. * * It must returns a float value that will be the scale value applied to the shape on each path point
  148442. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  148443. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  148444. * * 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
  148445. * * 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
  148446. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  148447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148451. * @param name defines the name of the mesh
  148452. * @param options defines the options used to create the mesh
  148453. * @param scene defines the hosting scene
  148454. * @returns the custom extruded shape mesh
  148455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  148456. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148458. */
  148459. static ExtrudeShapeCustom(name: string, options: {
  148460. shape: Vector3[];
  148461. path: Vector3[];
  148462. scaleFunction?: any;
  148463. rotationFunction?: any;
  148464. ribbonCloseArray?: boolean;
  148465. ribbonClosePath?: boolean;
  148466. cap?: number;
  148467. updatable?: boolean;
  148468. sideOrientation?: number;
  148469. frontUVs?: Vector4;
  148470. backUVs?: Vector4;
  148471. instance?: Mesh;
  148472. invertUV?: boolean;
  148473. }, scene?: Nullable<Scene>): Mesh;
  148474. /**
  148475. * Creates lathe mesh.
  148476. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148477. * * 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
  148478. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148479. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148480. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148481. * * 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
  148482. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148483. * * 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
  148484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148488. * @param name defines the name of the mesh
  148489. * @param options defines the options used to create the mesh
  148490. * @param scene defines the hosting scene
  148491. * @returns the lathe mesh
  148492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148493. */
  148494. static CreateLathe(name: string, options: {
  148495. shape: Vector3[];
  148496. radius?: number;
  148497. tessellation?: number;
  148498. clip?: number;
  148499. arc?: number;
  148500. closed?: boolean;
  148501. updatable?: boolean;
  148502. sideOrientation?: number;
  148503. frontUVs?: Vector4;
  148504. backUVs?: Vector4;
  148505. cap?: number;
  148506. invertUV?: boolean;
  148507. }, scene?: Nullable<Scene>): Mesh;
  148508. /**
  148509. * Creates a tiled plane mesh
  148510. * * You can set a limited pattern arrangement with the tiles
  148511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @param name defines the name of the mesh
  148515. * @param options defines the options used to create the mesh
  148516. * @param scene defines the hosting scene
  148517. * @returns the plane mesh
  148518. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148519. */
  148520. static CreateTiledPlane(name: string, options: {
  148521. pattern?: number;
  148522. tileSize?: number;
  148523. tileWidth?: number;
  148524. tileHeight?: number;
  148525. size?: number;
  148526. width?: number;
  148527. height?: number;
  148528. alignHorizontal?: number;
  148529. alignVertical?: number;
  148530. sideOrientation?: number;
  148531. frontUVs?: Vector4;
  148532. backUVs?: Vector4;
  148533. updatable?: boolean;
  148534. }, scene?: Nullable<Scene>): Mesh;
  148535. /**
  148536. * Creates a plane mesh
  148537. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  148538. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  148539. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  148540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148543. * @param name defines the name of the mesh
  148544. * @param options defines the options used to create the mesh
  148545. * @param scene defines the hosting scene
  148546. * @returns the plane mesh
  148547. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148548. */
  148549. static CreatePlane(name: string, options: {
  148550. size?: number;
  148551. width?: number;
  148552. height?: number;
  148553. sideOrientation?: number;
  148554. frontUVs?: Vector4;
  148555. backUVs?: Vector4;
  148556. updatable?: boolean;
  148557. sourcePlane?: Plane;
  148558. }, scene?: Nullable<Scene>): Mesh;
  148559. /**
  148560. * Creates a ground mesh
  148561. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  148562. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  148563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148564. * @param name defines the name of the mesh
  148565. * @param options defines the options used to create the mesh
  148566. * @param scene defines the hosting scene
  148567. * @returns the ground mesh
  148568. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  148569. */
  148570. static CreateGround(name: string, options: {
  148571. width?: number;
  148572. height?: number;
  148573. subdivisions?: number;
  148574. subdivisionsX?: number;
  148575. subdivisionsY?: number;
  148576. updatable?: boolean;
  148577. }, scene?: Nullable<Scene>): Mesh;
  148578. /**
  148579. * Creates a tiled ground mesh
  148580. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  148581. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  148582. * * 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
  148583. * * 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
  148584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148585. * @param name defines the name of the mesh
  148586. * @param options defines the options used to create the mesh
  148587. * @param scene defines the hosting scene
  148588. * @returns the tiled ground mesh
  148589. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  148590. */
  148591. static CreateTiledGround(name: string, options: {
  148592. xmin: number;
  148593. zmin: number;
  148594. xmax: number;
  148595. zmax: number;
  148596. subdivisions?: {
  148597. w: number;
  148598. h: number;
  148599. };
  148600. precision?: {
  148601. w: number;
  148602. h: number;
  148603. };
  148604. updatable?: boolean;
  148605. }, scene?: Nullable<Scene>): Mesh;
  148606. /**
  148607. * Creates a ground mesh from a height map
  148608. * * The parameter `url` sets the URL of the height map image resource.
  148609. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  148610. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  148611. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  148612. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  148613. * * 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.
  148614. * * 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).
  148615. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  148616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148617. * @param name defines the name of the mesh
  148618. * @param url defines the url to the height map
  148619. * @param options defines the options used to create the mesh
  148620. * @param scene defines the hosting scene
  148621. * @returns the ground mesh
  148622. * @see https://doc.babylonjs.com/babylon101/height_map
  148623. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  148624. */
  148625. static CreateGroundFromHeightMap(name: string, url: string, options: {
  148626. width?: number;
  148627. height?: number;
  148628. subdivisions?: number;
  148629. minHeight?: number;
  148630. maxHeight?: number;
  148631. colorFilter?: Color3;
  148632. alphaFilter?: number;
  148633. updatable?: boolean;
  148634. onReady?: (mesh: GroundMesh) => void;
  148635. }, scene?: Nullable<Scene>): GroundMesh;
  148636. /**
  148637. * Creates a polygon mesh
  148638. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148639. * * 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
  148640. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148643. * * Remember you can only change the shape positions, not their number when updating a polygon
  148644. * @param name defines the name of the mesh
  148645. * @param options defines the options used to create the mesh
  148646. * @param scene defines the hosting scene
  148647. * @param earcutInjection can be used to inject your own earcut reference
  148648. * @returns the polygon mesh
  148649. */
  148650. static CreatePolygon(name: string, options: {
  148651. shape: Vector3[];
  148652. holes?: Vector3[][];
  148653. depth?: number;
  148654. faceUV?: Vector4[];
  148655. faceColors?: Color4[];
  148656. updatable?: boolean;
  148657. sideOrientation?: number;
  148658. frontUVs?: Vector4;
  148659. backUVs?: Vector4;
  148660. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148661. /**
  148662. * Creates an extruded polygon mesh, with depth in the Y direction.
  148663. * * 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)
  148664. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148665. * @param name defines the name of the mesh
  148666. * @param options defines the options used to create the mesh
  148667. * @param scene defines the hosting scene
  148668. * @param earcutInjection can be used to inject your own earcut reference
  148669. * @returns the polygon mesh
  148670. */
  148671. static ExtrudePolygon(name: string, options: {
  148672. shape: Vector3[];
  148673. holes?: Vector3[][];
  148674. depth?: number;
  148675. faceUV?: Vector4[];
  148676. faceColors?: Color4[];
  148677. updatable?: boolean;
  148678. sideOrientation?: number;
  148679. frontUVs?: Vector4;
  148680. backUVs?: Vector4;
  148681. wrap?: boolean;
  148682. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148683. /**
  148684. * Creates a tube mesh.
  148685. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148686. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148687. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148688. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148689. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148690. * * 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)
  148691. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148692. * * 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
  148693. * * 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
  148694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148698. * @param name defines the name of the mesh
  148699. * @param options defines the options used to create the mesh
  148700. * @param scene defines the hosting scene
  148701. * @returns the tube mesh
  148702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148703. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148704. */
  148705. static CreateTube(name: string, options: {
  148706. path: Vector3[];
  148707. radius?: number;
  148708. tessellation?: number;
  148709. radiusFunction?: {
  148710. (i: number, distance: number): number;
  148711. };
  148712. cap?: number;
  148713. arc?: number;
  148714. updatable?: boolean;
  148715. sideOrientation?: number;
  148716. frontUVs?: Vector4;
  148717. backUVs?: Vector4;
  148718. instance?: Mesh;
  148719. invertUV?: boolean;
  148720. }, scene?: Nullable<Scene>): Mesh;
  148721. /**
  148722. * Creates a polyhedron mesh
  148723. * * 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
  148724. * * The parameter `size` (positive float, default 1) sets the polygon size
  148725. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  148726. * * 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`
  148727. * * 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
  148728. * * 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)`)
  148729. * * 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
  148730. * * 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
  148731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148734. * @param name defines the name of the mesh
  148735. * @param options defines the options used to create the mesh
  148736. * @param scene defines the hosting scene
  148737. * @returns the polyhedron mesh
  148738. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  148739. */
  148740. static CreatePolyhedron(name: string, options: {
  148741. type?: number;
  148742. size?: number;
  148743. sizeX?: number;
  148744. sizeY?: number;
  148745. sizeZ?: number;
  148746. custom?: any;
  148747. faceUV?: Vector4[];
  148748. faceColors?: Color4[];
  148749. flat?: boolean;
  148750. updatable?: boolean;
  148751. sideOrientation?: number;
  148752. frontUVs?: Vector4;
  148753. backUVs?: Vector4;
  148754. }, scene?: Nullable<Scene>): Mesh;
  148755. /**
  148756. * Creates a decal mesh.
  148757. * 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
  148758. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148759. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148760. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148761. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148762. * @param name defines the name of the mesh
  148763. * @param sourceMesh defines the mesh where the decal must be applied
  148764. * @param options defines the options used to create the mesh
  148765. * @param scene defines the hosting scene
  148766. * @returns the decal mesh
  148767. * @see https://doc.babylonjs.com/how_to/decals
  148768. */
  148769. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148770. position?: Vector3;
  148771. normal?: Vector3;
  148772. size?: Vector3;
  148773. angle?: number;
  148774. }): Mesh;
  148775. /**
  148776. * Creates a Capsule Mesh
  148777. * @param name defines the name of the mesh.
  148778. * @param options the constructors options used to shape the mesh.
  148779. * @param scene defines the scene the mesh is scoped to.
  148780. * @returns the capsule mesh
  148781. * @see https://doc.babylonjs.com/how_to/capsule_shape
  148782. */
  148783. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  148784. }
  148785. }
  148786. declare module BABYLON {
  148787. /**
  148788. * A simplifier interface for future simplification implementations
  148789. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148790. */
  148791. export interface ISimplifier {
  148792. /**
  148793. * Simplification of a given mesh according to the given settings.
  148794. * Since this requires computation, it is assumed that the function runs async.
  148795. * @param settings The settings of the simplification, including quality and distance
  148796. * @param successCallback A callback that will be called after the mesh was simplified.
  148797. * @param errorCallback in case of an error, this callback will be called. optional.
  148798. */
  148799. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  148800. }
  148801. /**
  148802. * Expected simplification settings.
  148803. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  148804. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148805. */
  148806. export interface ISimplificationSettings {
  148807. /**
  148808. * Gets or sets the expected quality
  148809. */
  148810. quality: number;
  148811. /**
  148812. * Gets or sets the distance when this optimized version should be used
  148813. */
  148814. distance: number;
  148815. /**
  148816. * Gets an already optimized mesh
  148817. */
  148818. optimizeMesh?: boolean;
  148819. }
  148820. /**
  148821. * Class used to specify simplification options
  148822. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148823. */
  148824. export class SimplificationSettings implements ISimplificationSettings {
  148825. /** expected quality */
  148826. quality: number;
  148827. /** distance when this optimized version should be used */
  148828. distance: number;
  148829. /** already optimized mesh */
  148830. optimizeMesh?: boolean | undefined;
  148831. /**
  148832. * Creates a SimplificationSettings
  148833. * @param quality expected quality
  148834. * @param distance distance when this optimized version should be used
  148835. * @param optimizeMesh already optimized mesh
  148836. */
  148837. constructor(
  148838. /** expected quality */
  148839. quality: number,
  148840. /** distance when this optimized version should be used */
  148841. distance: number,
  148842. /** already optimized mesh */
  148843. optimizeMesh?: boolean | undefined);
  148844. }
  148845. /**
  148846. * Interface used to define a simplification task
  148847. */
  148848. export interface ISimplificationTask {
  148849. /**
  148850. * Array of settings
  148851. */
  148852. settings: Array<ISimplificationSettings>;
  148853. /**
  148854. * Simplification type
  148855. */
  148856. simplificationType: SimplificationType;
  148857. /**
  148858. * Mesh to simplify
  148859. */
  148860. mesh: Mesh;
  148861. /**
  148862. * Callback called on success
  148863. */
  148864. successCallback?: () => void;
  148865. /**
  148866. * Defines if parallel processing can be used
  148867. */
  148868. parallelProcessing: boolean;
  148869. }
  148870. /**
  148871. * Queue used to order the simplification tasks
  148872. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148873. */
  148874. export class SimplificationQueue {
  148875. private _simplificationArray;
  148876. /**
  148877. * Gets a boolean indicating that the process is still running
  148878. */
  148879. running: boolean;
  148880. /**
  148881. * Creates a new queue
  148882. */
  148883. constructor();
  148884. /**
  148885. * Adds a new simplification task
  148886. * @param task defines a task to add
  148887. */
  148888. addTask(task: ISimplificationTask): void;
  148889. /**
  148890. * Execute next task
  148891. */
  148892. executeNext(): void;
  148893. /**
  148894. * Execute a simplification task
  148895. * @param task defines the task to run
  148896. */
  148897. runSimplification(task: ISimplificationTask): void;
  148898. private getSimplifier;
  148899. }
  148900. /**
  148901. * The implemented types of simplification
  148902. * At the moment only Quadratic Error Decimation is implemented
  148903. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148904. */
  148905. export enum SimplificationType {
  148906. /** Quadratic error decimation */
  148907. QUADRATIC = 0
  148908. }
  148909. /**
  148910. * An implementation of the Quadratic Error simplification algorithm.
  148911. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148912. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148913. * @author RaananW
  148914. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148915. */
  148916. export class QuadraticErrorSimplification implements ISimplifier {
  148917. private _mesh;
  148918. private triangles;
  148919. private vertices;
  148920. private references;
  148921. private _reconstructedMesh;
  148922. /** Gets or sets the number pf sync interations */
  148923. syncIterations: number;
  148924. /** Gets or sets the aggressiveness of the simplifier */
  148925. aggressiveness: number;
  148926. /** Gets or sets the number of allowed iterations for decimation */
  148927. decimationIterations: number;
  148928. /** Gets or sets the espilon to use for bounding box computation */
  148929. boundingBoxEpsilon: number;
  148930. /**
  148931. * Creates a new QuadraticErrorSimplification
  148932. * @param _mesh defines the target mesh
  148933. */
  148934. constructor(_mesh: Mesh);
  148935. /**
  148936. * Simplification of a given mesh according to the given settings.
  148937. * Since this requires computation, it is assumed that the function runs async.
  148938. * @param settings The settings of the simplification, including quality and distance
  148939. * @param successCallback A callback that will be called after the mesh was simplified.
  148940. */
  148941. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148942. private runDecimation;
  148943. private initWithMesh;
  148944. private init;
  148945. private reconstructMesh;
  148946. private initDecimatedMesh;
  148947. private isFlipped;
  148948. private updateTriangles;
  148949. private identifyBorder;
  148950. private updateMesh;
  148951. private vertexError;
  148952. private calculateError;
  148953. }
  148954. }
  148955. declare module BABYLON {
  148956. interface Scene {
  148957. /** @hidden (Backing field) */
  148958. _simplificationQueue: SimplificationQueue;
  148959. /**
  148960. * Gets or sets the simplification queue attached to the scene
  148961. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148962. */
  148963. simplificationQueue: SimplificationQueue;
  148964. }
  148965. interface Mesh {
  148966. /**
  148967. * Simplify the mesh according to the given array of settings.
  148968. * Function will return immediately and will simplify async
  148969. * @param settings a collection of simplification settings
  148970. * @param parallelProcessing should all levels calculate parallel or one after the other
  148971. * @param simplificationType the type of simplification to run
  148972. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148973. * @returns the current mesh
  148974. */
  148975. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148976. }
  148977. /**
  148978. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148979. * created in a scene
  148980. */
  148981. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148982. /**
  148983. * The component name helpfull to identify the component in the list of scene components.
  148984. */
  148985. readonly name: string;
  148986. /**
  148987. * The scene the component belongs to.
  148988. */
  148989. scene: Scene;
  148990. /**
  148991. * Creates a new instance of the component for the given scene
  148992. * @param scene Defines the scene to register the component in
  148993. */
  148994. constructor(scene: Scene);
  148995. /**
  148996. * Registers the component in a given scene
  148997. */
  148998. register(): void;
  148999. /**
  149000. * Rebuilds the elements related to this component in case of
  149001. * context lost for instance.
  149002. */
  149003. rebuild(): void;
  149004. /**
  149005. * Disposes the component and the associated ressources
  149006. */
  149007. dispose(): void;
  149008. private _beforeCameraUpdate;
  149009. }
  149010. }
  149011. declare module BABYLON {
  149012. interface Mesh {
  149013. /**
  149014. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149015. */
  149016. thinInstanceEnablePicking: boolean;
  149017. /**
  149018. * Creates a new thin instance
  149019. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149020. * @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
  149021. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149022. */
  149023. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149024. /**
  149025. * Adds the transformation (matrix) of the current mesh as a thin instance
  149026. * @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
  149027. * @returns the thin instance index number
  149028. */
  149029. thinInstanceAddSelf(refresh: boolean): number;
  149030. /**
  149031. * Registers a custom attribute to be used with thin instances
  149032. * @param kind name of the attribute
  149033. * @param stride size in floats of the attribute
  149034. */
  149035. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149036. /**
  149037. * Sets the matrix of a thin instance
  149038. * @param index index of the thin instance
  149039. * @param matrix matrix to set
  149040. * @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
  149041. */
  149042. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149043. /**
  149044. * Sets the value of a custom attribute for a thin instance
  149045. * @param kind name of the attribute
  149046. * @param index index of the thin instance
  149047. * @param value value to set
  149048. * @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
  149049. */
  149050. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149051. /**
  149052. * 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.
  149053. */
  149054. thinInstanceCount: number;
  149055. /**
  149056. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149057. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149058. * @param buffer buffer to set
  149059. * @param stride size in floats of each value of the buffer
  149060. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149061. */
  149062. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149063. /**
  149064. * Gets the list of world matrices
  149065. * @return an array containing all the world matrices from the thin instances
  149066. */
  149067. thinInstanceGetWorldMatrices(): Matrix[];
  149068. /**
  149069. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149070. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149071. */
  149072. thinInstanceBufferUpdated(kind: string): void;
  149073. /**
  149074. * Applies a partial update to a buffer directly on the GPU
  149075. * 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
  149076. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149077. * @param data the data to set in the GPU buffer
  149078. * @param offset the offset in the GPU buffer where to update the data
  149079. */
  149080. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149081. /**
  149082. * Refreshes the bounding info, taking into account all the thin instances defined
  149083. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149084. */
  149085. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149086. /** @hidden */
  149087. _thinInstanceInitializeUserStorage(): void;
  149088. /** @hidden */
  149089. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149090. /** @hidden */
  149091. _userThinInstanceBuffersStorage: {
  149092. data: {
  149093. [key: string]: Float32Array;
  149094. };
  149095. sizes: {
  149096. [key: string]: number;
  149097. };
  149098. vertexBuffers: {
  149099. [key: string]: Nullable<VertexBuffer>;
  149100. };
  149101. strides: {
  149102. [key: string]: number;
  149103. };
  149104. };
  149105. }
  149106. }
  149107. declare module BABYLON {
  149108. /**
  149109. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149110. */
  149111. export interface INavigationEnginePlugin {
  149112. /**
  149113. * plugin name
  149114. */
  149115. name: string;
  149116. /**
  149117. * Creates a navigation mesh
  149118. * @param meshes array of all the geometry used to compute the navigatio mesh
  149119. * @param parameters bunch of parameters used to filter geometry
  149120. */
  149121. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149122. /**
  149123. * Create a navigation mesh debug mesh
  149124. * @param scene is where the mesh will be added
  149125. * @returns debug display mesh
  149126. */
  149127. createDebugNavMesh(scene: Scene): Mesh;
  149128. /**
  149129. * Get a navigation mesh constrained position, closest to the parameter position
  149130. * @param position world position
  149131. * @returns the closest point to position constrained by the navigation mesh
  149132. */
  149133. getClosestPoint(position: Vector3): Vector3;
  149134. /**
  149135. * Get a navigation mesh constrained position, closest to the parameter position
  149136. * @param position world position
  149137. * @param result output the closest point to position constrained by the navigation mesh
  149138. */
  149139. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149140. /**
  149141. * Get a navigation mesh constrained position, within a particular radius
  149142. * @param position world position
  149143. * @param maxRadius the maximum distance to the constrained world position
  149144. * @returns the closest point to position constrained by the navigation mesh
  149145. */
  149146. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149147. /**
  149148. * Get a navigation mesh constrained position, within a particular radius
  149149. * @param position world position
  149150. * @param maxRadius the maximum distance to the constrained world position
  149151. * @param result output the closest point to position constrained by the navigation mesh
  149152. */
  149153. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149154. /**
  149155. * Compute the final position from a segment made of destination-position
  149156. * @param position world position
  149157. * @param destination world position
  149158. * @returns the resulting point along the navmesh
  149159. */
  149160. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149161. /**
  149162. * Compute the final position from a segment made of destination-position
  149163. * @param position world position
  149164. * @param destination world position
  149165. * @param result output the resulting point along the navmesh
  149166. */
  149167. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149168. /**
  149169. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149170. * @param start world position
  149171. * @param end world position
  149172. * @returns array containing world position composing the path
  149173. */
  149174. computePath(start: Vector3, end: Vector3): Vector3[];
  149175. /**
  149176. * If this plugin is supported
  149177. * @returns true if plugin is supported
  149178. */
  149179. isSupported(): boolean;
  149180. /**
  149181. * Create a new Crowd so you can add agents
  149182. * @param maxAgents the maximum agent count in the crowd
  149183. * @param maxAgentRadius the maximum radius an agent can have
  149184. * @param scene to attach the crowd to
  149185. * @returns the crowd you can add agents to
  149186. */
  149187. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149188. /**
  149189. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149190. * The queries will try to find a solution within those bounds
  149191. * default is (1,1,1)
  149192. * @param extent x,y,z value that define the extent around the queries point of reference
  149193. */
  149194. setDefaultQueryExtent(extent: Vector3): void;
  149195. /**
  149196. * Get the Bounding box extent specified by setDefaultQueryExtent
  149197. * @returns the box extent values
  149198. */
  149199. getDefaultQueryExtent(): Vector3;
  149200. /**
  149201. * build the navmesh from a previously saved state using getNavmeshData
  149202. * @param data the Uint8Array returned by getNavmeshData
  149203. */
  149204. buildFromNavmeshData(data: Uint8Array): void;
  149205. /**
  149206. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149207. * @returns data the Uint8Array that can be saved and reused
  149208. */
  149209. getNavmeshData(): Uint8Array;
  149210. /**
  149211. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149212. * @param result output the box extent values
  149213. */
  149214. getDefaultQueryExtentToRef(result: Vector3): void;
  149215. /**
  149216. * Release all resources
  149217. */
  149218. dispose(): void;
  149219. }
  149220. /**
  149221. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149222. */
  149223. export interface ICrowd {
  149224. /**
  149225. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149226. * You can attach anything to that node. The node position is updated in the scene update tick.
  149227. * @param pos world position that will be constrained by the navigation mesh
  149228. * @param parameters agent parameters
  149229. * @param transform hooked to the agent that will be update by the scene
  149230. * @returns agent index
  149231. */
  149232. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149233. /**
  149234. * Returns the agent position in world space
  149235. * @param index agent index returned by addAgent
  149236. * @returns world space position
  149237. */
  149238. getAgentPosition(index: number): Vector3;
  149239. /**
  149240. * Gets the agent position result in world space
  149241. * @param index agent index returned by addAgent
  149242. * @param result output world space position
  149243. */
  149244. getAgentPositionToRef(index: number, result: Vector3): void;
  149245. /**
  149246. * Gets the agent velocity in world space
  149247. * @param index agent index returned by addAgent
  149248. * @returns world space velocity
  149249. */
  149250. getAgentVelocity(index: number): Vector3;
  149251. /**
  149252. * Gets the agent velocity result in world space
  149253. * @param index agent index returned by addAgent
  149254. * @param result output world space velocity
  149255. */
  149256. getAgentVelocityToRef(index: number, result: Vector3): void;
  149257. /**
  149258. * Gets the agent next target point on the path
  149259. * @param index agent index returned by addAgent
  149260. * @returns world space position
  149261. */
  149262. getAgentNextTargetPath(index: number): Vector3;
  149263. /**
  149264. * Gets the agent state
  149265. * @param index agent index returned by addAgent
  149266. * @returns agent state
  149267. */
  149268. getAgentState(index: number): number;
  149269. /**
  149270. * returns true if the agent in over an off mesh link connection
  149271. * @param index agent index returned by addAgent
  149272. * @returns true if over an off mesh link connection
  149273. */
  149274. overOffmeshConnection(index: number): boolean;
  149275. /**
  149276. * Gets the agent next target point on the path
  149277. * @param index agent index returned by addAgent
  149278. * @param result output world space position
  149279. */
  149280. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149281. /**
  149282. * remove a particular agent previously created
  149283. * @param index agent index returned by addAgent
  149284. */
  149285. removeAgent(index: number): void;
  149286. /**
  149287. * get the list of all agents attached to this crowd
  149288. * @returns list of agent indices
  149289. */
  149290. getAgents(): number[];
  149291. /**
  149292. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149293. * @param deltaTime in seconds
  149294. */
  149295. update(deltaTime: number): void;
  149296. /**
  149297. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149298. * @param index agent index returned by addAgent
  149299. * @param destination targeted world position
  149300. */
  149301. agentGoto(index: number, destination: Vector3): void;
  149302. /**
  149303. * Teleport the agent to a new position
  149304. * @param index agent index returned by addAgent
  149305. * @param destination targeted world position
  149306. */
  149307. agentTeleport(index: number, destination: Vector3): void;
  149308. /**
  149309. * Update agent parameters
  149310. * @param index agent index returned by addAgent
  149311. * @param parameters agent parameters
  149312. */
  149313. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149314. /**
  149315. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149316. * The queries will try to find a solution within those bounds
  149317. * default is (1,1,1)
  149318. * @param extent x,y,z value that define the extent around the queries point of reference
  149319. */
  149320. setDefaultQueryExtent(extent: Vector3): void;
  149321. /**
  149322. * Get the Bounding box extent specified by setDefaultQueryExtent
  149323. * @returns the box extent values
  149324. */
  149325. getDefaultQueryExtent(): Vector3;
  149326. /**
  149327. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149328. * @param result output the box extent values
  149329. */
  149330. getDefaultQueryExtentToRef(result: Vector3): void;
  149331. /**
  149332. * Release all resources
  149333. */
  149334. dispose(): void;
  149335. }
  149336. /**
  149337. * Configures an agent
  149338. */
  149339. export interface IAgentParameters {
  149340. /**
  149341. * Agent radius. [Limit: >= 0]
  149342. */
  149343. radius: number;
  149344. /**
  149345. * Agent height. [Limit: > 0]
  149346. */
  149347. height: number;
  149348. /**
  149349. * Maximum allowed acceleration. [Limit: >= 0]
  149350. */
  149351. maxAcceleration: number;
  149352. /**
  149353. * Maximum allowed speed. [Limit: >= 0]
  149354. */
  149355. maxSpeed: number;
  149356. /**
  149357. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  149358. */
  149359. collisionQueryRange: number;
  149360. /**
  149361. * The path visibility optimization range. [Limit: > 0]
  149362. */
  149363. pathOptimizationRange: number;
  149364. /**
  149365. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  149366. */
  149367. separationWeight: number;
  149368. }
  149369. /**
  149370. * Configures the navigation mesh creation
  149371. */
  149372. export interface INavMeshParameters {
  149373. /**
  149374. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  149375. */
  149376. cs: number;
  149377. /**
  149378. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  149379. */
  149380. ch: number;
  149381. /**
  149382. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  149383. */
  149384. walkableSlopeAngle: number;
  149385. /**
  149386. * Minimum floor to 'ceiling' height that will still allow the floor area to
  149387. * be considered walkable. [Limit: >= 3] [Units: vx]
  149388. */
  149389. walkableHeight: number;
  149390. /**
  149391. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  149392. */
  149393. walkableClimb: number;
  149394. /**
  149395. * The distance to erode/shrink the walkable area of the heightfield away from
  149396. * obstructions. [Limit: >=0] [Units: vx]
  149397. */
  149398. walkableRadius: number;
  149399. /**
  149400. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  149401. */
  149402. maxEdgeLen: number;
  149403. /**
  149404. * The maximum distance a simplfied contour's border edges should deviate
  149405. * the original raw contour. [Limit: >=0] [Units: vx]
  149406. */
  149407. maxSimplificationError: number;
  149408. /**
  149409. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  149410. */
  149411. minRegionArea: number;
  149412. /**
  149413. * Any regions with a span count smaller than this value will, if possible,
  149414. * be merged with larger regions. [Limit: >=0] [Units: vx]
  149415. */
  149416. mergeRegionArea: number;
  149417. /**
  149418. * The maximum number of vertices allowed for polygons generated during the
  149419. * contour to polygon conversion process. [Limit: >= 3]
  149420. */
  149421. maxVertsPerPoly: number;
  149422. /**
  149423. * Sets the sampling distance to use when generating the detail mesh.
  149424. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  149425. */
  149426. detailSampleDist: number;
  149427. /**
  149428. * The maximum distance the detail mesh surface should deviate from heightfield
  149429. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  149430. */
  149431. detailSampleMaxError: number;
  149432. }
  149433. }
  149434. declare module BABYLON {
  149435. /**
  149436. * RecastJS navigation plugin
  149437. */
  149438. export class RecastJSPlugin implements INavigationEnginePlugin {
  149439. /**
  149440. * Reference to the Recast library
  149441. */
  149442. bjsRECAST: any;
  149443. /**
  149444. * plugin name
  149445. */
  149446. name: string;
  149447. /**
  149448. * the first navmesh created. We might extend this to support multiple navmeshes
  149449. */
  149450. navMesh: any;
  149451. /**
  149452. * Initializes the recastJS plugin
  149453. * @param recastInjection can be used to inject your own recast reference
  149454. */
  149455. constructor(recastInjection?: any);
  149456. /**
  149457. * Creates a navigation mesh
  149458. * @param meshes array of all the geometry used to compute the navigatio mesh
  149459. * @param parameters bunch of parameters used to filter geometry
  149460. */
  149461. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149462. /**
  149463. * Create a navigation mesh debug mesh
  149464. * @param scene is where the mesh will be added
  149465. * @returns debug display mesh
  149466. */
  149467. createDebugNavMesh(scene: Scene): Mesh;
  149468. /**
  149469. * Get a navigation mesh constrained position, closest to the parameter position
  149470. * @param position world position
  149471. * @returns the closest point to position constrained by the navigation mesh
  149472. */
  149473. getClosestPoint(position: Vector3): Vector3;
  149474. /**
  149475. * Get a navigation mesh constrained position, closest to the parameter position
  149476. * @param position world position
  149477. * @param result output the closest point to position constrained by the navigation mesh
  149478. */
  149479. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149480. /**
  149481. * Get a navigation mesh constrained position, within a particular radius
  149482. * @param position world position
  149483. * @param maxRadius the maximum distance to the constrained world position
  149484. * @returns the closest point to position constrained by the navigation mesh
  149485. */
  149486. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149487. /**
  149488. * Get a navigation mesh constrained position, within a particular radius
  149489. * @param position world position
  149490. * @param maxRadius the maximum distance to the constrained world position
  149491. * @param result output the closest point to position constrained by the navigation mesh
  149492. */
  149493. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149494. /**
  149495. * Compute the final position from a segment made of destination-position
  149496. * @param position world position
  149497. * @param destination world position
  149498. * @returns the resulting point along the navmesh
  149499. */
  149500. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149501. /**
  149502. * Compute the final position from a segment made of destination-position
  149503. * @param position world position
  149504. * @param destination world position
  149505. * @param result output the resulting point along the navmesh
  149506. */
  149507. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149508. /**
  149509. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149510. * @param start world position
  149511. * @param end world position
  149512. * @returns array containing world position composing the path
  149513. */
  149514. computePath(start: Vector3, end: Vector3): Vector3[];
  149515. /**
  149516. * Create a new Crowd so you can add agents
  149517. * @param maxAgents the maximum agent count in the crowd
  149518. * @param maxAgentRadius the maximum radius an agent can have
  149519. * @param scene to attach the crowd to
  149520. * @returns the crowd you can add agents to
  149521. */
  149522. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149523. /**
  149524. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149525. * The queries will try to find a solution within those bounds
  149526. * default is (1,1,1)
  149527. * @param extent x,y,z value that define the extent around the queries point of reference
  149528. */
  149529. setDefaultQueryExtent(extent: Vector3): void;
  149530. /**
  149531. * Get the Bounding box extent specified by setDefaultQueryExtent
  149532. * @returns the box extent values
  149533. */
  149534. getDefaultQueryExtent(): Vector3;
  149535. /**
  149536. * build the navmesh from a previously saved state using getNavmeshData
  149537. * @param data the Uint8Array returned by getNavmeshData
  149538. */
  149539. buildFromNavmeshData(data: Uint8Array): void;
  149540. /**
  149541. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149542. * @returns data the Uint8Array that can be saved and reused
  149543. */
  149544. getNavmeshData(): Uint8Array;
  149545. /**
  149546. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149547. * @param result output the box extent values
  149548. */
  149549. getDefaultQueryExtentToRef(result: Vector3): void;
  149550. /**
  149551. * Disposes
  149552. */
  149553. dispose(): void;
  149554. /**
  149555. * If this plugin is supported
  149556. * @returns true if plugin is supported
  149557. */
  149558. isSupported(): boolean;
  149559. }
  149560. /**
  149561. * Recast detour crowd implementation
  149562. */
  149563. export class RecastJSCrowd implements ICrowd {
  149564. /**
  149565. * Recast/detour plugin
  149566. */
  149567. bjsRECASTPlugin: RecastJSPlugin;
  149568. /**
  149569. * Link to the detour crowd
  149570. */
  149571. recastCrowd: any;
  149572. /**
  149573. * One transform per agent
  149574. */
  149575. transforms: TransformNode[];
  149576. /**
  149577. * All agents created
  149578. */
  149579. agents: number[];
  149580. /**
  149581. * Link to the scene is kept to unregister the crowd from the scene
  149582. */
  149583. private _scene;
  149584. /**
  149585. * Observer for crowd updates
  149586. */
  149587. private _onBeforeAnimationsObserver;
  149588. /**
  149589. * Constructor
  149590. * @param plugin recastJS plugin
  149591. * @param maxAgents the maximum agent count in the crowd
  149592. * @param maxAgentRadius the maximum radius an agent can have
  149593. * @param scene to attach the crowd to
  149594. * @returns the crowd you can add agents to
  149595. */
  149596. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  149597. /**
  149598. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149599. * You can attach anything to that node. The node position is updated in the scene update tick.
  149600. * @param pos world position that will be constrained by the navigation mesh
  149601. * @param parameters agent parameters
  149602. * @param transform hooked to the agent that will be update by the scene
  149603. * @returns agent index
  149604. */
  149605. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149606. /**
  149607. * Returns the agent position in world space
  149608. * @param index agent index returned by addAgent
  149609. * @returns world space position
  149610. */
  149611. getAgentPosition(index: number): Vector3;
  149612. /**
  149613. * Returns the agent position result in world space
  149614. * @param index agent index returned by addAgent
  149615. * @param result output world space position
  149616. */
  149617. getAgentPositionToRef(index: number, result: Vector3): void;
  149618. /**
  149619. * Returns the agent velocity in world space
  149620. * @param index agent index returned by addAgent
  149621. * @returns world space velocity
  149622. */
  149623. getAgentVelocity(index: number): Vector3;
  149624. /**
  149625. * Returns the agent velocity result in world space
  149626. * @param index agent index returned by addAgent
  149627. * @param result output world space velocity
  149628. */
  149629. getAgentVelocityToRef(index: number, result: Vector3): void;
  149630. /**
  149631. * Returns the agent next target point on the path
  149632. * @param index agent index returned by addAgent
  149633. * @returns world space position
  149634. */
  149635. getAgentNextTargetPath(index: number): Vector3;
  149636. /**
  149637. * Returns the agent next target point on the path
  149638. * @param index agent index returned by addAgent
  149639. * @param result output world space position
  149640. */
  149641. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149642. /**
  149643. * Gets the agent state
  149644. * @param index agent index returned by addAgent
  149645. * @returns agent state
  149646. */
  149647. getAgentState(index: number): number;
  149648. /**
  149649. * returns true if the agent in over an off mesh link connection
  149650. * @param index agent index returned by addAgent
  149651. * @returns true if over an off mesh link connection
  149652. */
  149653. overOffmeshConnection(index: number): boolean;
  149654. /**
  149655. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149656. * @param index agent index returned by addAgent
  149657. * @param destination targeted world position
  149658. */
  149659. agentGoto(index: number, destination: Vector3): void;
  149660. /**
  149661. * Teleport the agent to a new position
  149662. * @param index agent index returned by addAgent
  149663. * @param destination targeted world position
  149664. */
  149665. agentTeleport(index: number, destination: Vector3): void;
  149666. /**
  149667. * Update agent parameters
  149668. * @param index agent index returned by addAgent
  149669. * @param parameters agent parameters
  149670. */
  149671. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149672. /**
  149673. * remove a particular agent previously created
  149674. * @param index agent index returned by addAgent
  149675. */
  149676. removeAgent(index: number): void;
  149677. /**
  149678. * get the list of all agents attached to this crowd
  149679. * @returns list of agent indices
  149680. */
  149681. getAgents(): number[];
  149682. /**
  149683. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149684. * @param deltaTime in seconds
  149685. */
  149686. update(deltaTime: number): void;
  149687. /**
  149688. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149689. * The queries will try to find a solution within those bounds
  149690. * default is (1,1,1)
  149691. * @param extent x,y,z value that define the extent around the queries point of reference
  149692. */
  149693. setDefaultQueryExtent(extent: Vector3): void;
  149694. /**
  149695. * Get the Bounding box extent specified by setDefaultQueryExtent
  149696. * @returns the box extent values
  149697. */
  149698. getDefaultQueryExtent(): Vector3;
  149699. /**
  149700. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149701. * @param result output the box extent values
  149702. */
  149703. getDefaultQueryExtentToRef(result: Vector3): void;
  149704. /**
  149705. * Release all resources
  149706. */
  149707. dispose(): void;
  149708. }
  149709. }
  149710. declare module BABYLON {
  149711. /**
  149712. * Class used to enable access to IndexedDB
  149713. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  149714. */
  149715. export class Database implements IOfflineProvider {
  149716. private _callbackManifestChecked;
  149717. private _currentSceneUrl;
  149718. private _db;
  149719. private _enableSceneOffline;
  149720. private _enableTexturesOffline;
  149721. private _manifestVersionFound;
  149722. private _mustUpdateRessources;
  149723. private _hasReachedQuota;
  149724. private _isSupported;
  149725. private _idbFactory;
  149726. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  149727. private static IsUASupportingBlobStorage;
  149728. /**
  149729. * Gets a boolean indicating if Database storate is enabled (off by default)
  149730. */
  149731. static IDBStorageEnabled: boolean;
  149732. /**
  149733. * Gets a boolean indicating if scene must be saved in the database
  149734. */
  149735. get enableSceneOffline(): boolean;
  149736. /**
  149737. * Gets a boolean indicating if textures must be saved in the database
  149738. */
  149739. get enableTexturesOffline(): boolean;
  149740. /**
  149741. * Creates a new Database
  149742. * @param urlToScene defines the url to load the scene
  149743. * @param callbackManifestChecked defines the callback to use when manifest is checked
  149744. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  149745. */
  149746. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  149747. private static _ParseURL;
  149748. private static _ReturnFullUrlLocation;
  149749. private _checkManifestFile;
  149750. /**
  149751. * Open the database and make it available
  149752. * @param successCallback defines the callback to call on success
  149753. * @param errorCallback defines the callback to call on error
  149754. */
  149755. open(successCallback: () => void, errorCallback: () => void): void;
  149756. /**
  149757. * Loads an image from the database
  149758. * @param url defines the url to load from
  149759. * @param image defines the target DOM image
  149760. */
  149761. loadImage(url: string, image: HTMLImageElement): void;
  149762. private _loadImageFromDBAsync;
  149763. private _saveImageIntoDBAsync;
  149764. private _checkVersionFromDB;
  149765. private _loadVersionFromDBAsync;
  149766. private _saveVersionIntoDBAsync;
  149767. /**
  149768. * Loads a file from database
  149769. * @param url defines the URL to load from
  149770. * @param sceneLoaded defines a callback to call on success
  149771. * @param progressCallBack defines a callback to call when progress changed
  149772. * @param errorCallback defines a callback to call on error
  149773. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  149774. */
  149775. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  149776. private _loadFileAsync;
  149777. private _saveFileAsync;
  149778. /**
  149779. * Validates if xhr data is correct
  149780. * @param xhr defines the request to validate
  149781. * @param dataType defines the expected data type
  149782. * @returns true if data is correct
  149783. */
  149784. private static _ValidateXHRData;
  149785. }
  149786. }
  149787. declare module BABYLON {
  149788. /** @hidden */
  149789. export var gpuUpdateParticlesPixelShader: {
  149790. name: string;
  149791. shader: string;
  149792. };
  149793. }
  149794. declare module BABYLON {
  149795. /** @hidden */
  149796. export var gpuUpdateParticlesVertexShader: {
  149797. name: string;
  149798. shader: string;
  149799. };
  149800. }
  149801. declare module BABYLON {
  149802. /** @hidden */
  149803. export var clipPlaneFragmentDeclaration2: {
  149804. name: string;
  149805. shader: string;
  149806. };
  149807. }
  149808. declare module BABYLON {
  149809. /** @hidden */
  149810. export var gpuRenderParticlesPixelShader: {
  149811. name: string;
  149812. shader: string;
  149813. };
  149814. }
  149815. declare module BABYLON {
  149816. /** @hidden */
  149817. export var clipPlaneVertexDeclaration2: {
  149818. name: string;
  149819. shader: string;
  149820. };
  149821. }
  149822. declare module BABYLON {
  149823. /** @hidden */
  149824. export var gpuRenderParticlesVertexShader: {
  149825. name: string;
  149826. shader: string;
  149827. };
  149828. }
  149829. declare module BABYLON {
  149830. /**
  149831. * This represents a GPU particle system in Babylon
  149832. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  149833. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  149834. */
  149835. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  149836. /**
  149837. * The layer mask we are rendering the particles through.
  149838. */
  149839. layerMask: number;
  149840. private _capacity;
  149841. private _activeCount;
  149842. private _currentActiveCount;
  149843. private _accumulatedCount;
  149844. private _renderEffect;
  149845. private _updateEffect;
  149846. private _buffer0;
  149847. private _buffer1;
  149848. private _spriteBuffer;
  149849. private _updateVAO;
  149850. private _renderVAO;
  149851. private _targetIndex;
  149852. private _sourceBuffer;
  149853. private _targetBuffer;
  149854. private _currentRenderId;
  149855. private _started;
  149856. private _stopped;
  149857. private _timeDelta;
  149858. private _randomTexture;
  149859. private _randomTexture2;
  149860. private _attributesStrideSize;
  149861. private _updateEffectOptions;
  149862. private _randomTextureSize;
  149863. private _actualFrame;
  149864. private _customEffect;
  149865. private readonly _rawTextureWidth;
  149866. /**
  149867. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  149868. */
  149869. static get IsSupported(): boolean;
  149870. /**
  149871. * An event triggered when the system is disposed.
  149872. */
  149873. onDisposeObservable: Observable<IParticleSystem>;
  149874. /**
  149875. * An event triggered when the system is stopped
  149876. */
  149877. onStoppedObservable: Observable<IParticleSystem>;
  149878. /**
  149879. * Gets the maximum number of particles active at the same time.
  149880. * @returns The max number of active particles.
  149881. */
  149882. getCapacity(): number;
  149883. /**
  149884. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149885. * to override the particles.
  149886. */
  149887. forceDepthWrite: boolean;
  149888. /**
  149889. * Gets or set the number of active particles
  149890. */
  149891. get activeParticleCount(): number;
  149892. set activeParticleCount(value: number);
  149893. private _preWarmDone;
  149894. /**
  149895. * Specifies if the particles are updated in emitter local space or world space.
  149896. */
  149897. isLocal: boolean;
  149898. /** Gets or sets a matrix to use to compute projection */
  149899. defaultProjectionMatrix: Matrix;
  149900. /**
  149901. * Is this system ready to be used/rendered
  149902. * @return true if the system is ready
  149903. */
  149904. isReady(): boolean;
  149905. /**
  149906. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149907. * @returns True if it has been started, otherwise false.
  149908. */
  149909. isStarted(): boolean;
  149910. /**
  149911. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149912. * @returns True if it has been stopped, otherwise false.
  149913. */
  149914. isStopped(): boolean;
  149915. /**
  149916. * Gets a boolean indicating that the system is stopping
  149917. * @returns true if the system is currently stopping
  149918. */
  149919. isStopping(): boolean;
  149920. /**
  149921. * Gets the number of particles active at the same time.
  149922. * @returns The number of active particles.
  149923. */
  149924. getActiveCount(): number;
  149925. /**
  149926. * Starts the particle system and begins to emit
  149927. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149928. */
  149929. start(delay?: number): void;
  149930. /**
  149931. * Stops the particle system.
  149932. */
  149933. stop(): void;
  149934. /**
  149935. * Remove all active particles
  149936. */
  149937. reset(): void;
  149938. /**
  149939. * Returns the string "GPUParticleSystem"
  149940. * @returns a string containing the class name
  149941. */
  149942. getClassName(): string;
  149943. /**
  149944. * Gets the custom effect used to render the particles
  149945. * @param blendMode Blend mode for which the effect should be retrieved
  149946. * @returns The effect
  149947. */
  149948. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149949. /**
  149950. * Sets the custom effect used to render the particles
  149951. * @param effect The effect to set
  149952. * @param blendMode Blend mode for which the effect should be set
  149953. */
  149954. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149955. /** @hidden */
  149956. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149957. /**
  149958. * Observable that will be called just before the particles are drawn
  149959. */
  149960. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149961. /**
  149962. * Gets the name of the particle vertex shader
  149963. */
  149964. get vertexShaderName(): string;
  149965. private _colorGradientsTexture;
  149966. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149967. /**
  149968. * Adds a new color gradient
  149969. * @param gradient defines the gradient to use (between 0 and 1)
  149970. * @param color1 defines the color to affect to the specified gradient
  149971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149972. * @returns the current particle system
  149973. */
  149974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149975. private _refreshColorGradient;
  149976. /** Force the system to rebuild all gradients that need to be resync */
  149977. forceRefreshGradients(): void;
  149978. /**
  149979. * Remove a specific color gradient
  149980. * @param gradient defines the gradient to remove
  149981. * @returns the current particle system
  149982. */
  149983. removeColorGradient(gradient: number): GPUParticleSystem;
  149984. private _angularSpeedGradientsTexture;
  149985. private _sizeGradientsTexture;
  149986. private _velocityGradientsTexture;
  149987. private _limitVelocityGradientsTexture;
  149988. private _dragGradientsTexture;
  149989. private _addFactorGradient;
  149990. /**
  149991. * Adds a new size gradient
  149992. * @param gradient defines the gradient to use (between 0 and 1)
  149993. * @param factor defines the size factor to affect to the specified gradient
  149994. * @returns the current particle system
  149995. */
  149996. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149997. /**
  149998. * Remove a specific size gradient
  149999. * @param gradient defines the gradient to remove
  150000. * @returns the current particle system
  150001. */
  150002. removeSizeGradient(gradient: number): GPUParticleSystem;
  150003. private _refreshFactorGradient;
  150004. /**
  150005. * Adds a new angular speed gradient
  150006. * @param gradient defines the gradient to use (between 0 and 1)
  150007. * @param factor defines the angular speed to affect to the specified gradient
  150008. * @returns the current particle system
  150009. */
  150010. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  150011. /**
  150012. * Remove a specific angular speed gradient
  150013. * @param gradient defines the gradient to remove
  150014. * @returns the current particle system
  150015. */
  150016. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150017. /**
  150018. * Adds a new velocity gradient
  150019. * @param gradient defines the gradient to use (between 0 and 1)
  150020. * @param factor defines the velocity to affect to the specified gradient
  150021. * @returns the current particle system
  150022. */
  150023. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150024. /**
  150025. * Remove a specific velocity gradient
  150026. * @param gradient defines the gradient to remove
  150027. * @returns the current particle system
  150028. */
  150029. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150030. /**
  150031. * Adds a new limit velocity gradient
  150032. * @param gradient defines the gradient to use (between 0 and 1)
  150033. * @param factor defines the limit velocity value to affect to the specified gradient
  150034. * @returns the current particle system
  150035. */
  150036. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150037. /**
  150038. * Remove a specific limit velocity gradient
  150039. * @param gradient defines the gradient to remove
  150040. * @returns the current particle system
  150041. */
  150042. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150043. /**
  150044. * Adds a new drag gradient
  150045. * @param gradient defines the gradient to use (between 0 and 1)
  150046. * @param factor defines the drag value to affect to the specified gradient
  150047. * @returns the current particle system
  150048. */
  150049. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150050. /**
  150051. * Remove a specific drag gradient
  150052. * @param gradient defines the gradient to remove
  150053. * @returns the current particle system
  150054. */
  150055. removeDragGradient(gradient: number): GPUParticleSystem;
  150056. /**
  150057. * Not supported by GPUParticleSystem
  150058. * @param gradient defines the gradient to use (between 0 and 1)
  150059. * @param factor defines the emit rate value to affect to the specified gradient
  150060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150061. * @returns the current particle system
  150062. */
  150063. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150064. /**
  150065. * Not supported by GPUParticleSystem
  150066. * @param gradient defines the gradient to remove
  150067. * @returns the current particle system
  150068. */
  150069. removeEmitRateGradient(gradient: number): IParticleSystem;
  150070. /**
  150071. * Not supported by GPUParticleSystem
  150072. * @param gradient defines the gradient to use (between 0 and 1)
  150073. * @param factor defines the start size value to affect to the specified gradient
  150074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150075. * @returns the current particle system
  150076. */
  150077. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150078. /**
  150079. * Not supported by GPUParticleSystem
  150080. * @param gradient defines the gradient to remove
  150081. * @returns the current particle system
  150082. */
  150083. removeStartSizeGradient(gradient: number): IParticleSystem;
  150084. /**
  150085. * Not supported by GPUParticleSystem
  150086. * @param gradient defines the gradient to use (between 0 and 1)
  150087. * @param min defines the color remap minimal range
  150088. * @param max defines the color remap maximal range
  150089. * @returns the current particle system
  150090. */
  150091. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150092. /**
  150093. * Not supported by GPUParticleSystem
  150094. * @param gradient defines the gradient to remove
  150095. * @returns the current particle system
  150096. */
  150097. removeColorRemapGradient(): IParticleSystem;
  150098. /**
  150099. * Not supported by GPUParticleSystem
  150100. * @param gradient defines the gradient to use (between 0 and 1)
  150101. * @param min defines the alpha remap minimal range
  150102. * @param max defines the alpha remap maximal range
  150103. * @returns the current particle system
  150104. */
  150105. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150106. /**
  150107. * Not supported by GPUParticleSystem
  150108. * @param gradient defines the gradient to remove
  150109. * @returns the current particle system
  150110. */
  150111. removeAlphaRemapGradient(): IParticleSystem;
  150112. /**
  150113. * Not supported by GPUParticleSystem
  150114. * @param gradient defines the gradient to use (between 0 and 1)
  150115. * @param color defines the color to affect to the specified gradient
  150116. * @returns the current particle system
  150117. */
  150118. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150119. /**
  150120. * Not supported by GPUParticleSystem
  150121. * @param gradient defines the gradient to remove
  150122. * @returns the current particle system
  150123. */
  150124. removeRampGradient(): IParticleSystem;
  150125. /**
  150126. * Not supported by GPUParticleSystem
  150127. * @returns the list of ramp gradients
  150128. */
  150129. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150130. /**
  150131. * Not supported by GPUParticleSystem
  150132. * Gets or sets a boolean indicating that ramp gradients must be used
  150133. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150134. */
  150135. get useRampGradients(): boolean;
  150136. set useRampGradients(value: boolean);
  150137. /**
  150138. * Not supported by GPUParticleSystem
  150139. * @param gradient defines the gradient to use (between 0 and 1)
  150140. * @param factor defines the life time factor to affect to the specified gradient
  150141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150142. * @returns the current particle system
  150143. */
  150144. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150145. /**
  150146. * Not supported by GPUParticleSystem
  150147. * @param gradient defines the gradient to remove
  150148. * @returns the current particle system
  150149. */
  150150. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150151. /**
  150152. * Instantiates a GPU particle system.
  150153. * 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.
  150154. * @param name The name of the particle system
  150155. * @param options The options used to create the system
  150156. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150157. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150158. * @param customEffect a custom effect used to change the way particles are rendered by default
  150159. */
  150160. constructor(name: string, options: Partial<{
  150161. capacity: number;
  150162. randomTextureSize: number;
  150163. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150164. protected _reset(): void;
  150165. private _createUpdateVAO;
  150166. private _createRenderVAO;
  150167. private _initialize;
  150168. /** @hidden */
  150169. _recreateUpdateEffect(): void;
  150170. private _getEffect;
  150171. /**
  150172. * Fill the defines array according to the current settings of the particle system
  150173. * @param defines Array to be updated
  150174. * @param blendMode blend mode to take into account when updating the array
  150175. */
  150176. fillDefines(defines: Array<string>, blendMode?: number): void;
  150177. /**
  150178. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150179. * @param uniforms Uniforms array to fill
  150180. * @param attributes Attributes array to fill
  150181. * @param samplers Samplers array to fill
  150182. */
  150183. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150184. /** @hidden */
  150185. _recreateRenderEffect(): Effect;
  150186. /**
  150187. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150188. * @param preWarm defines if we are in the pre-warmimg phase
  150189. */
  150190. animate(preWarm?: boolean): void;
  150191. private _createFactorGradientTexture;
  150192. private _createSizeGradientTexture;
  150193. private _createAngularSpeedGradientTexture;
  150194. private _createVelocityGradientTexture;
  150195. private _createLimitVelocityGradientTexture;
  150196. private _createDragGradientTexture;
  150197. private _createColorGradientTexture;
  150198. /**
  150199. * Renders the particle system in its current state
  150200. * @param preWarm defines if the system should only update the particles but not render them
  150201. * @returns the current number of particles
  150202. */
  150203. render(preWarm?: boolean): number;
  150204. /**
  150205. * Rebuilds the particle system
  150206. */
  150207. rebuild(): void;
  150208. private _releaseBuffers;
  150209. private _releaseVAOs;
  150210. /**
  150211. * Disposes the particle system and free the associated resources
  150212. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150213. */
  150214. dispose(disposeTexture?: boolean): void;
  150215. /**
  150216. * Clones the particle system.
  150217. * @param name The name of the cloned object
  150218. * @param newEmitter The new emitter to use
  150219. * @returns the cloned particle system
  150220. */
  150221. clone(name: string, newEmitter: any): GPUParticleSystem;
  150222. /**
  150223. * Serializes the particle system to a JSON object
  150224. * @param serializeTexture defines if the texture must be serialized as well
  150225. * @returns the JSON object
  150226. */
  150227. serialize(serializeTexture?: boolean): any;
  150228. /**
  150229. * Parses a JSON object to create a GPU particle system.
  150230. * @param parsedParticleSystem The JSON object to parse
  150231. * @param sceneOrEngine The scene or the engine to create the particle system in
  150232. * @param rootUrl The root url to use to load external dependencies like texture
  150233. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150234. * @returns the parsed GPU particle system
  150235. */
  150236. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150237. }
  150238. }
  150239. declare module BABYLON {
  150240. /**
  150241. * Represents a set of particle systems working together to create a specific effect
  150242. */
  150243. export class ParticleSystemSet implements IDisposable {
  150244. /**
  150245. * Gets or sets base Assets URL
  150246. */
  150247. static BaseAssetsUrl: string;
  150248. private _emitterCreationOptions;
  150249. private _emitterNode;
  150250. /**
  150251. * Gets the particle system list
  150252. */
  150253. systems: IParticleSystem[];
  150254. /**
  150255. * Gets the emitter node used with this set
  150256. */
  150257. get emitterNode(): Nullable<TransformNode>;
  150258. /**
  150259. * Creates a new emitter mesh as a sphere
  150260. * @param options defines the options used to create the sphere
  150261. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  150262. * @param scene defines the hosting scene
  150263. */
  150264. setEmitterAsSphere(options: {
  150265. diameter: number;
  150266. segments: number;
  150267. color: Color3;
  150268. }, renderingGroupId: number, scene: Scene): void;
  150269. /**
  150270. * Starts all particle systems of the set
  150271. * @param emitter defines an optional mesh to use as emitter for the particle systems
  150272. */
  150273. start(emitter?: AbstractMesh): void;
  150274. /**
  150275. * Release all associated resources
  150276. */
  150277. dispose(): void;
  150278. /**
  150279. * Serialize the set into a JSON compatible object
  150280. * @param serializeTexture defines if the texture must be serialized as well
  150281. * @returns a JSON compatible representation of the set
  150282. */
  150283. serialize(serializeTexture?: boolean): any;
  150284. /**
  150285. * Parse a new ParticleSystemSet from a serialized source
  150286. * @param data defines a JSON compatible representation of the set
  150287. * @param scene defines the hosting scene
  150288. * @param gpu defines if we want GPU particles or CPU particles
  150289. * @returns a new ParticleSystemSet
  150290. */
  150291. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  150292. }
  150293. }
  150294. declare module BABYLON {
  150295. /**
  150296. * This class is made for on one-liner static method to help creating particle system set.
  150297. */
  150298. export class ParticleHelper {
  150299. /**
  150300. * Gets or sets base Assets URL
  150301. */
  150302. static BaseAssetsUrl: string;
  150303. /** Define the Url to load snippets */
  150304. static SnippetUrl: string;
  150305. /**
  150306. * Create a default particle system that you can tweak
  150307. * @param emitter defines the emitter to use
  150308. * @param capacity defines the system capacity (default is 500 particles)
  150309. * @param scene defines the hosting scene
  150310. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  150311. * @returns the new Particle system
  150312. */
  150313. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  150314. /**
  150315. * This is the main static method (one-liner) of this helper to create different particle systems
  150316. * @param type This string represents the type to the particle system to create
  150317. * @param scene The scene where the particle system should live
  150318. * @param gpu If the system will use gpu
  150319. * @returns the ParticleSystemSet created
  150320. */
  150321. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  150322. /**
  150323. * Static function used to export a particle system to a ParticleSystemSet variable.
  150324. * Please note that the emitter shape is not exported
  150325. * @param systems defines the particle systems to export
  150326. * @returns the created particle system set
  150327. */
  150328. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  150329. /**
  150330. * Creates a particle system from a snippet saved in a remote file
  150331. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  150332. * @param url defines the url to load from
  150333. * @param scene defines the hosting scene
  150334. * @param gpu If the system will use gpu
  150335. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150336. * @returns a promise that will resolve to the new particle system
  150337. */
  150338. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150339. /**
  150340. * Creates a particle system from a snippet saved by the particle system editor
  150341. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  150342. * @param scene defines the hosting scene
  150343. * @param gpu If the system will use gpu
  150344. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150345. * @returns a promise that will resolve to the new particle system
  150346. */
  150347. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150348. }
  150349. }
  150350. declare module BABYLON {
  150351. interface Engine {
  150352. /**
  150353. * Create an effect to use with particle systems.
  150354. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  150355. * the particle system for which you want to create a custom effect in the last parameter
  150356. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  150357. * @param uniformsNames defines a list of attribute names
  150358. * @param samplers defines an array of string used to represent textures
  150359. * @param defines defines the string containing the defines to use to compile the shaders
  150360. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  150361. * @param onCompiled defines a function to call when the effect creation is successful
  150362. * @param onError defines a function to call when the effect creation has failed
  150363. * @param particleSystem the particle system you want to create the effect for
  150364. * @returns the new Effect
  150365. */
  150366. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  150367. }
  150368. interface Mesh {
  150369. /**
  150370. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  150371. * @returns an array of IParticleSystem
  150372. */
  150373. getEmittedParticleSystems(): IParticleSystem[];
  150374. /**
  150375. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  150376. * @returns an array of IParticleSystem
  150377. */
  150378. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  150379. }
  150380. }
  150381. declare module BABYLON {
  150382. /** Defines the 4 color options */
  150383. export enum PointColor {
  150384. /** color value */
  150385. Color = 2,
  150386. /** uv value */
  150387. UV = 1,
  150388. /** random value */
  150389. Random = 0,
  150390. /** stated value */
  150391. Stated = 3
  150392. }
  150393. /**
  150394. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  150395. * 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.
  150396. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  150397. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  150398. *
  150399. * Full documentation here : TO BE ENTERED
  150400. */
  150401. export class PointsCloudSystem implements IDisposable {
  150402. /**
  150403. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  150404. * Example : var p = SPS.particles[i];
  150405. */
  150406. particles: CloudPoint[];
  150407. /**
  150408. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  150409. */
  150410. nbParticles: number;
  150411. /**
  150412. * This a counter for your own usage. It's not set by any SPS functions.
  150413. */
  150414. counter: number;
  150415. /**
  150416. * The PCS name. This name is also given to the underlying mesh.
  150417. */
  150418. name: string;
  150419. /**
  150420. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  150421. */
  150422. mesh: Mesh;
  150423. /**
  150424. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  150425. * Please read :
  150426. */
  150427. vars: any;
  150428. /**
  150429. * @hidden
  150430. */
  150431. _size: number;
  150432. private _scene;
  150433. private _promises;
  150434. private _positions;
  150435. private _indices;
  150436. private _normals;
  150437. private _colors;
  150438. private _uvs;
  150439. private _indices32;
  150440. private _positions32;
  150441. private _colors32;
  150442. private _uvs32;
  150443. private _updatable;
  150444. private _isVisibilityBoxLocked;
  150445. private _alwaysVisible;
  150446. private _groups;
  150447. private _groupCounter;
  150448. private _computeParticleColor;
  150449. private _computeParticleTexture;
  150450. private _computeParticleRotation;
  150451. private _computeBoundingBox;
  150452. private _isReady;
  150453. /**
  150454. * Creates a PCS (Points Cloud System) object
  150455. * @param name (String) is the PCS name, this will be the underlying mesh name
  150456. * @param pointSize (number) is the size for each point
  150457. * @param scene (Scene) is the scene in which the PCS is added
  150458. * @param options defines the options of the PCS e.g.
  150459. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  150460. */
  150461. constructor(name: string, pointSize: number, scene: Scene, options?: {
  150462. updatable?: boolean;
  150463. });
  150464. /**
  150465. * Builds the PCS underlying mesh. Returns a standard Mesh.
  150466. * If no points were added to the PCS, the returned mesh is just a single point.
  150467. * @returns a promise for the created mesh
  150468. */
  150469. buildMeshAsync(): Promise<Mesh>;
  150470. /**
  150471. * @hidden
  150472. */
  150473. private _buildMesh;
  150474. private _addParticle;
  150475. private _randomUnitVector;
  150476. private _getColorIndicesForCoord;
  150477. private _setPointsColorOrUV;
  150478. private _colorFromTexture;
  150479. private _calculateDensity;
  150480. /**
  150481. * Adds points to the PCS in random positions within a unit sphere
  150482. * @param nb (positive integer) the number of particles to be created from this model
  150483. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  150484. * @returns the number of groups in the system
  150485. */
  150486. addPoints(nb: number, pointFunction?: any): number;
  150487. /**
  150488. * Adds points to the PCS from the surface of the model shape
  150489. * @param mesh is any Mesh object that will be used as a surface model for the points
  150490. * @param nb (positive integer) the number of particles to be created from this model
  150491. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150492. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150493. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150494. * @returns the number of groups in the system
  150495. */
  150496. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150497. /**
  150498. * Adds points to the PCS inside the model shape
  150499. * @param mesh is any Mesh object that will be used as a surface model for the points
  150500. * @param nb (positive integer) the number of particles to be created from this model
  150501. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150502. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150503. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150504. * @returns the number of groups in the system
  150505. */
  150506. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150507. /**
  150508. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  150509. * This method calls `updateParticle()` for each particle of the SPS.
  150510. * For an animated SPS, it is usually called within the render loop.
  150511. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  150512. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  150513. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  150514. * @returns the PCS.
  150515. */
  150516. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  150517. /**
  150518. * Disposes the PCS.
  150519. */
  150520. dispose(): void;
  150521. /**
  150522. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  150523. * doc :
  150524. * @returns the PCS.
  150525. */
  150526. refreshVisibleSize(): PointsCloudSystem;
  150527. /**
  150528. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  150529. * @param size the size (float) of the visibility box
  150530. * note : this doesn't lock the PCS mesh bounding box.
  150531. * doc :
  150532. */
  150533. setVisibilityBox(size: number): void;
  150534. /**
  150535. * Gets whether the PCS is always visible or not
  150536. * doc :
  150537. */
  150538. get isAlwaysVisible(): boolean;
  150539. /**
  150540. * Sets the PCS as always visible or not
  150541. * doc :
  150542. */
  150543. set isAlwaysVisible(val: boolean);
  150544. /**
  150545. * Tells to `setParticles()` to compute the particle rotations or not
  150546. * Default value : false. The PCS is faster when it's set to false
  150547. * Note : particle rotations are only applied to parent particles
  150548. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  150549. */
  150550. set computeParticleRotation(val: boolean);
  150551. /**
  150552. * Tells to `setParticles()` to compute the particle colors or not.
  150553. * Default value : true. The PCS is faster when it's set to false.
  150554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150555. */
  150556. set computeParticleColor(val: boolean);
  150557. set computeParticleTexture(val: boolean);
  150558. /**
  150559. * Gets if `setParticles()` computes the particle colors or not.
  150560. * Default value : false. The PCS is faster when it's set to false.
  150561. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150562. */
  150563. get computeParticleColor(): boolean;
  150564. /**
  150565. * Gets if `setParticles()` computes the particle textures or not.
  150566. * Default value : false. The PCS is faster when it's set to false.
  150567. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  150568. */
  150569. get computeParticleTexture(): boolean;
  150570. /**
  150571. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  150572. */
  150573. set computeBoundingBox(val: boolean);
  150574. /**
  150575. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  150576. */
  150577. get computeBoundingBox(): boolean;
  150578. /**
  150579. * This function does nothing. It may be overwritten to set all the particle first values.
  150580. * The PCS doesn't call this function, you may have to call it by your own.
  150581. * doc :
  150582. */
  150583. initParticles(): void;
  150584. /**
  150585. * This function does nothing. It may be overwritten to recycle a particle
  150586. * The PCS doesn't call this function, you can to call it
  150587. * doc :
  150588. * @param particle The particle to recycle
  150589. * @returns the recycled particle
  150590. */
  150591. recycleParticle(particle: CloudPoint): CloudPoint;
  150592. /**
  150593. * Updates a particle : this function should be overwritten by the user.
  150594. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  150595. * doc :
  150596. * @example : just set a particle position or velocity and recycle conditions
  150597. * @param particle The particle to update
  150598. * @returns the updated particle
  150599. */
  150600. updateParticle(particle: CloudPoint): CloudPoint;
  150601. /**
  150602. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  150603. * This does nothing and may be overwritten by the user.
  150604. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150605. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150606. * @param update the boolean update value actually passed to setParticles()
  150607. */
  150608. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150609. /**
  150610. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  150611. * This will be passed three parameters.
  150612. * This does nothing and may be overwritten by the user.
  150613. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150614. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150615. * @param update the boolean update value actually passed to setParticles()
  150616. */
  150617. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150618. }
  150619. }
  150620. declare module BABYLON {
  150621. /**
  150622. * Represents one particle of a points cloud system.
  150623. */
  150624. export class CloudPoint {
  150625. /**
  150626. * particle global index
  150627. */
  150628. idx: number;
  150629. /**
  150630. * The color of the particle
  150631. */
  150632. color: Nullable<Color4>;
  150633. /**
  150634. * The world space position of the particle.
  150635. */
  150636. position: Vector3;
  150637. /**
  150638. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  150639. */
  150640. rotation: Vector3;
  150641. /**
  150642. * The world space rotation quaternion of the particle.
  150643. */
  150644. rotationQuaternion: Nullable<Quaternion>;
  150645. /**
  150646. * The uv of the particle.
  150647. */
  150648. uv: Nullable<Vector2>;
  150649. /**
  150650. * The current speed of the particle.
  150651. */
  150652. velocity: Vector3;
  150653. /**
  150654. * The pivot point in the particle local space.
  150655. */
  150656. pivot: Vector3;
  150657. /**
  150658. * Must the particle be translated from its pivot point in its local space ?
  150659. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  150660. * Default : false
  150661. */
  150662. translateFromPivot: boolean;
  150663. /**
  150664. * Index of this particle in the global "positions" array (Internal use)
  150665. * @hidden
  150666. */
  150667. _pos: number;
  150668. /**
  150669. * @hidden Index of this particle in the global "indices" array (Internal use)
  150670. */
  150671. _ind: number;
  150672. /**
  150673. * Group this particle belongs to
  150674. */
  150675. _group: PointsGroup;
  150676. /**
  150677. * Group id of this particle
  150678. */
  150679. groupId: number;
  150680. /**
  150681. * Index of the particle in its group id (Internal use)
  150682. */
  150683. idxInGroup: number;
  150684. /**
  150685. * @hidden Particle BoundingInfo object (Internal use)
  150686. */
  150687. _boundingInfo: BoundingInfo;
  150688. /**
  150689. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  150690. */
  150691. _pcs: PointsCloudSystem;
  150692. /**
  150693. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  150694. */
  150695. _stillInvisible: boolean;
  150696. /**
  150697. * @hidden Last computed particle rotation matrix
  150698. */
  150699. _rotationMatrix: number[];
  150700. /**
  150701. * Parent particle Id, if any.
  150702. * Default null.
  150703. */
  150704. parentId: Nullable<number>;
  150705. /**
  150706. * @hidden Internal global position in the PCS.
  150707. */
  150708. _globalPosition: Vector3;
  150709. /**
  150710. * Creates a Point Cloud object.
  150711. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  150712. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  150713. * @param group (PointsGroup) is the group the particle belongs to
  150714. * @param groupId (integer) is the group identifier in the PCS.
  150715. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  150716. * @param pcs defines the PCS it is associated to
  150717. */
  150718. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  150719. /**
  150720. * get point size
  150721. */
  150722. get size(): Vector3;
  150723. /**
  150724. * Set point size
  150725. */
  150726. set size(scale: Vector3);
  150727. /**
  150728. * Legacy support, changed quaternion to rotationQuaternion
  150729. */
  150730. get quaternion(): Nullable<Quaternion>;
  150731. /**
  150732. * Legacy support, changed quaternion to rotationQuaternion
  150733. */
  150734. set quaternion(q: Nullable<Quaternion>);
  150735. /**
  150736. * Returns a boolean. True if the particle intersects a mesh, else false
  150737. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  150738. * @param target is the object (point or mesh) what the intersection is computed against
  150739. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  150740. * @returns true if it intersects
  150741. */
  150742. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  150743. /**
  150744. * get the rotation matrix of the particle
  150745. * @hidden
  150746. */
  150747. getRotationMatrix(m: Matrix): void;
  150748. }
  150749. /**
  150750. * Represents a group of points in a points cloud system
  150751. * * PCS internal tool, don't use it manually.
  150752. */
  150753. export class PointsGroup {
  150754. /**
  150755. * The group id
  150756. * @hidden
  150757. */
  150758. groupID: number;
  150759. /**
  150760. * image data for group (internal use)
  150761. * @hidden
  150762. */
  150763. _groupImageData: Nullable<ArrayBufferView>;
  150764. /**
  150765. * Image Width (internal use)
  150766. * @hidden
  150767. */
  150768. _groupImgWidth: number;
  150769. /**
  150770. * Image Height (internal use)
  150771. * @hidden
  150772. */
  150773. _groupImgHeight: number;
  150774. /**
  150775. * Custom position function (internal use)
  150776. * @hidden
  150777. */
  150778. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  150779. /**
  150780. * density per facet for surface points
  150781. * @hidden
  150782. */
  150783. _groupDensity: number[];
  150784. /**
  150785. * Only when points are colored by texture carries pointer to texture list array
  150786. * @hidden
  150787. */
  150788. _textureNb: number;
  150789. /**
  150790. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  150791. * PCS internal tool, don't use it manually.
  150792. * @hidden
  150793. */
  150794. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  150795. }
  150796. }
  150797. declare module BABYLON {
  150798. interface Scene {
  150799. /** @hidden (Backing field) */
  150800. _physicsEngine: Nullable<IPhysicsEngine>;
  150801. /** @hidden */
  150802. _physicsTimeAccumulator: number;
  150803. /**
  150804. * Gets the current physics engine
  150805. * @returns a IPhysicsEngine or null if none attached
  150806. */
  150807. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  150808. /**
  150809. * Enables physics to the current scene
  150810. * @param gravity defines the scene's gravity for the physics engine
  150811. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  150812. * @return a boolean indicating if the physics engine was initialized
  150813. */
  150814. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  150815. /**
  150816. * Disables and disposes the physics engine associated with the scene
  150817. */
  150818. disablePhysicsEngine(): void;
  150819. /**
  150820. * Gets a boolean indicating if there is an active physics engine
  150821. * @returns a boolean indicating if there is an active physics engine
  150822. */
  150823. isPhysicsEnabled(): boolean;
  150824. /**
  150825. * Deletes a physics compound impostor
  150826. * @param compound defines the compound to delete
  150827. */
  150828. deleteCompoundImpostor(compound: any): void;
  150829. /**
  150830. * An event triggered when physic simulation is about to be run
  150831. */
  150832. onBeforePhysicsObservable: Observable<Scene>;
  150833. /**
  150834. * An event triggered when physic simulation has been done
  150835. */
  150836. onAfterPhysicsObservable: Observable<Scene>;
  150837. }
  150838. interface AbstractMesh {
  150839. /** @hidden */
  150840. _physicsImpostor: Nullable<PhysicsImpostor>;
  150841. /**
  150842. * Gets or sets impostor used for physic simulation
  150843. * @see https://doc.babylonjs.com/features/physics_engine
  150844. */
  150845. physicsImpostor: Nullable<PhysicsImpostor>;
  150846. /**
  150847. * Gets the current physics impostor
  150848. * @see https://doc.babylonjs.com/features/physics_engine
  150849. * @returns a physics impostor or null
  150850. */
  150851. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  150852. /** Apply a physic impulse to the mesh
  150853. * @param force defines the force to apply
  150854. * @param contactPoint defines where to apply the force
  150855. * @returns the current mesh
  150856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150857. */
  150858. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  150859. /**
  150860. * Creates a physic joint between two meshes
  150861. * @param otherMesh defines the other mesh to use
  150862. * @param pivot1 defines the pivot to use on this mesh
  150863. * @param pivot2 defines the pivot to use on the other mesh
  150864. * @param options defines additional options (can be plugin dependent)
  150865. * @returns the current mesh
  150866. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  150867. */
  150868. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  150869. /** @hidden */
  150870. _disposePhysicsObserver: Nullable<Observer<Node>>;
  150871. }
  150872. /**
  150873. * Defines the physics engine scene component responsible to manage a physics engine
  150874. */
  150875. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150876. /**
  150877. * The component name helpful to identify the component in the list of scene components.
  150878. */
  150879. readonly name: string;
  150880. /**
  150881. * The scene the component belongs to.
  150882. */
  150883. scene: Scene;
  150884. /**
  150885. * Creates a new instance of the component for the given scene
  150886. * @param scene Defines the scene to register the component in
  150887. */
  150888. constructor(scene: Scene);
  150889. /**
  150890. * Registers the component in a given scene
  150891. */
  150892. register(): void;
  150893. /**
  150894. * Rebuilds the elements related to this component in case of
  150895. * context lost for instance.
  150896. */
  150897. rebuild(): void;
  150898. /**
  150899. * Disposes the component and the associated ressources
  150900. */
  150901. dispose(): void;
  150902. }
  150903. }
  150904. declare module BABYLON {
  150905. /**
  150906. * A helper for physics simulations
  150907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150908. */
  150909. export class PhysicsHelper {
  150910. private _scene;
  150911. private _physicsEngine;
  150912. /**
  150913. * Initializes the Physics helper
  150914. * @param scene Babylon.js scene
  150915. */
  150916. constructor(scene: Scene);
  150917. /**
  150918. * Applies a radial explosion impulse
  150919. * @param origin the origin of the explosion
  150920. * @param radiusOrEventOptions the radius or the options of radial explosion
  150921. * @param strength the explosion strength
  150922. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150923. * @returns A physics radial explosion event, or null
  150924. */
  150925. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150926. /**
  150927. * Applies a radial explosion force
  150928. * @param origin the origin of the explosion
  150929. * @param radiusOrEventOptions the radius or the options of radial explosion
  150930. * @param strength the explosion strength
  150931. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150932. * @returns A physics radial explosion event, or null
  150933. */
  150934. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150935. /**
  150936. * Creates a gravitational field
  150937. * @param origin the origin of the explosion
  150938. * @param radiusOrEventOptions the radius or the options of radial explosion
  150939. * @param strength the explosion strength
  150940. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150941. * @returns A physics gravitational field event, or null
  150942. */
  150943. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150944. /**
  150945. * Creates a physics updraft event
  150946. * @param origin the origin of the updraft
  150947. * @param radiusOrEventOptions the radius or the options of the updraft
  150948. * @param strength the strength of the updraft
  150949. * @param height the height of the updraft
  150950. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150951. * @returns A physics updraft event, or null
  150952. */
  150953. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150954. /**
  150955. * Creates a physics vortex event
  150956. * @param origin the of the vortex
  150957. * @param radiusOrEventOptions the radius or the options of the vortex
  150958. * @param strength the strength of the vortex
  150959. * @param height the height of the vortex
  150960. * @returns a Physics vortex event, or null
  150961. * A physics vortex event or null
  150962. */
  150963. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150964. }
  150965. /**
  150966. * Represents a physics radial explosion event
  150967. */
  150968. class PhysicsRadialExplosionEvent {
  150969. private _scene;
  150970. private _options;
  150971. private _sphere;
  150972. private _dataFetched;
  150973. /**
  150974. * Initializes a radial explosioin event
  150975. * @param _scene BabylonJS scene
  150976. * @param _options The options for the vortex event
  150977. */
  150978. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150979. /**
  150980. * Returns the data related to the radial explosion event (sphere).
  150981. * @returns The radial explosion event data
  150982. */
  150983. getData(): PhysicsRadialExplosionEventData;
  150984. /**
  150985. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150986. * @param impostor A physics imposter
  150987. * @param origin the origin of the explosion
  150988. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150989. */
  150990. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150991. /**
  150992. * Triggers affecterd impostors callbacks
  150993. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150994. */
  150995. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150996. /**
  150997. * Disposes the sphere.
  150998. * @param force Specifies if the sphere should be disposed by force
  150999. */
  151000. dispose(force?: boolean): void;
  151001. /*** Helpers ***/
  151002. private _prepareSphere;
  151003. private _intersectsWithSphere;
  151004. }
  151005. /**
  151006. * Represents a gravitational field event
  151007. */
  151008. class PhysicsGravitationalFieldEvent {
  151009. private _physicsHelper;
  151010. private _scene;
  151011. private _origin;
  151012. private _options;
  151013. private _tickCallback;
  151014. private _sphere;
  151015. private _dataFetched;
  151016. /**
  151017. * Initializes the physics gravitational field event
  151018. * @param _physicsHelper A physics helper
  151019. * @param _scene BabylonJS scene
  151020. * @param _origin The origin position of the gravitational field event
  151021. * @param _options The options for the vortex event
  151022. */
  151023. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151024. /**
  151025. * Returns the data related to the gravitational field event (sphere).
  151026. * @returns A gravitational field event
  151027. */
  151028. getData(): PhysicsGravitationalFieldEventData;
  151029. /**
  151030. * Enables the gravitational field.
  151031. */
  151032. enable(): void;
  151033. /**
  151034. * Disables the gravitational field.
  151035. */
  151036. disable(): void;
  151037. /**
  151038. * Disposes the sphere.
  151039. * @param force The force to dispose from the gravitational field event
  151040. */
  151041. dispose(force?: boolean): void;
  151042. private _tick;
  151043. }
  151044. /**
  151045. * Represents a physics updraft event
  151046. */
  151047. class PhysicsUpdraftEvent {
  151048. private _scene;
  151049. private _origin;
  151050. private _options;
  151051. private _physicsEngine;
  151052. private _originTop;
  151053. private _originDirection;
  151054. private _tickCallback;
  151055. private _cylinder;
  151056. private _cylinderPosition;
  151057. private _dataFetched;
  151058. /**
  151059. * Initializes the physics updraft event
  151060. * @param _scene BabylonJS scene
  151061. * @param _origin The origin position of the updraft
  151062. * @param _options The options for the updraft event
  151063. */
  151064. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151065. /**
  151066. * Returns the data related to the updraft event (cylinder).
  151067. * @returns A physics updraft event
  151068. */
  151069. getData(): PhysicsUpdraftEventData;
  151070. /**
  151071. * Enables the updraft.
  151072. */
  151073. enable(): void;
  151074. /**
  151075. * Disables the updraft.
  151076. */
  151077. disable(): void;
  151078. /**
  151079. * Disposes the cylinder.
  151080. * @param force Specifies if the updraft should be disposed by force
  151081. */
  151082. dispose(force?: boolean): void;
  151083. private getImpostorHitData;
  151084. private _tick;
  151085. /*** Helpers ***/
  151086. private _prepareCylinder;
  151087. private _intersectsWithCylinder;
  151088. }
  151089. /**
  151090. * Represents a physics vortex event
  151091. */
  151092. class PhysicsVortexEvent {
  151093. private _scene;
  151094. private _origin;
  151095. private _options;
  151096. private _physicsEngine;
  151097. private _originTop;
  151098. private _tickCallback;
  151099. private _cylinder;
  151100. private _cylinderPosition;
  151101. private _dataFetched;
  151102. /**
  151103. * Initializes the physics vortex event
  151104. * @param _scene The BabylonJS scene
  151105. * @param _origin The origin position of the vortex
  151106. * @param _options The options for the vortex event
  151107. */
  151108. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151109. /**
  151110. * Returns the data related to the vortex event (cylinder).
  151111. * @returns The physics vortex event data
  151112. */
  151113. getData(): PhysicsVortexEventData;
  151114. /**
  151115. * Enables the vortex.
  151116. */
  151117. enable(): void;
  151118. /**
  151119. * Disables the cortex.
  151120. */
  151121. disable(): void;
  151122. /**
  151123. * Disposes the sphere.
  151124. * @param force
  151125. */
  151126. dispose(force?: boolean): void;
  151127. private getImpostorHitData;
  151128. private _tick;
  151129. /*** Helpers ***/
  151130. private _prepareCylinder;
  151131. private _intersectsWithCylinder;
  151132. }
  151133. /**
  151134. * Options fot the radial explosion event
  151135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151136. */
  151137. export class PhysicsRadialExplosionEventOptions {
  151138. /**
  151139. * The radius of the sphere for the radial explosion.
  151140. */
  151141. radius: number;
  151142. /**
  151143. * The strenth of the explosion.
  151144. */
  151145. strength: number;
  151146. /**
  151147. * The strenght of the force in correspondence to the distance of the affected object
  151148. */
  151149. falloff: PhysicsRadialImpulseFalloff;
  151150. /**
  151151. * Sphere options for the radial explosion.
  151152. */
  151153. sphere: {
  151154. segments: number;
  151155. diameter: number;
  151156. };
  151157. /**
  151158. * Sphere options for the radial explosion.
  151159. */
  151160. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151161. }
  151162. /**
  151163. * Options fot the updraft event
  151164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151165. */
  151166. export class PhysicsUpdraftEventOptions {
  151167. /**
  151168. * The radius of the cylinder for the vortex
  151169. */
  151170. radius: number;
  151171. /**
  151172. * The strenth of the updraft.
  151173. */
  151174. strength: number;
  151175. /**
  151176. * The height of the cylinder for the updraft.
  151177. */
  151178. height: number;
  151179. /**
  151180. * The mode for the the updraft.
  151181. */
  151182. updraftMode: PhysicsUpdraftMode;
  151183. }
  151184. /**
  151185. * Options fot the vortex event
  151186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151187. */
  151188. export class PhysicsVortexEventOptions {
  151189. /**
  151190. * The radius of the cylinder for the vortex
  151191. */
  151192. radius: number;
  151193. /**
  151194. * The strenth of the vortex.
  151195. */
  151196. strength: number;
  151197. /**
  151198. * The height of the cylinder for the vortex.
  151199. */
  151200. height: number;
  151201. /**
  151202. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151203. */
  151204. centripetalForceThreshold: number;
  151205. /**
  151206. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151207. */
  151208. centripetalForceMultiplier: number;
  151209. /**
  151210. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151211. */
  151212. centrifugalForceMultiplier: number;
  151213. /**
  151214. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151215. */
  151216. updraftForceMultiplier: number;
  151217. }
  151218. /**
  151219. * The strenght of the force in correspondence to the distance of the affected object
  151220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151221. */
  151222. export enum PhysicsRadialImpulseFalloff {
  151223. /** Defines that impulse is constant in strength across it's whole radius */
  151224. Constant = 0,
  151225. /** Defines that impulse gets weaker if it's further from the origin */
  151226. Linear = 1
  151227. }
  151228. /**
  151229. * The strength of the force in correspondence to the distance of the affected object
  151230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151231. */
  151232. export enum PhysicsUpdraftMode {
  151233. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151234. Center = 0,
  151235. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151236. Perpendicular = 1
  151237. }
  151238. /**
  151239. * Interface for a physics hit data
  151240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151241. */
  151242. export interface PhysicsHitData {
  151243. /**
  151244. * The force applied at the contact point
  151245. */
  151246. force: Vector3;
  151247. /**
  151248. * The contact point
  151249. */
  151250. contactPoint: Vector3;
  151251. /**
  151252. * The distance from the origin to the contact point
  151253. */
  151254. distanceFromOrigin: number;
  151255. }
  151256. /**
  151257. * Interface for radial explosion event data
  151258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151259. */
  151260. export interface PhysicsRadialExplosionEventData {
  151261. /**
  151262. * A sphere used for the radial explosion event
  151263. */
  151264. sphere: Mesh;
  151265. }
  151266. /**
  151267. * Interface for gravitational field event data
  151268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151269. */
  151270. export interface PhysicsGravitationalFieldEventData {
  151271. /**
  151272. * A sphere mesh used for the gravitational field event
  151273. */
  151274. sphere: Mesh;
  151275. }
  151276. /**
  151277. * Interface for updraft event data
  151278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151279. */
  151280. export interface PhysicsUpdraftEventData {
  151281. /**
  151282. * A cylinder used for the updraft event
  151283. */
  151284. cylinder: Mesh;
  151285. }
  151286. /**
  151287. * Interface for vortex event data
  151288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151289. */
  151290. export interface PhysicsVortexEventData {
  151291. /**
  151292. * A cylinder used for the vortex event
  151293. */
  151294. cylinder: Mesh;
  151295. }
  151296. /**
  151297. * Interface for an affected physics impostor
  151298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151299. */
  151300. export interface PhysicsAffectedImpostorWithData {
  151301. /**
  151302. * The impostor affected by the effect
  151303. */
  151304. impostor: PhysicsImpostor;
  151305. /**
  151306. * The data about the hit/horce from the explosion
  151307. */
  151308. hitData: PhysicsHitData;
  151309. }
  151310. }
  151311. declare module BABYLON {
  151312. /** @hidden */
  151313. export var blackAndWhitePixelShader: {
  151314. name: string;
  151315. shader: string;
  151316. };
  151317. }
  151318. declare module BABYLON {
  151319. /**
  151320. * Post process used to render in black and white
  151321. */
  151322. export class BlackAndWhitePostProcess extends PostProcess {
  151323. /**
  151324. * Linear about to convert he result to black and white (default: 1)
  151325. */
  151326. degree: number;
  151327. /**
  151328. * Gets a string identifying the name of the class
  151329. * @returns "BlackAndWhitePostProcess" string
  151330. */
  151331. getClassName(): string;
  151332. /**
  151333. * Creates a black and white post process
  151334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  151335. * @param name The name of the effect.
  151336. * @param options The required width/height ratio to downsize to before computing the render pass.
  151337. * @param camera The camera to apply the render pass to.
  151338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151339. * @param engine The engine which the post process will be applied. (default: current engine)
  151340. * @param reusable If the post process can be reused on the same frame. (default: false)
  151341. */
  151342. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151343. /** @hidden */
  151344. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  151345. }
  151346. }
  151347. declare module BABYLON {
  151348. /**
  151349. * This represents a set of one or more post processes in Babylon.
  151350. * A post process can be used to apply a shader to a texture after it is rendered.
  151351. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151352. */
  151353. export class PostProcessRenderEffect {
  151354. private _postProcesses;
  151355. private _getPostProcesses;
  151356. private _singleInstance;
  151357. private _cameras;
  151358. private _indicesForCamera;
  151359. /**
  151360. * Name of the effect
  151361. * @hidden
  151362. */
  151363. _name: string;
  151364. /**
  151365. * Instantiates a post process render effect.
  151366. * A post process can be used to apply a shader to a texture after it is rendered.
  151367. * @param engine The engine the effect is tied to
  151368. * @param name The name of the effect
  151369. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  151370. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  151371. */
  151372. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  151373. /**
  151374. * Checks if all the post processes in the effect are supported.
  151375. */
  151376. get isSupported(): boolean;
  151377. /**
  151378. * Updates the current state of the effect
  151379. * @hidden
  151380. */
  151381. _update(): void;
  151382. /**
  151383. * Attaches the effect on cameras
  151384. * @param cameras The camera to attach to.
  151385. * @hidden
  151386. */
  151387. _attachCameras(cameras: Camera): void;
  151388. /**
  151389. * Attaches the effect on cameras
  151390. * @param cameras The camera to attach to.
  151391. * @hidden
  151392. */
  151393. _attachCameras(cameras: Camera[]): void;
  151394. /**
  151395. * Detaches the effect on cameras
  151396. * @param cameras The camera to detatch from.
  151397. * @hidden
  151398. */
  151399. _detachCameras(cameras: Camera): void;
  151400. /**
  151401. * Detatches the effect on cameras
  151402. * @param cameras The camera to detatch from.
  151403. * @hidden
  151404. */
  151405. _detachCameras(cameras: Camera[]): void;
  151406. /**
  151407. * Enables the effect on given cameras
  151408. * @param cameras The camera to enable.
  151409. * @hidden
  151410. */
  151411. _enable(cameras: Camera): void;
  151412. /**
  151413. * Enables the effect on given cameras
  151414. * @param cameras The camera to enable.
  151415. * @hidden
  151416. */
  151417. _enable(cameras: Nullable<Camera[]>): void;
  151418. /**
  151419. * Disables the effect on the given cameras
  151420. * @param cameras The camera to disable.
  151421. * @hidden
  151422. */
  151423. _disable(cameras: Camera): void;
  151424. /**
  151425. * Disables the effect on the given cameras
  151426. * @param cameras The camera to disable.
  151427. * @hidden
  151428. */
  151429. _disable(cameras: Nullable<Camera[]>): void;
  151430. /**
  151431. * Gets a list of the post processes contained in the effect.
  151432. * @param camera The camera to get the post processes on.
  151433. * @returns The list of the post processes in the effect.
  151434. */
  151435. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  151436. }
  151437. }
  151438. declare module BABYLON {
  151439. /** @hidden */
  151440. export var extractHighlightsPixelShader: {
  151441. name: string;
  151442. shader: string;
  151443. };
  151444. }
  151445. declare module BABYLON {
  151446. /**
  151447. * 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.
  151448. */
  151449. export class ExtractHighlightsPostProcess extends PostProcess {
  151450. /**
  151451. * The luminance threshold, pixels below this value will be set to black.
  151452. */
  151453. threshold: number;
  151454. /** @hidden */
  151455. _exposure: number;
  151456. /**
  151457. * Post process which has the input texture to be used when performing highlight extraction
  151458. * @hidden
  151459. */
  151460. _inputPostProcess: Nullable<PostProcess>;
  151461. /**
  151462. * Gets a string identifying the name of the class
  151463. * @returns "ExtractHighlightsPostProcess" string
  151464. */
  151465. getClassName(): string;
  151466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151467. }
  151468. }
  151469. declare module BABYLON {
  151470. /** @hidden */
  151471. export var bloomMergePixelShader: {
  151472. name: string;
  151473. shader: string;
  151474. };
  151475. }
  151476. declare module BABYLON {
  151477. /**
  151478. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151479. */
  151480. export class BloomMergePostProcess extends PostProcess {
  151481. /** Weight of the bloom to be added to the original input. */
  151482. weight: number;
  151483. /**
  151484. * Gets a string identifying the name of the class
  151485. * @returns "BloomMergePostProcess" string
  151486. */
  151487. getClassName(): string;
  151488. /**
  151489. * Creates a new instance of @see BloomMergePostProcess
  151490. * @param name The name of the effect.
  151491. * @param originalFromInput Post process which's input will be used for the merge.
  151492. * @param blurred Blurred highlights post process which's output will be used.
  151493. * @param weight Weight of the bloom to be added to the original input.
  151494. * @param options The required width/height ratio to downsize to before computing the render pass.
  151495. * @param camera The camera to apply the render pass to.
  151496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151497. * @param engine The engine which the post process will be applied. (default: current engine)
  151498. * @param reusable If the post process can be reused on the same frame. (default: false)
  151499. * @param textureType Type of textures used when performing the post process. (default: 0)
  151500. * @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)
  151501. */
  151502. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  151503. /** Weight of the bloom to be added to the original input. */
  151504. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151505. }
  151506. }
  151507. declare module BABYLON {
  151508. /**
  151509. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  151510. */
  151511. export class BloomEffect extends PostProcessRenderEffect {
  151512. private bloomScale;
  151513. /**
  151514. * @hidden Internal
  151515. */
  151516. _effects: Array<PostProcess>;
  151517. /**
  151518. * @hidden Internal
  151519. */
  151520. _downscale: ExtractHighlightsPostProcess;
  151521. private _blurX;
  151522. private _blurY;
  151523. private _merge;
  151524. /**
  151525. * The luminance threshold to find bright areas of the image to bloom.
  151526. */
  151527. get threshold(): number;
  151528. set threshold(value: number);
  151529. /**
  151530. * The strength of the bloom.
  151531. */
  151532. get weight(): number;
  151533. set weight(value: number);
  151534. /**
  151535. * Specifies the size of the bloom blur kernel, relative to the final output size
  151536. */
  151537. get kernel(): number;
  151538. set kernel(value: number);
  151539. /**
  151540. * Creates a new instance of @see BloomEffect
  151541. * @param scene The scene the effect belongs to.
  151542. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  151543. * @param bloomKernel The size of the kernel to be used when applying the blur.
  151544. * @param bloomWeight The the strength of bloom.
  151545. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151546. * @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)
  151547. */
  151548. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  151549. /**
  151550. * Disposes each of the internal effects for a given camera.
  151551. * @param camera The camera to dispose the effect on.
  151552. */
  151553. disposeEffects(camera: Camera): void;
  151554. /**
  151555. * @hidden Internal
  151556. */
  151557. _updateEffects(): void;
  151558. /**
  151559. * Internal
  151560. * @returns if all the contained post processes are ready.
  151561. * @hidden
  151562. */
  151563. _isReady(): boolean;
  151564. }
  151565. }
  151566. declare module BABYLON {
  151567. /** @hidden */
  151568. export var chromaticAberrationPixelShader: {
  151569. name: string;
  151570. shader: string;
  151571. };
  151572. }
  151573. declare module BABYLON {
  151574. /**
  151575. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  151576. */
  151577. export class ChromaticAberrationPostProcess extends PostProcess {
  151578. /**
  151579. * The amount of seperation of rgb channels (default: 30)
  151580. */
  151581. aberrationAmount: number;
  151582. /**
  151583. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  151584. */
  151585. radialIntensity: number;
  151586. /**
  151587. * 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))
  151588. */
  151589. direction: Vector2;
  151590. /**
  151591. * 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))
  151592. */
  151593. centerPosition: Vector2;
  151594. /** The width of the screen to apply the effect on */
  151595. screenWidth: number;
  151596. /** The height of the screen to apply the effect on */
  151597. screenHeight: number;
  151598. /**
  151599. * Gets a string identifying the name of the class
  151600. * @returns "ChromaticAberrationPostProcess" string
  151601. */
  151602. getClassName(): string;
  151603. /**
  151604. * Creates a new instance ChromaticAberrationPostProcess
  151605. * @param name The name of the effect.
  151606. * @param screenWidth The width of the screen to apply the effect on.
  151607. * @param screenHeight The height of the screen to apply the effect on.
  151608. * @param options The required width/height ratio to downsize to before computing the render pass.
  151609. * @param camera The camera to apply the render pass to.
  151610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151611. * @param engine The engine which the post process will be applied. (default: current engine)
  151612. * @param reusable If the post process can be reused on the same frame. (default: false)
  151613. * @param textureType Type of textures used when performing the post process. (default: 0)
  151614. * @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)
  151615. */
  151616. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151617. /** @hidden */
  151618. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  151619. }
  151620. }
  151621. declare module BABYLON {
  151622. /** @hidden */
  151623. export var circleOfConfusionPixelShader: {
  151624. name: string;
  151625. shader: string;
  151626. };
  151627. }
  151628. declare module BABYLON {
  151629. /**
  151630. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  151631. */
  151632. export class CircleOfConfusionPostProcess extends PostProcess {
  151633. /**
  151634. * 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.
  151635. */
  151636. lensSize: number;
  151637. /**
  151638. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151639. */
  151640. fStop: number;
  151641. /**
  151642. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151643. */
  151644. focusDistance: number;
  151645. /**
  151646. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  151647. */
  151648. focalLength: number;
  151649. /**
  151650. * Gets a string identifying the name of the class
  151651. * @returns "CircleOfConfusionPostProcess" string
  151652. */
  151653. getClassName(): string;
  151654. private _depthTexture;
  151655. /**
  151656. * Creates a new instance CircleOfConfusionPostProcess
  151657. * @param name The name of the effect.
  151658. * @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.
  151659. * @param options The required width/height ratio to downsize to before computing the render pass.
  151660. * @param camera The camera to apply the render pass to.
  151661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151662. * @param engine The engine which the post process will be applied. (default: current engine)
  151663. * @param reusable If the post process can be reused on the same frame. (default: false)
  151664. * @param textureType Type of textures used when performing the post process. (default: 0)
  151665. * @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)
  151666. */
  151667. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151668. /**
  151669. * 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.
  151670. */
  151671. set depthTexture(value: RenderTargetTexture);
  151672. }
  151673. }
  151674. declare module BABYLON {
  151675. /** @hidden */
  151676. export var colorCorrectionPixelShader: {
  151677. name: string;
  151678. shader: string;
  151679. };
  151680. }
  151681. declare module BABYLON {
  151682. /**
  151683. *
  151684. * This post-process allows the modification of rendered colors by using
  151685. * a 'look-up table' (LUT). This effect is also called Color Grading.
  151686. *
  151687. * The object needs to be provided an url to a texture containing the color
  151688. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  151689. * Use an image editing software to tweak the LUT to match your needs.
  151690. *
  151691. * For an example of a color LUT, see here:
  151692. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  151693. * For explanations on color grading, see here:
  151694. * @see http://udn.epicgames.com/Three/ColorGrading.html
  151695. *
  151696. */
  151697. export class ColorCorrectionPostProcess extends PostProcess {
  151698. private _colorTableTexture;
  151699. /**
  151700. * Gets the color table url used to create the LUT texture
  151701. */
  151702. colorTableUrl: string;
  151703. /**
  151704. * Gets a string identifying the name of the class
  151705. * @returns "ColorCorrectionPostProcess" string
  151706. */
  151707. getClassName(): string;
  151708. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151709. /** @hidden */
  151710. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  151711. }
  151712. }
  151713. declare module BABYLON {
  151714. /** @hidden */
  151715. export var convolutionPixelShader: {
  151716. name: string;
  151717. shader: string;
  151718. };
  151719. }
  151720. declare module BABYLON {
  151721. /**
  151722. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  151723. * input texture to perform effects such as edge detection or sharpening
  151724. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151725. */
  151726. export class ConvolutionPostProcess extends PostProcess {
  151727. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  151728. kernel: number[];
  151729. /**
  151730. * Gets a string identifying the name of the class
  151731. * @returns "ConvolutionPostProcess" string
  151732. */
  151733. getClassName(): string;
  151734. /**
  151735. * Creates a new instance ConvolutionPostProcess
  151736. * @param name The name of the effect.
  151737. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  151738. * @param options The required width/height ratio to downsize to before computing the render pass.
  151739. * @param camera The camera to apply the render pass to.
  151740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151741. * @param engine The engine which the post process will be applied. (default: current engine)
  151742. * @param reusable If the post process can be reused on the same frame. (default: false)
  151743. * @param textureType Type of textures used when performing the post process. (default: 0)
  151744. */
  151745. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151746. /** @hidden */
  151747. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  151748. /**
  151749. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151750. */
  151751. static EdgeDetect0Kernel: number[];
  151752. /**
  151753. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151754. */
  151755. static EdgeDetect1Kernel: number[];
  151756. /**
  151757. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151758. */
  151759. static EdgeDetect2Kernel: number[];
  151760. /**
  151761. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151762. */
  151763. static SharpenKernel: number[];
  151764. /**
  151765. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151766. */
  151767. static EmbossKernel: number[];
  151768. /**
  151769. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151770. */
  151771. static GaussianKernel: number[];
  151772. }
  151773. }
  151774. declare module BABYLON {
  151775. /**
  151776. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  151777. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  151778. * based on samples that have a large difference in distance than the center pixel.
  151779. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  151780. */
  151781. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  151782. /**
  151783. * The direction the blur should be applied
  151784. */
  151785. direction: Vector2;
  151786. /**
  151787. * Gets a string identifying the name of the class
  151788. * @returns "DepthOfFieldBlurPostProcess" string
  151789. */
  151790. getClassName(): string;
  151791. /**
  151792. * Creates a new instance CircleOfConfusionPostProcess
  151793. * @param name The name of the effect.
  151794. * @param scene The scene the effect belongs to.
  151795. * @param direction The direction the blur should be applied.
  151796. * @param kernel The size of the kernel used to blur.
  151797. * @param options The required width/height ratio to downsize to before computing the render pass.
  151798. * @param camera The camera to apply the render pass to.
  151799. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  151800. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  151801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151802. * @param engine The engine which the post process will be applied. (default: current engine)
  151803. * @param reusable If the post process can be reused on the same frame. (default: false)
  151804. * @param textureType Type of textures used when performing the post process. (default: 0)
  151805. * @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)
  151806. */
  151807. 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);
  151808. }
  151809. }
  151810. declare module BABYLON {
  151811. /** @hidden */
  151812. export var depthOfFieldMergePixelShader: {
  151813. name: string;
  151814. shader: string;
  151815. };
  151816. }
  151817. declare module BABYLON {
  151818. /**
  151819. * Options to be set when merging outputs from the default pipeline.
  151820. */
  151821. export class DepthOfFieldMergePostProcessOptions {
  151822. /**
  151823. * The original image to merge on top of
  151824. */
  151825. originalFromInput: PostProcess;
  151826. /**
  151827. * Parameters to perform the merge of the depth of field effect
  151828. */
  151829. depthOfField?: {
  151830. circleOfConfusion: PostProcess;
  151831. blurSteps: Array<PostProcess>;
  151832. };
  151833. /**
  151834. * Parameters to perform the merge of bloom effect
  151835. */
  151836. bloom?: {
  151837. blurred: PostProcess;
  151838. weight: number;
  151839. };
  151840. }
  151841. /**
  151842. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151843. */
  151844. export class DepthOfFieldMergePostProcess extends PostProcess {
  151845. private blurSteps;
  151846. /**
  151847. * Gets a string identifying the name of the class
  151848. * @returns "DepthOfFieldMergePostProcess" string
  151849. */
  151850. getClassName(): string;
  151851. /**
  151852. * Creates a new instance of DepthOfFieldMergePostProcess
  151853. * @param name The name of the effect.
  151854. * @param originalFromInput Post process which's input will be used for the merge.
  151855. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  151856. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  151863. * @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)
  151864. */
  151865. 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);
  151866. /**
  151867. * Updates the effect with the current post process compile time values and recompiles the shader.
  151868. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  151869. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  151870. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  151871. * @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
  151872. * @param onCompiled Called when the shader has been compiled.
  151873. * @param onError Called if there is an error when compiling a shader.
  151874. */
  151875. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151876. }
  151877. }
  151878. declare module BABYLON {
  151879. /**
  151880. * Specifies the level of max blur that should be applied when using the depth of field effect
  151881. */
  151882. export enum DepthOfFieldEffectBlurLevel {
  151883. /**
  151884. * Subtle blur
  151885. */
  151886. Low = 0,
  151887. /**
  151888. * Medium blur
  151889. */
  151890. Medium = 1,
  151891. /**
  151892. * Large blur
  151893. */
  151894. High = 2
  151895. }
  151896. /**
  151897. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151898. */
  151899. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151900. private _circleOfConfusion;
  151901. /**
  151902. * @hidden Internal, blurs from high to low
  151903. */
  151904. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151905. private _depthOfFieldBlurY;
  151906. private _dofMerge;
  151907. /**
  151908. * @hidden Internal post processes in depth of field effect
  151909. */
  151910. _effects: Array<PostProcess>;
  151911. /**
  151912. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151913. */
  151914. set focalLength(value: number);
  151915. get focalLength(): number;
  151916. /**
  151917. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151918. */
  151919. set fStop(value: number);
  151920. get fStop(): number;
  151921. /**
  151922. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151923. */
  151924. set focusDistance(value: number);
  151925. get focusDistance(): number;
  151926. /**
  151927. * 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.
  151928. */
  151929. set lensSize(value: number);
  151930. get lensSize(): number;
  151931. /**
  151932. * Creates a new instance DepthOfFieldEffect
  151933. * @param scene The scene the effect belongs to.
  151934. * @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.
  151935. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151936. * @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)
  151937. */
  151938. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151939. /**
  151940. * Get the current class name of the current effet
  151941. * @returns "DepthOfFieldEffect"
  151942. */
  151943. getClassName(): string;
  151944. /**
  151945. * 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.
  151946. */
  151947. set depthTexture(value: RenderTargetTexture);
  151948. /**
  151949. * Disposes each of the internal effects for a given camera.
  151950. * @param camera The camera to dispose the effect on.
  151951. */
  151952. disposeEffects(camera: Camera): void;
  151953. /**
  151954. * @hidden Internal
  151955. */
  151956. _updateEffects(): void;
  151957. /**
  151958. * Internal
  151959. * @returns if all the contained post processes are ready.
  151960. * @hidden
  151961. */
  151962. _isReady(): boolean;
  151963. }
  151964. }
  151965. declare module BABYLON {
  151966. /** @hidden */
  151967. export var displayPassPixelShader: {
  151968. name: string;
  151969. shader: string;
  151970. };
  151971. }
  151972. declare module BABYLON {
  151973. /**
  151974. * DisplayPassPostProcess which produces an output the same as it's input
  151975. */
  151976. export class DisplayPassPostProcess extends PostProcess {
  151977. /**
  151978. * Gets a string identifying the name of the class
  151979. * @returns "DisplayPassPostProcess" string
  151980. */
  151981. getClassName(): string;
  151982. /**
  151983. * Creates the DisplayPassPostProcess
  151984. * @param name The name of the effect.
  151985. * @param options The required width/height ratio to downsize to before computing the render pass.
  151986. * @param camera The camera to apply the render pass to.
  151987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151988. * @param engine The engine which the post process will be applied. (default: current engine)
  151989. * @param reusable If the post process can be reused on the same frame. (default: false)
  151990. */
  151991. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151992. /** @hidden */
  151993. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151994. }
  151995. }
  151996. declare module BABYLON {
  151997. /** @hidden */
  151998. export var filterPixelShader: {
  151999. name: string;
  152000. shader: string;
  152001. };
  152002. }
  152003. declare module BABYLON {
  152004. /**
  152005. * Applies a kernel filter to the image
  152006. */
  152007. export class FilterPostProcess extends PostProcess {
  152008. /** The matrix to be applied to the image */
  152009. kernelMatrix: Matrix;
  152010. /**
  152011. * Gets a string identifying the name of the class
  152012. * @returns "FilterPostProcess" string
  152013. */
  152014. getClassName(): string;
  152015. /**
  152016. *
  152017. * @param name The name of the effect.
  152018. * @param kernelMatrix The matrix to be applied to the image
  152019. * @param options The required width/height ratio to downsize to before computing the render pass.
  152020. * @param camera The camera to apply the render pass to.
  152021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152022. * @param engine The engine which the post process will be applied. (default: current engine)
  152023. * @param reusable If the post process can be reused on the same frame. (default: false)
  152024. */
  152025. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152026. /** @hidden */
  152027. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152028. }
  152029. }
  152030. declare module BABYLON {
  152031. /** @hidden */
  152032. export var fxaaPixelShader: {
  152033. name: string;
  152034. shader: string;
  152035. };
  152036. }
  152037. declare module BABYLON {
  152038. /** @hidden */
  152039. export var fxaaVertexShader: {
  152040. name: string;
  152041. shader: string;
  152042. };
  152043. }
  152044. declare module BABYLON {
  152045. /**
  152046. * Fxaa post process
  152047. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152048. */
  152049. export class FxaaPostProcess extends PostProcess {
  152050. /**
  152051. * Gets a string identifying the name of the class
  152052. * @returns "FxaaPostProcess" string
  152053. */
  152054. getClassName(): string;
  152055. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152056. private _getDefines;
  152057. /** @hidden */
  152058. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152059. }
  152060. }
  152061. declare module BABYLON {
  152062. /** @hidden */
  152063. export var grainPixelShader: {
  152064. name: string;
  152065. shader: string;
  152066. };
  152067. }
  152068. declare module BABYLON {
  152069. /**
  152070. * The GrainPostProcess adds noise to the image at mid luminance levels
  152071. */
  152072. export class GrainPostProcess extends PostProcess {
  152073. /**
  152074. * The intensity of the grain added (default: 30)
  152075. */
  152076. intensity: number;
  152077. /**
  152078. * If the grain should be randomized on every frame
  152079. */
  152080. animated: boolean;
  152081. /**
  152082. * Gets a string identifying the name of the class
  152083. * @returns "GrainPostProcess" string
  152084. */
  152085. getClassName(): string;
  152086. /**
  152087. * Creates a new instance of @see GrainPostProcess
  152088. * @param name The name of the effect.
  152089. * @param options The required width/height ratio to downsize to before computing the render pass.
  152090. * @param camera The camera to apply the render pass to.
  152091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152092. * @param engine The engine which the post process will be applied. (default: current engine)
  152093. * @param reusable If the post process can be reused on the same frame. (default: false)
  152094. * @param textureType Type of textures used when performing the post process. (default: 0)
  152095. * @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)
  152096. */
  152097. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152098. /** @hidden */
  152099. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152100. }
  152101. }
  152102. declare module BABYLON {
  152103. /** @hidden */
  152104. export var highlightsPixelShader: {
  152105. name: string;
  152106. shader: string;
  152107. };
  152108. }
  152109. declare module BABYLON {
  152110. /**
  152111. * Extracts highlights from the image
  152112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152113. */
  152114. export class HighlightsPostProcess extends PostProcess {
  152115. /**
  152116. * Gets a string identifying the name of the class
  152117. * @returns "HighlightsPostProcess" string
  152118. */
  152119. getClassName(): string;
  152120. /**
  152121. * Extracts highlights from the image
  152122. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152123. * @param name The name of the effect.
  152124. * @param options The required width/height ratio to downsize to before computing the render pass.
  152125. * @param camera The camera to apply the render pass to.
  152126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152127. * @param engine The engine which the post process will be applied. (default: current engine)
  152128. * @param reusable If the post process can be reused on the same frame. (default: false)
  152129. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152130. */
  152131. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152132. }
  152133. }
  152134. declare module BABYLON {
  152135. /**
  152136. * Contains all parameters needed for the prepass to perform
  152137. * motion blur
  152138. */
  152139. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152140. /**
  152141. * Is motion blur enabled
  152142. */
  152143. enabled: boolean;
  152144. /**
  152145. * Name of the configuration
  152146. */
  152147. name: string;
  152148. /**
  152149. * Textures that should be present in the MRT for this effect to work
  152150. */
  152151. readonly texturesRequired: number[];
  152152. }
  152153. }
  152154. declare module BABYLON {
  152155. interface Scene {
  152156. /** @hidden (Backing field) */
  152157. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152158. /**
  152159. * Gets or Sets the current geometry buffer associated to the scene.
  152160. */
  152161. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152162. /**
  152163. * Enables a GeometryBufferRender and associates it with the scene
  152164. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152165. * @returns the GeometryBufferRenderer
  152166. */
  152167. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152168. /**
  152169. * Disables the GeometryBufferRender associated with the scene
  152170. */
  152171. disableGeometryBufferRenderer(): void;
  152172. }
  152173. /**
  152174. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152175. * in several rendering techniques.
  152176. */
  152177. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152178. /**
  152179. * The component name helpful to identify the component in the list of scene components.
  152180. */
  152181. readonly name: string;
  152182. /**
  152183. * The scene the component belongs to.
  152184. */
  152185. scene: Scene;
  152186. /**
  152187. * Creates a new instance of the component for the given scene
  152188. * @param scene Defines the scene to register the component in
  152189. */
  152190. constructor(scene: Scene);
  152191. /**
  152192. * Registers the component in a given scene
  152193. */
  152194. register(): void;
  152195. /**
  152196. * Rebuilds the elements related to this component in case of
  152197. * context lost for instance.
  152198. */
  152199. rebuild(): void;
  152200. /**
  152201. * Disposes the component and the associated ressources
  152202. */
  152203. dispose(): void;
  152204. private _gatherRenderTargets;
  152205. }
  152206. }
  152207. declare module BABYLON {
  152208. /** @hidden */
  152209. export var motionBlurPixelShader: {
  152210. name: string;
  152211. shader: string;
  152212. };
  152213. }
  152214. declare module BABYLON {
  152215. /**
  152216. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152217. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152218. * As an example, all you have to do is to create the post-process:
  152219. * var mb = new BABYLON.MotionBlurPostProcess(
  152220. * 'mb', // The name of the effect.
  152221. * scene, // The scene containing the objects to blur according to their velocity.
  152222. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152223. * camera // The camera to apply the render pass to.
  152224. * );
  152225. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152226. */
  152227. export class MotionBlurPostProcess extends PostProcess {
  152228. /**
  152229. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152230. */
  152231. motionStrength: number;
  152232. /**
  152233. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152234. */
  152235. get motionBlurSamples(): number;
  152236. /**
  152237. * Sets the number of iterations to be used for motion blur quality
  152238. */
  152239. set motionBlurSamples(samples: number);
  152240. private _motionBlurSamples;
  152241. private _forceGeometryBuffer;
  152242. private _geometryBufferRenderer;
  152243. private _prePassRenderer;
  152244. /**
  152245. * Gets a string identifying the name of the class
  152246. * @returns "MotionBlurPostProcess" string
  152247. */
  152248. getClassName(): string;
  152249. /**
  152250. * Creates a new instance MotionBlurPostProcess
  152251. * @param name The name of the effect.
  152252. * @param scene The scene containing the objects to blur according to their velocity.
  152253. * @param options The required width/height ratio to downsize to before computing the render pass.
  152254. * @param camera The camera to apply the render pass to.
  152255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152256. * @param engine The engine which the post process will be applied. (default: current engine)
  152257. * @param reusable If the post process can be reused on the same frame. (default: false)
  152258. * @param textureType Type of textures used when performing the post process. (default: 0)
  152259. * @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)
  152260. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152261. */
  152262. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152263. /**
  152264. * Excludes the given skinned mesh from computing bones velocities.
  152265. * 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.
  152266. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  152267. */
  152268. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152269. /**
  152270. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  152271. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  152272. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  152273. */
  152274. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152275. /**
  152276. * Disposes the post process.
  152277. * @param camera The camera to dispose the post process on.
  152278. */
  152279. dispose(camera?: Camera): void;
  152280. /** @hidden */
  152281. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  152282. }
  152283. }
  152284. declare module BABYLON {
  152285. /** @hidden */
  152286. export var refractionPixelShader: {
  152287. name: string;
  152288. shader: string;
  152289. };
  152290. }
  152291. declare module BABYLON {
  152292. /**
  152293. * Post process which applies a refractin texture
  152294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152295. */
  152296. export class RefractionPostProcess extends PostProcess {
  152297. private _refTexture;
  152298. private _ownRefractionTexture;
  152299. /** the base color of the refraction (used to taint the rendering) */
  152300. color: Color3;
  152301. /** simulated refraction depth */
  152302. depth: number;
  152303. /** the coefficient of the base color (0 to remove base color tainting) */
  152304. colorLevel: number;
  152305. /** Gets the url used to load the refraction texture */
  152306. refractionTextureUrl: string;
  152307. /**
  152308. * Gets or sets the refraction texture
  152309. * Please note that you are responsible for disposing the texture if you set it manually
  152310. */
  152311. get refractionTexture(): Texture;
  152312. set refractionTexture(value: Texture);
  152313. /**
  152314. * Gets a string identifying the name of the class
  152315. * @returns "RefractionPostProcess" string
  152316. */
  152317. getClassName(): string;
  152318. /**
  152319. * Initializes the RefractionPostProcess
  152320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152321. * @param name The name of the effect.
  152322. * @param refractionTextureUrl Url of the refraction texture to use
  152323. * @param color the base color of the refraction (used to taint the rendering)
  152324. * @param depth simulated refraction depth
  152325. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  152326. * @param camera The camera to apply the render pass to.
  152327. * @param options The required width/height ratio to downsize to before computing the render pass.
  152328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152329. * @param engine The engine which the post process will be applied. (default: current engine)
  152330. * @param reusable If the post process can be reused on the same frame. (default: false)
  152331. */
  152332. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152333. /**
  152334. * Disposes of the post process
  152335. * @param camera Camera to dispose post process on
  152336. */
  152337. dispose(camera: Camera): void;
  152338. /** @hidden */
  152339. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  152340. }
  152341. }
  152342. declare module BABYLON {
  152343. /** @hidden */
  152344. export var sharpenPixelShader: {
  152345. name: string;
  152346. shader: string;
  152347. };
  152348. }
  152349. declare module BABYLON {
  152350. /**
  152351. * The SharpenPostProcess applies a sharpen kernel to every pixel
  152352. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152353. */
  152354. export class SharpenPostProcess extends PostProcess {
  152355. /**
  152356. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  152357. */
  152358. colorAmount: number;
  152359. /**
  152360. * How much sharpness should be applied (default: 0.3)
  152361. */
  152362. edgeAmount: number;
  152363. /**
  152364. * Gets a string identifying the name of the class
  152365. * @returns "SharpenPostProcess" string
  152366. */
  152367. getClassName(): string;
  152368. /**
  152369. * Creates a new instance ConvolutionPostProcess
  152370. * @param name The name of the effect.
  152371. * @param options The required width/height ratio to downsize to before computing the render pass.
  152372. * @param camera The camera to apply the render pass to.
  152373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152374. * @param engine The engine which the post process will be applied. (default: current engine)
  152375. * @param reusable If the post process can be reused on the same frame. (default: false)
  152376. * @param textureType Type of textures used when performing the post process. (default: 0)
  152377. * @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)
  152378. */
  152379. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152380. /** @hidden */
  152381. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  152382. }
  152383. }
  152384. declare module BABYLON {
  152385. /**
  152386. * PostProcessRenderPipeline
  152387. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152388. */
  152389. export class PostProcessRenderPipeline {
  152390. private engine;
  152391. private _renderEffects;
  152392. private _renderEffectsForIsolatedPass;
  152393. /**
  152394. * List of inspectable custom properties (used by the Inspector)
  152395. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  152396. */
  152397. inspectableCustomProperties: IInspectable[];
  152398. /**
  152399. * @hidden
  152400. */
  152401. protected _cameras: Camera[];
  152402. /** @hidden */
  152403. _name: string;
  152404. /**
  152405. * Gets pipeline name
  152406. */
  152407. get name(): string;
  152408. /** Gets the list of attached cameras */
  152409. get cameras(): Camera[];
  152410. /**
  152411. * Initializes a PostProcessRenderPipeline
  152412. * @param engine engine to add the pipeline to
  152413. * @param name name of the pipeline
  152414. */
  152415. constructor(engine: Engine, name: string);
  152416. /**
  152417. * Gets the class name
  152418. * @returns "PostProcessRenderPipeline"
  152419. */
  152420. getClassName(): string;
  152421. /**
  152422. * If all the render effects in the pipeline are supported
  152423. */
  152424. get isSupported(): boolean;
  152425. /**
  152426. * Adds an effect to the pipeline
  152427. * @param renderEffect the effect to add
  152428. */
  152429. addEffect(renderEffect: PostProcessRenderEffect): void;
  152430. /** @hidden */
  152431. _rebuild(): void;
  152432. /** @hidden */
  152433. _enableEffect(renderEffectName: string, cameras: Camera): void;
  152434. /** @hidden */
  152435. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  152436. /** @hidden */
  152437. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152438. /** @hidden */
  152439. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152440. /** @hidden */
  152441. _attachCameras(cameras: Camera, unique: boolean): void;
  152442. /** @hidden */
  152443. _attachCameras(cameras: Camera[], unique: boolean): void;
  152444. /** @hidden */
  152445. _detachCameras(cameras: Camera): void;
  152446. /** @hidden */
  152447. _detachCameras(cameras: Nullable<Camera[]>): void;
  152448. /** @hidden */
  152449. _update(): void;
  152450. /** @hidden */
  152451. _reset(): void;
  152452. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  152453. /**
  152454. * Sets the required values to the prepass renderer.
  152455. * @param prePassRenderer defines the prepass renderer to setup.
  152456. * @returns true if the pre pass is needed.
  152457. */
  152458. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  152459. /**
  152460. * Disposes of the pipeline
  152461. */
  152462. dispose(): void;
  152463. }
  152464. }
  152465. declare module BABYLON {
  152466. /**
  152467. * PostProcessRenderPipelineManager class
  152468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152469. */
  152470. export class PostProcessRenderPipelineManager {
  152471. private _renderPipelines;
  152472. /**
  152473. * Initializes a PostProcessRenderPipelineManager
  152474. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152475. */
  152476. constructor();
  152477. /**
  152478. * Gets the list of supported render pipelines
  152479. */
  152480. get supportedPipelines(): PostProcessRenderPipeline[];
  152481. /**
  152482. * Adds a pipeline to the manager
  152483. * @param renderPipeline The pipeline to add
  152484. */
  152485. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  152486. /**
  152487. * Attaches a camera to the pipeline
  152488. * @param renderPipelineName The name of the pipeline to attach to
  152489. * @param cameras the camera to attach
  152490. * @param unique if the camera can be attached multiple times to the pipeline
  152491. */
  152492. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  152493. /**
  152494. * Detaches a camera from the pipeline
  152495. * @param renderPipelineName The name of the pipeline to detach from
  152496. * @param cameras the camera to detach
  152497. */
  152498. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  152499. /**
  152500. * Enables an effect by name on a pipeline
  152501. * @param renderPipelineName the name of the pipeline to enable the effect in
  152502. * @param renderEffectName the name of the effect to enable
  152503. * @param cameras the cameras that the effect should be enabled on
  152504. */
  152505. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152506. /**
  152507. * Disables an effect by name on a pipeline
  152508. * @param renderPipelineName the name of the pipeline to disable the effect in
  152509. * @param renderEffectName the name of the effect to disable
  152510. * @param cameras the cameras that the effect should be disabled on
  152511. */
  152512. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152513. /**
  152514. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  152515. */
  152516. update(): void;
  152517. /** @hidden */
  152518. _rebuild(): void;
  152519. /**
  152520. * Disposes of the manager and pipelines
  152521. */
  152522. dispose(): void;
  152523. }
  152524. }
  152525. declare module BABYLON {
  152526. interface Scene {
  152527. /** @hidden (Backing field) */
  152528. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152529. /**
  152530. * Gets the postprocess render pipeline manager
  152531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152532. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152533. */
  152534. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152535. }
  152536. /**
  152537. * Defines the Render Pipeline scene component responsible to rendering pipelines
  152538. */
  152539. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  152540. /**
  152541. * The component name helpfull to identify the component in the list of scene components.
  152542. */
  152543. readonly name: string;
  152544. /**
  152545. * The scene the component belongs to.
  152546. */
  152547. scene: Scene;
  152548. /**
  152549. * Creates a new instance of the component for the given scene
  152550. * @param scene Defines the scene to register the component in
  152551. */
  152552. constructor(scene: Scene);
  152553. /**
  152554. * Registers the component in a given scene
  152555. */
  152556. register(): void;
  152557. /**
  152558. * Rebuilds the elements related to this component in case of
  152559. * context lost for instance.
  152560. */
  152561. rebuild(): void;
  152562. /**
  152563. * Disposes the component and the associated ressources
  152564. */
  152565. dispose(): void;
  152566. private _gatherRenderTargets;
  152567. }
  152568. }
  152569. declare module BABYLON {
  152570. /**
  152571. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  152572. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152573. */
  152574. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152575. private _scene;
  152576. private _camerasToBeAttached;
  152577. /**
  152578. * ID of the sharpen post process,
  152579. */
  152580. private readonly SharpenPostProcessId;
  152581. /**
  152582. * @ignore
  152583. * ID of the image processing post process;
  152584. */
  152585. readonly ImageProcessingPostProcessId: string;
  152586. /**
  152587. * @ignore
  152588. * ID of the Fast Approximate Anti-Aliasing post process;
  152589. */
  152590. readonly FxaaPostProcessId: string;
  152591. /**
  152592. * ID of the chromatic aberration post process,
  152593. */
  152594. private readonly ChromaticAberrationPostProcessId;
  152595. /**
  152596. * ID of the grain post process
  152597. */
  152598. private readonly GrainPostProcessId;
  152599. /**
  152600. * Sharpen post process which will apply a sharpen convolution to enhance edges
  152601. */
  152602. sharpen: SharpenPostProcess;
  152603. private _sharpenEffect;
  152604. private bloom;
  152605. /**
  152606. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  152607. */
  152608. depthOfField: DepthOfFieldEffect;
  152609. /**
  152610. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152611. */
  152612. fxaa: FxaaPostProcess;
  152613. /**
  152614. * Image post processing pass used to perform operations such as tone mapping or color grading.
  152615. */
  152616. imageProcessing: ImageProcessingPostProcess;
  152617. /**
  152618. * Chromatic aberration post process which will shift rgb colors in the image
  152619. */
  152620. chromaticAberration: ChromaticAberrationPostProcess;
  152621. private _chromaticAberrationEffect;
  152622. /**
  152623. * Grain post process which add noise to the image
  152624. */
  152625. grain: GrainPostProcess;
  152626. private _grainEffect;
  152627. /**
  152628. * Glow post process which adds a glow to emissive areas of the image
  152629. */
  152630. private _glowLayer;
  152631. /**
  152632. * Animations which can be used to tweak settings over a period of time
  152633. */
  152634. animations: Animation[];
  152635. private _imageProcessingConfigurationObserver;
  152636. private _sharpenEnabled;
  152637. private _bloomEnabled;
  152638. private _depthOfFieldEnabled;
  152639. private _depthOfFieldBlurLevel;
  152640. private _fxaaEnabled;
  152641. private _imageProcessingEnabled;
  152642. private _defaultPipelineTextureType;
  152643. private _bloomScale;
  152644. private _chromaticAberrationEnabled;
  152645. private _grainEnabled;
  152646. private _buildAllowed;
  152647. /**
  152648. * This is triggered each time the pipeline has been built.
  152649. */
  152650. onBuildObservable: Observable<DefaultRenderingPipeline>;
  152651. /**
  152652. * Gets active scene
  152653. */
  152654. get scene(): Scene;
  152655. /**
  152656. * Enable or disable the sharpen process from the pipeline
  152657. */
  152658. set sharpenEnabled(enabled: boolean);
  152659. get sharpenEnabled(): boolean;
  152660. private _resizeObserver;
  152661. private _hardwareScaleLevel;
  152662. private _bloomKernel;
  152663. /**
  152664. * Specifies the size of the bloom blur kernel, relative to the final output size
  152665. */
  152666. get bloomKernel(): number;
  152667. set bloomKernel(value: number);
  152668. /**
  152669. * Specifies the weight of the bloom in the final rendering
  152670. */
  152671. private _bloomWeight;
  152672. /**
  152673. * Specifies the luma threshold for the area that will be blurred by the bloom
  152674. */
  152675. private _bloomThreshold;
  152676. private _hdr;
  152677. /**
  152678. * The strength of the bloom.
  152679. */
  152680. set bloomWeight(value: number);
  152681. get bloomWeight(): number;
  152682. /**
  152683. * The strength of the bloom.
  152684. */
  152685. set bloomThreshold(value: number);
  152686. get bloomThreshold(): number;
  152687. /**
  152688. * The scale of the bloom, lower value will provide better performance.
  152689. */
  152690. set bloomScale(value: number);
  152691. get bloomScale(): number;
  152692. /**
  152693. * Enable or disable the bloom from the pipeline
  152694. */
  152695. set bloomEnabled(enabled: boolean);
  152696. get bloomEnabled(): boolean;
  152697. private _rebuildBloom;
  152698. /**
  152699. * If the depth of field is enabled.
  152700. */
  152701. get depthOfFieldEnabled(): boolean;
  152702. set depthOfFieldEnabled(enabled: boolean);
  152703. /**
  152704. * Blur level of the depth of field effect. (Higher blur will effect performance)
  152705. */
  152706. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  152707. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  152708. /**
  152709. * If the anti aliasing is enabled.
  152710. */
  152711. set fxaaEnabled(enabled: boolean);
  152712. get fxaaEnabled(): boolean;
  152713. private _samples;
  152714. /**
  152715. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152716. */
  152717. set samples(sampleCount: number);
  152718. get samples(): number;
  152719. /**
  152720. * If image processing is enabled.
  152721. */
  152722. set imageProcessingEnabled(enabled: boolean);
  152723. get imageProcessingEnabled(): boolean;
  152724. /**
  152725. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  152726. */
  152727. set glowLayerEnabled(enabled: boolean);
  152728. get glowLayerEnabled(): boolean;
  152729. /**
  152730. * Gets the glow layer (or null if not defined)
  152731. */
  152732. get glowLayer(): Nullable<GlowLayer>;
  152733. /**
  152734. * Enable or disable the chromaticAberration process from the pipeline
  152735. */
  152736. set chromaticAberrationEnabled(enabled: boolean);
  152737. get chromaticAberrationEnabled(): boolean;
  152738. /**
  152739. * Enable or disable the grain process from the pipeline
  152740. */
  152741. set grainEnabled(enabled: boolean);
  152742. get grainEnabled(): boolean;
  152743. /**
  152744. * @constructor
  152745. * @param name - The rendering pipeline name (default: "")
  152746. * @param hdr - If high dynamic range textures should be used (default: true)
  152747. * @param scene - The scene linked to this pipeline (default: the last created scene)
  152748. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  152749. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  152750. */
  152751. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  152752. /**
  152753. * Get the class name
  152754. * @returns "DefaultRenderingPipeline"
  152755. */
  152756. getClassName(): string;
  152757. /**
  152758. * Force the compilation of the entire pipeline.
  152759. */
  152760. prepare(): void;
  152761. private _hasCleared;
  152762. private _prevPostProcess;
  152763. private _prevPrevPostProcess;
  152764. private _setAutoClearAndTextureSharing;
  152765. private _depthOfFieldSceneObserver;
  152766. private _buildPipeline;
  152767. private _disposePostProcesses;
  152768. /**
  152769. * Adds a camera to the pipeline
  152770. * @param camera the camera to be added
  152771. */
  152772. addCamera(camera: Camera): void;
  152773. /**
  152774. * Removes a camera from the pipeline
  152775. * @param camera the camera to remove
  152776. */
  152777. removeCamera(camera: Camera): void;
  152778. /**
  152779. * Dispose of the pipeline and stop all post processes
  152780. */
  152781. dispose(): void;
  152782. /**
  152783. * Serialize the rendering pipeline (Used when exporting)
  152784. * @returns the serialized object
  152785. */
  152786. serialize(): any;
  152787. /**
  152788. * Parse the serialized pipeline
  152789. * @param source Source pipeline.
  152790. * @param scene The scene to load the pipeline to.
  152791. * @param rootUrl The URL of the serialized pipeline.
  152792. * @returns An instantiated pipeline from the serialized object.
  152793. */
  152794. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  152795. }
  152796. }
  152797. declare module BABYLON {
  152798. /** @hidden */
  152799. export var lensHighlightsPixelShader: {
  152800. name: string;
  152801. shader: string;
  152802. };
  152803. }
  152804. declare module BABYLON {
  152805. /** @hidden */
  152806. export var depthOfFieldPixelShader: {
  152807. name: string;
  152808. shader: string;
  152809. };
  152810. }
  152811. declare module BABYLON {
  152812. /**
  152813. * BABYLON.JS Chromatic Aberration GLSL Shader
  152814. * Author: Olivier Guyot
  152815. * Separates very slightly R, G and B colors on the edges of the screen
  152816. * Inspired by Francois Tarlier & Martins Upitis
  152817. */
  152818. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  152819. /**
  152820. * @ignore
  152821. * The chromatic aberration PostProcess id in the pipeline
  152822. */
  152823. LensChromaticAberrationEffect: string;
  152824. /**
  152825. * @ignore
  152826. * The highlights enhancing PostProcess id in the pipeline
  152827. */
  152828. HighlightsEnhancingEffect: string;
  152829. /**
  152830. * @ignore
  152831. * The depth-of-field PostProcess id in the pipeline
  152832. */
  152833. LensDepthOfFieldEffect: string;
  152834. private _scene;
  152835. private _depthTexture;
  152836. private _grainTexture;
  152837. private _chromaticAberrationPostProcess;
  152838. private _highlightsPostProcess;
  152839. private _depthOfFieldPostProcess;
  152840. private _edgeBlur;
  152841. private _grainAmount;
  152842. private _chromaticAberration;
  152843. private _distortion;
  152844. private _highlightsGain;
  152845. private _highlightsThreshold;
  152846. private _dofDistance;
  152847. private _dofAperture;
  152848. private _dofDarken;
  152849. private _dofPentagon;
  152850. private _blurNoise;
  152851. /**
  152852. * @constructor
  152853. *
  152854. * Effect parameters are as follow:
  152855. * {
  152856. * chromatic_aberration: number; // from 0 to x (1 for realism)
  152857. * edge_blur: number; // from 0 to x (1 for realism)
  152858. * distortion: number; // from 0 to x (1 for realism)
  152859. * grain_amount: number; // from 0 to 1
  152860. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  152861. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  152862. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  152863. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  152864. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  152865. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  152866. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  152867. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  152868. * }
  152869. * Note: if an effect parameter is unset, effect is disabled
  152870. *
  152871. * @param name The rendering pipeline name
  152872. * @param parameters - An object containing all parameters (see above)
  152873. * @param scene The scene linked to this pipeline
  152874. * @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)
  152875. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152876. */
  152877. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  152878. /**
  152879. * Get the class name
  152880. * @returns "LensRenderingPipeline"
  152881. */
  152882. getClassName(): string;
  152883. /**
  152884. * Gets associated scene
  152885. */
  152886. get scene(): Scene;
  152887. /**
  152888. * Gets or sets the edge blur
  152889. */
  152890. get edgeBlur(): number;
  152891. set edgeBlur(value: number);
  152892. /**
  152893. * Gets or sets the grain amount
  152894. */
  152895. get grainAmount(): number;
  152896. set grainAmount(value: number);
  152897. /**
  152898. * Gets or sets the chromatic aberration amount
  152899. */
  152900. get chromaticAberration(): number;
  152901. set chromaticAberration(value: number);
  152902. /**
  152903. * Gets or sets the depth of field aperture
  152904. */
  152905. get dofAperture(): number;
  152906. set dofAperture(value: number);
  152907. /**
  152908. * Gets or sets the edge distortion
  152909. */
  152910. get edgeDistortion(): number;
  152911. set edgeDistortion(value: number);
  152912. /**
  152913. * Gets or sets the depth of field distortion
  152914. */
  152915. get dofDistortion(): number;
  152916. set dofDistortion(value: number);
  152917. /**
  152918. * Gets or sets the darken out of focus amount
  152919. */
  152920. get darkenOutOfFocus(): number;
  152921. set darkenOutOfFocus(value: number);
  152922. /**
  152923. * Gets or sets a boolean indicating if blur noise is enabled
  152924. */
  152925. get blurNoise(): boolean;
  152926. set blurNoise(value: boolean);
  152927. /**
  152928. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152929. */
  152930. get pentagonBokeh(): boolean;
  152931. set pentagonBokeh(value: boolean);
  152932. /**
  152933. * Gets or sets the highlight grain amount
  152934. */
  152935. get highlightsGain(): number;
  152936. set highlightsGain(value: number);
  152937. /**
  152938. * Gets or sets the highlight threshold
  152939. */
  152940. get highlightsThreshold(): number;
  152941. set highlightsThreshold(value: number);
  152942. /**
  152943. * Sets the amount of blur at the edges
  152944. * @param amount blur amount
  152945. */
  152946. setEdgeBlur(amount: number): void;
  152947. /**
  152948. * Sets edge blur to 0
  152949. */
  152950. disableEdgeBlur(): void;
  152951. /**
  152952. * Sets the amout of grain
  152953. * @param amount Amount of grain
  152954. */
  152955. setGrainAmount(amount: number): void;
  152956. /**
  152957. * Set grain amount to 0
  152958. */
  152959. disableGrain(): void;
  152960. /**
  152961. * Sets the chromatic aberration amount
  152962. * @param amount amount of chromatic aberration
  152963. */
  152964. setChromaticAberration(amount: number): void;
  152965. /**
  152966. * Sets chromatic aberration amount to 0
  152967. */
  152968. disableChromaticAberration(): void;
  152969. /**
  152970. * Sets the EdgeDistortion amount
  152971. * @param amount amount of EdgeDistortion
  152972. */
  152973. setEdgeDistortion(amount: number): void;
  152974. /**
  152975. * Sets edge distortion to 0
  152976. */
  152977. disableEdgeDistortion(): void;
  152978. /**
  152979. * Sets the FocusDistance amount
  152980. * @param amount amount of FocusDistance
  152981. */
  152982. setFocusDistance(amount: number): void;
  152983. /**
  152984. * Disables depth of field
  152985. */
  152986. disableDepthOfField(): void;
  152987. /**
  152988. * Sets the Aperture amount
  152989. * @param amount amount of Aperture
  152990. */
  152991. setAperture(amount: number): void;
  152992. /**
  152993. * Sets the DarkenOutOfFocus amount
  152994. * @param amount amount of DarkenOutOfFocus
  152995. */
  152996. setDarkenOutOfFocus(amount: number): void;
  152997. private _pentagonBokehIsEnabled;
  152998. /**
  152999. * Creates a pentagon bokeh effect
  153000. */
  153001. enablePentagonBokeh(): void;
  153002. /**
  153003. * Disables the pentagon bokeh effect
  153004. */
  153005. disablePentagonBokeh(): void;
  153006. /**
  153007. * Enables noise blur
  153008. */
  153009. enableNoiseBlur(): void;
  153010. /**
  153011. * Disables noise blur
  153012. */
  153013. disableNoiseBlur(): void;
  153014. /**
  153015. * Sets the HighlightsGain amount
  153016. * @param amount amount of HighlightsGain
  153017. */
  153018. setHighlightsGain(amount: number): void;
  153019. /**
  153020. * Sets the HighlightsThreshold amount
  153021. * @param amount amount of HighlightsThreshold
  153022. */
  153023. setHighlightsThreshold(amount: number): void;
  153024. /**
  153025. * Disables highlights
  153026. */
  153027. disableHighlights(): void;
  153028. /**
  153029. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153030. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153031. */
  153032. dispose(disableDepthRender?: boolean): void;
  153033. private _createChromaticAberrationPostProcess;
  153034. private _createHighlightsPostProcess;
  153035. private _createDepthOfFieldPostProcess;
  153036. private _createGrainTexture;
  153037. }
  153038. }
  153039. declare module BABYLON {
  153040. /**
  153041. * Contains all parameters needed for the prepass to perform
  153042. * screen space subsurface scattering
  153043. */
  153044. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153045. /**
  153046. * Is subsurface enabled
  153047. */
  153048. enabled: boolean;
  153049. /**
  153050. * Name of the configuration
  153051. */
  153052. name: string;
  153053. /**
  153054. * Textures that should be present in the MRT for this effect to work
  153055. */
  153056. readonly texturesRequired: number[];
  153057. }
  153058. }
  153059. declare module BABYLON {
  153060. /** @hidden */
  153061. export var ssao2PixelShader: {
  153062. name: string;
  153063. shader: string;
  153064. };
  153065. }
  153066. declare module BABYLON {
  153067. /** @hidden */
  153068. export var ssaoCombinePixelShader: {
  153069. name: string;
  153070. shader: string;
  153071. };
  153072. }
  153073. declare module BABYLON {
  153074. /**
  153075. * Render pipeline to produce ssao effect
  153076. */
  153077. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153078. /**
  153079. * @ignore
  153080. * The PassPostProcess id in the pipeline that contains the original scene color
  153081. */
  153082. SSAOOriginalSceneColorEffect: string;
  153083. /**
  153084. * @ignore
  153085. * The SSAO PostProcess id in the pipeline
  153086. */
  153087. SSAORenderEffect: string;
  153088. /**
  153089. * @ignore
  153090. * The horizontal blur PostProcess id in the pipeline
  153091. */
  153092. SSAOBlurHRenderEffect: string;
  153093. /**
  153094. * @ignore
  153095. * The vertical blur PostProcess id in the pipeline
  153096. */
  153097. SSAOBlurVRenderEffect: string;
  153098. /**
  153099. * @ignore
  153100. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153101. */
  153102. SSAOCombineRenderEffect: string;
  153103. /**
  153104. * The output strength of the SSAO post-process. Default value is 1.0.
  153105. */
  153106. totalStrength: number;
  153107. /**
  153108. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153109. */
  153110. maxZ: number;
  153111. /**
  153112. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153113. */
  153114. minZAspect: number;
  153115. private _samples;
  153116. /**
  153117. * Number of samples used for the SSAO calculations. Default value is 8
  153118. */
  153119. set samples(n: number);
  153120. get samples(): number;
  153121. private _textureSamples;
  153122. /**
  153123. * Number of samples to use for antialiasing
  153124. */
  153125. set textureSamples(n: number);
  153126. get textureSamples(): number;
  153127. /**
  153128. * Force rendering the geometry through geometry buffer
  153129. */
  153130. private _forceGeometryBuffer;
  153131. /**
  153132. * Ratio object used for SSAO ratio and blur ratio
  153133. */
  153134. private _ratio;
  153135. /**
  153136. * Dynamically generated sphere sampler.
  153137. */
  153138. private _sampleSphere;
  153139. /**
  153140. * Blur filter offsets
  153141. */
  153142. private _samplerOffsets;
  153143. private _expensiveBlur;
  153144. /**
  153145. * If bilateral blur should be used
  153146. */
  153147. set expensiveBlur(b: boolean);
  153148. get expensiveBlur(): boolean;
  153149. /**
  153150. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153151. */
  153152. radius: number;
  153153. /**
  153154. * The base color of the SSAO post-process
  153155. * The final result is "base + ssao" between [0, 1]
  153156. */
  153157. base: number;
  153158. /**
  153159. * Support test.
  153160. */
  153161. static get IsSupported(): boolean;
  153162. private _scene;
  153163. private _randomTexture;
  153164. private _originalColorPostProcess;
  153165. private _ssaoPostProcess;
  153166. private _blurHPostProcess;
  153167. private _blurVPostProcess;
  153168. private _ssaoCombinePostProcess;
  153169. private _prePassRenderer;
  153170. /**
  153171. * Gets active scene
  153172. */
  153173. get scene(): Scene;
  153174. /**
  153175. * @constructor
  153176. * @param name The rendering pipeline name
  153177. * @param scene The scene linked to this pipeline
  153178. * @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 }
  153179. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153180. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153181. */
  153182. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153183. /**
  153184. * Get the class name
  153185. * @returns "SSAO2RenderingPipeline"
  153186. */
  153187. getClassName(): string;
  153188. /**
  153189. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153190. */
  153191. dispose(disableGeometryBufferRenderer?: boolean): void;
  153192. private _createBlurPostProcess;
  153193. /** @hidden */
  153194. _rebuild(): void;
  153195. private _bits;
  153196. private _radicalInverse_VdC;
  153197. private _hammersley;
  153198. private _hemisphereSample_uniform;
  153199. private _generateHemisphere;
  153200. private _getDefinesForSSAO;
  153201. private _createSSAOPostProcess;
  153202. private _createSSAOCombinePostProcess;
  153203. private _createRandomTexture;
  153204. /**
  153205. * Serialize the rendering pipeline (Used when exporting)
  153206. * @returns the serialized object
  153207. */
  153208. serialize(): any;
  153209. /**
  153210. * Parse the serialized pipeline
  153211. * @param source Source pipeline.
  153212. * @param scene The scene to load the pipeline to.
  153213. * @param rootUrl The URL of the serialized pipeline.
  153214. * @returns An instantiated pipeline from the serialized object.
  153215. */
  153216. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153217. }
  153218. }
  153219. declare module BABYLON {
  153220. /** @hidden */
  153221. export var ssaoPixelShader: {
  153222. name: string;
  153223. shader: string;
  153224. };
  153225. }
  153226. declare module BABYLON {
  153227. /**
  153228. * Render pipeline to produce ssao effect
  153229. */
  153230. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  153231. /**
  153232. * @ignore
  153233. * The PassPostProcess id in the pipeline that contains the original scene color
  153234. */
  153235. SSAOOriginalSceneColorEffect: string;
  153236. /**
  153237. * @ignore
  153238. * The SSAO PostProcess id in the pipeline
  153239. */
  153240. SSAORenderEffect: string;
  153241. /**
  153242. * @ignore
  153243. * The horizontal blur PostProcess id in the pipeline
  153244. */
  153245. SSAOBlurHRenderEffect: string;
  153246. /**
  153247. * @ignore
  153248. * The vertical blur PostProcess id in the pipeline
  153249. */
  153250. SSAOBlurVRenderEffect: string;
  153251. /**
  153252. * @ignore
  153253. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153254. */
  153255. SSAOCombineRenderEffect: string;
  153256. /**
  153257. * The output strength of the SSAO post-process. Default value is 1.0.
  153258. */
  153259. totalStrength: number;
  153260. /**
  153261. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  153262. */
  153263. radius: number;
  153264. /**
  153265. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  153266. * Must not be equal to fallOff and superior to fallOff.
  153267. * Default value is 0.0075
  153268. */
  153269. area: number;
  153270. /**
  153271. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  153272. * Must not be equal to area and inferior to area.
  153273. * Default value is 0.000001
  153274. */
  153275. fallOff: number;
  153276. /**
  153277. * The base color of the SSAO post-process
  153278. * The final result is "base + ssao" between [0, 1]
  153279. */
  153280. base: number;
  153281. private _scene;
  153282. private _depthTexture;
  153283. private _randomTexture;
  153284. private _originalColorPostProcess;
  153285. private _ssaoPostProcess;
  153286. private _blurHPostProcess;
  153287. private _blurVPostProcess;
  153288. private _ssaoCombinePostProcess;
  153289. private _firstUpdate;
  153290. /**
  153291. * Gets active scene
  153292. */
  153293. get scene(): Scene;
  153294. /**
  153295. * @constructor
  153296. * @param name - The rendering pipeline name
  153297. * @param scene - The scene linked to this pipeline
  153298. * @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 }
  153299. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  153300. */
  153301. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  153302. /**
  153303. * Get the class name
  153304. * @returns "SSAORenderingPipeline"
  153305. */
  153306. getClassName(): string;
  153307. /**
  153308. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153309. */
  153310. dispose(disableDepthRender?: boolean): void;
  153311. private _createBlurPostProcess;
  153312. /** @hidden */
  153313. _rebuild(): void;
  153314. private _createSSAOPostProcess;
  153315. private _createSSAOCombinePostProcess;
  153316. private _createRandomTexture;
  153317. }
  153318. }
  153319. declare module BABYLON {
  153320. /**
  153321. * Contains all parameters needed for the prepass to perform
  153322. * screen space reflections
  153323. */
  153324. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  153325. /**
  153326. * Is ssr enabled
  153327. */
  153328. enabled: boolean;
  153329. /**
  153330. * Name of the configuration
  153331. */
  153332. name: string;
  153333. /**
  153334. * Textures that should be present in the MRT for this effect to work
  153335. */
  153336. readonly texturesRequired: number[];
  153337. }
  153338. }
  153339. declare module BABYLON {
  153340. /** @hidden */
  153341. export var screenSpaceReflectionPixelShader: {
  153342. name: string;
  153343. shader: string;
  153344. };
  153345. }
  153346. declare module BABYLON {
  153347. /**
  153348. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  153349. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  153350. */
  153351. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  153352. /**
  153353. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  153354. */
  153355. threshold: number;
  153356. /**
  153357. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  153358. */
  153359. strength: number;
  153360. /**
  153361. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  153362. */
  153363. reflectionSpecularFalloffExponent: number;
  153364. /**
  153365. * 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]
  153366. */
  153367. step: number;
  153368. /**
  153369. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  153370. */
  153371. roughnessFactor: number;
  153372. private _forceGeometryBuffer;
  153373. private _geometryBufferRenderer;
  153374. private _prePassRenderer;
  153375. private _enableSmoothReflections;
  153376. private _reflectionSamples;
  153377. private _smoothSteps;
  153378. /**
  153379. * Gets a string identifying the name of the class
  153380. * @returns "ScreenSpaceReflectionPostProcess" string
  153381. */
  153382. getClassName(): string;
  153383. /**
  153384. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  153385. * @param name The name of the effect.
  153386. * @param scene The scene containing the objects to calculate reflections.
  153387. * @param options The required width/height ratio to downsize to before computing the render pass.
  153388. * @param camera The camera to apply the render pass to.
  153389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153390. * @param engine The engine which the post process will be applied. (default: current engine)
  153391. * @param reusable If the post process can be reused on the same frame. (default: false)
  153392. * @param textureType Type of textures used when performing the post process. (default: 0)
  153393. * @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)
  153394. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153395. */
  153396. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153397. /**
  153398. * Gets wether or not smoothing reflections is enabled.
  153399. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153400. */
  153401. get enableSmoothReflections(): boolean;
  153402. /**
  153403. * Sets wether or not smoothing reflections is enabled.
  153404. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153405. */
  153406. set enableSmoothReflections(enabled: boolean);
  153407. /**
  153408. * Gets the number of samples taken while computing reflections. More samples count is high,
  153409. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153410. */
  153411. get reflectionSamples(): number;
  153412. /**
  153413. * Sets the number of samples taken while computing reflections. More samples count is high,
  153414. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153415. */
  153416. set reflectionSamples(samples: number);
  153417. /**
  153418. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  153419. * more the post-process will require GPU power and can generate a drop in FPS.
  153420. * Default value (5.0) work pretty well in all cases but can be adjusted.
  153421. */
  153422. get smoothSteps(): number;
  153423. set smoothSteps(steps: number);
  153424. private _updateEffectDefines;
  153425. /** @hidden */
  153426. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  153427. }
  153428. }
  153429. declare module BABYLON {
  153430. /** @hidden */
  153431. export var standardPixelShader: {
  153432. name: string;
  153433. shader: string;
  153434. };
  153435. }
  153436. declare module BABYLON {
  153437. /**
  153438. * Standard rendering pipeline
  153439. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153440. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  153441. */
  153442. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153443. /**
  153444. * Public members
  153445. */
  153446. /**
  153447. * Post-process which contains the original scene color before the pipeline applies all the effects
  153448. */
  153449. originalPostProcess: Nullable<PostProcess>;
  153450. /**
  153451. * Post-process used to down scale an image x4
  153452. */
  153453. downSampleX4PostProcess: Nullable<PostProcess>;
  153454. /**
  153455. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  153456. */
  153457. brightPassPostProcess: Nullable<PostProcess>;
  153458. /**
  153459. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  153460. */
  153461. blurHPostProcesses: PostProcess[];
  153462. /**
  153463. * Post-process array storing all the vertical blur post-processes used by the pipeline
  153464. */
  153465. blurVPostProcesses: PostProcess[];
  153466. /**
  153467. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  153468. */
  153469. textureAdderPostProcess: Nullable<PostProcess>;
  153470. /**
  153471. * Post-process used to create volumetric lighting effect
  153472. */
  153473. volumetricLightPostProcess: Nullable<PostProcess>;
  153474. /**
  153475. * Post-process used to smooth the previous volumetric light post-process on the X axis
  153476. */
  153477. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  153478. /**
  153479. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  153480. */
  153481. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  153482. /**
  153483. * Post-process used to merge the volumetric light effect and the real scene color
  153484. */
  153485. volumetricLightMergePostProces: Nullable<PostProcess>;
  153486. /**
  153487. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  153488. */
  153489. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  153490. /**
  153491. * Base post-process used to calculate the average luminance of the final image for HDR
  153492. */
  153493. luminancePostProcess: Nullable<PostProcess>;
  153494. /**
  153495. * Post-processes used to create down sample post-processes in order to get
  153496. * the average luminance of the final image for HDR
  153497. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  153498. */
  153499. luminanceDownSamplePostProcesses: PostProcess[];
  153500. /**
  153501. * Post-process used to create a HDR effect (light adaptation)
  153502. */
  153503. hdrPostProcess: Nullable<PostProcess>;
  153504. /**
  153505. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  153506. */
  153507. textureAdderFinalPostProcess: Nullable<PostProcess>;
  153508. /**
  153509. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  153510. */
  153511. lensFlareFinalPostProcess: Nullable<PostProcess>;
  153512. /**
  153513. * Post-process used to merge the final HDR post-process and the real scene color
  153514. */
  153515. hdrFinalPostProcess: Nullable<PostProcess>;
  153516. /**
  153517. * Post-process used to create a lens flare effect
  153518. */
  153519. lensFlarePostProcess: Nullable<PostProcess>;
  153520. /**
  153521. * Post-process that merges the result of the lens flare post-process and the real scene color
  153522. */
  153523. lensFlareComposePostProcess: Nullable<PostProcess>;
  153524. /**
  153525. * Post-process used to create a motion blur effect
  153526. */
  153527. motionBlurPostProcess: Nullable<PostProcess>;
  153528. /**
  153529. * Post-process used to create a depth of field effect
  153530. */
  153531. depthOfFieldPostProcess: Nullable<PostProcess>;
  153532. /**
  153533. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153534. */
  153535. fxaaPostProcess: Nullable<FxaaPostProcess>;
  153536. /**
  153537. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  153538. */
  153539. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  153540. /**
  153541. * Represents the brightness threshold in order to configure the illuminated surfaces
  153542. */
  153543. brightThreshold: number;
  153544. /**
  153545. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  153546. */
  153547. blurWidth: number;
  153548. /**
  153549. * Sets if the blur for highlighted surfaces must be only horizontal
  153550. */
  153551. horizontalBlur: boolean;
  153552. /**
  153553. * Gets the overall exposure used by the pipeline
  153554. */
  153555. get exposure(): number;
  153556. /**
  153557. * Sets the overall exposure used by the pipeline
  153558. */
  153559. set exposure(value: number);
  153560. /**
  153561. * Texture used typically to simulate "dirty" on camera lens
  153562. */
  153563. lensTexture: Nullable<Texture>;
  153564. /**
  153565. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  153566. */
  153567. volumetricLightCoefficient: number;
  153568. /**
  153569. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  153570. */
  153571. volumetricLightPower: number;
  153572. /**
  153573. * Used the set the blur intensity to smooth the volumetric lights
  153574. */
  153575. volumetricLightBlurScale: number;
  153576. /**
  153577. * Light (spot or directional) used to generate the volumetric lights rays
  153578. * The source light must have a shadow generate so the pipeline can get its
  153579. * depth map
  153580. */
  153581. sourceLight: Nullable<SpotLight | DirectionalLight>;
  153582. /**
  153583. * For eye adaptation, represents the minimum luminance the eye can see
  153584. */
  153585. hdrMinimumLuminance: number;
  153586. /**
  153587. * For eye adaptation, represents the decrease luminance speed
  153588. */
  153589. hdrDecreaseRate: number;
  153590. /**
  153591. * For eye adaptation, represents the increase luminance speed
  153592. */
  153593. hdrIncreaseRate: number;
  153594. /**
  153595. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153596. */
  153597. get hdrAutoExposure(): boolean;
  153598. /**
  153599. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153600. */
  153601. set hdrAutoExposure(value: boolean);
  153602. /**
  153603. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  153604. */
  153605. lensColorTexture: Nullable<Texture>;
  153606. /**
  153607. * The overall strengh for the lens flare effect
  153608. */
  153609. lensFlareStrength: number;
  153610. /**
  153611. * Dispersion coefficient for lens flare ghosts
  153612. */
  153613. lensFlareGhostDispersal: number;
  153614. /**
  153615. * Main lens flare halo width
  153616. */
  153617. lensFlareHaloWidth: number;
  153618. /**
  153619. * Based on the lens distortion effect, defines how much the lens flare result
  153620. * is distorted
  153621. */
  153622. lensFlareDistortionStrength: number;
  153623. /**
  153624. * Configures the blur intensity used for for lens flare (halo)
  153625. */
  153626. lensFlareBlurWidth: number;
  153627. /**
  153628. * Lens star texture must be used to simulate rays on the flares and is available
  153629. * in the documentation
  153630. */
  153631. lensStarTexture: Nullable<Texture>;
  153632. /**
  153633. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  153634. * flare effect by taking account of the dirt texture
  153635. */
  153636. lensFlareDirtTexture: Nullable<Texture>;
  153637. /**
  153638. * Represents the focal length for the depth of field effect
  153639. */
  153640. depthOfFieldDistance: number;
  153641. /**
  153642. * Represents the blur intensity for the blurred part of the depth of field effect
  153643. */
  153644. depthOfFieldBlurWidth: number;
  153645. /**
  153646. * Gets how much the image is blurred by the movement while using the motion blur post-process
  153647. */
  153648. get motionStrength(): number;
  153649. /**
  153650. * Sets how much the image is blurred by the movement while using the motion blur post-process
  153651. */
  153652. set motionStrength(strength: number);
  153653. /**
  153654. * Gets wether or not the motion blur post-process is object based or screen based.
  153655. */
  153656. get objectBasedMotionBlur(): boolean;
  153657. /**
  153658. * Sets wether or not the motion blur post-process should be object based or screen based
  153659. */
  153660. set objectBasedMotionBlur(value: boolean);
  153661. /**
  153662. * List of animations for the pipeline (IAnimatable implementation)
  153663. */
  153664. animations: Animation[];
  153665. /**
  153666. * Private members
  153667. */
  153668. private _scene;
  153669. private _currentDepthOfFieldSource;
  153670. private _basePostProcess;
  153671. private _fixedExposure;
  153672. private _currentExposure;
  153673. private _hdrAutoExposure;
  153674. private _hdrCurrentLuminance;
  153675. private _motionStrength;
  153676. private _isObjectBasedMotionBlur;
  153677. private _floatTextureType;
  153678. private _camerasToBeAttached;
  153679. private _ratio;
  153680. private _bloomEnabled;
  153681. private _depthOfFieldEnabled;
  153682. private _vlsEnabled;
  153683. private _lensFlareEnabled;
  153684. private _hdrEnabled;
  153685. private _motionBlurEnabled;
  153686. private _fxaaEnabled;
  153687. private _screenSpaceReflectionsEnabled;
  153688. private _motionBlurSamples;
  153689. private _volumetricLightStepsCount;
  153690. private _samples;
  153691. /**
  153692. * @ignore
  153693. * Specifies if the bloom pipeline is enabled
  153694. */
  153695. get BloomEnabled(): boolean;
  153696. set BloomEnabled(enabled: boolean);
  153697. /**
  153698. * @ignore
  153699. * Specifies if the depth of field pipeline is enabed
  153700. */
  153701. get DepthOfFieldEnabled(): boolean;
  153702. set DepthOfFieldEnabled(enabled: boolean);
  153703. /**
  153704. * @ignore
  153705. * Specifies if the lens flare pipeline is enabed
  153706. */
  153707. get LensFlareEnabled(): boolean;
  153708. set LensFlareEnabled(enabled: boolean);
  153709. /**
  153710. * @ignore
  153711. * Specifies if the HDR pipeline is enabled
  153712. */
  153713. get HDREnabled(): boolean;
  153714. set HDREnabled(enabled: boolean);
  153715. /**
  153716. * @ignore
  153717. * Specifies if the volumetric lights scattering effect is enabled
  153718. */
  153719. get VLSEnabled(): boolean;
  153720. set VLSEnabled(enabled: boolean);
  153721. /**
  153722. * @ignore
  153723. * Specifies if the motion blur effect is enabled
  153724. */
  153725. get MotionBlurEnabled(): boolean;
  153726. set MotionBlurEnabled(enabled: boolean);
  153727. /**
  153728. * Specifies if anti-aliasing is enabled
  153729. */
  153730. get fxaaEnabled(): boolean;
  153731. set fxaaEnabled(enabled: boolean);
  153732. /**
  153733. * Specifies if screen space reflections are enabled.
  153734. */
  153735. get screenSpaceReflectionsEnabled(): boolean;
  153736. set screenSpaceReflectionsEnabled(enabled: boolean);
  153737. /**
  153738. * Specifies the number of steps used to calculate the volumetric lights
  153739. * Typically in interval [50, 200]
  153740. */
  153741. get volumetricLightStepsCount(): number;
  153742. set volumetricLightStepsCount(count: number);
  153743. /**
  153744. * Specifies the number of samples used for the motion blur effect
  153745. * Typically in interval [16, 64]
  153746. */
  153747. get motionBlurSamples(): number;
  153748. set motionBlurSamples(samples: number);
  153749. /**
  153750. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153751. */
  153752. get samples(): number;
  153753. set samples(sampleCount: number);
  153754. /**
  153755. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153756. * @constructor
  153757. * @param name The rendering pipeline name
  153758. * @param scene The scene linked to this pipeline
  153759. * @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)
  153760. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  153761. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153762. */
  153763. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  153764. private _buildPipeline;
  153765. private _createDownSampleX4PostProcess;
  153766. private _createBrightPassPostProcess;
  153767. private _createBlurPostProcesses;
  153768. private _createTextureAdderPostProcess;
  153769. private _createVolumetricLightPostProcess;
  153770. private _createLuminancePostProcesses;
  153771. private _createHdrPostProcess;
  153772. private _createLensFlarePostProcess;
  153773. private _createDepthOfFieldPostProcess;
  153774. private _createMotionBlurPostProcess;
  153775. private _getDepthTexture;
  153776. private _disposePostProcesses;
  153777. /**
  153778. * Dispose of the pipeline and stop all post processes
  153779. */
  153780. dispose(): void;
  153781. /**
  153782. * Serialize the rendering pipeline (Used when exporting)
  153783. * @returns the serialized object
  153784. */
  153785. serialize(): any;
  153786. /**
  153787. * Parse the serialized pipeline
  153788. * @param source Source pipeline.
  153789. * @param scene The scene to load the pipeline to.
  153790. * @param rootUrl The URL of the serialized pipeline.
  153791. * @returns An instantiated pipeline from the serialized object.
  153792. */
  153793. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  153794. /**
  153795. * Luminance steps
  153796. */
  153797. static LuminanceSteps: number;
  153798. }
  153799. }
  153800. declare module BABYLON {
  153801. /** @hidden */
  153802. export var stereoscopicInterlacePixelShader: {
  153803. name: string;
  153804. shader: string;
  153805. };
  153806. }
  153807. declare module BABYLON {
  153808. /**
  153809. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  153810. */
  153811. export class StereoscopicInterlacePostProcessI extends PostProcess {
  153812. private _stepSize;
  153813. private _passedProcess;
  153814. /**
  153815. * Gets a string identifying the name of the class
  153816. * @returns "StereoscopicInterlacePostProcessI" string
  153817. */
  153818. getClassName(): string;
  153819. /**
  153820. * Initializes a StereoscopicInterlacePostProcessI
  153821. * @param name The name of the effect.
  153822. * @param rigCameras The rig cameras to be appled to the post process
  153823. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  153824. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  153825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153826. * @param engine The engine which the post process will be applied. (default: current engine)
  153827. * @param reusable If the post process can be reused on the same frame. (default: false)
  153828. */
  153829. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153830. }
  153831. /**
  153832. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  153833. */
  153834. export class StereoscopicInterlacePostProcess extends PostProcess {
  153835. private _stepSize;
  153836. private _passedProcess;
  153837. /**
  153838. * Gets a string identifying the name of the class
  153839. * @returns "StereoscopicInterlacePostProcess" string
  153840. */
  153841. getClassName(): string;
  153842. /**
  153843. * Initializes a StereoscopicInterlacePostProcess
  153844. * @param name The name of the effect.
  153845. * @param rigCameras The rig cameras to be appled to the post process
  153846. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  153847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153848. * @param engine The engine which the post process will be applied. (default: current engine)
  153849. * @param reusable If the post process can be reused on the same frame. (default: false)
  153850. */
  153851. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153852. }
  153853. }
  153854. declare module BABYLON {
  153855. /** @hidden */
  153856. export var tonemapPixelShader: {
  153857. name: string;
  153858. shader: string;
  153859. };
  153860. }
  153861. declare module BABYLON {
  153862. /** Defines operator used for tonemapping */
  153863. export enum TonemappingOperator {
  153864. /** Hable */
  153865. Hable = 0,
  153866. /** Reinhard */
  153867. Reinhard = 1,
  153868. /** HejiDawson */
  153869. HejiDawson = 2,
  153870. /** Photographic */
  153871. Photographic = 3
  153872. }
  153873. /**
  153874. * Defines a post process to apply tone mapping
  153875. */
  153876. export class TonemapPostProcess extends PostProcess {
  153877. private _operator;
  153878. /** Defines the required exposure adjustement */
  153879. exposureAdjustment: number;
  153880. /**
  153881. * Gets a string identifying the name of the class
  153882. * @returns "TonemapPostProcess" string
  153883. */
  153884. getClassName(): string;
  153885. /**
  153886. * Creates a new TonemapPostProcess
  153887. * @param name defines the name of the postprocess
  153888. * @param _operator defines the operator to use
  153889. * @param exposureAdjustment defines the required exposure adjustement
  153890. * @param camera defines the camera to use (can be null)
  153891. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153892. * @param engine defines the hosting engine (can be ignore if camera is set)
  153893. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153894. */
  153895. constructor(name: string, _operator: TonemappingOperator,
  153896. /** Defines the required exposure adjustement */
  153897. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153898. }
  153899. }
  153900. declare module BABYLON {
  153901. /** @hidden */
  153902. export var volumetricLightScatteringPixelShader: {
  153903. name: string;
  153904. shader: string;
  153905. };
  153906. }
  153907. declare module BABYLON {
  153908. /** @hidden */
  153909. export var volumetricLightScatteringPassVertexShader: {
  153910. name: string;
  153911. shader: string;
  153912. };
  153913. }
  153914. declare module BABYLON {
  153915. /** @hidden */
  153916. export var volumetricLightScatteringPassPixelShader: {
  153917. name: string;
  153918. shader: string;
  153919. };
  153920. }
  153921. declare module BABYLON {
  153922. /**
  153923. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153924. */
  153925. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153926. private _volumetricLightScatteringPass;
  153927. private _volumetricLightScatteringRTT;
  153928. private _viewPort;
  153929. private _screenCoordinates;
  153930. private _cachedDefines;
  153931. /**
  153932. * If not undefined, the mesh position is computed from the attached node position
  153933. */
  153934. attachedNode: {
  153935. position: Vector3;
  153936. };
  153937. /**
  153938. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153939. */
  153940. customMeshPosition: Vector3;
  153941. /**
  153942. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153943. */
  153944. useCustomMeshPosition: boolean;
  153945. /**
  153946. * If the post-process should inverse the light scattering direction
  153947. */
  153948. invert: boolean;
  153949. /**
  153950. * The internal mesh used by the post-process
  153951. */
  153952. mesh: Mesh;
  153953. /**
  153954. * @hidden
  153955. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153956. */
  153957. get useDiffuseColor(): boolean;
  153958. set useDiffuseColor(useDiffuseColor: boolean);
  153959. /**
  153960. * Array containing the excluded meshes not rendered in the internal pass
  153961. */
  153962. excludedMeshes: AbstractMesh[];
  153963. /**
  153964. * Controls the overall intensity of the post-process
  153965. */
  153966. exposure: number;
  153967. /**
  153968. * Dissipates each sample's contribution in range [0, 1]
  153969. */
  153970. decay: number;
  153971. /**
  153972. * Controls the overall intensity of each sample
  153973. */
  153974. weight: number;
  153975. /**
  153976. * Controls the density of each sample
  153977. */
  153978. density: number;
  153979. /**
  153980. * @constructor
  153981. * @param name The post-process name
  153982. * @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)
  153983. * @param camera The camera that the post-process will be attached to
  153984. * @param mesh The mesh used to create the light scattering
  153985. * @param samples The post-process quality, default 100
  153986. * @param samplingModeThe post-process filtering mode
  153987. * @param engine The babylon engine
  153988. * @param reusable If the post-process is reusable
  153989. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153990. */
  153991. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153992. /**
  153993. * Returns the string "VolumetricLightScatteringPostProcess"
  153994. * @returns "VolumetricLightScatteringPostProcess"
  153995. */
  153996. getClassName(): string;
  153997. private _isReady;
  153998. /**
  153999. * Sets the new light position for light scattering effect
  154000. * @param position The new custom light position
  154001. */
  154002. setCustomMeshPosition(position: Vector3): void;
  154003. /**
  154004. * Returns the light position for light scattering effect
  154005. * @return Vector3 The custom light position
  154006. */
  154007. getCustomMeshPosition(): Vector3;
  154008. /**
  154009. * Disposes the internal assets and detaches the post-process from the camera
  154010. */
  154011. dispose(camera: Camera): void;
  154012. /**
  154013. * Returns the render target texture used by the post-process
  154014. * @return the render target texture used by the post-process
  154015. */
  154016. getPass(): RenderTargetTexture;
  154017. private _meshExcluded;
  154018. private _createPass;
  154019. private _updateMeshScreenCoordinates;
  154020. /**
  154021. * Creates a default mesh for the Volumeric Light Scattering post-process
  154022. * @param name The mesh name
  154023. * @param scene The scene where to create the mesh
  154024. * @return the default mesh
  154025. */
  154026. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154027. }
  154028. }
  154029. declare module BABYLON {
  154030. /** @hidden */
  154031. export var screenSpaceCurvaturePixelShader: {
  154032. name: string;
  154033. shader: string;
  154034. };
  154035. }
  154036. declare module BABYLON {
  154037. /**
  154038. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154039. */
  154040. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154041. /**
  154042. * Defines how much ridge the curvature effect displays.
  154043. */
  154044. ridge: number;
  154045. /**
  154046. * Defines how much valley the curvature effect displays.
  154047. */
  154048. valley: number;
  154049. private _geometryBufferRenderer;
  154050. /**
  154051. * Gets a string identifying the name of the class
  154052. * @returns "ScreenSpaceCurvaturePostProcess" string
  154053. */
  154054. getClassName(): string;
  154055. /**
  154056. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154057. * @param name The name of the effect.
  154058. * @param scene The scene containing the objects to blur according to their velocity.
  154059. * @param options The required width/height ratio to downsize to before computing the render pass.
  154060. * @param camera The camera to apply the render pass to.
  154061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154062. * @param engine The engine which the post process will be applied. (default: current engine)
  154063. * @param reusable If the post process can be reused on the same frame. (default: false)
  154064. * @param textureType Type of textures used when performing the post process. (default: 0)
  154065. * @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)
  154066. */
  154067. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154068. /**
  154069. * Support test.
  154070. */
  154071. static get IsSupported(): boolean;
  154072. /** @hidden */
  154073. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154074. }
  154075. }
  154076. declare module BABYLON {
  154077. interface Scene {
  154078. /** @hidden (Backing field) */
  154079. _boundingBoxRenderer: BoundingBoxRenderer;
  154080. /** @hidden (Backing field) */
  154081. _forceShowBoundingBoxes: boolean;
  154082. /**
  154083. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154084. */
  154085. forceShowBoundingBoxes: boolean;
  154086. /**
  154087. * Gets the bounding box renderer associated with the scene
  154088. * @returns a BoundingBoxRenderer
  154089. */
  154090. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154091. }
  154092. interface AbstractMesh {
  154093. /** @hidden (Backing field) */
  154094. _showBoundingBox: boolean;
  154095. /**
  154096. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154097. */
  154098. showBoundingBox: boolean;
  154099. }
  154100. /**
  154101. * Component responsible of rendering the bounding box of the meshes in a scene.
  154102. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154103. */
  154104. export class BoundingBoxRenderer implements ISceneComponent {
  154105. /**
  154106. * The component name helpfull to identify the component in the list of scene components.
  154107. */
  154108. readonly name: string;
  154109. /**
  154110. * The scene the component belongs to.
  154111. */
  154112. scene: Scene;
  154113. /**
  154114. * Color of the bounding box lines placed in front of an object
  154115. */
  154116. frontColor: Color3;
  154117. /**
  154118. * Color of the bounding box lines placed behind an object
  154119. */
  154120. backColor: Color3;
  154121. /**
  154122. * Defines if the renderer should show the back lines or not
  154123. */
  154124. showBackLines: boolean;
  154125. /**
  154126. * Observable raised before rendering a bounding box
  154127. */
  154128. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154129. /**
  154130. * Observable raised after rendering a bounding box
  154131. */
  154132. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154133. /**
  154134. * Observable raised after resources are created
  154135. */
  154136. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154137. /**
  154138. * When false, no bounding boxes will be rendered
  154139. */
  154140. enabled: boolean;
  154141. /**
  154142. * @hidden
  154143. */
  154144. renderList: SmartArray<BoundingBox>;
  154145. private _colorShader;
  154146. private _vertexBuffers;
  154147. private _indexBuffer;
  154148. private _fillIndexBuffer;
  154149. private _fillIndexData;
  154150. /**
  154151. * Instantiates a new bounding box renderer in a scene.
  154152. * @param scene the scene the renderer renders in
  154153. */
  154154. constructor(scene: Scene);
  154155. /**
  154156. * Registers the component in a given scene
  154157. */
  154158. register(): void;
  154159. private _evaluateSubMesh;
  154160. private _preActiveMesh;
  154161. private _prepareResources;
  154162. private _createIndexBuffer;
  154163. /**
  154164. * Rebuilds the elements related to this component in case of
  154165. * context lost for instance.
  154166. */
  154167. rebuild(): void;
  154168. /**
  154169. * @hidden
  154170. */
  154171. reset(): void;
  154172. /**
  154173. * Render the bounding boxes of a specific rendering group
  154174. * @param renderingGroupId defines the rendering group to render
  154175. */
  154176. render(renderingGroupId: number): void;
  154177. /**
  154178. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154179. * @param mesh Define the mesh to render the occlusion bounding box for
  154180. */
  154181. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154182. /**
  154183. * Dispose and release the resources attached to this renderer.
  154184. */
  154185. dispose(): void;
  154186. }
  154187. }
  154188. declare module BABYLON {
  154189. interface Scene {
  154190. /** @hidden (Backing field) */
  154191. _depthRenderer: {
  154192. [id: string]: DepthRenderer;
  154193. };
  154194. /**
  154195. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154196. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154197. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154198. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154199. * @returns the created depth renderer
  154200. */
  154201. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154202. /**
  154203. * Disables a depth renderer for a given camera
  154204. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154205. */
  154206. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154207. }
  154208. /**
  154209. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154210. * in several rendering techniques.
  154211. */
  154212. export class DepthRendererSceneComponent implements ISceneComponent {
  154213. /**
  154214. * The component name helpfull to identify the component in the list of scene components.
  154215. */
  154216. readonly name: string;
  154217. /**
  154218. * The scene the component belongs to.
  154219. */
  154220. scene: Scene;
  154221. /**
  154222. * Creates a new instance of the component for the given scene
  154223. * @param scene Defines the scene to register the component in
  154224. */
  154225. constructor(scene: Scene);
  154226. /**
  154227. * Registers the component in a given scene
  154228. */
  154229. register(): void;
  154230. /**
  154231. * Rebuilds the elements related to this component in case of
  154232. * context lost for instance.
  154233. */
  154234. rebuild(): void;
  154235. /**
  154236. * Disposes the component and the associated ressources
  154237. */
  154238. dispose(): void;
  154239. private _gatherRenderTargets;
  154240. private _gatherActiveCameraRenderTargets;
  154241. }
  154242. }
  154243. declare module BABYLON {
  154244. interface AbstractScene {
  154245. /** @hidden (Backing field) */
  154246. _prePassRenderer: Nullable<PrePassRenderer>;
  154247. /**
  154248. * Gets or Sets the current prepass renderer associated to the scene.
  154249. */
  154250. prePassRenderer: Nullable<PrePassRenderer>;
  154251. /**
  154252. * Enables the prepass and associates it with the scene
  154253. * @returns the PrePassRenderer
  154254. */
  154255. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  154256. /**
  154257. * Disables the prepass associated with the scene
  154258. */
  154259. disablePrePassRenderer(): void;
  154260. }
  154261. /**
  154262. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154263. * in several rendering techniques.
  154264. */
  154265. export class PrePassRendererSceneComponent implements ISceneComponent {
  154266. /**
  154267. * The component name helpful to identify the component in the list of scene components.
  154268. */
  154269. readonly name: string;
  154270. /**
  154271. * The scene the component belongs to.
  154272. */
  154273. scene: Scene;
  154274. /**
  154275. * Creates a new instance of the component for the given scene
  154276. * @param scene Defines the scene to register the component in
  154277. */
  154278. constructor(scene: Scene);
  154279. /**
  154280. * Registers the component in a given scene
  154281. */
  154282. register(): void;
  154283. private _beforeCameraDraw;
  154284. private _afterCameraDraw;
  154285. private _beforeClearStage;
  154286. /**
  154287. * Rebuilds the elements related to this component in case of
  154288. * context lost for instance.
  154289. */
  154290. rebuild(): void;
  154291. /**
  154292. * Disposes the component and the associated ressources
  154293. */
  154294. dispose(): void;
  154295. }
  154296. }
  154297. declare module BABYLON {
  154298. /** @hidden */
  154299. export var fibonacci: {
  154300. name: string;
  154301. shader: string;
  154302. };
  154303. }
  154304. declare module BABYLON {
  154305. /** @hidden */
  154306. export var diffusionProfile: {
  154307. name: string;
  154308. shader: string;
  154309. };
  154310. }
  154311. declare module BABYLON {
  154312. /** @hidden */
  154313. export var subSurfaceScatteringPixelShader: {
  154314. name: string;
  154315. shader: string;
  154316. };
  154317. }
  154318. declare module BABYLON {
  154319. /**
  154320. * Sub surface scattering post process
  154321. */
  154322. export class SubSurfaceScatteringPostProcess extends PostProcess {
  154323. /**
  154324. * Gets a string identifying the name of the class
  154325. * @returns "SubSurfaceScatteringPostProcess" string
  154326. */
  154327. getClassName(): string;
  154328. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  154329. }
  154330. }
  154331. declare module BABYLON {
  154332. /**
  154333. * Contains all parameters needed for the prepass to perform
  154334. * screen space subsurface scattering
  154335. */
  154336. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  154337. /** @hidden */
  154338. static _SceneComponentInitialization: (scene: Scene) => void;
  154339. private _ssDiffusionS;
  154340. private _ssFilterRadii;
  154341. private _ssDiffusionD;
  154342. /**
  154343. * Post process to attach for screen space subsurface scattering
  154344. */
  154345. postProcess: SubSurfaceScatteringPostProcess;
  154346. /**
  154347. * Diffusion profile color for subsurface scattering
  154348. */
  154349. get ssDiffusionS(): number[];
  154350. /**
  154351. * Diffusion profile max color channel value for subsurface scattering
  154352. */
  154353. get ssDiffusionD(): number[];
  154354. /**
  154355. * Diffusion profile filter radius for subsurface scattering
  154356. */
  154357. get ssFilterRadii(): number[];
  154358. /**
  154359. * Is subsurface enabled
  154360. */
  154361. enabled: boolean;
  154362. /**
  154363. * Name of the configuration
  154364. */
  154365. name: string;
  154366. /**
  154367. * Diffusion profile colors for subsurface scattering
  154368. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  154369. * See ...
  154370. * Note that you can only store up to 5 of them
  154371. */
  154372. ssDiffusionProfileColors: Color3[];
  154373. /**
  154374. * Defines the ratio real world => scene units.
  154375. * Used for subsurface scattering
  154376. */
  154377. metersPerUnit: number;
  154378. /**
  154379. * Textures that should be present in the MRT for this effect to work
  154380. */
  154381. readonly texturesRequired: number[];
  154382. private _scene;
  154383. /**
  154384. * Builds a subsurface configuration object
  154385. * @param scene The scene
  154386. */
  154387. constructor(scene: Scene);
  154388. /**
  154389. * Adds a new diffusion profile.
  154390. * Useful for more realistic subsurface scattering on diverse materials.
  154391. * @param color The color of the diffusion profile. Should be the average color of the material.
  154392. * @return The index of the diffusion profile for the material subsurface configuration
  154393. */
  154394. addDiffusionProfile(color: Color3): number;
  154395. /**
  154396. * Creates the sss post process
  154397. * @return The created post process
  154398. */
  154399. createPostProcess(): SubSurfaceScatteringPostProcess;
  154400. /**
  154401. * Deletes all diffusion profiles.
  154402. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  154403. */
  154404. clearAllDiffusionProfiles(): void;
  154405. /**
  154406. * Disposes this object
  154407. */
  154408. dispose(): void;
  154409. /**
  154410. * @hidden
  154411. * https://zero-radiance.github.io/post/sampling-diffusion/
  154412. *
  154413. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  154414. * ------------------------------------------------------------------------------------
  154415. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  154416. * PDF[r, phi, s] = r * R[r, phi, s]
  154417. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  154418. * ------------------------------------------------------------------------------------
  154419. * We importance sample the color channel with the widest scattering distance.
  154420. */
  154421. getDiffusionProfileParameters(color: Color3): number;
  154422. /**
  154423. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  154424. * 'u' is the random number (the value of the CDF): [0, 1).
  154425. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  154426. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  154427. */
  154428. private _sampleBurleyDiffusionProfile;
  154429. }
  154430. }
  154431. declare module BABYLON {
  154432. interface AbstractScene {
  154433. /** @hidden (Backing field) */
  154434. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154435. /**
  154436. * Gets or Sets the current prepass renderer associated to the scene.
  154437. */
  154438. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154439. /**
  154440. * Enables the subsurface effect for prepass
  154441. * @returns the SubSurfaceConfiguration
  154442. */
  154443. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  154444. /**
  154445. * Disables the subsurface effect for prepass
  154446. */
  154447. disableSubSurfaceForPrePass(): void;
  154448. }
  154449. /**
  154450. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154451. * in several rendering techniques.
  154452. */
  154453. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  154454. /**
  154455. * The component name helpful to identify the component in the list of scene components.
  154456. */
  154457. readonly name: string;
  154458. /**
  154459. * The scene the component belongs to.
  154460. */
  154461. scene: Scene;
  154462. /**
  154463. * Creates a new instance of the component for the given scene
  154464. * @param scene Defines the scene to register the component in
  154465. */
  154466. constructor(scene: Scene);
  154467. /**
  154468. * Registers the component in a given scene
  154469. */
  154470. register(): void;
  154471. /**
  154472. * Serializes the component data to the specified json object
  154473. * @param serializationObject The object to serialize to
  154474. */
  154475. serialize(serializationObject: any): void;
  154476. /**
  154477. * Adds all the elements from the container to the scene
  154478. * @param container the container holding the elements
  154479. */
  154480. addFromContainer(container: AbstractScene): void;
  154481. /**
  154482. * Removes all the elements in the container from the scene
  154483. * @param container contains the elements to remove
  154484. * @param dispose if the removed element should be disposed (default: false)
  154485. */
  154486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  154487. /**
  154488. * Rebuilds the elements related to this component in case of
  154489. * context lost for instance.
  154490. */
  154491. rebuild(): void;
  154492. /**
  154493. * Disposes the component and the associated ressources
  154494. */
  154495. dispose(): void;
  154496. }
  154497. }
  154498. declare module BABYLON {
  154499. /** @hidden */
  154500. export var outlinePixelShader: {
  154501. name: string;
  154502. shader: string;
  154503. };
  154504. }
  154505. declare module BABYLON {
  154506. /** @hidden */
  154507. export var outlineVertexShader: {
  154508. name: string;
  154509. shader: string;
  154510. };
  154511. }
  154512. declare module BABYLON {
  154513. interface Scene {
  154514. /** @hidden */
  154515. _outlineRenderer: OutlineRenderer;
  154516. /**
  154517. * Gets the outline renderer associated with the scene
  154518. * @returns a OutlineRenderer
  154519. */
  154520. getOutlineRenderer(): OutlineRenderer;
  154521. }
  154522. interface AbstractMesh {
  154523. /** @hidden (Backing field) */
  154524. _renderOutline: boolean;
  154525. /**
  154526. * Gets or sets a boolean indicating if the outline must be rendered as well
  154527. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  154528. */
  154529. renderOutline: boolean;
  154530. /** @hidden (Backing field) */
  154531. _renderOverlay: boolean;
  154532. /**
  154533. * Gets or sets a boolean indicating if the overlay must be rendered as well
  154534. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  154535. */
  154536. renderOverlay: boolean;
  154537. }
  154538. /**
  154539. * This class is responsible to draw bothe outline/overlay of meshes.
  154540. * It should not be used directly but through the available method on mesh.
  154541. */
  154542. export class OutlineRenderer implements ISceneComponent {
  154543. /**
  154544. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  154545. */
  154546. private static _StencilReference;
  154547. /**
  154548. * The name of the component. Each component must have a unique name.
  154549. */
  154550. name: string;
  154551. /**
  154552. * The scene the component belongs to.
  154553. */
  154554. scene: Scene;
  154555. /**
  154556. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  154557. */
  154558. zOffset: number;
  154559. private _engine;
  154560. private _effect;
  154561. private _cachedDefines;
  154562. private _savedDepthWrite;
  154563. /**
  154564. * Instantiates a new outline renderer. (There could be only one per scene).
  154565. * @param scene Defines the scene it belongs to
  154566. */
  154567. constructor(scene: Scene);
  154568. /**
  154569. * Register the component to one instance of a scene.
  154570. */
  154571. register(): void;
  154572. /**
  154573. * Rebuilds the elements related to this component in case of
  154574. * context lost for instance.
  154575. */
  154576. rebuild(): void;
  154577. /**
  154578. * Disposes the component and the associated ressources.
  154579. */
  154580. dispose(): void;
  154581. /**
  154582. * Renders the outline in the canvas.
  154583. * @param subMesh Defines the sumesh to render
  154584. * @param batch Defines the batch of meshes in case of instances
  154585. * @param useOverlay Defines if the rendering is for the overlay or the outline
  154586. */
  154587. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  154588. /**
  154589. * Returns whether or not the outline renderer is ready for a given submesh.
  154590. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  154591. * @param subMesh Defines the submesh to check readyness for
  154592. * @param useInstances Defines wheter wee are trying to render instances or not
  154593. * @returns true if ready otherwise false
  154594. */
  154595. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  154596. private _beforeRenderingMesh;
  154597. private _afterRenderingMesh;
  154598. }
  154599. }
  154600. declare module BABYLON {
  154601. /**
  154602. * Defines the basic options interface of a Sprite Frame Source Size.
  154603. */
  154604. export interface ISpriteJSONSpriteSourceSize {
  154605. /**
  154606. * number of the original width of the Frame
  154607. */
  154608. w: number;
  154609. /**
  154610. * number of the original height of the Frame
  154611. */
  154612. h: number;
  154613. }
  154614. /**
  154615. * Defines the basic options interface of a Sprite Frame Data.
  154616. */
  154617. export interface ISpriteJSONSpriteFrameData {
  154618. /**
  154619. * number of the x offset of the Frame
  154620. */
  154621. x: number;
  154622. /**
  154623. * number of the y offset of the Frame
  154624. */
  154625. y: number;
  154626. /**
  154627. * number of the width of the Frame
  154628. */
  154629. w: number;
  154630. /**
  154631. * number of the height of the Frame
  154632. */
  154633. h: number;
  154634. }
  154635. /**
  154636. * Defines the basic options interface of a JSON Sprite.
  154637. */
  154638. export interface ISpriteJSONSprite {
  154639. /**
  154640. * string name of the Frame
  154641. */
  154642. filename: string;
  154643. /**
  154644. * ISpriteJSONSpriteFrame basic object of the frame data
  154645. */
  154646. frame: ISpriteJSONSpriteFrameData;
  154647. /**
  154648. * boolean to flag is the frame was rotated.
  154649. */
  154650. rotated: boolean;
  154651. /**
  154652. * boolean to flag is the frame was trimmed.
  154653. */
  154654. trimmed: boolean;
  154655. /**
  154656. * ISpriteJSONSpriteFrame basic object of the source data
  154657. */
  154658. spriteSourceSize: ISpriteJSONSpriteFrameData;
  154659. /**
  154660. * ISpriteJSONSpriteFrame basic object of the source data
  154661. */
  154662. sourceSize: ISpriteJSONSpriteSourceSize;
  154663. }
  154664. /**
  154665. * Defines the basic options interface of a JSON atlas.
  154666. */
  154667. export interface ISpriteJSONAtlas {
  154668. /**
  154669. * Array of objects that contain the frame data.
  154670. */
  154671. frames: Array<ISpriteJSONSprite>;
  154672. /**
  154673. * object basic object containing the sprite meta data.
  154674. */
  154675. meta?: object;
  154676. }
  154677. }
  154678. declare module BABYLON {
  154679. /** @hidden */
  154680. export var spriteMapPixelShader: {
  154681. name: string;
  154682. shader: string;
  154683. };
  154684. }
  154685. declare module BABYLON {
  154686. /** @hidden */
  154687. export var spriteMapVertexShader: {
  154688. name: string;
  154689. shader: string;
  154690. };
  154691. }
  154692. declare module BABYLON {
  154693. /**
  154694. * Defines the basic options interface of a SpriteMap
  154695. */
  154696. export interface ISpriteMapOptions {
  154697. /**
  154698. * Vector2 of the number of cells in the grid.
  154699. */
  154700. stageSize?: Vector2;
  154701. /**
  154702. * Vector2 of the size of the output plane in World Units.
  154703. */
  154704. outputSize?: Vector2;
  154705. /**
  154706. * Vector3 of the position of the output plane in World Units.
  154707. */
  154708. outputPosition?: Vector3;
  154709. /**
  154710. * Vector3 of the rotation of the output plane.
  154711. */
  154712. outputRotation?: Vector3;
  154713. /**
  154714. * number of layers that the system will reserve in resources.
  154715. */
  154716. layerCount?: number;
  154717. /**
  154718. * number of max animation frames a single cell will reserve in resources.
  154719. */
  154720. maxAnimationFrames?: number;
  154721. /**
  154722. * number cell index of the base tile when the system compiles.
  154723. */
  154724. baseTile?: number;
  154725. /**
  154726. * boolean flip the sprite after its been repositioned by the framing data.
  154727. */
  154728. flipU?: boolean;
  154729. /**
  154730. * Vector3 scalar of the global RGB values of the SpriteMap.
  154731. */
  154732. colorMultiply?: Vector3;
  154733. }
  154734. /**
  154735. * Defines the IDisposable interface in order to be cleanable from resources.
  154736. */
  154737. export interface ISpriteMap extends IDisposable {
  154738. /**
  154739. * String name of the SpriteMap.
  154740. */
  154741. name: string;
  154742. /**
  154743. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  154744. */
  154745. atlasJSON: ISpriteJSONAtlas;
  154746. /**
  154747. * Texture of the SpriteMap.
  154748. */
  154749. spriteSheet: Texture;
  154750. /**
  154751. * The parameters to initialize the SpriteMap with.
  154752. */
  154753. options: ISpriteMapOptions;
  154754. }
  154755. /**
  154756. * Class used to manage a grid restricted sprite deployment on an Output plane.
  154757. */
  154758. export class SpriteMap implements ISpriteMap {
  154759. /** The Name of the spriteMap */
  154760. name: string;
  154761. /** The JSON file with the frame and meta data */
  154762. atlasJSON: ISpriteJSONAtlas;
  154763. /** The systems Sprite Sheet Texture */
  154764. spriteSheet: Texture;
  154765. /** Arguments passed with the Constructor */
  154766. options: ISpriteMapOptions;
  154767. /** Public Sprite Storage array, parsed from atlasJSON */
  154768. sprites: Array<ISpriteJSONSprite>;
  154769. /** Returns the Number of Sprites in the System */
  154770. get spriteCount(): number;
  154771. /** Returns the Position of Output Plane*/
  154772. get position(): Vector3;
  154773. /** Returns the Position of Output Plane*/
  154774. set position(v: Vector3);
  154775. /** Returns the Rotation of Output Plane*/
  154776. get rotation(): Vector3;
  154777. /** Returns the Rotation of Output Plane*/
  154778. set rotation(v: Vector3);
  154779. /** Sets the AnimationMap*/
  154780. get animationMap(): RawTexture;
  154781. /** Sets the AnimationMap*/
  154782. set animationMap(v: RawTexture);
  154783. /** Scene that the SpriteMap was created in */
  154784. private _scene;
  154785. /** Texture Buffer of Float32 that holds tile frame data*/
  154786. private _frameMap;
  154787. /** Texture Buffers of Float32 that holds tileMap data*/
  154788. private _tileMaps;
  154789. /** Texture Buffer of Float32 that holds Animation Data*/
  154790. private _animationMap;
  154791. /** Custom ShaderMaterial Central to the System*/
  154792. private _material;
  154793. /** Custom ShaderMaterial Central to the System*/
  154794. private _output;
  154795. /** Systems Time Ticker*/
  154796. private _time;
  154797. /**
  154798. * Creates a new SpriteMap
  154799. * @param name defines the SpriteMaps Name
  154800. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  154801. * @param spriteSheet is the Texture that the Sprites are on.
  154802. * @param options a basic deployment configuration
  154803. * @param scene The Scene that the map is deployed on
  154804. */
  154805. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  154806. /**
  154807. * Returns tileID location
  154808. * @returns Vector2 the cell position ID
  154809. */
  154810. getTileID(): Vector2;
  154811. /**
  154812. * Gets the UV location of the mouse over the SpriteMap.
  154813. * @returns Vector2 the UV position of the mouse interaction
  154814. */
  154815. getMousePosition(): Vector2;
  154816. /**
  154817. * Creates the "frame" texture Buffer
  154818. * -------------------------------------
  154819. * Structure of frames
  154820. * "filename": "Falling-Water-2.png",
  154821. * "frame": {"x":69,"y":103,"w":24,"h":32},
  154822. * "rotated": true,
  154823. * "trimmed": true,
  154824. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  154825. * "sourceSize": {"w":32,"h":32}
  154826. * @returns RawTexture of the frameMap
  154827. */
  154828. private _createFrameBuffer;
  154829. /**
  154830. * Creates the tileMap texture Buffer
  154831. * @param buffer normally and array of numbers, or a false to generate from scratch
  154832. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  154833. * @returns RawTexture of the tileMap
  154834. */
  154835. private _createTileBuffer;
  154836. /**
  154837. * Modifies the data of the tileMaps
  154838. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  154839. * @param pos is the iVector2 Coordinates of the Tile
  154840. * @param tile The SpriteIndex of the new Tile
  154841. */
  154842. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  154843. /**
  154844. * Creates the animationMap texture Buffer
  154845. * @param buffer normally and array of numbers, or a false to generate from scratch
  154846. * @returns RawTexture of the animationMap
  154847. */
  154848. private _createTileAnimationBuffer;
  154849. /**
  154850. * Modifies the data of the animationMap
  154851. * @param cellID is the Index of the Sprite
  154852. * @param _frame is the target Animation frame
  154853. * @param toCell is the Target Index of the next frame of the animation
  154854. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  154855. * @param speed is a global scalar of the time variable on the map.
  154856. */
  154857. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  154858. /**
  154859. * Exports the .tilemaps file
  154860. */
  154861. saveTileMaps(): void;
  154862. /**
  154863. * Imports the .tilemaps file
  154864. * @param url of the .tilemaps file
  154865. */
  154866. loadTileMaps(url: string): void;
  154867. /**
  154868. * Release associated resources
  154869. */
  154870. dispose(): void;
  154871. }
  154872. }
  154873. declare module BABYLON {
  154874. /**
  154875. * Class used to manage multiple sprites of different sizes on the same spritesheet
  154876. * @see https://doc.babylonjs.com/babylon101/sprites
  154877. */
  154878. export class SpritePackedManager extends SpriteManager {
  154879. /** defines the packed manager's name */
  154880. name: string;
  154881. /**
  154882. * Creates a new sprite manager from a packed sprite sheet
  154883. * @param name defines the manager's name
  154884. * @param imgUrl defines the sprite sheet url
  154885. * @param capacity defines the maximum allowed number of sprites
  154886. * @param scene defines the hosting scene
  154887. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154888. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154889. * @param samplingMode defines the smapling mode to use with spritesheet
  154890. * @param fromPacked set to true; do not alter
  154891. */
  154892. constructor(
  154893. /** defines the packed manager's name */
  154894. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154895. }
  154896. }
  154897. declare module BABYLON {
  154898. /**
  154899. * Defines the list of states available for a task inside a AssetsManager
  154900. */
  154901. export enum AssetTaskState {
  154902. /**
  154903. * Initialization
  154904. */
  154905. INIT = 0,
  154906. /**
  154907. * Running
  154908. */
  154909. RUNNING = 1,
  154910. /**
  154911. * Done
  154912. */
  154913. DONE = 2,
  154914. /**
  154915. * Error
  154916. */
  154917. ERROR = 3
  154918. }
  154919. /**
  154920. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154921. */
  154922. export abstract class AbstractAssetTask {
  154923. /**
  154924. * Task name
  154925. */ name: string;
  154926. /**
  154927. * Callback called when the task is successful
  154928. */
  154929. onSuccess: (task: any) => void;
  154930. /**
  154931. * Callback called when the task is not successful
  154932. */
  154933. onError: (task: any, message?: string, exception?: any) => void;
  154934. /**
  154935. * Creates a new AssetsManager
  154936. * @param name defines the name of the task
  154937. */
  154938. constructor(
  154939. /**
  154940. * Task name
  154941. */ name: string);
  154942. private _isCompleted;
  154943. private _taskState;
  154944. private _errorObject;
  154945. /**
  154946. * Get if the task is completed
  154947. */
  154948. get isCompleted(): boolean;
  154949. /**
  154950. * Gets the current state of the task
  154951. */
  154952. get taskState(): AssetTaskState;
  154953. /**
  154954. * Gets the current error object (if task is in error)
  154955. */
  154956. get errorObject(): {
  154957. message?: string;
  154958. exception?: any;
  154959. };
  154960. /**
  154961. * Internal only
  154962. * @hidden
  154963. */
  154964. _setErrorObject(message?: string, exception?: any): void;
  154965. /**
  154966. * Execute the current task
  154967. * @param scene defines the scene where you want your assets to be loaded
  154968. * @param onSuccess is a callback called when the task is successfully executed
  154969. * @param onError is a callback called if an error occurs
  154970. */
  154971. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154972. /**
  154973. * Execute the current task
  154974. * @param scene defines the scene where you want your assets to be loaded
  154975. * @param onSuccess is a callback called when the task is successfully executed
  154976. * @param onError is a callback called if an error occurs
  154977. */
  154978. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154979. /**
  154980. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154981. * This can be used with failed tasks that have the reason for failure fixed.
  154982. */
  154983. reset(): void;
  154984. private onErrorCallback;
  154985. private onDoneCallback;
  154986. }
  154987. /**
  154988. * Define the interface used by progress events raised during assets loading
  154989. */
  154990. export interface IAssetsProgressEvent {
  154991. /**
  154992. * Defines the number of remaining tasks to process
  154993. */
  154994. remainingCount: number;
  154995. /**
  154996. * Defines the total number of tasks
  154997. */
  154998. totalCount: number;
  154999. /**
  155000. * Defines the task that was just processed
  155001. */
  155002. task: AbstractAssetTask;
  155003. }
  155004. /**
  155005. * Class used to share progress information about assets loading
  155006. */
  155007. export class AssetsProgressEvent implements IAssetsProgressEvent {
  155008. /**
  155009. * Defines the number of remaining tasks to process
  155010. */
  155011. remainingCount: number;
  155012. /**
  155013. * Defines the total number of tasks
  155014. */
  155015. totalCount: number;
  155016. /**
  155017. * Defines the task that was just processed
  155018. */
  155019. task: AbstractAssetTask;
  155020. /**
  155021. * Creates a AssetsProgressEvent
  155022. * @param remainingCount defines the number of remaining tasks to process
  155023. * @param totalCount defines the total number of tasks
  155024. * @param task defines the task that was just processed
  155025. */
  155026. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155027. }
  155028. /**
  155029. * Define a task used by AssetsManager to load assets into a container
  155030. */
  155031. export class ContainerAssetTask extends AbstractAssetTask {
  155032. /**
  155033. * Defines the name of the task
  155034. */
  155035. name: string;
  155036. /**
  155037. * Defines the list of mesh's names you want to load
  155038. */
  155039. meshesNames: any;
  155040. /**
  155041. * Defines the root url to use as a base to load your meshes and associated resources
  155042. */
  155043. rootUrl: string;
  155044. /**
  155045. * Defines the filename or File of the scene to load from
  155046. */
  155047. sceneFilename: string | File;
  155048. /**
  155049. * Get the loaded asset container
  155050. */
  155051. loadedContainer: AssetContainer;
  155052. /**
  155053. * Gets the list of loaded meshes
  155054. */
  155055. loadedMeshes: Array<AbstractMesh>;
  155056. /**
  155057. * Gets the list of loaded particle systems
  155058. */
  155059. loadedParticleSystems: Array<IParticleSystem>;
  155060. /**
  155061. * Gets the list of loaded skeletons
  155062. */
  155063. loadedSkeletons: Array<Skeleton>;
  155064. /**
  155065. * Gets the list of loaded animation groups
  155066. */
  155067. loadedAnimationGroups: Array<AnimationGroup>;
  155068. /**
  155069. * Callback called when the task is successful
  155070. */
  155071. onSuccess: (task: ContainerAssetTask) => void;
  155072. /**
  155073. * Callback called when the task is successful
  155074. */
  155075. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155076. /**
  155077. * Creates a new ContainerAssetTask
  155078. * @param name defines the name of the task
  155079. * @param meshesNames defines the list of mesh's names you want to load
  155080. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155081. * @param sceneFilename defines the filename or File of the scene to load from
  155082. */
  155083. constructor(
  155084. /**
  155085. * Defines the name of the task
  155086. */
  155087. name: string,
  155088. /**
  155089. * Defines the list of mesh's names you want to load
  155090. */
  155091. meshesNames: any,
  155092. /**
  155093. * Defines the root url to use as a base to load your meshes and associated resources
  155094. */
  155095. rootUrl: string,
  155096. /**
  155097. * Defines the filename or File of the scene to load from
  155098. */
  155099. sceneFilename: string | File);
  155100. /**
  155101. * Execute the current task
  155102. * @param scene defines the scene where you want your assets to be loaded
  155103. * @param onSuccess is a callback called when the task is successfully executed
  155104. * @param onError is a callback called if an error occurs
  155105. */
  155106. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155107. }
  155108. /**
  155109. * Define a task used by AssetsManager to load meshes
  155110. */
  155111. export class MeshAssetTask extends AbstractAssetTask {
  155112. /**
  155113. * Defines the name of the task
  155114. */
  155115. name: string;
  155116. /**
  155117. * Defines the list of mesh's names you want to load
  155118. */
  155119. meshesNames: any;
  155120. /**
  155121. * Defines the root url to use as a base to load your meshes and associated resources
  155122. */
  155123. rootUrl: string;
  155124. /**
  155125. * Defines the filename or File of the scene to load from
  155126. */
  155127. sceneFilename: string | File;
  155128. /**
  155129. * Gets the list of loaded meshes
  155130. */
  155131. loadedMeshes: Array<AbstractMesh>;
  155132. /**
  155133. * Gets the list of loaded particle systems
  155134. */
  155135. loadedParticleSystems: Array<IParticleSystem>;
  155136. /**
  155137. * Gets the list of loaded skeletons
  155138. */
  155139. loadedSkeletons: Array<Skeleton>;
  155140. /**
  155141. * Gets the list of loaded animation groups
  155142. */
  155143. loadedAnimationGroups: Array<AnimationGroup>;
  155144. /**
  155145. * Callback called when the task is successful
  155146. */
  155147. onSuccess: (task: MeshAssetTask) => void;
  155148. /**
  155149. * Callback called when the task is successful
  155150. */
  155151. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155152. /**
  155153. * Creates a new MeshAssetTask
  155154. * @param name defines the name of the task
  155155. * @param meshesNames defines the list of mesh's names you want to load
  155156. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155157. * @param sceneFilename defines the filename or File of the scene to load from
  155158. */
  155159. constructor(
  155160. /**
  155161. * Defines the name of the task
  155162. */
  155163. name: string,
  155164. /**
  155165. * Defines the list of mesh's names you want to load
  155166. */
  155167. meshesNames: any,
  155168. /**
  155169. * Defines the root url to use as a base to load your meshes and associated resources
  155170. */
  155171. rootUrl: string,
  155172. /**
  155173. * Defines the filename or File of the scene to load from
  155174. */
  155175. sceneFilename: string | File);
  155176. /**
  155177. * Execute the current task
  155178. * @param scene defines the scene where you want your assets to be loaded
  155179. * @param onSuccess is a callback called when the task is successfully executed
  155180. * @param onError is a callback called if an error occurs
  155181. */
  155182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155183. }
  155184. /**
  155185. * Define a task used by AssetsManager to load text content
  155186. */
  155187. export class TextFileAssetTask extends AbstractAssetTask {
  155188. /**
  155189. * Defines the name of the task
  155190. */
  155191. name: string;
  155192. /**
  155193. * Defines the location of the file to load
  155194. */
  155195. url: string;
  155196. /**
  155197. * Gets the loaded text string
  155198. */
  155199. text: string;
  155200. /**
  155201. * Callback called when the task is successful
  155202. */
  155203. onSuccess: (task: TextFileAssetTask) => void;
  155204. /**
  155205. * Callback called when the task is successful
  155206. */
  155207. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155208. /**
  155209. * Creates a new TextFileAssetTask object
  155210. * @param name defines the name of the task
  155211. * @param url defines the location of the file to load
  155212. */
  155213. constructor(
  155214. /**
  155215. * Defines the name of the task
  155216. */
  155217. name: string,
  155218. /**
  155219. * Defines the location of the file to load
  155220. */
  155221. url: string);
  155222. /**
  155223. * Execute the current task
  155224. * @param scene defines the scene where you want your assets to be loaded
  155225. * @param onSuccess is a callback called when the task is successfully executed
  155226. * @param onError is a callback called if an error occurs
  155227. */
  155228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155229. }
  155230. /**
  155231. * Define a task used by AssetsManager to load binary data
  155232. */
  155233. export class BinaryFileAssetTask extends AbstractAssetTask {
  155234. /**
  155235. * Defines the name of the task
  155236. */
  155237. name: string;
  155238. /**
  155239. * Defines the location of the file to load
  155240. */
  155241. url: string;
  155242. /**
  155243. * Gets the lodaded data (as an array buffer)
  155244. */
  155245. data: ArrayBuffer;
  155246. /**
  155247. * Callback called when the task is successful
  155248. */
  155249. onSuccess: (task: BinaryFileAssetTask) => void;
  155250. /**
  155251. * Callback called when the task is successful
  155252. */
  155253. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  155254. /**
  155255. * Creates a new BinaryFileAssetTask object
  155256. * @param name defines the name of the new task
  155257. * @param url defines the location of the file to load
  155258. */
  155259. constructor(
  155260. /**
  155261. * Defines the name of the task
  155262. */
  155263. name: string,
  155264. /**
  155265. * Defines the location of the file to load
  155266. */
  155267. url: string);
  155268. /**
  155269. * Execute the current task
  155270. * @param scene defines the scene where you want your assets to be loaded
  155271. * @param onSuccess is a callback called when the task is successfully executed
  155272. * @param onError is a callback called if an error occurs
  155273. */
  155274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155275. }
  155276. /**
  155277. * Define a task used by AssetsManager to load images
  155278. */
  155279. export class ImageAssetTask extends AbstractAssetTask {
  155280. /**
  155281. * Defines the name of the task
  155282. */
  155283. name: string;
  155284. /**
  155285. * Defines the location of the image to load
  155286. */
  155287. url: string;
  155288. /**
  155289. * Gets the loaded images
  155290. */
  155291. image: HTMLImageElement;
  155292. /**
  155293. * Callback called when the task is successful
  155294. */
  155295. onSuccess: (task: ImageAssetTask) => void;
  155296. /**
  155297. * Callback called when the task is successful
  155298. */
  155299. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  155300. /**
  155301. * Creates a new ImageAssetTask
  155302. * @param name defines the name of the task
  155303. * @param url defines the location of the image to load
  155304. */
  155305. constructor(
  155306. /**
  155307. * Defines the name of the task
  155308. */
  155309. name: string,
  155310. /**
  155311. * Defines the location of the image to load
  155312. */
  155313. url: string);
  155314. /**
  155315. * Execute the current task
  155316. * @param scene defines the scene where you want your assets to be loaded
  155317. * @param onSuccess is a callback called when the task is successfully executed
  155318. * @param onError is a callback called if an error occurs
  155319. */
  155320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155321. }
  155322. /**
  155323. * Defines the interface used by texture loading tasks
  155324. */
  155325. export interface ITextureAssetTask<TEX extends BaseTexture> {
  155326. /**
  155327. * Gets the loaded texture
  155328. */
  155329. texture: TEX;
  155330. }
  155331. /**
  155332. * Define a task used by AssetsManager to load 2D textures
  155333. */
  155334. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  155335. /**
  155336. * Defines the name of the task
  155337. */
  155338. name: string;
  155339. /**
  155340. * Defines the location of the file to load
  155341. */
  155342. url: string;
  155343. /**
  155344. * Defines if mipmap should not be generated (default is false)
  155345. */
  155346. noMipmap?: boolean | undefined;
  155347. /**
  155348. * Defines if texture must be inverted on Y axis (default is true)
  155349. */
  155350. invertY: boolean;
  155351. /**
  155352. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155353. */
  155354. samplingMode: number;
  155355. /**
  155356. * Gets the loaded texture
  155357. */
  155358. texture: Texture;
  155359. /**
  155360. * Callback called when the task is successful
  155361. */
  155362. onSuccess: (task: TextureAssetTask) => void;
  155363. /**
  155364. * Callback called when the task is successful
  155365. */
  155366. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  155367. /**
  155368. * Creates a new TextureAssetTask object
  155369. * @param name defines the name of the task
  155370. * @param url defines the location of the file to load
  155371. * @param noMipmap defines if mipmap should not be generated (default is false)
  155372. * @param invertY defines if texture must be inverted on Y axis (default is true)
  155373. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155374. */
  155375. constructor(
  155376. /**
  155377. * Defines the name of the task
  155378. */
  155379. name: string,
  155380. /**
  155381. * Defines the location of the file to load
  155382. */
  155383. url: string,
  155384. /**
  155385. * Defines if mipmap should not be generated (default is false)
  155386. */
  155387. noMipmap?: boolean | undefined,
  155388. /**
  155389. * Defines if texture must be inverted on Y axis (default is true)
  155390. */
  155391. invertY?: boolean,
  155392. /**
  155393. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155394. */
  155395. samplingMode?: number);
  155396. /**
  155397. * Execute the current task
  155398. * @param scene defines the scene where you want your assets to be loaded
  155399. * @param onSuccess is a callback called when the task is successfully executed
  155400. * @param onError is a callback called if an error occurs
  155401. */
  155402. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155403. }
  155404. /**
  155405. * Define a task used by AssetsManager to load cube textures
  155406. */
  155407. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  155408. /**
  155409. * Defines the name of the task
  155410. */
  155411. name: string;
  155412. /**
  155413. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155414. */
  155415. url: string;
  155416. /**
  155417. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155418. */
  155419. extensions?: string[] | undefined;
  155420. /**
  155421. * Defines if mipmaps should not be generated (default is false)
  155422. */
  155423. noMipmap?: boolean | undefined;
  155424. /**
  155425. * Defines the explicit list of files (undefined by default)
  155426. */
  155427. files?: string[] | undefined;
  155428. /**
  155429. * Gets the loaded texture
  155430. */
  155431. texture: CubeTexture;
  155432. /**
  155433. * Callback called when the task is successful
  155434. */
  155435. onSuccess: (task: CubeTextureAssetTask) => void;
  155436. /**
  155437. * Callback called when the task is successful
  155438. */
  155439. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  155440. /**
  155441. * Creates a new CubeTextureAssetTask
  155442. * @param name defines the name of the task
  155443. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155444. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155445. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155446. * @param files defines the explicit list of files (undefined by default)
  155447. */
  155448. constructor(
  155449. /**
  155450. * Defines the name of the task
  155451. */
  155452. name: string,
  155453. /**
  155454. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155455. */
  155456. url: string,
  155457. /**
  155458. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155459. */
  155460. extensions?: string[] | undefined,
  155461. /**
  155462. * Defines if mipmaps should not be generated (default is false)
  155463. */
  155464. noMipmap?: boolean | undefined,
  155465. /**
  155466. * Defines the explicit list of files (undefined by default)
  155467. */
  155468. files?: string[] | undefined);
  155469. /**
  155470. * Execute the current task
  155471. * @param scene defines the scene where you want your assets to be loaded
  155472. * @param onSuccess is a callback called when the task is successfully executed
  155473. * @param onError is a callback called if an error occurs
  155474. */
  155475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155476. }
  155477. /**
  155478. * Define a task used by AssetsManager to load HDR cube textures
  155479. */
  155480. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  155481. /**
  155482. * Defines the name of the task
  155483. */
  155484. name: string;
  155485. /**
  155486. * Defines the location of the file to load
  155487. */
  155488. url: string;
  155489. /**
  155490. * Defines the desired size (the more it increases the longer the generation will be)
  155491. */
  155492. size: number;
  155493. /**
  155494. * Defines if mipmaps should not be generated (default is false)
  155495. */
  155496. noMipmap: boolean;
  155497. /**
  155498. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155499. */
  155500. generateHarmonics: boolean;
  155501. /**
  155502. * 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)
  155503. */
  155504. gammaSpace: boolean;
  155505. /**
  155506. * Internal Use Only
  155507. */
  155508. reserved: boolean;
  155509. /**
  155510. * Gets the loaded texture
  155511. */
  155512. texture: HDRCubeTexture;
  155513. /**
  155514. * Callback called when the task is successful
  155515. */
  155516. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  155517. /**
  155518. * Callback called when the task is successful
  155519. */
  155520. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  155521. /**
  155522. * Creates a new HDRCubeTextureAssetTask object
  155523. * @param name defines the name of the task
  155524. * @param url defines the location of the file to load
  155525. * @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.
  155526. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155527. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155528. * @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)
  155529. * @param reserved Internal use only
  155530. */
  155531. constructor(
  155532. /**
  155533. * Defines the name of the task
  155534. */
  155535. name: string,
  155536. /**
  155537. * Defines the location of the file to load
  155538. */
  155539. url: string,
  155540. /**
  155541. * Defines the desired size (the more it increases the longer the generation will be)
  155542. */
  155543. size: number,
  155544. /**
  155545. * Defines if mipmaps should not be generated (default is false)
  155546. */
  155547. noMipmap?: boolean,
  155548. /**
  155549. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155550. */
  155551. generateHarmonics?: boolean,
  155552. /**
  155553. * 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)
  155554. */
  155555. gammaSpace?: boolean,
  155556. /**
  155557. * Internal Use Only
  155558. */
  155559. reserved?: boolean);
  155560. /**
  155561. * Execute the current task
  155562. * @param scene defines the scene where you want your assets to be loaded
  155563. * @param onSuccess is a callback called when the task is successfully executed
  155564. * @param onError is a callback called if an error occurs
  155565. */
  155566. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155567. }
  155568. /**
  155569. * Define a task used by AssetsManager to load Equirectangular cube textures
  155570. */
  155571. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  155572. /**
  155573. * Defines the name of the task
  155574. */
  155575. name: string;
  155576. /**
  155577. * Defines the location of the file to load
  155578. */
  155579. url: string;
  155580. /**
  155581. * Defines the desired size (the more it increases the longer the generation will be)
  155582. */
  155583. size: number;
  155584. /**
  155585. * Defines if mipmaps should not be generated (default is false)
  155586. */
  155587. noMipmap: boolean;
  155588. /**
  155589. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155590. * but the standard material would require them in Gamma space) (default is true)
  155591. */
  155592. gammaSpace: boolean;
  155593. /**
  155594. * Gets the loaded texture
  155595. */
  155596. texture: EquiRectangularCubeTexture;
  155597. /**
  155598. * Callback called when the task is successful
  155599. */
  155600. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  155601. /**
  155602. * Callback called when the task is successful
  155603. */
  155604. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  155605. /**
  155606. * Creates a new EquiRectangularCubeTextureAssetTask object
  155607. * @param name defines the name of the task
  155608. * @param url defines the location of the file to load
  155609. * @param size defines the desired size (the more it increases the longer the generation will be)
  155610. * If the size is omitted this implies you are using a preprocessed cubemap.
  155611. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155612. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  155613. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  155614. * (default is true)
  155615. */
  155616. constructor(
  155617. /**
  155618. * Defines the name of the task
  155619. */
  155620. name: string,
  155621. /**
  155622. * Defines the location of the file to load
  155623. */
  155624. url: string,
  155625. /**
  155626. * Defines the desired size (the more it increases the longer the generation will be)
  155627. */
  155628. size: number,
  155629. /**
  155630. * Defines if mipmaps should not be generated (default is false)
  155631. */
  155632. noMipmap?: boolean,
  155633. /**
  155634. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155635. * but the standard material would require them in Gamma space) (default is true)
  155636. */
  155637. gammaSpace?: boolean);
  155638. /**
  155639. * Execute the current task
  155640. * @param scene defines the scene where you want your assets to be loaded
  155641. * @param onSuccess is a callback called when the task is successfully executed
  155642. * @param onError is a callback called if an error occurs
  155643. */
  155644. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155645. }
  155646. /**
  155647. * This class can be used to easily import assets into a scene
  155648. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  155649. */
  155650. export class AssetsManager {
  155651. private _scene;
  155652. private _isLoading;
  155653. protected _tasks: AbstractAssetTask[];
  155654. protected _waitingTasksCount: number;
  155655. protected _totalTasksCount: number;
  155656. /**
  155657. * Callback called when all tasks are processed
  155658. */
  155659. onFinish: (tasks: AbstractAssetTask[]) => void;
  155660. /**
  155661. * Callback called when a task is successful
  155662. */
  155663. onTaskSuccess: (task: AbstractAssetTask) => void;
  155664. /**
  155665. * Callback called when a task had an error
  155666. */
  155667. onTaskError: (task: AbstractAssetTask) => void;
  155668. /**
  155669. * Callback called when a task is done (whatever the result is)
  155670. */
  155671. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  155672. /**
  155673. * Observable called when all tasks are processed
  155674. */
  155675. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  155676. /**
  155677. * Observable called when a task had an error
  155678. */
  155679. onTaskErrorObservable: Observable<AbstractAssetTask>;
  155680. /**
  155681. * Observable called when all tasks were executed
  155682. */
  155683. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  155684. /**
  155685. * Observable called when a task is done (whatever the result is)
  155686. */
  155687. onProgressObservable: Observable<IAssetsProgressEvent>;
  155688. /**
  155689. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  155690. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  155691. */
  155692. useDefaultLoadingScreen: boolean;
  155693. /**
  155694. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  155695. * when all assets have been downloaded.
  155696. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  155697. */
  155698. autoHideLoadingUI: boolean;
  155699. /**
  155700. * Creates a new AssetsManager
  155701. * @param scene defines the scene to work on
  155702. */
  155703. constructor(scene: Scene);
  155704. /**
  155705. * Add a ContainerAssetTask to the list of active tasks
  155706. * @param taskName defines the name of the new task
  155707. * @param meshesNames defines the name of meshes to load
  155708. * @param rootUrl defines the root url to use to locate files
  155709. * @param sceneFilename defines the filename of the scene file
  155710. * @returns a new ContainerAssetTask object
  155711. */
  155712. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  155713. /**
  155714. * Add a MeshAssetTask to the list of active tasks
  155715. * @param taskName defines the name of the new task
  155716. * @param meshesNames defines the name of meshes to load
  155717. * @param rootUrl defines the root url to use to locate files
  155718. * @param sceneFilename defines the filename of the scene file
  155719. * @returns a new MeshAssetTask object
  155720. */
  155721. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  155722. /**
  155723. * Add a TextFileAssetTask to the list of active tasks
  155724. * @param taskName defines the name of the new task
  155725. * @param url defines the url of the file to load
  155726. * @returns a new TextFileAssetTask object
  155727. */
  155728. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  155729. /**
  155730. * Add a BinaryFileAssetTask to the list of active tasks
  155731. * @param taskName defines the name of the new task
  155732. * @param url defines the url of the file to load
  155733. * @returns a new BinaryFileAssetTask object
  155734. */
  155735. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  155736. /**
  155737. * Add a ImageAssetTask to the list of active tasks
  155738. * @param taskName defines the name of the new task
  155739. * @param url defines the url of the file to load
  155740. * @returns a new ImageAssetTask object
  155741. */
  155742. addImageTask(taskName: string, url: string): ImageAssetTask;
  155743. /**
  155744. * Add a TextureAssetTask to the list of active tasks
  155745. * @param taskName defines the name of the new task
  155746. * @param url defines the url of the file to load
  155747. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155748. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  155749. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  155750. * @returns a new TextureAssetTask object
  155751. */
  155752. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  155753. /**
  155754. * Add a CubeTextureAssetTask to the list of active tasks
  155755. * @param taskName defines the name of the new task
  155756. * @param url defines the url of the file to load
  155757. * @param extensions defines the extension to use to load the cube map (can be null)
  155758. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155759. * @param files defines the list of files to load (can be null)
  155760. * @returns a new CubeTextureAssetTask object
  155761. */
  155762. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  155763. /**
  155764. *
  155765. * Add a HDRCubeTextureAssetTask to the list of active tasks
  155766. * @param taskName defines the name of the new task
  155767. * @param url defines the url of the file to load
  155768. * @param size defines the size you want for the cubemap (can be null)
  155769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155770. * @param generateHarmonics defines if you want to automatically generate (true by default)
  155771. * @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)
  155772. * @param reserved Internal use only
  155773. * @returns a new HDRCubeTextureAssetTask object
  155774. */
  155775. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  155776. /**
  155777. *
  155778. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  155779. * @param taskName defines the name of the new task
  155780. * @param url defines the url of the file to load
  155781. * @param size defines the size you want for the cubemap (can be null)
  155782. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155783. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  155784. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  155785. * @returns a new EquiRectangularCubeTextureAssetTask object
  155786. */
  155787. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  155788. /**
  155789. * Remove a task from the assets manager.
  155790. * @param task the task to remove
  155791. */
  155792. removeTask(task: AbstractAssetTask): void;
  155793. private _decreaseWaitingTasksCount;
  155794. private _runTask;
  155795. /**
  155796. * Reset the AssetsManager and remove all tasks
  155797. * @return the current instance of the AssetsManager
  155798. */
  155799. reset(): AssetsManager;
  155800. /**
  155801. * Start the loading process
  155802. * @return the current instance of the AssetsManager
  155803. */
  155804. load(): AssetsManager;
  155805. /**
  155806. * Start the loading process as an async operation
  155807. * @return a promise returning the list of failed tasks
  155808. */
  155809. loadAsync(): Promise<void>;
  155810. }
  155811. }
  155812. declare module BABYLON {
  155813. /**
  155814. * Wrapper class for promise with external resolve and reject.
  155815. */
  155816. export class Deferred<T> {
  155817. /**
  155818. * The promise associated with this deferred object.
  155819. */
  155820. readonly promise: Promise<T>;
  155821. private _resolve;
  155822. private _reject;
  155823. /**
  155824. * The resolve method of the promise associated with this deferred object.
  155825. */
  155826. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  155827. /**
  155828. * The reject method of the promise associated with this deferred object.
  155829. */
  155830. get reject(): (reason?: any) => void;
  155831. /**
  155832. * Constructor for this deferred object.
  155833. */
  155834. constructor();
  155835. }
  155836. }
  155837. declare module BABYLON {
  155838. /**
  155839. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  155840. */
  155841. export class MeshExploder {
  155842. private _centerMesh;
  155843. private _meshes;
  155844. private _meshesOrigins;
  155845. private _toCenterVectors;
  155846. private _scaledDirection;
  155847. private _newPosition;
  155848. private _centerPosition;
  155849. /**
  155850. * Explodes meshes from a center mesh.
  155851. * @param meshes The meshes to explode.
  155852. * @param centerMesh The mesh to be center of explosion.
  155853. */
  155854. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  155855. private _setCenterMesh;
  155856. /**
  155857. * Get class name
  155858. * @returns "MeshExploder"
  155859. */
  155860. getClassName(): string;
  155861. /**
  155862. * "Exploded meshes"
  155863. * @returns Array of meshes with the centerMesh at index 0.
  155864. */
  155865. getMeshes(): Array<Mesh>;
  155866. /**
  155867. * Explodes meshes giving a specific direction
  155868. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  155869. */
  155870. explode(direction?: number): void;
  155871. }
  155872. }
  155873. declare module BABYLON {
  155874. /**
  155875. * Class used to help managing file picking and drag'n'drop
  155876. */
  155877. export class FilesInput {
  155878. /**
  155879. * List of files ready to be loaded
  155880. */
  155881. static get FilesToLoad(): {
  155882. [key: string]: File;
  155883. };
  155884. /**
  155885. * Callback called when a file is processed
  155886. */
  155887. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155888. private _engine;
  155889. private _currentScene;
  155890. private _sceneLoadedCallback;
  155891. private _progressCallback;
  155892. private _additionalRenderLoopLogicCallback;
  155893. private _textureLoadingCallback;
  155894. private _startingProcessingFilesCallback;
  155895. private _onReloadCallback;
  155896. private _errorCallback;
  155897. private _elementToMonitor;
  155898. private _sceneFileToLoad;
  155899. private _filesToLoad;
  155900. /**
  155901. * Creates a new FilesInput
  155902. * @param engine defines the rendering engine
  155903. * @param scene defines the hosting scene
  155904. * @param sceneLoadedCallback callback called when scene is loaded
  155905. * @param progressCallback callback called to track progress
  155906. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155907. * @param textureLoadingCallback callback called when a texture is loading
  155908. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155909. * @param onReloadCallback callback called when a reload is requested
  155910. * @param errorCallback callback call if an error occurs
  155911. */
  155912. 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>);
  155913. private _dragEnterHandler;
  155914. private _dragOverHandler;
  155915. private _dropHandler;
  155916. /**
  155917. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155918. * @param elementToMonitor defines the DOM element to track
  155919. */
  155920. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155921. /** Gets the current list of files to load */
  155922. get filesToLoad(): File[];
  155923. /**
  155924. * Release all associated resources
  155925. */
  155926. dispose(): void;
  155927. private renderFunction;
  155928. private drag;
  155929. private drop;
  155930. private _traverseFolder;
  155931. private _processFiles;
  155932. /**
  155933. * Load files from a drop event
  155934. * @param event defines the drop event to use as source
  155935. */
  155936. loadFiles(event: any): void;
  155937. private _processReload;
  155938. /**
  155939. * Reload the current scene from the loaded files
  155940. */
  155941. reload(): void;
  155942. }
  155943. }
  155944. declare module BABYLON {
  155945. /**
  155946. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155947. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155948. */
  155949. export class SceneOptimization {
  155950. /**
  155951. * Defines the priority of this optimization (0 by default which means first in the list)
  155952. */
  155953. priority: number;
  155954. /**
  155955. * Gets a string describing the action executed by the current optimization
  155956. * @returns description string
  155957. */
  155958. getDescription(): string;
  155959. /**
  155960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155961. * @param scene defines the current scene where to apply this optimization
  155962. * @param optimizer defines the current optimizer
  155963. * @returns true if everything that can be done was applied
  155964. */
  155965. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155966. /**
  155967. * Creates the SceneOptimization object
  155968. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155969. * @param desc defines the description associated with the optimization
  155970. */
  155971. constructor(
  155972. /**
  155973. * Defines the priority of this optimization (0 by default which means first in the list)
  155974. */
  155975. priority?: number);
  155976. }
  155977. /**
  155978. * Defines an optimization used to reduce the size of render target textures
  155979. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155980. */
  155981. export class TextureOptimization extends SceneOptimization {
  155982. /**
  155983. * Defines the priority of this optimization (0 by default which means first in the list)
  155984. */
  155985. priority: number;
  155986. /**
  155987. * 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
  155988. */
  155989. maximumSize: number;
  155990. /**
  155991. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155992. */
  155993. step: number;
  155994. /**
  155995. * Gets a string describing the action executed by the current optimization
  155996. * @returns description string
  155997. */
  155998. getDescription(): string;
  155999. /**
  156000. * Creates the TextureOptimization object
  156001. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156002. * @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
  156003. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156004. */
  156005. constructor(
  156006. /**
  156007. * Defines the priority of this optimization (0 by default which means first in the list)
  156008. */
  156009. priority?: number,
  156010. /**
  156011. * 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
  156012. */
  156013. maximumSize?: number,
  156014. /**
  156015. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156016. */
  156017. step?: number);
  156018. /**
  156019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156020. * @param scene defines the current scene where to apply this optimization
  156021. * @param optimizer defines the current optimizer
  156022. * @returns true if everything that can be done was applied
  156023. */
  156024. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156025. }
  156026. /**
  156027. * Defines an optimization used to increase or decrease the rendering resolution
  156028. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156029. */
  156030. export class HardwareScalingOptimization extends SceneOptimization {
  156031. /**
  156032. * Defines the priority of this optimization (0 by default which means first in the list)
  156033. */
  156034. priority: number;
  156035. /**
  156036. * Defines the maximum scale to use (2 by default)
  156037. */
  156038. maximumScale: number;
  156039. /**
  156040. * Defines the step to use between two passes (0.5 by default)
  156041. */
  156042. step: number;
  156043. private _currentScale;
  156044. private _directionOffset;
  156045. /**
  156046. * Gets a string describing the action executed by the current optimization
  156047. * @return description string
  156048. */
  156049. getDescription(): string;
  156050. /**
  156051. * Creates the HardwareScalingOptimization object
  156052. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156053. * @param maximumScale defines the maximum scale to use (2 by default)
  156054. * @param step defines the step to use between two passes (0.5 by default)
  156055. */
  156056. constructor(
  156057. /**
  156058. * Defines the priority of this optimization (0 by default which means first in the list)
  156059. */
  156060. priority?: number,
  156061. /**
  156062. * Defines the maximum scale to use (2 by default)
  156063. */
  156064. maximumScale?: number,
  156065. /**
  156066. * Defines the step to use between two passes (0.5 by default)
  156067. */
  156068. step?: number);
  156069. /**
  156070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156071. * @param scene defines the current scene where to apply this optimization
  156072. * @param optimizer defines the current optimizer
  156073. * @returns true if everything that can be done was applied
  156074. */
  156075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156076. }
  156077. /**
  156078. * Defines an optimization used to remove shadows
  156079. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156080. */
  156081. export class ShadowsOptimization extends SceneOptimization {
  156082. /**
  156083. * Gets a string describing the action executed by the current optimization
  156084. * @return description string
  156085. */
  156086. getDescription(): string;
  156087. /**
  156088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156089. * @param scene defines the current scene where to apply this optimization
  156090. * @param optimizer defines the current optimizer
  156091. * @returns true if everything that can be done was applied
  156092. */
  156093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156094. }
  156095. /**
  156096. * Defines an optimization used to turn post-processes off
  156097. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156098. */
  156099. export class PostProcessesOptimization extends SceneOptimization {
  156100. /**
  156101. * Gets a string describing the action executed by the current optimization
  156102. * @return description string
  156103. */
  156104. getDescription(): string;
  156105. /**
  156106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156107. * @param scene defines the current scene where to apply this optimization
  156108. * @param optimizer defines the current optimizer
  156109. * @returns true if everything that can be done was applied
  156110. */
  156111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156112. }
  156113. /**
  156114. * Defines an optimization used to turn lens flares off
  156115. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156116. */
  156117. export class LensFlaresOptimization extends SceneOptimization {
  156118. /**
  156119. * Gets a string describing the action executed by the current optimization
  156120. * @return description string
  156121. */
  156122. getDescription(): string;
  156123. /**
  156124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156125. * @param scene defines the current scene where to apply this optimization
  156126. * @param optimizer defines the current optimizer
  156127. * @returns true if everything that can be done was applied
  156128. */
  156129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156130. }
  156131. /**
  156132. * Defines an optimization based on user defined callback.
  156133. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156134. */
  156135. export class CustomOptimization extends SceneOptimization {
  156136. /**
  156137. * Callback called to apply the custom optimization.
  156138. */
  156139. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156140. /**
  156141. * Callback called to get custom description
  156142. */
  156143. onGetDescription: () => string;
  156144. /**
  156145. * Gets a string describing the action executed by the current optimization
  156146. * @returns description string
  156147. */
  156148. getDescription(): string;
  156149. /**
  156150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156151. * @param scene defines the current scene where to apply this optimization
  156152. * @param optimizer defines the current optimizer
  156153. * @returns true if everything that can be done was applied
  156154. */
  156155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156156. }
  156157. /**
  156158. * Defines an optimization used to turn particles off
  156159. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156160. */
  156161. export class ParticlesOptimization extends SceneOptimization {
  156162. /**
  156163. * Gets a string describing the action executed by the current optimization
  156164. * @return description string
  156165. */
  156166. getDescription(): string;
  156167. /**
  156168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156169. * @param scene defines the current scene where to apply this optimization
  156170. * @param optimizer defines the current optimizer
  156171. * @returns true if everything that can be done was applied
  156172. */
  156173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156174. }
  156175. /**
  156176. * Defines an optimization used to turn render targets off
  156177. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156178. */
  156179. export class RenderTargetsOptimization extends SceneOptimization {
  156180. /**
  156181. * Gets a string describing the action executed by the current optimization
  156182. * @return description string
  156183. */
  156184. getDescription(): string;
  156185. /**
  156186. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156187. * @param scene defines the current scene where to apply this optimization
  156188. * @param optimizer defines the current optimizer
  156189. * @returns true if everything that can be done was applied
  156190. */
  156191. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156192. }
  156193. /**
  156194. * Defines an optimization used to merge meshes with compatible materials
  156195. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156196. */
  156197. export class MergeMeshesOptimization extends SceneOptimization {
  156198. private static _UpdateSelectionTree;
  156199. /**
  156200. * Gets or sets a boolean which defines if optimization octree has to be updated
  156201. */
  156202. static get UpdateSelectionTree(): boolean;
  156203. /**
  156204. * Gets or sets a boolean which defines if optimization octree has to be updated
  156205. */
  156206. static set UpdateSelectionTree(value: boolean);
  156207. /**
  156208. * Gets a string describing the action executed by the current optimization
  156209. * @return description string
  156210. */
  156211. getDescription(): string;
  156212. private _canBeMerged;
  156213. /**
  156214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156215. * @param scene defines the current scene where to apply this optimization
  156216. * @param optimizer defines the current optimizer
  156217. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156218. * @returns true if everything that can be done was applied
  156219. */
  156220. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156221. }
  156222. /**
  156223. * Defines a list of options used by SceneOptimizer
  156224. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156225. */
  156226. export class SceneOptimizerOptions {
  156227. /**
  156228. * Defines the target frame rate to reach (60 by default)
  156229. */
  156230. targetFrameRate: number;
  156231. /**
  156232. * Defines the interval between two checkes (2000ms by default)
  156233. */
  156234. trackerDuration: number;
  156235. /**
  156236. * Gets the list of optimizations to apply
  156237. */
  156238. optimizations: SceneOptimization[];
  156239. /**
  156240. * Creates a new list of options used by SceneOptimizer
  156241. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  156242. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  156243. */
  156244. constructor(
  156245. /**
  156246. * Defines the target frame rate to reach (60 by default)
  156247. */
  156248. targetFrameRate?: number,
  156249. /**
  156250. * Defines the interval between two checkes (2000ms by default)
  156251. */
  156252. trackerDuration?: number);
  156253. /**
  156254. * Add a new optimization
  156255. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  156256. * @returns the current SceneOptimizerOptions
  156257. */
  156258. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  156259. /**
  156260. * Add a new custom optimization
  156261. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  156262. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  156263. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156264. * @returns the current SceneOptimizerOptions
  156265. */
  156266. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  156267. /**
  156268. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  156269. * @param targetFrameRate defines the target frame rate (60 by default)
  156270. * @returns a SceneOptimizerOptions object
  156271. */
  156272. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156273. /**
  156274. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  156275. * @param targetFrameRate defines the target frame rate (60 by default)
  156276. * @returns a SceneOptimizerOptions object
  156277. */
  156278. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156279. /**
  156280. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  156281. * @param targetFrameRate defines the target frame rate (60 by default)
  156282. * @returns a SceneOptimizerOptions object
  156283. */
  156284. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156285. }
  156286. /**
  156287. * Class used to run optimizations in order to reach a target frame rate
  156288. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156289. */
  156290. export class SceneOptimizer implements IDisposable {
  156291. private _isRunning;
  156292. private _options;
  156293. private _scene;
  156294. private _currentPriorityLevel;
  156295. private _targetFrameRate;
  156296. private _trackerDuration;
  156297. private _currentFrameRate;
  156298. private _sceneDisposeObserver;
  156299. private _improvementMode;
  156300. /**
  156301. * Defines an observable called when the optimizer reaches the target frame rate
  156302. */
  156303. onSuccessObservable: Observable<SceneOptimizer>;
  156304. /**
  156305. * Defines an observable called when the optimizer enables an optimization
  156306. */
  156307. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  156308. /**
  156309. * Defines an observable called when the optimizer is not able to reach the target frame rate
  156310. */
  156311. onFailureObservable: Observable<SceneOptimizer>;
  156312. /**
  156313. * Gets a boolean indicating if the optimizer is in improvement mode
  156314. */
  156315. get isInImprovementMode(): boolean;
  156316. /**
  156317. * Gets the current priority level (0 at start)
  156318. */
  156319. get currentPriorityLevel(): number;
  156320. /**
  156321. * Gets the current frame rate checked by the SceneOptimizer
  156322. */
  156323. get currentFrameRate(): number;
  156324. /**
  156325. * Gets or sets the current target frame rate (60 by default)
  156326. */
  156327. get targetFrameRate(): number;
  156328. /**
  156329. * Gets or sets the current target frame rate (60 by default)
  156330. */
  156331. set targetFrameRate(value: number);
  156332. /**
  156333. * Gets or sets the current interval between two checks (every 2000ms by default)
  156334. */
  156335. get trackerDuration(): number;
  156336. /**
  156337. * Gets or sets the current interval between two checks (every 2000ms by default)
  156338. */
  156339. set trackerDuration(value: number);
  156340. /**
  156341. * Gets the list of active optimizations
  156342. */
  156343. get optimizations(): SceneOptimization[];
  156344. /**
  156345. * Creates a new SceneOptimizer
  156346. * @param scene defines the scene to work on
  156347. * @param options defines the options to use with the SceneOptimizer
  156348. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  156349. * @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)
  156350. */
  156351. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  156352. /**
  156353. * Stops the current optimizer
  156354. */
  156355. stop(): void;
  156356. /**
  156357. * Reset the optimizer to initial step (current priority level = 0)
  156358. */
  156359. reset(): void;
  156360. /**
  156361. * Start the optimizer. By default it will try to reach a specific framerate
  156362. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  156363. */
  156364. start(): void;
  156365. private _checkCurrentState;
  156366. /**
  156367. * Release all resources
  156368. */
  156369. dispose(): void;
  156370. /**
  156371. * Helper function to create a SceneOptimizer with one single line of code
  156372. * @param scene defines the scene to work on
  156373. * @param options defines the options to use with the SceneOptimizer
  156374. * @param onSuccess defines a callback to call on success
  156375. * @param onFailure defines a callback to call on failure
  156376. * @returns the new SceneOptimizer object
  156377. */
  156378. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  156379. }
  156380. }
  156381. declare module BABYLON {
  156382. /**
  156383. * Class used to serialize a scene into a string
  156384. */
  156385. export class SceneSerializer {
  156386. /**
  156387. * Clear cache used by a previous serialization
  156388. */
  156389. static ClearCache(): void;
  156390. /**
  156391. * Serialize a scene into a JSON compatible object
  156392. * @param scene defines the scene to serialize
  156393. * @returns a JSON compatible object
  156394. */
  156395. static Serialize(scene: Scene): any;
  156396. /**
  156397. * Serialize a mesh into a JSON compatible object
  156398. * @param toSerialize defines the mesh to serialize
  156399. * @param withParents defines if parents must be serialized as well
  156400. * @param withChildren defines if children must be serialized as well
  156401. * @returns a JSON compatible object
  156402. */
  156403. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  156404. }
  156405. }
  156406. declare module BABYLON {
  156407. /**
  156408. * Class used to host texture specific utilities
  156409. */
  156410. export class TextureTools {
  156411. /**
  156412. * Uses the GPU to create a copy texture rescaled at a given size
  156413. * @param texture Texture to copy from
  156414. * @param width defines the desired width
  156415. * @param height defines the desired height
  156416. * @param useBilinearMode defines if bilinear mode has to be used
  156417. * @return the generated texture
  156418. */
  156419. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  156420. }
  156421. }
  156422. declare module BABYLON {
  156423. /**
  156424. * This represents the different options available for the video capture.
  156425. */
  156426. export interface VideoRecorderOptions {
  156427. /** Defines the mime type of the video. */
  156428. mimeType: string;
  156429. /** Defines the FPS the video should be recorded at. */
  156430. fps: number;
  156431. /** Defines the chunk size for the recording data. */
  156432. recordChunckSize: number;
  156433. /** The audio tracks to attach to the recording. */
  156434. audioTracks?: MediaStreamTrack[];
  156435. }
  156436. /**
  156437. * This can help with recording videos from BabylonJS.
  156438. * This is based on the available WebRTC functionalities of the browser.
  156439. *
  156440. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  156441. */
  156442. export class VideoRecorder {
  156443. private static readonly _defaultOptions;
  156444. /**
  156445. * Returns whether or not the VideoRecorder is available in your browser.
  156446. * @param engine Defines the Babylon Engine.
  156447. * @returns true if supported otherwise false.
  156448. */
  156449. static IsSupported(engine: Engine): boolean;
  156450. private readonly _options;
  156451. private _canvas;
  156452. private _mediaRecorder;
  156453. private _recordedChunks;
  156454. private _fileName;
  156455. private _resolve;
  156456. private _reject;
  156457. /**
  156458. * True when a recording is already in progress.
  156459. */
  156460. get isRecording(): boolean;
  156461. /**
  156462. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  156463. * @param engine Defines the BabylonJS Engine you wish to record.
  156464. * @param options Defines options that can be used to customize the capture.
  156465. */
  156466. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  156467. /**
  156468. * Stops the current recording before the default capture timeout passed in the startRecording function.
  156469. */
  156470. stopRecording(): void;
  156471. /**
  156472. * Starts recording the canvas for a max duration specified in parameters.
  156473. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  156474. * If null no automatic download will start and you can rely on the promise to get the data back.
  156475. * @param maxDuration Defines the maximum recording time in seconds.
  156476. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  156477. * @return A promise callback at the end of the recording with the video data in Blob.
  156478. */
  156479. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  156480. /**
  156481. * Releases internal resources used during the recording.
  156482. */
  156483. dispose(): void;
  156484. private _handleDataAvailable;
  156485. private _handleError;
  156486. private _handleStop;
  156487. }
  156488. }
  156489. declare module BABYLON {
  156490. /**
  156491. * Class containing a set of static utilities functions for screenshots
  156492. */
  156493. export class ScreenshotTools {
  156494. /**
  156495. * Captures a screenshot of the current rendering
  156496. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156497. * @param engine defines the rendering engine
  156498. * @param camera defines the source camera
  156499. * @param size This parameter can be set to a single number or to an object with the
  156500. * following (optional) properties: precision, width, height. If a single number is passed,
  156501. * it will be used for both width and height. If an object is passed, the screenshot size
  156502. * will be derived from the parameters. The precision property is a multiplier allowing
  156503. * rendering at a higher or lower resolution
  156504. * @param successCallback defines the callback receives a single parameter which contains the
  156505. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156506. * src parameter of an <img> to display it
  156507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156508. * Check your browser for supported MIME types
  156509. */
  156510. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  156511. /**
  156512. * Captures a screenshot of the current rendering
  156513. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156514. * @param engine defines the rendering engine
  156515. * @param camera defines the source camera
  156516. * @param size This parameter can be set to a single number or to an object with the
  156517. * following (optional) properties: precision, width, height. If a single number is passed,
  156518. * it will be used for both width and height. If an object is passed, the screenshot size
  156519. * will be derived from the parameters. The precision property is a multiplier allowing
  156520. * rendering at a higher or lower resolution
  156521. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156522. * Check your browser for supported MIME types
  156523. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156524. * to the src parameter of an <img> to display it
  156525. */
  156526. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  156527. /**
  156528. * Generates an image screenshot from the specified camera.
  156529. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156530. * @param engine The engine to use for rendering
  156531. * @param camera The camera to use for rendering
  156532. * @param size This parameter can be set to a single number or to an object with the
  156533. * following (optional) properties: precision, width, height. If a single number is passed,
  156534. * it will be used for both width and height. If an object is passed, the screenshot size
  156535. * will be derived from the parameters. The precision property is a multiplier allowing
  156536. * rendering at a higher or lower resolution
  156537. * @param successCallback The callback receives a single parameter which contains the
  156538. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156539. * src parameter of an <img> to display it
  156540. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156541. * Check your browser for supported MIME types
  156542. * @param samples Texture samples (default: 1)
  156543. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156544. * @param fileName A name for for the downloaded file.
  156545. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156546. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  156547. */
  156548. 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;
  156549. /**
  156550. * Generates an image screenshot from the specified camera.
  156551. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156552. * @param engine The engine to use for rendering
  156553. * @param camera The camera to use for rendering
  156554. * @param size This parameter can be set to a single number or to an object with the
  156555. * following (optional) properties: precision, width, height. If a single number is passed,
  156556. * it will be used for both width and height. If an object is passed, the screenshot size
  156557. * will be derived from the parameters. The precision property is a multiplier allowing
  156558. * rendering at a higher or lower resolution
  156559. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156560. * Check your browser for supported MIME types
  156561. * @param samples Texture samples (default: 1)
  156562. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156563. * @param fileName A name for for the downloaded file.
  156564. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156565. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156566. * to the src parameter of an <img> to display it
  156567. */
  156568. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  156569. /**
  156570. * Gets height and width for screenshot size
  156571. * @private
  156572. */
  156573. private static _getScreenshotSize;
  156574. }
  156575. }
  156576. declare module BABYLON {
  156577. /**
  156578. * Interface for a data buffer
  156579. */
  156580. export interface IDataBuffer {
  156581. /**
  156582. * Reads bytes from the data buffer.
  156583. * @param byteOffset The byte offset to read
  156584. * @param byteLength The byte length to read
  156585. * @returns A promise that resolves when the bytes are read
  156586. */
  156587. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  156588. /**
  156589. * The byte length of the buffer.
  156590. */
  156591. readonly byteLength: number;
  156592. }
  156593. /**
  156594. * Utility class for reading from a data buffer
  156595. */
  156596. export class DataReader {
  156597. /**
  156598. * The data buffer associated with this data reader.
  156599. */
  156600. readonly buffer: IDataBuffer;
  156601. /**
  156602. * The current byte offset from the beginning of the data buffer.
  156603. */
  156604. byteOffset: number;
  156605. private _dataView;
  156606. private _dataByteOffset;
  156607. /**
  156608. * Constructor
  156609. * @param buffer The buffer to read
  156610. */
  156611. constructor(buffer: IDataBuffer);
  156612. /**
  156613. * Loads the given byte length.
  156614. * @param byteLength The byte length to load
  156615. * @returns A promise that resolves when the load is complete
  156616. */
  156617. loadAsync(byteLength: number): Promise<void>;
  156618. /**
  156619. * Read a unsigned 32-bit integer from the currently loaded data range.
  156620. * @returns The 32-bit integer read
  156621. */
  156622. readUint32(): number;
  156623. /**
  156624. * Read a byte array from the currently loaded data range.
  156625. * @param byteLength The byte length to read
  156626. * @returns The byte array read
  156627. */
  156628. readUint8Array(byteLength: number): Uint8Array;
  156629. /**
  156630. * Read a string from the currently loaded data range.
  156631. * @param byteLength The byte length to read
  156632. * @returns The string read
  156633. */
  156634. readString(byteLength: number): string;
  156635. /**
  156636. * Skips the given byte length the currently loaded data range.
  156637. * @param byteLength The byte length to skip
  156638. */
  156639. skipBytes(byteLength: number): void;
  156640. }
  156641. }
  156642. declare module BABYLON {
  156643. /**
  156644. * Class for storing data to local storage if available or in-memory storage otherwise
  156645. */
  156646. export class DataStorage {
  156647. private static _Storage;
  156648. private static _GetStorage;
  156649. /**
  156650. * Reads a string from the data storage
  156651. * @param key The key to read
  156652. * @param defaultValue The value if the key doesn't exist
  156653. * @returns The string value
  156654. */
  156655. static ReadString(key: string, defaultValue: string): string;
  156656. /**
  156657. * Writes a string to the data storage
  156658. * @param key The key to write
  156659. * @param value The value to write
  156660. */
  156661. static WriteString(key: string, value: string): void;
  156662. /**
  156663. * Reads a boolean from the data storage
  156664. * @param key The key to read
  156665. * @param defaultValue The value if the key doesn't exist
  156666. * @returns The boolean value
  156667. */
  156668. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  156669. /**
  156670. * Writes a boolean to the data storage
  156671. * @param key The key to write
  156672. * @param value The value to write
  156673. */
  156674. static WriteBoolean(key: string, value: boolean): void;
  156675. /**
  156676. * Reads a number from the data storage
  156677. * @param key The key to read
  156678. * @param defaultValue The value if the key doesn't exist
  156679. * @returns The number value
  156680. */
  156681. static ReadNumber(key: string, defaultValue: number): number;
  156682. /**
  156683. * Writes a number to the data storage
  156684. * @param key The key to write
  156685. * @param value The value to write
  156686. */
  156687. static WriteNumber(key: string, value: number): void;
  156688. }
  156689. }
  156690. declare module BABYLON {
  156691. /**
  156692. * Class used to record delta files between 2 scene states
  156693. */
  156694. export class SceneRecorder {
  156695. private _trackedScene;
  156696. private _savedJSON;
  156697. /**
  156698. * Track a given scene. This means the current scene state will be considered the original state
  156699. * @param scene defines the scene to track
  156700. */
  156701. track(scene: Scene): void;
  156702. /**
  156703. * Get the delta between current state and original state
  156704. * @returns a string containing the delta
  156705. */
  156706. getDelta(): any;
  156707. private _compareArray;
  156708. private _compareObjects;
  156709. private _compareCollections;
  156710. private static GetShadowGeneratorById;
  156711. /**
  156712. * Apply a given delta to a given scene
  156713. * @param deltaJSON defines the JSON containing the delta
  156714. * @param scene defines the scene to apply the delta to
  156715. */
  156716. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  156717. private static _ApplyPropertiesToEntity;
  156718. private static _ApplyDeltaForEntity;
  156719. }
  156720. }
  156721. declare module BABYLON {
  156722. /**
  156723. * A 3D trajectory consisting of an order list of vectors describing a
  156724. * path of motion through 3D space.
  156725. */
  156726. export class Trajectory {
  156727. private _points;
  156728. private readonly _segmentLength;
  156729. /**
  156730. * Serialize to JSON.
  156731. * @returns serialized JSON string
  156732. */
  156733. serialize(): string;
  156734. /**
  156735. * Deserialize from JSON.
  156736. * @param json serialized JSON string
  156737. * @returns deserialized Trajectory
  156738. */
  156739. static Deserialize(json: string): Trajectory;
  156740. /**
  156741. * Create a new empty Trajectory.
  156742. * @param segmentLength radius of discretization for Trajectory points
  156743. */
  156744. constructor(segmentLength?: number);
  156745. /**
  156746. * Get the length of the Trajectory.
  156747. * @returns length of the Trajectory
  156748. */
  156749. getLength(): number;
  156750. /**
  156751. * Append a new point to the Trajectory.
  156752. * NOTE: This implementation has many allocations.
  156753. * @param point point to append to the Trajectory
  156754. */
  156755. add(point: DeepImmutable<Vector3>): void;
  156756. /**
  156757. * Create a new Trajectory with a segment length chosen to make it
  156758. * probable that the new Trajectory will have a specified number of
  156759. * segments. This operation is imprecise.
  156760. * @param targetResolution number of segments desired
  156761. * @returns new Trajectory with approximately the requested number of segments
  156762. */
  156763. resampleAtTargetResolution(targetResolution: number): Trajectory;
  156764. /**
  156765. * Convert Trajectory segments into tokenized representation. This
  156766. * representation is an array of numbers where each nth number is the
  156767. * index of the token which is most similar to the nth segment of the
  156768. * Trajectory.
  156769. * @param tokens list of vectors which serve as discrete tokens
  156770. * @returns list of indices of most similar token per segment
  156771. */
  156772. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  156773. private static _forwardDir;
  156774. private static _inverseFromVec;
  156775. private static _upDir;
  156776. private static _fromToVec;
  156777. private static _lookMatrix;
  156778. /**
  156779. * Transform the rotation (i.e., direction) of a segment to isolate
  156780. * the relative transformation represented by the segment. This operation
  156781. * may or may not succeed due to singularities in the equations that define
  156782. * motion relativity in this context.
  156783. * @param priorVec the origin of the prior segment
  156784. * @param fromVec the origin of the current segment
  156785. * @param toVec the destination of the current segment
  156786. * @param result reference to output variable
  156787. * @returns whether or not transformation was successful
  156788. */
  156789. private static _transformSegmentDirToRef;
  156790. private static _bestMatch;
  156791. private static _score;
  156792. private static _bestScore;
  156793. /**
  156794. * Determine which token vector is most similar to the
  156795. * segment vector.
  156796. * @param segment segment vector
  156797. * @param tokens token vector list
  156798. * @returns index of the most similar token to the segment
  156799. */
  156800. private static _tokenizeSegment;
  156801. }
  156802. /**
  156803. * Class representing a set of known, named trajectories to which Trajectories can be
  156804. * added and using which Trajectories can be recognized.
  156805. */
  156806. export class TrajectoryClassifier {
  156807. private _maximumAllowableMatchCost;
  156808. private _vector3Alphabet;
  156809. private _levenshteinAlphabet;
  156810. private _nameToDescribedTrajectory;
  156811. /**
  156812. * Serialize to JSON.
  156813. * @returns JSON serialization
  156814. */
  156815. serialize(): string;
  156816. /**
  156817. * Deserialize from JSON.
  156818. * @param json JSON serialization
  156819. * @returns deserialized TrajectorySet
  156820. */
  156821. static Deserialize(json: string): TrajectoryClassifier;
  156822. /**
  156823. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  156824. * VERY naive, need to be generating these things from known
  156825. * sets. Better version later, probably eliminating this one.
  156826. * @returns auto-generated TrajectorySet
  156827. */
  156828. static Generate(): TrajectoryClassifier;
  156829. private constructor();
  156830. /**
  156831. * Add a new Trajectory to the set with a given name.
  156832. * @param trajectory new Trajectory to be added
  156833. * @param classification name to which to add the Trajectory
  156834. */
  156835. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  156836. /**
  156837. * Remove a known named trajectory and all Trajectories associated with it.
  156838. * @param classification name to remove
  156839. * @returns whether anything was removed
  156840. */
  156841. deleteClassification(classification: string): boolean;
  156842. /**
  156843. * Attempt to recognize a Trajectory from among all the classifications
  156844. * already known to the classifier.
  156845. * @param trajectory Trajectory to be recognized
  156846. * @returns classification of Trajectory if recognized, null otherwise
  156847. */
  156848. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  156849. }
  156850. }
  156851. declare module BABYLON {
  156852. /**
  156853. * An interface for all Hit test features
  156854. */
  156855. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  156856. /**
  156857. * Triggered when new babylon (transformed) hit test results are available
  156858. */
  156859. onHitTestResultObservable: Observable<T[]>;
  156860. }
  156861. /**
  156862. * Options used for hit testing
  156863. */
  156864. export interface IWebXRLegacyHitTestOptions {
  156865. /**
  156866. * Only test when user interacted with the scene. Default - hit test every frame
  156867. */
  156868. testOnPointerDownOnly?: boolean;
  156869. /**
  156870. * The node to use to transform the local results to world coordinates
  156871. */
  156872. worldParentNode?: TransformNode;
  156873. }
  156874. /**
  156875. * Interface defining the babylon result of raycasting/hit-test
  156876. */
  156877. export interface IWebXRLegacyHitResult {
  156878. /**
  156879. * Transformation matrix that can be applied to a node that will put it in the hit point location
  156880. */
  156881. transformationMatrix: Matrix;
  156882. /**
  156883. * The native hit test result
  156884. */
  156885. xrHitResult: XRHitResult | XRHitTestResult;
  156886. }
  156887. /**
  156888. * The currently-working hit-test module.
  156889. * Hit test (or Ray-casting) is used to interact with the real world.
  156890. * For further information read here - https://github.com/immersive-web/hit-test
  156891. */
  156892. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156893. /**
  156894. * options to use when constructing this feature
  156895. */
  156896. readonly options: IWebXRLegacyHitTestOptions;
  156897. private _direction;
  156898. private _mat;
  156899. private _onSelectEnabled;
  156900. private _origin;
  156901. /**
  156902. * The module's name
  156903. */
  156904. static readonly Name: string;
  156905. /**
  156906. * The (Babylon) version of this module.
  156907. * This is an integer representing the implementation version.
  156908. * This number does not correspond to the WebXR specs version
  156909. */
  156910. static readonly Version: number;
  156911. /**
  156912. * Populated with the last native XR Hit Results
  156913. */
  156914. lastNativeXRHitResults: XRHitResult[];
  156915. /**
  156916. * Triggered when new babylon (transformed) hit test results are available
  156917. */
  156918. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156919. /**
  156920. * Creates a new instance of the (legacy version) hit test feature
  156921. * @param _xrSessionManager an instance of WebXRSessionManager
  156922. * @param options options to use when constructing this feature
  156923. */
  156924. constructor(_xrSessionManager: WebXRSessionManager,
  156925. /**
  156926. * options to use when constructing this feature
  156927. */
  156928. options?: IWebXRLegacyHitTestOptions);
  156929. /**
  156930. * execute a hit test with an XR Ray
  156931. *
  156932. * @param xrSession a native xrSession that will execute this hit test
  156933. * @param xrRay the ray (position and direction) to use for ray-casting
  156934. * @param referenceSpace native XR reference space to use for the hit-test
  156935. * @param filter filter function that will filter the results
  156936. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156937. */
  156938. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156939. /**
  156940. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156941. * @param event the (select) event to use to select with
  156942. * @param referenceSpace the reference space to use for this hit test
  156943. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156944. */
  156945. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  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 _onHitTestResults;
  156966. private _onSelect;
  156967. }
  156968. }
  156969. declare module BABYLON {
  156970. /**
  156971. * Options used for hit testing (version 2)
  156972. */
  156973. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156974. /**
  156975. * Do not create a permanent hit test. Will usually be used when only
  156976. * transient inputs are needed.
  156977. */
  156978. disablePermanentHitTest?: boolean;
  156979. /**
  156980. * Enable transient (for example touch-based) hit test inspections
  156981. */
  156982. enableTransientHitTest?: boolean;
  156983. /**
  156984. * Offset ray for the permanent hit test
  156985. */
  156986. offsetRay?: Vector3;
  156987. /**
  156988. * Offset ray for the transient hit test
  156989. */
  156990. transientOffsetRay?: Vector3;
  156991. /**
  156992. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156993. */
  156994. useReferenceSpace?: boolean;
  156995. /**
  156996. * Override the default entity type(s) of the hit-test result
  156997. */
  156998. entityTypes?: XRHitTestTrackableType[];
  156999. }
  157000. /**
  157001. * Interface defining the babylon result of hit-test
  157002. */
  157003. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  157004. /**
  157005. * The input source that generated this hit test (if transient)
  157006. */
  157007. inputSource?: XRInputSource;
  157008. /**
  157009. * Is this a transient hit test
  157010. */
  157011. isTransient?: boolean;
  157012. /**
  157013. * Position of the hit test result
  157014. */
  157015. position: Vector3;
  157016. /**
  157017. * Rotation of the hit test result
  157018. */
  157019. rotationQuaternion: Quaternion;
  157020. /**
  157021. * The native hit test result
  157022. */
  157023. xrHitResult: XRHitTestResult;
  157024. }
  157025. /**
  157026. * The currently-working hit-test module.
  157027. * Hit test (or Ray-casting) is used to interact with the real world.
  157028. * For further information read here - https://github.com/immersive-web/hit-test
  157029. *
  157030. * Tested on chrome (mobile) 80.
  157031. */
  157032. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157033. /**
  157034. * options to use when constructing this feature
  157035. */
  157036. readonly options: IWebXRHitTestOptions;
  157037. private _tmpMat;
  157038. private _tmpPos;
  157039. private _tmpQuat;
  157040. private _transientXrHitTestSource;
  157041. private _xrHitTestSource;
  157042. private initHitTestSource;
  157043. /**
  157044. * The module's name
  157045. */
  157046. static readonly Name: string;
  157047. /**
  157048. * The (Babylon) version of this module.
  157049. * This is an integer representing the implementation version.
  157050. * This number does not correspond to the WebXR specs version
  157051. */
  157052. static readonly Version: number;
  157053. /**
  157054. * When set to true, each hit test will have its own position/rotation objects
  157055. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157056. * the developers will clone them or copy them as they see fit.
  157057. */
  157058. autoCloneTransformation: boolean;
  157059. /**
  157060. * Triggered when new babylon (transformed) hit test results are available
  157061. * Note - this will be called when results come back from the device. It can be an empty array!!
  157062. */
  157063. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157064. /**
  157065. * Use this to temporarily pause hit test checks.
  157066. */
  157067. paused: boolean;
  157068. /**
  157069. * Creates a new instance of the hit test feature
  157070. * @param _xrSessionManager an instance of WebXRSessionManager
  157071. * @param options options to use when constructing this feature
  157072. */
  157073. constructor(_xrSessionManager: WebXRSessionManager,
  157074. /**
  157075. * options to use when constructing this feature
  157076. */
  157077. options?: IWebXRHitTestOptions);
  157078. /**
  157079. * attach this feature
  157080. * Will usually be called by the features manager
  157081. *
  157082. * @returns true if successful.
  157083. */
  157084. attach(): boolean;
  157085. /**
  157086. * detach this feature.
  157087. * Will usually be called by the features manager
  157088. *
  157089. * @returns true if successful.
  157090. */
  157091. detach(): boolean;
  157092. /**
  157093. * Dispose this feature and all of the resources attached
  157094. */
  157095. dispose(): void;
  157096. protected _onXRFrame(frame: XRFrame): void;
  157097. private _processWebXRHitTestResult;
  157098. }
  157099. }
  157100. declare module BABYLON {
  157101. /**
  157102. * Configuration options of the anchor system
  157103. */
  157104. export interface IWebXRAnchorSystemOptions {
  157105. /**
  157106. * a node that will be used to convert local to world coordinates
  157107. */
  157108. worldParentNode?: TransformNode;
  157109. /**
  157110. * If set to true a reference of the created anchors will be kept until the next session starts
  157111. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157112. */
  157113. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157114. }
  157115. /**
  157116. * A babylon container for an XR Anchor
  157117. */
  157118. export interface IWebXRAnchor {
  157119. /**
  157120. * A babylon-assigned ID for this anchor
  157121. */
  157122. id: number;
  157123. /**
  157124. * Transformation matrix to apply to an object attached to this anchor
  157125. */
  157126. transformationMatrix: Matrix;
  157127. /**
  157128. * The native anchor object
  157129. */
  157130. xrAnchor: XRAnchor;
  157131. /**
  157132. * if defined, this object will be constantly updated by the anchor's position and rotation
  157133. */
  157134. attachedNode?: TransformNode;
  157135. }
  157136. /**
  157137. * An implementation of the anchor system for WebXR.
  157138. * For further information see https://github.com/immersive-web/anchors/
  157139. */
  157140. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157141. private _options;
  157142. private _lastFrameDetected;
  157143. private _trackedAnchors;
  157144. private _referenceSpaceForFrameAnchors;
  157145. private _futureAnchors;
  157146. /**
  157147. * The module's name
  157148. */
  157149. static readonly Name: string;
  157150. /**
  157151. * The (Babylon) version of this module.
  157152. * This is an integer representing the implementation version.
  157153. * This number does not correspond to the WebXR specs version
  157154. */
  157155. static readonly Version: number;
  157156. /**
  157157. * Observers registered here will be executed when a new anchor was added to the session
  157158. */
  157159. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157160. /**
  157161. * Observers registered here will be executed when an anchor was removed from the session
  157162. */
  157163. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157164. /**
  157165. * Observers registered here will be executed when an existing anchor updates
  157166. * This can execute N times every frame
  157167. */
  157168. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157169. /**
  157170. * Set the reference space to use for anchor creation, when not using a hit test.
  157171. * Will default to the session's reference space if not defined
  157172. */
  157173. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157174. /**
  157175. * constructs a new anchor system
  157176. * @param _xrSessionManager an instance of WebXRSessionManager
  157177. * @param _options configuration object for this feature
  157178. */
  157179. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157180. private _tmpVector;
  157181. private _tmpQuaternion;
  157182. private _populateTmpTransformation;
  157183. /**
  157184. * Create a new anchor point using a hit test result at a specific point in the scene
  157185. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157186. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157187. *
  157188. * @param hitTestResult The hit test result to use for this anchor creation
  157189. * @param position an optional position offset for this anchor
  157190. * @param rotationQuaternion an optional rotation offset for this anchor
  157191. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157192. */
  157193. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  157194. /**
  157195. * Add a new anchor at a specific position and rotation
  157196. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157197. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157198. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157199. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157200. *
  157201. * @param position the position in which to add an anchor
  157202. * @param rotationQuaternion an optional rotation for the anchor transformation
  157203. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157204. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157205. */
  157206. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  157207. /**
  157208. * detach this feature.
  157209. * Will usually be called by the features manager
  157210. *
  157211. * @returns true if successful.
  157212. */
  157213. detach(): boolean;
  157214. /**
  157215. * Dispose this feature and all of the resources attached
  157216. */
  157217. dispose(): void;
  157218. protected _onXRFrame(frame: XRFrame): void;
  157219. /**
  157220. * avoiding using Array.find for global support.
  157221. * @param xrAnchor the plane to find in the array
  157222. */
  157223. private _findIndexInAnchorArray;
  157224. private _updateAnchorWithXRFrame;
  157225. private _createAnchorAtTransformation;
  157226. }
  157227. }
  157228. declare module BABYLON {
  157229. /**
  157230. * Options used in the plane detector module
  157231. */
  157232. export interface IWebXRPlaneDetectorOptions {
  157233. /**
  157234. * The node to use to transform the local results to world coordinates
  157235. */
  157236. worldParentNode?: TransformNode;
  157237. /**
  157238. * If set to true a reference of the created planes will be kept until the next session starts
  157239. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  157240. */
  157241. doNotRemovePlanesOnSessionEnded?: boolean;
  157242. }
  157243. /**
  157244. * A babylon interface for a WebXR plane.
  157245. * A Plane is actually a polygon, built from N points in space
  157246. *
  157247. * Supported in chrome 79, not supported in canary 81 ATM
  157248. */
  157249. export interface IWebXRPlane {
  157250. /**
  157251. * a babylon-assigned ID for this polygon
  157252. */
  157253. id: number;
  157254. /**
  157255. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  157256. */
  157257. polygonDefinition: Array<Vector3>;
  157258. /**
  157259. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  157260. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  157261. */
  157262. transformationMatrix: Matrix;
  157263. /**
  157264. * the native xr-plane object
  157265. */
  157266. xrPlane: XRPlane;
  157267. }
  157268. /**
  157269. * The plane detector is used to detect planes in the real world when in AR
  157270. * For more information see https://github.com/immersive-web/real-world-geometry/
  157271. */
  157272. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  157273. private _options;
  157274. private _detectedPlanes;
  157275. private _enabled;
  157276. private _lastFrameDetected;
  157277. /**
  157278. * The module's name
  157279. */
  157280. static readonly Name: string;
  157281. /**
  157282. * The (Babylon) version of this module.
  157283. * This is an integer representing the implementation version.
  157284. * This number does not correspond to the WebXR specs version
  157285. */
  157286. static readonly Version: number;
  157287. /**
  157288. * Observers registered here will be executed when a new plane was added to the session
  157289. */
  157290. onPlaneAddedObservable: Observable<IWebXRPlane>;
  157291. /**
  157292. * Observers registered here will be executed when a plane is no longer detected in the session
  157293. */
  157294. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  157295. /**
  157296. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  157297. * This can execute N times every frame
  157298. */
  157299. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  157300. /**
  157301. * construct a new Plane Detector
  157302. * @param _xrSessionManager an instance of xr Session manager
  157303. * @param _options configuration to use when constructing this feature
  157304. */
  157305. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  157306. /**
  157307. * detach this feature.
  157308. * Will usually be called by the features manager
  157309. *
  157310. * @returns true if successful.
  157311. */
  157312. detach(): boolean;
  157313. /**
  157314. * Dispose this feature and all of the resources attached
  157315. */
  157316. dispose(): void;
  157317. /**
  157318. * Check if the needed objects are defined.
  157319. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157320. */
  157321. isCompatible(): boolean;
  157322. protected _onXRFrame(frame: XRFrame): void;
  157323. private _init;
  157324. private _updatePlaneWithXRPlane;
  157325. /**
  157326. * avoiding using Array.find for global support.
  157327. * @param xrPlane the plane to find in the array
  157328. */
  157329. private findIndexInPlaneArray;
  157330. }
  157331. }
  157332. declare module BABYLON {
  157333. /**
  157334. * Options interface for the background remover plugin
  157335. */
  157336. export interface IWebXRBackgroundRemoverOptions {
  157337. /**
  157338. * Further background meshes to disable when entering AR
  157339. */
  157340. backgroundMeshes?: AbstractMesh[];
  157341. /**
  157342. * flags to configure the removal of the environment helper.
  157343. * If not set, the entire background will be removed. If set, flags should be set as well.
  157344. */
  157345. environmentHelperRemovalFlags?: {
  157346. /**
  157347. * Should the skybox be removed (default false)
  157348. */
  157349. skyBox?: boolean;
  157350. /**
  157351. * Should the ground be removed (default false)
  157352. */
  157353. ground?: boolean;
  157354. };
  157355. /**
  157356. * don't disable the environment helper
  157357. */
  157358. ignoreEnvironmentHelper?: boolean;
  157359. }
  157360. /**
  157361. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  157362. */
  157363. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  157364. /**
  157365. * read-only options to be used in this module
  157366. */
  157367. readonly options: IWebXRBackgroundRemoverOptions;
  157368. /**
  157369. * The module's name
  157370. */
  157371. static readonly Name: string;
  157372. /**
  157373. * The (Babylon) version of this module.
  157374. * This is an integer representing the implementation version.
  157375. * This number does not correspond to the WebXR specs version
  157376. */
  157377. static readonly Version: number;
  157378. /**
  157379. * registered observers will be triggered when the background state changes
  157380. */
  157381. onBackgroundStateChangedObservable: Observable<boolean>;
  157382. /**
  157383. * constructs a new background remover module
  157384. * @param _xrSessionManager the session manager for this module
  157385. * @param options read-only options to be used in this module
  157386. */
  157387. constructor(_xrSessionManager: WebXRSessionManager,
  157388. /**
  157389. * read-only options to be used in this module
  157390. */
  157391. options?: IWebXRBackgroundRemoverOptions);
  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. * Dispose this feature and all of the resources attached
  157408. */
  157409. dispose(): void;
  157410. protected _onXRFrame(_xrFrame: XRFrame): void;
  157411. private _setBackgroundState;
  157412. }
  157413. }
  157414. declare module BABYLON {
  157415. /**
  157416. * Options for the controller physics feature
  157417. */
  157418. export class IWebXRControllerPhysicsOptions {
  157419. /**
  157420. * Should the headset get its own impostor
  157421. */
  157422. enableHeadsetImpostor?: boolean;
  157423. /**
  157424. * Optional parameters for the headset impostor
  157425. */
  157426. headsetImpostorParams?: {
  157427. /**
  157428. * The type of impostor to create. Default is sphere
  157429. */
  157430. impostorType: number;
  157431. /**
  157432. * the size of the impostor. Defaults to 10cm
  157433. */
  157434. impostorSize?: number | {
  157435. width: number;
  157436. height: number;
  157437. depth: number;
  157438. };
  157439. /**
  157440. * Friction definitions
  157441. */
  157442. friction?: number;
  157443. /**
  157444. * Restitution
  157445. */
  157446. restitution?: number;
  157447. };
  157448. /**
  157449. * The physics properties of the future impostors
  157450. */
  157451. physicsProperties?: {
  157452. /**
  157453. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  157454. * Note that this requires a physics engine that supports mesh impostors!
  157455. */
  157456. useControllerMesh?: boolean;
  157457. /**
  157458. * The type of impostor to create. Default is sphere
  157459. */
  157460. impostorType?: number;
  157461. /**
  157462. * the size of the impostor. Defaults to 10cm
  157463. */
  157464. impostorSize?: number | {
  157465. width: number;
  157466. height: number;
  157467. depth: number;
  157468. };
  157469. /**
  157470. * Friction definitions
  157471. */
  157472. friction?: number;
  157473. /**
  157474. * Restitution
  157475. */
  157476. restitution?: number;
  157477. };
  157478. /**
  157479. * the xr input to use with this pointer selection
  157480. */
  157481. xrInput: WebXRInput;
  157482. }
  157483. /**
  157484. * Add physics impostor to your webxr controllers,
  157485. * including naive calculation of their linear and angular velocity
  157486. */
  157487. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  157488. private readonly _options;
  157489. private _attachController;
  157490. private _controllers;
  157491. private _debugMode;
  157492. private _delta;
  157493. private _headsetImpostor?;
  157494. private _headsetMesh?;
  157495. private _lastTimestamp;
  157496. private _tmpQuaternion;
  157497. private _tmpVector;
  157498. /**
  157499. * The module's name
  157500. */
  157501. static readonly Name: string;
  157502. /**
  157503. * The (Babylon) version of this module.
  157504. * This is an integer representing the implementation version.
  157505. * This number does not correspond to the webxr specs version
  157506. */
  157507. static readonly Version: number;
  157508. /**
  157509. * Construct a new Controller Physics Feature
  157510. * @param _xrSessionManager the corresponding xr session manager
  157511. * @param _options options to create this feature with
  157512. */
  157513. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  157514. /**
  157515. * @hidden
  157516. * enable debugging - will show console outputs and the impostor mesh
  157517. */
  157518. _enablePhysicsDebug(): void;
  157519. /**
  157520. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  157521. * @param xrController the controller to add
  157522. */
  157523. addController(xrController: WebXRInputSource): void;
  157524. /**
  157525. * attach this feature
  157526. * Will usually be called by the features manager
  157527. *
  157528. * @returns true if successful.
  157529. */
  157530. attach(): boolean;
  157531. /**
  157532. * detach this feature.
  157533. * Will usually be called by the features manager
  157534. *
  157535. * @returns true if successful.
  157536. */
  157537. detach(): boolean;
  157538. /**
  157539. * Get the headset impostor, if enabled
  157540. * @returns the impostor
  157541. */
  157542. getHeadsetImpostor(): PhysicsImpostor | undefined;
  157543. /**
  157544. * Get the physics impostor of a specific controller.
  157545. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  157546. * @param controller the controller or the controller id of which to get the impostor
  157547. * @returns the impostor or null
  157548. */
  157549. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  157550. /**
  157551. * Update the physics properties provided in the constructor
  157552. * @param newProperties the new properties object
  157553. */
  157554. setPhysicsProperties(newProperties: {
  157555. impostorType?: number;
  157556. impostorSize?: number | {
  157557. width: number;
  157558. height: number;
  157559. depth: number;
  157560. };
  157561. friction?: number;
  157562. restitution?: number;
  157563. }): void;
  157564. protected _onXRFrame(_xrFrame: any): void;
  157565. private _detachController;
  157566. }
  157567. }
  157568. declare module BABYLON {
  157569. /**
  157570. * A babylon interface for a "WebXR" feature point.
  157571. * Represents the position and confidence value of a given feature point.
  157572. */
  157573. export interface IWebXRFeaturePoint {
  157574. /**
  157575. * Represents the position of the feature point in world space.
  157576. */
  157577. position: Vector3;
  157578. /**
  157579. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  157580. */
  157581. confidenceValue: number;
  157582. }
  157583. /**
  157584. * The feature point system is used to detect feature points from real world geometry.
  157585. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  157586. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  157587. */
  157588. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  157589. private _enabled;
  157590. private _featurePointCloud;
  157591. /**
  157592. * The module's name
  157593. */
  157594. static readonly Name: string;
  157595. /**
  157596. * The (Babylon) version of this module.
  157597. * This is an integer representing the implementation version.
  157598. * This number does not correspond to the WebXR specs version
  157599. */
  157600. static readonly Version: number;
  157601. /**
  157602. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  157603. * Will notify the observers about which feature points have been added.
  157604. */
  157605. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  157606. /**
  157607. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  157608. * Will notify the observers about which feature points have been updated.
  157609. */
  157610. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  157611. /**
  157612. * The current feature point cloud maintained across frames.
  157613. */
  157614. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  157615. /**
  157616. * construct the feature point system
  157617. * @param _xrSessionManager an instance of xr Session manager
  157618. */
  157619. constructor(_xrSessionManager: WebXRSessionManager);
  157620. /**
  157621. * Detach this feature.
  157622. * Will usually be called by the features manager
  157623. *
  157624. * @returns true if successful.
  157625. */
  157626. detach(): boolean;
  157627. /**
  157628. * Dispose this feature and all of the resources attached
  157629. */
  157630. dispose(): void;
  157631. /**
  157632. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  157633. */
  157634. protected _onXRFrame(frame: XRFrame): void;
  157635. /**
  157636. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  157637. */
  157638. private _init;
  157639. }
  157640. }
  157641. declare module BABYLON {
  157642. /**
  157643. * Configuration interface for the hand tracking feature
  157644. */
  157645. export interface IWebXRHandTrackingOptions {
  157646. /**
  157647. * The xrInput that will be used as source for new hands
  157648. */
  157649. xrInput: WebXRInput;
  157650. /**
  157651. * Configuration object for the joint meshes
  157652. */
  157653. jointMeshes?: {
  157654. /**
  157655. * Should the meshes created be invisible (defaults to false)
  157656. */
  157657. invisible?: boolean;
  157658. /**
  157659. * A source mesh to be used to create instances. Defaults to a sphere.
  157660. * This mesh will be the source for all other (25) meshes.
  157661. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  157662. */
  157663. sourceMesh?: Mesh;
  157664. /**
  157665. * This function will be called after a mesh was created for a specific joint.
  157666. * Using this function you can either manipulate the instance or return a new mesh.
  157667. * When returning a new mesh the instance created before will be disposed
  157668. */
  157669. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  157670. /**
  157671. * Should the source mesh stay visible. Defaults to false
  157672. */
  157673. keepOriginalVisible?: boolean;
  157674. /**
  157675. * Scale factor for all instances (defaults to 2)
  157676. */
  157677. scaleFactor?: number;
  157678. /**
  157679. * Should each instance have its own physics impostor
  157680. */
  157681. enablePhysics?: boolean;
  157682. /**
  157683. * If enabled, override default physics properties
  157684. */
  157685. physicsProps?: {
  157686. friction?: number;
  157687. restitution?: number;
  157688. impostorType?: number;
  157689. };
  157690. /**
  157691. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  157692. */
  157693. handMesh?: AbstractMesh;
  157694. };
  157695. }
  157696. /**
  157697. * Parts of the hands divided to writs and finger names
  157698. */
  157699. export const enum HandPart {
  157700. /**
  157701. * HandPart - Wrist
  157702. */
  157703. WRIST = "wrist",
  157704. /**
  157705. * HandPart - The THumb
  157706. */
  157707. THUMB = "thumb",
  157708. /**
  157709. * HandPart - Index finger
  157710. */
  157711. INDEX = "index",
  157712. /**
  157713. * HandPart - Middle finger
  157714. */
  157715. MIDDLE = "middle",
  157716. /**
  157717. * HandPart - Ring finger
  157718. */
  157719. RING = "ring",
  157720. /**
  157721. * HandPart - Little finger
  157722. */
  157723. LITTLE = "little"
  157724. }
  157725. /**
  157726. * Representing a single hand (with its corresponding native XRHand object)
  157727. */
  157728. export class WebXRHand implements IDisposable {
  157729. /** the controller to which the hand correlates */
  157730. readonly xrController: WebXRInputSource;
  157731. /** the meshes to be used to track the hand joints */
  157732. readonly trackedMeshes: AbstractMesh[];
  157733. /**
  157734. * Hand-parts definition (key is HandPart)
  157735. */
  157736. handPartsDefinition: {
  157737. [key: string]: number[];
  157738. };
  157739. /**
  157740. * Populate the HandPartsDefinition object.
  157741. * This is called as a side effect since certain browsers don't have XRHand defined.
  157742. */
  157743. private generateHandPartsDefinition;
  157744. /**
  157745. * Construct a new hand object
  157746. * @param xrController the controller to which the hand correlates
  157747. * @param trackedMeshes the meshes to be used to track the hand joints
  157748. */
  157749. constructor(
  157750. /** the controller to which the hand correlates */
  157751. xrController: WebXRInputSource,
  157752. /** the meshes to be used to track the hand joints */
  157753. trackedMeshes: AbstractMesh[]);
  157754. /**
  157755. * Update this hand from the latest xr frame
  157756. * @param xrFrame xrFrame to update from
  157757. * @param referenceSpace The current viewer reference space
  157758. * @param scaleFactor optional scale factor for the meshes
  157759. */
  157760. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  157761. /**
  157762. * Get meshes of part of the hand
  157763. * @param part the part of hand to get
  157764. * @returns An array of meshes that correlate to the hand part requested
  157765. */
  157766. getHandPartMeshes(part: HandPart): AbstractMesh[];
  157767. /**
  157768. * Dispose this Hand object
  157769. */
  157770. dispose(): void;
  157771. }
  157772. /**
  157773. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  157774. */
  157775. export class WebXRHandTracking extends WebXRAbstractFeature {
  157776. /**
  157777. * options to use when constructing this feature
  157778. */
  157779. readonly options: IWebXRHandTrackingOptions;
  157780. private static _idCounter;
  157781. /**
  157782. * The module's name
  157783. */
  157784. static readonly Name: string;
  157785. /**
  157786. * The (Babylon) version of this module.
  157787. * This is an integer representing the implementation version.
  157788. * This number does not correspond to the WebXR specs version
  157789. */
  157790. static readonly Version: number;
  157791. /**
  157792. * This observable will notify registered observers when a new hand object was added and initialized
  157793. */
  157794. onHandAddedObservable: Observable<WebXRHand>;
  157795. /**
  157796. * This observable will notify its observers right before the hand object is disposed
  157797. */
  157798. onHandRemovedObservable: Observable<WebXRHand>;
  157799. private _hands;
  157800. /**
  157801. * Creates a new instance of the hit test feature
  157802. * @param _xrSessionManager an instance of WebXRSessionManager
  157803. * @param options options to use when constructing this feature
  157804. */
  157805. constructor(_xrSessionManager: WebXRSessionManager,
  157806. /**
  157807. * options to use when constructing this feature
  157808. */
  157809. options: IWebXRHandTrackingOptions);
  157810. /**
  157811. * Check if the needed objects are defined.
  157812. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157813. */
  157814. isCompatible(): boolean;
  157815. /**
  157816. * attach this feature
  157817. * Will usually be called by the features manager
  157818. *
  157819. * @returns true if successful.
  157820. */
  157821. attach(): boolean;
  157822. /**
  157823. * detach this feature.
  157824. * Will usually be called by the features manager
  157825. *
  157826. * @returns true if successful.
  157827. */
  157828. detach(): boolean;
  157829. /**
  157830. * Dispose this feature and all of the resources attached
  157831. */
  157832. dispose(): void;
  157833. /**
  157834. * Get the hand object according to the controller id
  157835. * @param controllerId the controller id to which we want to get the hand
  157836. * @returns null if not found or the WebXRHand object if found
  157837. */
  157838. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  157839. /**
  157840. * Get a hand object according to the requested handedness
  157841. * @param handedness the handedness to request
  157842. * @returns null if not found or the WebXRHand object if found
  157843. */
  157844. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  157845. protected _onXRFrame(_xrFrame: XRFrame): void;
  157846. private _attachHand;
  157847. private _detachHand;
  157848. }
  157849. }
  157850. declare module BABYLON {
  157851. /**
  157852. * The motion controller class for all microsoft mixed reality controllers
  157853. */
  157854. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  157855. protected readonly _mapping: {
  157856. defaultButton: {
  157857. valueNodeName: string;
  157858. unpressedNodeName: string;
  157859. pressedNodeName: string;
  157860. };
  157861. defaultAxis: {
  157862. valueNodeName: string;
  157863. minNodeName: string;
  157864. maxNodeName: string;
  157865. };
  157866. buttons: {
  157867. "xr-standard-trigger": {
  157868. rootNodeName: string;
  157869. componentProperty: string;
  157870. states: string[];
  157871. };
  157872. "xr-standard-squeeze": {
  157873. rootNodeName: string;
  157874. componentProperty: string;
  157875. states: string[];
  157876. };
  157877. "xr-standard-touchpad": {
  157878. rootNodeName: string;
  157879. labelAnchorNodeName: string;
  157880. touchPointNodeName: string;
  157881. };
  157882. "xr-standard-thumbstick": {
  157883. rootNodeName: string;
  157884. componentProperty: string;
  157885. states: string[];
  157886. };
  157887. };
  157888. axes: {
  157889. "xr-standard-touchpad": {
  157890. "x-axis": {
  157891. rootNodeName: string;
  157892. };
  157893. "y-axis": {
  157894. rootNodeName: string;
  157895. };
  157896. };
  157897. "xr-standard-thumbstick": {
  157898. "x-axis": {
  157899. rootNodeName: string;
  157900. };
  157901. "y-axis": {
  157902. rootNodeName: string;
  157903. };
  157904. };
  157905. };
  157906. };
  157907. /**
  157908. * The base url used to load the left and right controller models
  157909. */
  157910. static MODEL_BASE_URL: string;
  157911. /**
  157912. * The name of the left controller model file
  157913. */
  157914. static MODEL_LEFT_FILENAME: string;
  157915. /**
  157916. * The name of the right controller model file
  157917. */
  157918. static MODEL_RIGHT_FILENAME: string;
  157919. profileId: string;
  157920. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157921. protected _getFilenameAndPath(): {
  157922. filename: string;
  157923. path: string;
  157924. };
  157925. protected _getModelLoadingConstraints(): boolean;
  157926. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157927. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157928. protected _updateModel(): void;
  157929. }
  157930. }
  157931. declare module BABYLON {
  157932. /**
  157933. * The motion controller class for oculus touch (quest, rift).
  157934. * This class supports legacy mapping as well the standard xr mapping
  157935. */
  157936. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157937. private _forceLegacyControllers;
  157938. private _modelRootNode;
  157939. /**
  157940. * The base url used to load the left and right controller models
  157941. */
  157942. static MODEL_BASE_URL: string;
  157943. /**
  157944. * The name of the left controller model file
  157945. */
  157946. static MODEL_LEFT_FILENAME: string;
  157947. /**
  157948. * The name of the right controller model file
  157949. */
  157950. static MODEL_RIGHT_FILENAME: string;
  157951. /**
  157952. * Base Url for the Quest controller model.
  157953. */
  157954. static QUEST_MODEL_BASE_URL: string;
  157955. profileId: string;
  157956. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157957. protected _getFilenameAndPath(): {
  157958. filename: string;
  157959. path: string;
  157960. };
  157961. protected _getModelLoadingConstraints(): boolean;
  157962. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157963. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157964. protected _updateModel(): void;
  157965. /**
  157966. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157967. * between the touch and touch 2.
  157968. */
  157969. private _isQuest;
  157970. }
  157971. }
  157972. declare module BABYLON {
  157973. /**
  157974. * The motion controller class for the standard HTC-Vive controllers
  157975. */
  157976. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157977. private _modelRootNode;
  157978. /**
  157979. * The base url used to load the left and right controller models
  157980. */
  157981. static MODEL_BASE_URL: string;
  157982. /**
  157983. * File name for the controller model.
  157984. */
  157985. static MODEL_FILENAME: string;
  157986. profileId: string;
  157987. /**
  157988. * Create a new Vive motion controller object
  157989. * @param scene the scene to use to create this controller
  157990. * @param gamepadObject the corresponding gamepad object
  157991. * @param handedness the handedness of the controller
  157992. */
  157993. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157994. protected _getFilenameAndPath(): {
  157995. filename: string;
  157996. path: string;
  157997. };
  157998. protected _getModelLoadingConstraints(): boolean;
  157999. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158000. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158001. protected _updateModel(): void;
  158002. }
  158003. }
  158004. declare module BABYLON {
  158005. /**
  158006. * A cursor which tracks a point on a path
  158007. */
  158008. export class PathCursor {
  158009. private path;
  158010. /**
  158011. * Stores path cursor callbacks for when an onchange event is triggered
  158012. */
  158013. private _onchange;
  158014. /**
  158015. * The value of the path cursor
  158016. */
  158017. value: number;
  158018. /**
  158019. * The animation array of the path cursor
  158020. */
  158021. animations: Animation[];
  158022. /**
  158023. * Initializes the path cursor
  158024. * @param path The path to track
  158025. */
  158026. constructor(path: Path2);
  158027. /**
  158028. * Gets the cursor point on the path
  158029. * @returns A point on the path cursor at the cursor location
  158030. */
  158031. getPoint(): Vector3;
  158032. /**
  158033. * Moves the cursor ahead by the step amount
  158034. * @param step The amount to move the cursor forward
  158035. * @returns This path cursor
  158036. */
  158037. moveAhead(step?: number): PathCursor;
  158038. /**
  158039. * Moves the cursor behind by the step amount
  158040. * @param step The amount to move the cursor back
  158041. * @returns This path cursor
  158042. */
  158043. moveBack(step?: number): PathCursor;
  158044. /**
  158045. * Moves the cursor by the step amount
  158046. * If the step amount is greater than one, an exception is thrown
  158047. * @param step The amount to move the cursor
  158048. * @returns This path cursor
  158049. */
  158050. move(step: number): PathCursor;
  158051. /**
  158052. * Ensures that the value is limited between zero and one
  158053. * @returns This path cursor
  158054. */
  158055. private ensureLimits;
  158056. /**
  158057. * Runs onchange callbacks on change (used by the animation engine)
  158058. * @returns This path cursor
  158059. */
  158060. private raiseOnChange;
  158061. /**
  158062. * Executes a function on change
  158063. * @param f A path cursor onchange callback
  158064. * @returns This path cursor
  158065. */
  158066. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158067. }
  158068. }
  158069. declare module BABYLON {
  158070. /** @hidden */
  158071. export var blurPixelShader: {
  158072. name: string;
  158073. shader: string;
  158074. };
  158075. }
  158076. declare module BABYLON {
  158077. /** @hidden */
  158078. export var pointCloudVertexDeclaration: {
  158079. name: string;
  158080. shader: string;
  158081. };
  158082. }
  158083. // Mixins
  158084. interface Window {
  158085. mozIndexedDB: IDBFactory;
  158086. webkitIndexedDB: IDBFactory;
  158087. msIndexedDB: IDBFactory;
  158088. webkitURL: typeof URL;
  158089. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158090. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158091. WebGLRenderingContext: WebGLRenderingContext;
  158092. MSGesture: MSGesture;
  158093. CANNON: any;
  158094. AudioContext: AudioContext;
  158095. webkitAudioContext: AudioContext;
  158096. PointerEvent: any;
  158097. Math: Math;
  158098. Uint8Array: Uint8ArrayConstructor;
  158099. Float32Array: Float32ArrayConstructor;
  158100. mozURL: typeof URL;
  158101. msURL: typeof URL;
  158102. VRFrameData: any; // WebVR, from specs 1.1
  158103. DracoDecoderModule: any;
  158104. setImmediate(handler: (...args: any[]) => void): number;
  158105. }
  158106. interface HTMLCanvasElement {
  158107. requestPointerLock(): void;
  158108. msRequestPointerLock?(): void;
  158109. mozRequestPointerLock?(): void;
  158110. webkitRequestPointerLock?(): void;
  158111. /** Track wether a record is in progress */
  158112. isRecording: boolean;
  158113. /** Capture Stream method defined by some browsers */
  158114. captureStream(fps?: number): MediaStream;
  158115. }
  158116. interface CanvasRenderingContext2D {
  158117. msImageSmoothingEnabled: boolean;
  158118. }
  158119. interface MouseEvent {
  158120. mozMovementX: number;
  158121. mozMovementY: number;
  158122. webkitMovementX: number;
  158123. webkitMovementY: number;
  158124. msMovementX: number;
  158125. msMovementY: number;
  158126. }
  158127. interface Navigator {
  158128. mozGetVRDevices: (any: any) => any;
  158129. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158130. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158131. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158132. webkitGetGamepads(): Gamepad[];
  158133. msGetGamepads(): Gamepad[];
  158134. webkitGamepads(): Gamepad[];
  158135. }
  158136. interface HTMLVideoElement {
  158137. mozSrcObject: any;
  158138. }
  158139. interface Math {
  158140. fround(x: number): number;
  158141. imul(a: number, b: number): number;
  158142. }
  158143. interface WebGLRenderingContext {
  158144. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158145. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158146. vertexAttribDivisor(index: number, divisor: number): void;
  158147. createVertexArray(): any;
  158148. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158149. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158150. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158151. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158152. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158153. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158154. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158155. // Queries
  158156. createQuery(): WebGLQuery;
  158157. deleteQuery(query: WebGLQuery): void;
  158158. beginQuery(target: number, query: WebGLQuery): void;
  158159. endQuery(target: number): void;
  158160. getQueryParameter(query: WebGLQuery, pname: number): any;
  158161. getQuery(target: number, pname: number): any;
  158162. MAX_SAMPLES: number;
  158163. RGBA8: number;
  158164. READ_FRAMEBUFFER: number;
  158165. DRAW_FRAMEBUFFER: number;
  158166. UNIFORM_BUFFER: number;
  158167. HALF_FLOAT_OES: number;
  158168. RGBA16F: number;
  158169. RGBA32F: number;
  158170. R32F: number;
  158171. RG32F: number;
  158172. RGB32F: number;
  158173. R16F: number;
  158174. RG16F: number;
  158175. RGB16F: number;
  158176. RED: number;
  158177. RG: number;
  158178. R8: number;
  158179. RG8: number;
  158180. UNSIGNED_INT_24_8: number;
  158181. DEPTH24_STENCIL8: number;
  158182. MIN: number;
  158183. MAX: number;
  158184. /* Multiple Render Targets */
  158185. drawBuffers(buffers: number[]): void;
  158186. readBuffer(src: number): void;
  158187. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158188. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158189. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158190. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158191. // Occlusion Query
  158192. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158193. ANY_SAMPLES_PASSED: number;
  158194. QUERY_RESULT_AVAILABLE: number;
  158195. QUERY_RESULT: number;
  158196. }
  158197. interface WebGLProgram {
  158198. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158199. }
  158200. interface EXT_disjoint_timer_query {
  158201. QUERY_COUNTER_BITS_EXT: number;
  158202. TIME_ELAPSED_EXT: number;
  158203. TIMESTAMP_EXT: number;
  158204. GPU_DISJOINT_EXT: number;
  158205. QUERY_RESULT_EXT: number;
  158206. QUERY_RESULT_AVAILABLE_EXT: number;
  158207. queryCounterEXT(query: WebGLQuery, target: number): void;
  158208. createQueryEXT(): WebGLQuery;
  158209. beginQueryEXT(target: number, query: WebGLQuery): void;
  158210. endQueryEXT(target: number): void;
  158211. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158212. deleteQueryEXT(query: WebGLQuery): void;
  158213. }
  158214. interface WebGLUniformLocation {
  158215. _currentState: any;
  158216. }
  158217. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158218. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158219. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158220. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158221. interface WebGLRenderingContext {
  158222. readonly RASTERIZER_DISCARD: number;
  158223. readonly DEPTH_COMPONENT24: number;
  158224. readonly TEXTURE_3D: number;
  158225. readonly TEXTURE_2D_ARRAY: number;
  158226. readonly TEXTURE_COMPARE_FUNC: number;
  158227. readonly TEXTURE_COMPARE_MODE: number;
  158228. readonly COMPARE_REF_TO_TEXTURE: number;
  158229. readonly TEXTURE_WRAP_R: number;
  158230. readonly HALF_FLOAT: number;
  158231. readonly RGB8: number;
  158232. readonly RED_INTEGER: number;
  158233. readonly RG_INTEGER: number;
  158234. readonly RGB_INTEGER: number;
  158235. readonly RGBA_INTEGER: number;
  158236. readonly R8_SNORM: number;
  158237. readonly RG8_SNORM: number;
  158238. readonly RGB8_SNORM: number;
  158239. readonly RGBA8_SNORM: number;
  158240. readonly R8I: number;
  158241. readonly RG8I: number;
  158242. readonly RGB8I: number;
  158243. readonly RGBA8I: number;
  158244. readonly R8UI: number;
  158245. readonly RG8UI: number;
  158246. readonly RGB8UI: number;
  158247. readonly RGBA8UI: number;
  158248. readonly R16I: number;
  158249. readonly RG16I: number;
  158250. readonly RGB16I: number;
  158251. readonly RGBA16I: number;
  158252. readonly R16UI: number;
  158253. readonly RG16UI: number;
  158254. readonly RGB16UI: number;
  158255. readonly RGBA16UI: number;
  158256. readonly R32I: number;
  158257. readonly RG32I: number;
  158258. readonly RGB32I: number;
  158259. readonly RGBA32I: number;
  158260. readonly R32UI: number;
  158261. readonly RG32UI: number;
  158262. readonly RGB32UI: number;
  158263. readonly RGBA32UI: number;
  158264. readonly RGB10_A2UI: number;
  158265. readonly R11F_G11F_B10F: number;
  158266. readonly RGB9_E5: number;
  158267. readonly RGB10_A2: number;
  158268. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  158269. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  158270. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  158271. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  158272. readonly DEPTH_COMPONENT32F: number;
  158273. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  158274. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  158275. 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;
  158276. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  158277. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  158278. readonly TRANSFORM_FEEDBACK: number;
  158279. readonly INTERLEAVED_ATTRIBS: number;
  158280. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  158281. createTransformFeedback(): WebGLTransformFeedback;
  158282. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  158283. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  158284. beginTransformFeedback(primitiveMode: number): void;
  158285. endTransformFeedback(): void;
  158286. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  158287. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158288. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158289. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158290. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  158291. }
  158292. interface ImageBitmap {
  158293. readonly width: number;
  158294. readonly height: number;
  158295. close(): void;
  158296. }
  158297. interface WebGLQuery extends WebGLObject {
  158298. }
  158299. declare var WebGLQuery: {
  158300. prototype: WebGLQuery;
  158301. new(): WebGLQuery;
  158302. };
  158303. interface WebGLSampler extends WebGLObject {
  158304. }
  158305. declare var WebGLSampler: {
  158306. prototype: WebGLSampler;
  158307. new(): WebGLSampler;
  158308. };
  158309. interface WebGLSync extends WebGLObject {
  158310. }
  158311. declare var WebGLSync: {
  158312. prototype: WebGLSync;
  158313. new(): WebGLSync;
  158314. };
  158315. interface WebGLTransformFeedback extends WebGLObject {
  158316. }
  158317. declare var WebGLTransformFeedback: {
  158318. prototype: WebGLTransformFeedback;
  158319. new(): WebGLTransformFeedback;
  158320. };
  158321. interface WebGLVertexArrayObject extends WebGLObject {
  158322. }
  158323. declare var WebGLVertexArrayObject: {
  158324. prototype: WebGLVertexArrayObject;
  158325. new(): WebGLVertexArrayObject;
  158326. };
  158327. // Type definitions for WebVR API
  158328. // Project: https://w3c.github.io/webvr/
  158329. // Definitions by: six a <https://github.com/lostfictions>
  158330. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158331. interface VRDisplay extends EventTarget {
  158332. /**
  158333. * Dictionary of capabilities describing the VRDisplay.
  158334. */
  158335. readonly capabilities: VRDisplayCapabilities;
  158336. /**
  158337. * z-depth defining the far plane of the eye view frustum
  158338. * enables mapping of values in the render target depth
  158339. * attachment to scene coordinates. Initially set to 10000.0.
  158340. */
  158341. depthFar: number;
  158342. /**
  158343. * z-depth defining the near plane of the eye view frustum
  158344. * enables mapping of values in the render target depth
  158345. * attachment to scene coordinates. Initially set to 0.01.
  158346. */
  158347. depthNear: number;
  158348. /**
  158349. * An identifier for this distinct VRDisplay. Used as an
  158350. * association point in the Gamepad API.
  158351. */
  158352. readonly displayId: number;
  158353. /**
  158354. * A display name, a user-readable name identifying it.
  158355. */
  158356. readonly displayName: string;
  158357. readonly isConnected: boolean;
  158358. readonly isPresenting: boolean;
  158359. /**
  158360. * If this VRDisplay supports room-scale experiences, the optional
  158361. * stage attribute contains details on the room-scale parameters.
  158362. */
  158363. readonly stageParameters: VRStageParameters | null;
  158364. /**
  158365. * Passing the value returned by `requestAnimationFrame` to
  158366. * `cancelAnimationFrame` will unregister the callback.
  158367. * @param handle Define the hanle of the request to cancel
  158368. */
  158369. cancelAnimationFrame(handle: number): void;
  158370. /**
  158371. * Stops presenting to the VRDisplay.
  158372. * @returns a promise to know when it stopped
  158373. */
  158374. exitPresent(): Promise<void>;
  158375. /**
  158376. * Return the current VREyeParameters for the given eye.
  158377. * @param whichEye Define the eye we want the parameter for
  158378. * @returns the eye parameters
  158379. */
  158380. getEyeParameters(whichEye: string): VREyeParameters;
  158381. /**
  158382. * Populates the passed VRFrameData with the information required to render
  158383. * the current frame.
  158384. * @param frameData Define the data structure to populate
  158385. * @returns true if ok otherwise false
  158386. */
  158387. getFrameData(frameData: VRFrameData): boolean;
  158388. /**
  158389. * Get the layers currently being presented.
  158390. * @returns the list of VR layers
  158391. */
  158392. getLayers(): VRLayer[];
  158393. /**
  158394. * Return a VRPose containing the future predicted pose of the VRDisplay
  158395. * when the current frame will be presented. The value returned will not
  158396. * change until JavaScript has returned control to the browser.
  158397. *
  158398. * The VRPose will contain the position, orientation, velocity,
  158399. * and acceleration of each of these properties.
  158400. * @returns the pose object
  158401. */
  158402. getPose(): VRPose;
  158403. /**
  158404. * Return the current instantaneous pose of the VRDisplay, with no
  158405. * prediction applied.
  158406. * @returns the current instantaneous pose
  158407. */
  158408. getImmediatePose(): VRPose;
  158409. /**
  158410. * The callback passed to `requestAnimationFrame` will be called
  158411. * any time a new frame should be rendered. When the VRDisplay is
  158412. * presenting the callback will be called at the native refresh
  158413. * rate of the HMD. When not presenting this function acts
  158414. * identically to how window.requestAnimationFrame acts. Content should
  158415. * make no assumptions of frame rate or vsync behavior as the HMD runs
  158416. * asynchronously from other displays and at differing refresh rates.
  158417. * @param callback Define the eaction to run next frame
  158418. * @returns the request handle it
  158419. */
  158420. requestAnimationFrame(callback: FrameRequestCallback): number;
  158421. /**
  158422. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  158423. * Repeat calls while already presenting will update the VRLayers being displayed.
  158424. * @param layers Define the list of layer to present
  158425. * @returns a promise to know when the request has been fulfilled
  158426. */
  158427. requestPresent(layers: VRLayer[]): Promise<void>;
  158428. /**
  158429. * Reset the pose for this display, treating its current position and
  158430. * orientation as the "origin/zero" values. VRPose.position,
  158431. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  158432. * updated when calling resetPose(). This should be called in only
  158433. * sitting-space experiences.
  158434. */
  158435. resetPose(): void;
  158436. /**
  158437. * The VRLayer provided to the VRDisplay will be captured and presented
  158438. * in the HMD. Calling this function has the same effect on the source
  158439. * canvas as any other operation that uses its source image, and canvases
  158440. * created without preserveDrawingBuffer set to true will be cleared.
  158441. * @param pose Define the pose to submit
  158442. */
  158443. submitFrame(pose?: VRPose): void;
  158444. }
  158445. declare var VRDisplay: {
  158446. prototype: VRDisplay;
  158447. new(): VRDisplay;
  158448. };
  158449. interface VRLayer {
  158450. leftBounds?: number[] | Float32Array | null;
  158451. rightBounds?: number[] | Float32Array | null;
  158452. source?: HTMLCanvasElement | null;
  158453. }
  158454. interface VRDisplayCapabilities {
  158455. readonly canPresent: boolean;
  158456. readonly hasExternalDisplay: boolean;
  158457. readonly hasOrientation: boolean;
  158458. readonly hasPosition: boolean;
  158459. readonly maxLayers: number;
  158460. }
  158461. interface VREyeParameters {
  158462. /** @deprecated */
  158463. readonly fieldOfView: VRFieldOfView;
  158464. readonly offset: Float32Array;
  158465. readonly renderHeight: number;
  158466. readonly renderWidth: number;
  158467. }
  158468. interface VRFieldOfView {
  158469. readonly downDegrees: number;
  158470. readonly leftDegrees: number;
  158471. readonly rightDegrees: number;
  158472. readonly upDegrees: number;
  158473. }
  158474. interface VRFrameData {
  158475. readonly leftProjectionMatrix: Float32Array;
  158476. readonly leftViewMatrix: Float32Array;
  158477. readonly pose: VRPose;
  158478. readonly rightProjectionMatrix: Float32Array;
  158479. readonly rightViewMatrix: Float32Array;
  158480. readonly timestamp: number;
  158481. }
  158482. interface VRPose {
  158483. readonly angularAcceleration: Float32Array | null;
  158484. readonly angularVelocity: Float32Array | null;
  158485. readonly linearAcceleration: Float32Array | null;
  158486. readonly linearVelocity: Float32Array | null;
  158487. readonly orientation: Float32Array | null;
  158488. readonly position: Float32Array | null;
  158489. readonly timestamp: number;
  158490. }
  158491. interface VRStageParameters {
  158492. sittingToStandingTransform?: Float32Array;
  158493. sizeX?: number;
  158494. sizeY?: number;
  158495. }
  158496. interface Navigator {
  158497. getVRDisplays(): Promise<VRDisplay[]>;
  158498. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  158499. }
  158500. interface Window {
  158501. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  158502. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  158503. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  158504. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158505. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158506. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  158507. }
  158508. interface Gamepad {
  158509. readonly displayId: number;
  158510. }
  158511. /**
  158512. * Available session modes
  158513. */
  158514. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  158515. /**
  158516. * Reference space types
  158517. */
  158518. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  158519. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  158520. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  158521. /**
  158522. * Handedness types
  158523. */
  158524. type XRHandedness = "none" | "left" | "right";
  158525. /**
  158526. * InputSource target ray modes
  158527. */
  158528. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  158529. /**
  158530. * Eye types
  158531. */
  158532. type XREye = "none" | "left" | "right";
  158533. /**
  158534. * Type of XR events available
  158535. */
  158536. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  158537. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  158538. type XRPlaneSet = Set<XRPlane>;
  158539. type XRAnchorSet = Set<XRAnchor>;
  158540. type XREventHandler = (callback: any) => void;
  158541. interface XRLayer extends EventTarget {}
  158542. interface XRSessionInit {
  158543. optionalFeatures?: string[];
  158544. requiredFeatures?: string[];
  158545. }
  158546. interface XRSessionEvent extends Event {
  158547. readonly session: XRSession;
  158548. }
  158549. interface XRSystem {
  158550. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  158551. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  158552. }
  158553. interface XRViewport {
  158554. readonly x: number;
  158555. readonly y: number;
  158556. readonly width: number;
  158557. readonly height: number;
  158558. }
  158559. interface XRWebGLLayerInit {
  158560. antialias?: boolean;
  158561. depth?: boolean;
  158562. stencil?: boolean;
  158563. alpha?: boolean;
  158564. multiview?: boolean;
  158565. framebufferScaleFactor?: number;
  158566. }
  158567. declare class XRWebGLLayer {
  158568. static getNativeFramebufferScaleFactor(session: XRSession): number;
  158569. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  158570. readonly antialias: boolean;
  158571. readonly framebuffer: WebGLFramebuffer;
  158572. readonly framebufferWidth: number;
  158573. readonly framebufferHeight: number;
  158574. readonly ignoreDepthValues: boolean;
  158575. getViewport: (view: XRView) => XRViewport;
  158576. }
  158577. // tslint:disable-next-line no-empty-interface
  158578. interface XRSpace extends EventTarget {}
  158579. interface XRRenderState {
  158580. readonly baseLayer?: XRWebGLLayer;
  158581. readonly depthFar: number;
  158582. readonly depthNear: number;
  158583. readonly inlineVerticalFieldOfView?: number;
  158584. }
  158585. interface XRRenderStateInit extends XRRenderState {
  158586. baseLayer: XRWebGLLayer;
  158587. depthFar: number;
  158588. depthNear: number;
  158589. inlineVerticalFieldOfView?: number;
  158590. layers?: XRLayer[];
  158591. }
  158592. interface XRReferenceSpace extends XRSpace {
  158593. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  158594. onreset: XREventHandler;
  158595. }
  158596. interface XRBoundedReferenceSpace extends XRSpace {
  158597. readonly boundsGeometry: DOMPointReadOnly[];
  158598. }
  158599. interface XRInputSource {
  158600. readonly handedness: XRHandedness;
  158601. readonly targetRayMode: XRTargetRayMode;
  158602. readonly targetRaySpace: XRSpace;
  158603. readonly gripSpace?: XRSpace;
  158604. readonly gamepad?: Gamepad;
  158605. readonly profiles: Array<string>;
  158606. readonly hand?: XRHand;
  158607. }
  158608. interface XRPose {
  158609. readonly transform: XRRigidTransform;
  158610. readonly emulatedPosition: boolean;
  158611. }
  158612. interface XRFrame {
  158613. readonly session: XRSession;
  158614. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  158615. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  158616. // AR
  158617. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  158618. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  158619. // Anchors
  158620. trackedAnchors?: XRAnchorSet;
  158621. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  158622. // Planes
  158623. worldInformation?: {
  158624. detectedPlanes?: XRPlaneSet;
  158625. };
  158626. // Hand tracking
  158627. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  158628. }
  158629. interface XRInputSourceEvent extends Event {
  158630. readonly frame: XRFrame;
  158631. readonly inputSource: XRInputSource;
  158632. }
  158633. type XRInputSourceArray = XRInputSource[];
  158634. interface XRSession {
  158635. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  158636. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  158637. /**
  158638. * Returns a list of this session's XRInputSources, each representing an input device
  158639. * used to control the camera and/or scene.
  158640. */
  158641. readonly inputSources: Array<XRInputSource>;
  158642. /**
  158643. * object which contains options affecting how the imagery is rendered.
  158644. * This includes things such as the near and far clipping planes
  158645. */
  158646. readonly renderState: XRRenderState;
  158647. readonly visibilityState: XRVisibilityState;
  158648. /**
  158649. * Removes a callback from the animation frame painting callback from
  158650. * XRSession's set of animation frame rendering callbacks, given the
  158651. * identifying handle returned by a previous call to requestAnimationFrame().
  158652. */
  158653. cancelAnimationFrame: (handle: number) => void;
  158654. /**
  158655. * Ends the WebXR session. Returns a promise which resolves when the
  158656. * session has been shut down.
  158657. */
  158658. end(): Promise<void>;
  158659. /**
  158660. * Schedules the specified method to be called the next time the user agent
  158661. * is working on rendering an animation frame for the WebXR device. Returns an
  158662. * integer value which can be used to identify the request for the purposes of
  158663. * canceling the callback using cancelAnimationFrame(). This method is comparable
  158664. * to the Window.requestAnimationFrame() method.
  158665. */
  158666. requestAnimationFrame: XRFrameRequestCallback;
  158667. /**
  158668. * Requests that a new XRReferenceSpace of the specified type be created.
  158669. * Returns a promise which resolves with the XRReferenceSpace or
  158670. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  158671. * the requested space type isn't supported by the device.
  158672. */
  158673. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  158674. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  158675. onend: XREventHandler;
  158676. oninputsourceschange: XREventHandler;
  158677. onselect: XREventHandler;
  158678. onselectstart: XREventHandler;
  158679. onselectend: XREventHandler;
  158680. onsqueeze: XREventHandler;
  158681. onsqueezestart: XREventHandler;
  158682. onsqueezeend: XREventHandler;
  158683. onvisibilitychange: XREventHandler;
  158684. // hit test
  158685. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  158686. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  158687. // legacy AR hit test
  158688. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  158689. // legacy plane detection
  158690. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  158691. }
  158692. interface XRViewerPose extends XRPose {
  158693. readonly views: Array<XRView>;
  158694. }
  158695. declare class XRRigidTransform {
  158696. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  158697. position: DOMPointReadOnly;
  158698. orientation: DOMPointReadOnly;
  158699. matrix: Float32Array;
  158700. inverse: XRRigidTransform;
  158701. }
  158702. interface XRView {
  158703. readonly eye: XREye;
  158704. readonly projectionMatrix: Float32Array;
  158705. readonly transform: XRRigidTransform;
  158706. readonly recommendedViewportScale?: number;
  158707. requestViewportScale(scale: number): void;
  158708. }
  158709. interface XRInputSourceChangeEvent extends Event {
  158710. session: XRSession;
  158711. removed: Array<XRInputSource>;
  158712. added: Array<XRInputSource>;
  158713. }
  158714. // Experimental/Draft features
  158715. declare class XRRay {
  158716. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  158717. origin: DOMPointReadOnly;
  158718. direction: DOMPointReadOnly;
  158719. matrix: Float32Array;
  158720. }
  158721. declare enum XRHitTestTrackableType {
  158722. "point",
  158723. "plane",
  158724. "mesh",
  158725. }
  158726. interface XRHitResult {
  158727. hitMatrix: Float32Array;
  158728. }
  158729. interface XRTransientInputHitTestResult {
  158730. readonly inputSource: XRInputSource;
  158731. readonly results: Array<XRHitTestResult>;
  158732. }
  158733. interface XRHitTestResult {
  158734. getPose(baseSpace: XRSpace): XRPose | undefined;
  158735. // When anchor system is enabled
  158736. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  158737. }
  158738. interface XRHitTestSource {
  158739. cancel(): void;
  158740. }
  158741. interface XRTransientInputHitTestSource {
  158742. cancel(): void;
  158743. }
  158744. interface XRHitTestOptionsInit {
  158745. space: XRSpace;
  158746. entityTypes?: Array<XRHitTestTrackableType>;
  158747. offsetRay?: XRRay;
  158748. }
  158749. interface XRTransientInputHitTestOptionsInit {
  158750. profile: string;
  158751. entityTypes?: Array<XRHitTestTrackableType>;
  158752. offsetRay?: XRRay;
  158753. }
  158754. interface XRAnchor {
  158755. anchorSpace: XRSpace;
  158756. delete(): void;
  158757. }
  158758. interface XRPlane {
  158759. orientation: "Horizontal" | "Vertical";
  158760. planeSpace: XRSpace;
  158761. polygon: Array<DOMPointReadOnly>;
  158762. lastChangedTime: number;
  158763. }
  158764. interface XRJointSpace extends XRSpace {}
  158765. interface XRJointPose extends XRPose {
  158766. radius: number | undefined;
  158767. }
  158768. interface XRHand extends Iterable<XRJointSpace> {
  158769. readonly length: number;
  158770. [index: number]: XRJointSpace;
  158771. readonly WRIST: number;
  158772. readonly THUMB_METACARPAL: number;
  158773. readonly THUMB_PHALANX_PROXIMAL: number;
  158774. readonly THUMB_PHALANX_DISTAL: number;
  158775. readonly THUMB_PHALANX_TIP: number;
  158776. readonly INDEX_METACARPAL: number;
  158777. readonly INDEX_PHALANX_PROXIMAL: number;
  158778. readonly INDEX_PHALANX_INTERMEDIATE: number;
  158779. readonly INDEX_PHALANX_DISTAL: number;
  158780. readonly INDEX_PHALANX_TIP: number;
  158781. readonly MIDDLE_METACARPAL: number;
  158782. readonly MIDDLE_PHALANX_PROXIMAL: number;
  158783. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  158784. readonly MIDDLE_PHALANX_DISTAL: number;
  158785. readonly MIDDLE_PHALANX_TIP: number;
  158786. readonly RING_METACARPAL: number;
  158787. readonly RING_PHALANX_PROXIMAL: number;
  158788. readonly RING_PHALANX_INTERMEDIATE: number;
  158789. readonly RING_PHALANX_DISTAL: number;
  158790. readonly RING_PHALANX_TIP: number;
  158791. readonly LITTLE_METACARPAL: number;
  158792. readonly LITTLE_PHALANX_PROXIMAL: number;
  158793. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  158794. readonly LITTLE_PHALANX_DISTAL: number;
  158795. readonly LITTLE_PHALANX_TIP: number;
  158796. }
  158797. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  158798. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  158799. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  158800. interface XRSession {
  158801. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  158802. }
  158803. interface XRFrame {
  158804. featurePointCloud? : Array<number>;
  158805. }